This commit is contained in:
Dragon2488 2016-12-17 16:12:14 +07:00
parent 9865ca8307
commit 97f7f34dae
10 changed files with 103 additions and 85 deletions

View file

@ -1,7 +1,7 @@
minecraft.version=1.10.2
forge.version=12.18.1.2079
gt.version=5.10.19
gt.version=5.10.20
forestry.version=5.2.7.220
ic2.version=2.6.99-ex110

Binary file not shown.

View file

@ -214,8 +214,6 @@ public class GregTech_API {
public static boolean sUnificationEntriesRegistered = false, sPreloadStarted = false, sPreloadFinished = false, sLoadStarted = false, sLoadFinished = false, sPostloadStarted = false, sPostloadFinished = false;
private static Class sBaseMetaTileEntityClass = null;
private static int sNextCoverId;
/**
* Adds Biomes to the Biome Lists for World Generation
*/
@ -371,8 +369,8 @@ public class GregTech_API {
public static void registerCover(ItemStack aStack, ITexture aCover, GT_CoverBehavior aBehavior) {
GT_ItemStack stack = new GT_ItemStack(aStack);
int coverId = ++sNextCoverId;
int coverId = stack.hashCode();
System.out.println("Cover " + aStack + " with id " + coverId);
sCoverItems.put(stack, coverId);
System.out.println();
sCovers.put(coverId, aCover == null || !aCover.isValidTexture() ? Textures.BlockIcons.ERROR_RENDERING[0] : aCover);

View file

@ -29,6 +29,7 @@ import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fml.common.FMLCommonHandler;
import java.util.ArrayList;
import java.util.HashMap;
@ -45,7 +46,6 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
* Creates the Item using these Parameters.
*
* @param aUnlocalized The Unlocalized Name of this Item.
* @param aGeneratedPrefixList The OreDict Prefixes you want to have generated.
*/
public GT_MetaBase_Item(String aUnlocalized) {
super(aUnlocalized, "Generated Item", null, false);
@ -159,11 +159,15 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
}
@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 5;
}
@Override
public EnumActionResult onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if(!aWorld.isRemote) {
use(aStack, 0, aPlayer);
isItemStackUsable(aStack);
ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack));
if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList)
if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, pos, side, hitX, hitY, hitZ, hand)) {
@ -172,9 +176,11 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci
}
if (aStack.stackSize <= 0) {
aPlayer.setHeldItem(hand, null);
return EnumActionResult.FAIL;
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}

View file

