diff --git a/build.properties b/build.properties index 16b95a90..5605e4ea 100644 --- a/build.properties +++ b/build.properties @@ -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 diff --git a/build/libs/gregtech-5.10.18-dev.jar b/build/libs/gregtech-5.10.18-dev.jar deleted file mode 100644 index 6f8c4690..00000000 Binary files a/build/libs/gregtech-5.10.18-dev.jar and /dev/null differ diff --git a/build/libs/gregtech-5.10.18-sources.jar b/build/libs/gregtech-5.10.18-sources.jar deleted file mode 100644 index 9ec69739..00000000 Binary files a/build/libs/gregtech-5.10.18-sources.jar and /dev/null differ diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index e3819a66..45f32b37 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -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); diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index 8c04bbfa..c6f0cef1 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -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,22 +159,28 @@ 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) { - use(aStack, 0, aPlayer); - isItemStackUsable(aStack); - ArrayList> tList = mItemBehaviors.get((short) getDamage(aStack)); - if (tList != null) for (IItemBehaviour tBehavior : tList) - if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, pos, side, hitX, hitY, hitZ, hand)) { - if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null); + if(!aWorld.isRemote) { + use(aStack, 0, aPlayer); + ArrayList> tList = mItemBehaviors.get((short) getDamage(aStack)); + if (tList != null) for (IItemBehaviour tBehavior : tList) + if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, pos, side, hitX, hitY, hitZ, hand)) { + if (aStack.stackSize <= 0) aPlayer.setHeldItem(hand, null); + return EnumActionResult.SUCCESS; + } + if (aStack.stackSize <= 0) { + aPlayer.setHeldItem(hand, null); return EnumActionResult.SUCCESS; } - if (aStack.stackSize <= 0) { - aPlayer.setHeldItem(hand, null); - return EnumActionResult.FAIL; + return EnumActionResult.SUCCESS; } - return EnumActionResult.FAIL; + return EnumActionResult.PASS; } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 6de4bd98..96283df4 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -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 diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 764ea4c1..8e5211d3 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -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 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 mCapeList = new HashSet<>(); private final List mPosR; private final List mPosG; @@ -54,14 +73,11 @@ public class GT_Client extends GT_Proxy private final List 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,50 +221,25 @@ 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)); - } + public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) { + 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); + } + else if ((aTileEntity instanceof ITurnable || aTileEntity instanceof IWrenchable || ROTATABLE_VANILLA_BLOCKS.contains(block)) && GT_Utility.isStackInList(currentItem, GregTech_API.sWrenchList)) { + drawGrid(aEvent); } } } - /*@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)))) { - drawGrid(aEvent); - return; - } - if ((((aTileEntity instanceof ITurnable)) || (ROTATABLE_VANILLA_BLOCKS.contains(aBlock)) || ((aTileEntity instanceof IWrenchable))) && (GT_Utility.isStackInList(aEvent.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) { if (GT_Utility.getFullInvisibility(aEvent.getEntityPlayer())) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index c65eebeb..56b93055 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -258,21 +258,18 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { IGregTechTileEntity gregTechTileEntity = getGregTile(worldIn, pos); - if(gregTechTileEntity == null) { + if (gregTechTileEntity == null) { return false; } - if(playerIn.isSneaking()) { + if (playerIn.isSneaking()) { ItemStack handItem = playerIn.inventory.getCurrentItem(); - if(handItem != null && GT_Utility.isStackInList(handItem, GregTech_API.sScrewdriverList)) { - return true; - } + return handItem != null && GT_Utility.isStackInList(handItem, GregTech_API.sScrewdriverList); + } + if (gregTechTileEntity.getTimer() < 50L) { return false; } - if(gregTechTileEntity.getTimer() < 50L) { - return false; - } - if(!worldIn.isRemote && gregTechTileEntity.isUseableByPlayer(playerIn)) { - return gregTechTileEntity.onRightclick(playerIn, (byte) side.getIndex(), hitX, hitY, hitZ, hand); + if (!worldIn.isRemote && gregTechTileEntity.isUseableByPlayer(playerIn)) { + return gregTechTileEntity.onRightclick(playerIn, (byte) side.getIndex(), hitX, hitY, hitZ, EnumHand.MAIN_HAND); } return false; } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java index 7beab925..e057ed50 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Wrench.java @@ -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,14 +32,15 @@ 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) { + if (tileEntity instanceof IWrenchable) { IWrenchable wrenchable = (IWrenchable) tileEntity; - if(aPlayer.isSneaking()) { + if (aPlayer.isSneaking()) { if (wrenchable.wrenchCanRemove(aWorld, blockPos, aPlayer)) { List wrenchDrops = wrenchable.getWrenchDrops(aWorld, blockPos, aWorld.getBlockState(blockPos), tileEntity, aPlayer, 0); - for(ItemStack wrenchDrop : wrenchDrops) { - if(!aPlayer.inventory.addItemStackToInventory(wrenchDrop)) { + for (ItemStack wrenchDrop : wrenchDrops) { + if (!aPlayer.inventory.addItemStackToInventory(wrenchDrop)) { Block.spawnAsEntity(aWorld, blockPos, wrenchDrop); } } @@ -47,8 +51,8 @@ public class Behaviour_Wrench return true; } } else { - if(wrenchable.getFacing(aWorld, blockPos) != aSide) { - if(wrenchable.setFacing(aWorld, blockPos, aSide, aPlayer)) { + if (wrenchable.getFacing(aWorld, blockPos) != aSide) { + if (wrenchable.setFacing(aWorld, blockPos, aSide, aPlayer)) { ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(100), 1.0F, -1.0F, blockPos); return true; @@ -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; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java index db78ba73..68ac64c7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_BronzeBlastFurnace.java @@ -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; }