@ -851,8 +851,10 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (getCoverIDAtSide(aSide) != 0) cSide = aSide;
if (getCoverIDAtSide(cSide) == 0) {
if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) {
if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(cSide, new GT_ItemStack(tCurrentItem), this) && mMetaTileEntity.allowCoverOnSide(cSide, new GT_ItemStack(tCurrentItem))) {
GT_ItemStack gtItemStack = new GT_ItemStack(tCurrentItem);
if (GregTech_API.sCoverItems.containsKey(gtItemStack)) {
GT_CoverBehavior behavior = GregTech_API.getCoverBehavior(gtItemStack);
if (behavior.isCoverPlaceable(cSide, gtItemStack, this) && mMetaTileEntity.allowCoverOnSide(cSide, gtItemStack)) {
setCoverItemAtSide(cSide, tCurrentItem);
if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--;
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, getXCoord(), getYCoord(), getZCoord());
@ -1076,7 +1078,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
@Override
public void setCoverItemAtSide(byte aSide, ItemStack aCover) {
int coverId = GregTech_API.getCoverId(new GT_ItemStack(aCover));
GregTech_API.getCoverBehavior(coverId).placeCover(aSide, coverId, aCover, this);
GT_CoverBehavior behavior = GregTech_API.getCoverBehavior(coverId);
behavior.placeCover(aSide, coverId, aCover, this);
}
@Override

View file

@ -5,25 +5,36 @@
package gregtech.common;
import codechicken.lib.vec.Rotation;
import gregtech.api.GregTech_API;
import gregtech.api.enums.*;
import gregtech.api.enums.Materials;
import gregtech.api.enums.TextureSet;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.ITurnable;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import gregtech.common.entities.GT_Entity_Arrow;
import gregtech.common.entities.GT_Entity_Arrow_Potion;
import gregtech.common.render.*;
import ic2.api.tile.IWrenchable;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import java.net.URL;
import java.util.*;
@ -35,6 +46,14 @@ import java.util.*;
public class GT_Client extends GT_Proxy
implements Runnable {
private static List<Block> ROTATABLE_VANILLA_BLOCKS;
static {
ROTATABLE_VANILLA_BLOCKS = Arrays.asList(Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.FURNACE, Blocks.LIT_FURNACE,
Blocks.DROPPER, Blocks.DISPENSER, Blocks.CHEST, Blocks.TRAPPED_CHEST, Blocks.ENDER_CHEST, Blocks.HOPPER,
Blocks.PUMPKIN, Blocks.LIT_PUMPKIN);
}
private final HashSet<String> mCapeList = new HashSet<>();
private final List<Materials> mPosR;
private final List<Materials> mPosG;
@ -54,14 +73,11 @@ public class GT_Client extends GT_Proxy
private final List<Materials> mMoltenNegA = new ArrayList<>();
private long mAnimationTick;
private boolean mAnimationDirection;
private boolean isFirstClientPlayerTick;
private String mMessage;
public GT_Client() {
mAnimationTick = 0L;
mAnimationDirection = false;
isFirstClientPlayerTick = true;
mMessage = "";
mPosR = Arrays.asList( /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force,
Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone);
@ -92,11 +108,17 @@ public class GT_Client extends GT_Proxy
}
/*private static void drawGrid(DrawBlockHighlightEvent aEvent) {
private static void drawGrid(DrawBlockHighlightEvent aEvent) {
GL11.glPushMatrix();
GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks));
GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F);
Rotation.sideRotations[aEvent.target.sideHit].glApply();
EntityPlayer player = aEvent.getPlayer();
float partialTicks = aEvent.getPartialTicks();
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
BlockPos pos = aEvent.getTarget().getBlockPos();
GL11.glTranslated(-d0, -d1, -d2);
GL11.glTranslated(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
Rotation.sideRotations[aEvent.getTarget().sideHit.getIndex()].glApply();
GL11.glTranslated(0.0D, -0.501D, 0.0D);
GL11.glLineWidth(2.0F);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F);
@ -111,7 +133,7 @@ public class GT_Client extends GT_Proxy
GL11.glVertex3d(-0.25D, 0.0D, 0.5D);
GL11.glEnd();
GL11.glPopMatrix();
}*/
}
public boolean isServerSide() {
return true;
@ -199,49 +221,24 @@ public class GT_Client extends GT_Proxy
}
}
} catch (Throwable e) {}
/*try {
GT_Log.out.println("GT_Mod: Downloading News.");
Scanner tScanner = new Scanner(new URL("http://files.minecraftforge.net/maven/com/gregoriust/gregtech/message.txt").openStream());
while (tScanner.hasNextLine()) {
this.mMessage = (this.mMessage + tScanner.nextLine() + " ");
}
} catch (Throwable e) {}*/
}
@SubscribeEvent
public void onPlayerTickEventClient(TickEvent.PlayerTickEvent aEvent) {
if ((!aEvent.player.isDead) && (aEvent.phase == TickEvent.Phase.END) && (aEvent.side.isClient())) {
if ((this.isFirstClientPlayerTick) && (aEvent.player == GT_Values.GT.getThePlayer())) {
this.isFirstClientPlayerTick = false;
if ((this.mMessage.length() > 5) && (GregTech_API.sSpecialFile.get(ConfigCategories.news, this.mMessage, true))) {
aEvent.player.addChatComponentMessage(new TextComponentString(this.mMessage));
}
}
}
}
/*@SubscribeEvent
public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) {
if (GT_Utility.isStackValid(aEvent.currentItem)) {
Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ);
TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ);
try {
Class.forName("codechicken.lib.vec.Rotation");
if (((aTileEntity instanceof BaseMetaPipeEntity)) && (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) && ((GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList)) || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)))) {
EntityPlayer aPlayer = aEvent.getPlayer();
ItemStack currentItem = aPlayer.getHeldItemMainhand();
BlockPos aPos = aEvent.getTarget().getBlockPos();
Block block = aPlayer.worldObj.getBlockState(aPos).getBlock();
if (GT_Utility.isStackValid(currentItem)) {
TileEntity aTileEntity = aPlayer.worldObj.getTileEntity(aPos);
if (((aTileEntity instanceof BaseMetaPipeEntity)) && (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.getTarget().sideHit.getIndex()) == 0) && ((GT_Utility.isStackInList(currentItem, GregTech_API.sCoverItems.keySet())) || (GT_Utility.isStackInList(currentItem, GregTech_API.sCrowbarList)) || (GT_Utility.isStackInList(currentItem, GregTech_API.sScrewdriverList)))) {
drawGrid(aEvent);
return;
}
if ((((aTileEntity instanceof ITurnable)) || (ROTATABLE_VANILLA_BLOCKS.contains(aBlock)) || ((aTileEntity instanceof IWrenchable))) && (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList))) {
else if ((aTileEntity instanceof ITurnable || aTileEntity instanceof IWrenchable || ROTATABLE_VANILLA_BLOCKS.contains(block)) && GT_Utility.isStackInList(currentItem, GregTech_API.sWrenchList)) {
drawGrid(aEvent);
return;
}
} catch (Throwable e) {
if (GT_Values.D1) {
e.printStackTrace(GT_Log.err);
}
}
}
}*/
@SubscribeEvent
public void receiveRenderEvent(net.minecraftforge.client.event.RenderPlayerEvent.Pre aEvent) {

View file

@ -263,16 +263,13 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
}
if (playerIn.isSneaking()) {
ItemStack handItem = playerIn.inventory.getCurrentItem();
if(handItem != null && GT_Utility.isStackInList(handItem, GregTech_API.sScrewdriverList)) {
return true;
}
return false;
return handItem != null && GT_Utility.isStackInList(handItem, GregTech_API.sScrewdriverList);
}
if (gregTechTileEntity.getTimer() < 50L) {
return false;
}
if (!worldIn.isRemote && gregTechTileEntity.isUseableByPlayer(playerIn)) {
return gregTechTileEntity.onRightclick(playerIn, (byte) side.getIndex(), hitX, hitY, hitZ, hand);
return gregTechTileEntity.onRightclick(playerIn, (byte) side.getIndex(), hitX, hitY, hitZ, EnumHand.MAIN_HAND);
}
return false;
}

View file

@ -7,11 +7,14 @@ import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Utility;
import ic2.api.tile.IWrenchable;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@ -29,6 +32,7 @@ public class Behaviour_Wrench
@Override
public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, BlockPos blockPos, EnumFacing aSide, float hitX, float hitY, float hitZ, EnumHand hand) {
if(!aWorld.isRemote && !aWorld.isAirBlock(blockPos)) {
TileEntity tileEntity = aWorld.getTileEntity(blockPos);
if (tileEntity instanceof IWrenchable) {
IWrenchable wrenchable = (IWrenchable) tileEntity;
@ -56,6 +60,17 @@ public class Behaviour_Wrench
}
}
}
IBlockState blockState = aWorld.getBlockState(blockPos);
for (IProperty property : blockState.getPropertyNames()) {
if (property.getName().equals("facing")) {
if(property.getAllowedValues().contains(aSide)) {
aWorld.setBlockState(blockPos, blockState.withProperty(property, aSide));
return true;
}
return false;
}
}
}
return false;
}

View file

@ -22,6 +22,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
public class GT_MetaTileEntity_BronzeBlastFurnace extends MetaTileEntity {
@ -143,7 +144,8 @@ public class GT_MetaTileEntity_BronzeBlastFurnace extends MetaTileEntity {
this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2");
}
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {
@Override
public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, EnumHand aHand) {
if (aBaseMetaTileEntity.isClientSide()) {
return true;
}