From 7d1f51a8937e0a86486267437d444696e81e8aa0 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:04:28 +0200 Subject: Buildscript + Spotless (#318) * Convert AES.java to readable class * Buildscript * Spotless --- .../gtPlusPlus/xmod/ic2/CustomInternalName.java | 26 +- src/main/java/gtPlusPlus/xmod/ic2/HANDLER_IC2.java | 33 +- .../xmod/ic2/block/RTGGenerator/BlockRTG.java | 372 +++++----- .../xmod/ic2/block/RTGGenerator/TileEntityRTG.java | 117 ++- .../ic2/block/RTGGenerator/gui/CONTAINER_RTG.java | 48 +- .../xmod/ic2/block/RTGGenerator/gui/GUI_RTG.java | 85 +-- .../kieticgenerator/IC2_BlockKineticGenerator.java | 115 ++- .../ic2/block/kieticgenerator/IC2_TEComponent.java | 48 +- .../container/ContainerKineticWindgenerator.java | 33 +- .../container/IC2_ContainerBase.java | 4 +- .../gui/GuiKineticWindGenerator.java | 135 ++-- .../tileentity/TileEntityKineticWindGenerator.java | 703 +++++++++--------- .../xmod/ic2/item/CustomKineticRotor.java | 482 ++++++------- .../gtPlusPlus/xmod/ic2/item/IC2_ItemGradual.java | 57 +- .../xmod/ic2/item/IC2_ItemGradualInteger.java | 85 +-- .../java/gtPlusPlus/xmod/ic2/item/IC2_ItemIC2.java | 153 ++-- .../java/gtPlusPlus/xmod/ic2/item/IC2_Items.java | 107 +-- .../gtPlusPlus/xmod/ic2/item/ItemGenerators.java | 85 +-- .../java/gtPlusPlus/xmod/ic2/item/RotorBase.java | 177 +++-- .../gtPlusPlus/xmod/ic2/item/RotorIridium.java | 224 +++--- .../xmod/ic2/item/reactor/IC2_FuelRod_Base.java | 85 ++- .../gtPlusPlus/xmod/ic2/recipe/RECIPE_IC2.java | 803 +++++++++++++-------- 22 files changed, 2013 insertions(+), 1964 deletions(-) (limited to 'src/main/java/gtPlusPlus/xmod/ic2') diff --git a/src/main/java/gtPlusPlus/xmod/ic2/CustomInternalName.java b/src/main/java/gtPlusPlus/xmod/ic2/CustomInternalName.java index a349d7f86e..6ac8a86504 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/CustomInternalName.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/CustomInternalName.java @@ -5,18 +5,18 @@ import net.minecraftforge.common.util.EnumHelper; public class CustomInternalName { - public static InternalName aHazmatHelmetEx; - public static InternalName aHazmatChestEx; - public static InternalName aHazmatLegsEx; - public static InternalName aHazmatBootsEx; - - public static void init() { - aHazmatHelmetEx = EnumHelper.addEnum(InternalName.class, "itemArmorHazmatHelmetEx", new Class[] {}, new Object[] {}); - aHazmatChestEx = EnumHelper.addEnum(InternalName.class, "itemArmorHazmatChestplateEx", new Class[] {}, new Object[] {}); - aHazmatLegsEx = EnumHelper.addEnum(InternalName.class, "itemArmorHazmatLeggingsEx", new Class[] {}, new Object[] {}); - aHazmatBootsEx = EnumHelper.addEnum(InternalName.class, "itemArmorRubBootsEx", new Class[] {}, new Object[] {}); - } + public static InternalName aHazmatHelmetEx; + public static InternalName aHazmatChestEx; + public static InternalName aHazmatLegsEx; + public static InternalName aHazmatBootsEx; - - + public static void init() { + aHazmatHelmetEx = + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatHelmetEx", new Class[] {}, new Object[] {}); + aHazmatChestEx = + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatChestplateEx", new Class[] {}, new Object[] {}); + aHazmatLegsEx = + EnumHelper.addEnum(InternalName.class, "itemArmorHazmatLeggingsEx", new Class[] {}, new Object[] {}); + aHazmatBootsEx = EnumHelper.addEnum(InternalName.class, "itemArmorRubBootsEx", new Class[] {}, new Object[] {}); + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/HANDLER_IC2.java b/src/main/java/gtPlusPlus/xmod/ic2/HANDLER_IC2.java index bb97132ab4..66b9d9aabe 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/HANDLER_IC2.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/HANDLER_IC2.java @@ -4,25 +4,22 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.xmod.ic2.item.IC2_Items; import gtPlusPlus.xmod.ic2.recipe.RECIPE_IC2; -public class HANDLER_IC2{ +public class HANDLER_IC2 { - public static void preInit() { - if (LoadedMods.IndustrialCraft2){ - IC2_Items.register(); - //new BlockRTG(InternalName.beer); - } - } + public static void preInit() { + if (LoadedMods.IndustrialCraft2) { + IC2_Items.register(); + // new BlockRTG(InternalName.beer); + } + } - public static void init() { - if (LoadedMods.IndustrialCraft2){ - - } - } - - public static void postInit() { - if (LoadedMods.IndustrialCraft2){ - RECIPE_IC2.initRecipes(); - } - } + public static void init() { + if (LoadedMods.IndustrialCraft2) {} + } + public static void postInit() { + if (LoadedMods.IndustrialCraft2) { + RECIPE_IC2.initRecipes(); + } + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/BlockRTG.java b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/BlockRTG.java index 2a1b5ab44d..03a2606f71 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/BlockRTG.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/BlockRTG.java @@ -1,23 +1,8 @@ package gtPlusPlus.xmod.ic2.block.RTGGenerator; -import java.util.List; -import java.util.Random; - -import org.apache.commons.lang3.mutable.MutableObject; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.block.material.Material; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.xmod.ic2.block.kieticgenerator.tileentity.TileEntityKineticWindGenerator; import gtPlusPlus.xmod.ic2.item.IC2_Items; @@ -28,181 +13,186 @@ import ic2.core.block.BlockMultiID; import ic2.core.block.TileEntityBlock; import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; import ic2.core.init.InternalName; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import org.apache.commons.lang3.mutable.MutableObject; -public class BlockRTG -extends BlockMultiID -{ - public BlockRTG(final InternalName internalName1) - { - super(internalName1, Material.iron, ItemGenerators.class); - this.setCreativeTab(AddToCreativeTab.tabMachines); - this.setHardness(3.0F); - this.setStepSound(soundTypeMetal); - - IC2_Items.blockRTG = new ItemStack(this, 1, 0); - IC2_Items.blockKineticGenerator = new ItemStack(this, 1, 1); - - GameRegistry.registerTileEntity(TileEntityRTG.class, "RTG Mach II"); - GameRegistry.registerTileEntity(TileEntityKineticWindGenerator.class, "Wind Ripper Mach II"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void getSubBlocks(final Item j, final CreativeTabs tabs, final List itemList) { - final Item item = Item.getItemFromBlock(this); - if (!item.getHasSubtypes()) { - itemList.add(new ItemStack(this)); - } else { - for (int i = 0; i < 16; i++) - { - final ItemStack is = new ItemStack(this, 1, i); - if (is.getItem().getUnlocalizedName(is) == null) { - break; - } - itemList.add(is); - } - } - } - - - @Override - public String getTextureFolder(final int id) - { - return "generator"; - } - - @Override - public int damageDropped(final int meta) - { - switch (meta) - { - case 2: - return 2; - } - return 0; - } - - @Override - public Class getTeClass(final int meta, final MutableObject[]> ctorArgTypes, final MutableObject ctorArgs) - { - try - { - switch (meta) - { - case 0: - return TileEntityRTG.class; - case 1: - return TileEntityKineticWindGenerator.class; - } - } - catch (final Exception e) - { - throw new RuntimeException(e); - } - return null; - } - - /* - * - * { - case 0: - return TileEntityGenerator.class; - case 1: - return TileEntityGeoGenerator.class; - case 2: - return TileEntityWaterGenerator.class; - case 3: - return TileEntitySolarGenerator.class; - case 4: - return TileEntityWindGenerator.class; - case 5: - return TileEntityNuclearReactorElectric.class; - case 6: - return TileEntityRTGenerator.class; - case 7: - return TileEntitySemifluidGenerator.class; - case 8: - return TileEntityStirlingGenerator.class; - case 9: - return TileEntityKineticGenerator.class; - } - * - * (non-Javadoc) - * @see net.minecraft.block.Block#randomDisplayTick(net.minecraft.world.World, int, int, int, java.util.Random) - */ - - @Override - public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random random) - { - if (!IC2.platform.isRendering()) { - return; - } - final int meta = world.getBlockMetadata(x, y, z); - if ((meta == 0) && (this.isActive(world, x, y, z))) - { - final TileEntityBlock te = (TileEntityBlock)this.getOwnTe(world, x, y, z); - if (te == null) { - return; - } - final int l = te.getFacing(); - final float f = x + 0.5F; - final float f1 = y + 0.0F + ((random.nextFloat() * 6.0F) / 16.0F); - final float f2 = z + 0.5F; - final float f3 = 0.52F; - final float f4 = (random.nextFloat() * 0.6F) - 0.3F; - switch (l) - { - case 4: - world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - break; - case 5: - world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); - break; - case 2: - world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); - break; - case 3: - world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); - } - } - else if (meta == 5) - { - final TileEntityNuclearReactorElectric te = (TileEntityNuclearReactorElectric)this.getOwnTe(world, x, y, z); - if (te == null) { - return; - } - int puffs = te.heat / 1000; - if (puffs <= 0) { - return; - } - puffs = world.rand.nextInt(puffs); - for (int n = 0; n < puffs; n++) { - world.spawnParticle("smoke", x + random.nextFloat(), y + 0.95F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D); - } - puffs -= world.rand.nextInt(4) + 3; - for (int n = 0; n < puffs; n++) { - world.spawnParticle("flame", x + random.nextFloat(), y + 1.0F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - public boolean onBlockActivated(final World world, final int i, final int j, final int k, final EntityPlayer entityplayer, final int side, final float a, final float b, final float c) - { - if ((entityplayer.getCurrentEquippedItem() != null) && (entityplayer.getCurrentEquippedItem().isItemEqual(Ic2Items.reactorChamber))) { - return false; - } - return super.onBlockActivated(world, i, j, k, entityplayer, side, a, b, c); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack stack) - { - return stack.getItemDamage() == 5 ? EnumRarity.uncommon : EnumRarity.common; - } +public class BlockRTG extends BlockMultiID { + public BlockRTG(final InternalName internalName1) { + super(internalName1, Material.iron, ItemGenerators.class); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setHardness(3.0F); + this.setStepSound(soundTypeMetal); + + IC2_Items.blockRTG = new ItemStack(this, 1, 0); + IC2_Items.blockKineticGenerator = new ItemStack(this, 1, 1); + + GameRegistry.registerTileEntity(TileEntityRTG.class, "RTG Mach II"); + GameRegistry.registerTileEntity(TileEntityKineticWindGenerator.class, "Wind Ripper Mach II"); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public void getSubBlocks(final Item j, final CreativeTabs tabs, final List itemList) { + final Item item = Item.getItemFromBlock(this); + if (!item.getHasSubtypes()) { + itemList.add(new ItemStack(this)); + } else { + for (int i = 0; i < 16; i++) { + final ItemStack is = new ItemStack(this, 1, i); + if (is.getItem().getUnlocalizedName(is) == null) { + break; + } + itemList.add(is); + } + } + } + + @Override + public String getTextureFolder(final int id) { + return "generator"; + } + + @Override + public int damageDropped(final int meta) { + switch (meta) { + case 2: + return 2; + } + return 0; + } + + @Override + public Class getTeClass( + final int meta, final MutableObject[]> ctorArgTypes, final MutableObject ctorArgs) { + try { + switch (meta) { + case 0: + return TileEntityRTG.class; + case 1: + return TileEntityKineticWindGenerator.class; + } + } catch (final Exception e) { + throw new RuntimeException(e); + } + return null; + } + + /* + * + * { + case 0: + return TileEntityGenerator.class; + case 1: + return TileEntityGeoGenerator.class; + case 2: + return TileEntityWaterGenerator.class; + case 3: + return TileEntitySolarGenerator.class; + case 4: + return TileEntityWindGenerator.class; + case 5: + return TileEntityNuclearReactorElectric.class; + case 6: + return TileEntityRTGenerator.class; + case 7: + return TileEntitySemifluidGenerator.class; + case 8: + return TileEntityStirlingGenerator.class; + case 9: + return TileEntityKineticGenerator.class; + } + * + * (non-Javadoc) + * @see net.minecraft.block.Block#randomDisplayTick(net.minecraft.world.World, int, int, int, java.util.Random) + */ + + @Override + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random random) { + if (!IC2.platform.isRendering()) { + return; + } + final int meta = world.getBlockMetadata(x, y, z); + if ((meta == 0) && (this.isActive(world, x, y, z))) { + final TileEntityBlock te = (TileEntityBlock) this.getOwnTe(world, x, y, z); + if (te == null) { + return; + } + final int l = te.getFacing(); + final float f = x + 0.5F; + final float f1 = y + 0.0F + ((random.nextFloat() * 6.0F) / 16.0F); + final float f2 = z + 0.5F; + final float f3 = 0.52F; + final float f4 = (random.nextFloat() * 0.6F) - 0.3F; + switch (l) { + case 4: + world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + break; + case 5: + world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D); + break; + case 2: + world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D); + break; + case 3: + world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D); + } + } else if (meta == 5) { + final TileEntityNuclearReactorElectric te = + (TileEntityNuclearReactorElectric) this.getOwnTe(world, x, y, z); + if (te == null) { + return; + } + int puffs = te.heat / 1000; + if (puffs <= 0) { + return; + } + puffs = world.rand.nextInt(puffs); + for (int n = 0; n < puffs; n++) { + world.spawnParticle( + "smoke", x + random.nextFloat(), y + 0.95F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D); + } + puffs -= world.rand.nextInt(4) + 3; + for (int n = 0; n < puffs; n++) { + world.spawnParticle( + "flame", x + random.nextFloat(), y + 1.0F, z + random.nextFloat(), 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public boolean onBlockActivated( + final World world, + final int i, + final int j, + final int k, + final EntityPlayer entityplayer, + final int side, + final float a, + final float b, + final float c) { + if ((entityplayer.getCurrentEquippedItem() != null) + && (entityplayer.getCurrentEquippedItem().isItemEqual(Ic2Items.reactorChamber))) { + return false; + } + return super.onBlockActivated(world, i, j, k, entityplayer, side, a, b, c); + } + + @Override + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(final ItemStack stack) { + return stack.getItemDamage() == 5 ? EnumRarity.uncommon : EnumRarity.common; + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/TileEntityRTG.java b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/TileEntityRTG.java index aa50243914..19602273c3 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/TileEntityRTG.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/TileEntityRTG.java @@ -2,11 +2,6 @@ package gtPlusPlus.xmod.ic2.block.RTGGenerator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; - import gtPlusPlus.xmod.ic2.block.RTGGenerator.gui.CONTAINER_RTG; import gtPlusPlus.xmod.ic2.block.RTGGenerator.gui.GUI_RTG; import ic2.core.ContainerBase; @@ -14,75 +9,65 @@ import ic2.core.Ic2Items; import ic2.core.block.generator.tileentity.TileEntityRTGenerator; import ic2.core.block.invslot.InvSlotConsumable; import ic2.core.block.invslot.InvSlotConsumableId; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; -public class TileEntityRTG -extends TileEntityRTGenerator -{ - public final InvSlotConsumable fuelSlot; - - public TileEntityRTG() - { - this.fuelSlot = new InvSlotConsumableId(this, "fuelSlot", 0, 12, new Item[] { Ic2Items.RTGPellets.getItem() }); - } - - @Override - public int gaugeFuelScaled(final int i) - { - return i; - } +public class TileEntityRTG extends TileEntityRTGenerator { + public final InvSlotConsumable fuelSlot; - @Override - public boolean gainEnergy() - { - int counter = 0; - for (int i = 0; i < this.fuelSlot.size(); i++) { - if (this.fuelSlot.get(i) != null) { - counter++; - } - } - if (counter == 0) { - return false; - } - this.storage += (int)Math.pow(2.0D, counter - 1); - return true; - } + public TileEntityRTG() { + this.fuelSlot = new InvSlotConsumableId(this, "fuelSlot", 0, 12, new Item[] {Ic2Items.RTGPellets.getItem()}); + } - @Override - public boolean gainFuel() - { - return false; - } + @Override + public int gaugeFuelScaled(final int i) { + return i; + } - @Override - public boolean needsFuel() - { - return true; - } + @Override + public boolean gainEnergy() { + int counter = 0; + for (int i = 0; i < this.fuelSlot.size(); i++) { + if (this.fuelSlot.get(i) != null) { + counter++; + } + } + if (counter == 0) { + return false; + } + this.storage += (int) Math.pow(2.0D, counter - 1); + return true; + } - @Override - public String getInventoryName() - { - return "RTG"; - } + @Override + public boolean gainFuel() { + return false; + } - @Override - public ContainerBase getGuiContainer(final EntityPlayer entityPlayer) - { - return new CONTAINER_RTG(entityPlayer, this); - } + @Override + public boolean needsFuel() { + return true; + } - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(final EntityPlayer entityPlayer, final boolean isAdmin) - { - return new GUI_RTG(new CONTAINER_RTG(entityPlayer, this)); - } + @Override + public String getInventoryName() { + return "RTG"; + } - @Override - public boolean delayActiveUpdate() - { - return true; - } + @Override + public ContainerBase getGuiContainer(final EntityPlayer entityPlayer) { + return new CONTAINER_RTG(entityPlayer, this); + } + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(final EntityPlayer entityPlayer, final boolean isAdmin) { + return new GUI_RTG(new CONTAINER_RTG(entityPlayer, this)); + } + @Override + public boolean delayActiveUpdate() { + return true; + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/CONTAINER_RTG.java b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/CONTAINER_RTG.java index 0afe47c983..9ac5476ed9 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/CONTAINER_RTG.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/CONTAINER_RTG.java @@ -1,37 +1,31 @@ package gtPlusPlus.xmod.ic2.block.RTGGenerator.gui; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; - import gtPlusPlus.xmod.ic2.block.RTGGenerator.TileEntityRTG; import ic2.core.block.generator.container.ContainerRTGenerator; import ic2.core.slot.SlotInvSlot; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; -public class CONTAINER_RTG -extends ContainerRTGenerator -{ - public CONTAINER_RTG(final EntityPlayer entityPlayer, final TileEntityRTG tileEntity1) - { - super(entityPlayer, tileEntity1); - for (int i = 0; i < 4; i++) { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, i, 36 + (i * 18), 18)); - } - for (int i = 4; i < 8; i++) { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, i, 36 + ((i - 4) * 18), 36)); - } - for (int i = 8; i < 12; i++) { - this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, i, 36 + ((i - 8) * 18), 54)); - } - } +public class CONTAINER_RTG extends ContainerRTGenerator { + public CONTAINER_RTG(final EntityPlayer entityPlayer, final TileEntityRTG tileEntity1) { + super(entityPlayer, tileEntity1); + for (int i = 0; i < 4; i++) { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, i, 36 + (i * 18), 18)); + } + for (int i = 4; i < 8; i++) { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, i, 36 + ((i - 4) * 18), 36)); + } + for (int i = 8; i < 12; i++) { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fuelSlot, i, 36 + ((i - 8) * 18), 54)); + } + } - @Override - public List getNetworkedFields() - { - final List ret = super.getNetworkedFields(); + @Override + public List getNetworkedFields() { + final List ret = super.getNetworkedFields(); - ret.add("storage"); + ret.add("storage"); - return ret; - } + return ret; + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/GUI_RTG.java b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/GUI_RTG.java index c6e09a78d1..913d456553 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/GUI_RTG.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/RTGGenerator/gui/GUI_RTG.java @@ -1,52 +1,55 @@ package gtPlusPlus.xmod.ic2.block.RTGGenerator.gui; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - import gtPlusPlus.xmod.ic2.block.RTGGenerator.TileEntityRTG; import ic2.core.IC2; import ic2.core.block.generator.gui.GuiRTGenerator; import ic2.core.util.GuiTooltipHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GUI_RTG -extends GuiRTGenerator -{ - public CONTAINER_RTG container; - - public GUI_RTG(final CONTAINER_RTG container1) - { - super(container1); - - this.container = container1; - this.name = "RTG Mach II"; - } - - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) - { - this.fontRendererObj.drawString(this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 4, 4210752); - - GuiTooltipHelper.drawAreaTooltip(par1 - this.guiLeft, par2 - this.guiTop, StatCollector.translateToLocalFormatted("ic2.generic.text.bufferEU", new Object[] { Double.valueOf(((TileEntityRTG)this.container.base).storage) }), 117, 38, 150, 48); - } - - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(background); - final int j = (this.width - this.xSize) / 2; - final int k = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); - - final int i1 = ((TileEntityRTG)this.container.base).gaugeStorageScaled(31); - this.drawTexturedModalRect(j + 119, k + 40, 179, 3, i1, 8); - } - - private static final ResourceLocation background = new ResourceLocation(IC2.textureDomain, "textures/gui/GUIRTGenerator.png"); +public class GUI_RTG extends GuiRTGenerator { + public CONTAINER_RTG container; + + public GUI_RTG(final CONTAINER_RTG container1) { + super(container1); + + this.container = container1; + this.name = "RTG Mach II"; + } + + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString( + this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 4, 4210752); + + GuiTooltipHelper.drawAreaTooltip( + par1 - this.guiLeft, + par2 - this.guiTop, + StatCollector.translateToLocalFormatted( + "ic2.generic.text.bufferEU", + new Object[] {Double.valueOf(((TileEntityRTG) this.container.base).storage)}), + 117, + 38, + 150, + 48); + } + + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(background); + final int j = (this.width - this.xSize) / 2; + final int k = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); + + final int i1 = ((TileEntityRTG) this.container.base).gaugeStorageScaled(31); + this.drawTexturedModalRect(j + 119, k + 40, 179, 3, i1, 8); + } + + private static final ResourceLocation background = + new ResourceLocation(IC2.textureDomain, "textures/gui/GUIRTGenerator.png"); } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_BlockKineticGenerator.java b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_BlockKineticGenerator.java index 95e785d1a1..4f9a2ccab1 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_BlockKineticGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_BlockKineticGenerator.java @@ -1,77 +1,72 @@ package gtPlusPlus.xmod.ic2.block.kieticgenerator; -import org.apache.commons.lang3.mutable.MutableObject; - import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - import gtPlusPlus.core.creative.AddToCreativeTab; import ic2.core.block.BlockMultiID; import ic2.core.block.kineticgenerator.tileentity.TileEntityManualKineticGenerator; import ic2.core.block.kineticgenerator.tileentity.TileEntityWindKineticGenerator; import ic2.core.init.InternalName; import ic2.core.item.block.ItemKineticGenerator; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import org.apache.commons.lang3.mutable.MutableObject; -public class IC2_BlockKineticGenerator -extends BlockMultiID -{ - public IC2_BlockKineticGenerator(final InternalName internalName1) - { - super(internalName1, Material.iron, ItemKineticGenerator.class); - - this.setHardness(3.0F); - this.setStepSound(Block.soundTypeMetal); - this.setCreativeTab(AddToCreativeTab.tabMachines); +public class IC2_BlockKineticGenerator extends BlockMultiID { + public IC2_BlockKineticGenerator(final InternalName internalName1) { + super(internalName1, Material.iron, ItemKineticGenerator.class); - GameRegistry.registerTileEntity(TileEntityWindKineticGenerator.class, "Advanced Kinetic Wind Generator"); + this.setHardness(3.0F); + this.setStepSound(Block.soundTypeMetal); + this.setCreativeTab(AddToCreativeTab.tabMachines); - } + GameRegistry.registerTileEntity(TileEntityWindKineticGenerator.class, "Advanced Kinetic Wind Generator"); + } - @Override - public String getTextureFolder(final int id) - { - return "kineticgenerator"; - } + @Override + public String getTextureFolder(final int id) { + return "kineticgenerator"; + } - @Override - public int damageDropped(final int meta) - { - return meta; - } + @Override + public int damageDropped(final int meta) { + return meta; + } - @Override - public Class getTeClass(final int meta, final MutableObject[]> ctorArgTypes, final MutableObject ctorArgs) - { - try - { - switch (meta) - { - case 0: - return TileEntityWindKineticGenerator.class; - } - } - catch (final Exception e) - { - e.printStackTrace(); - } - return null; - } + @Override + public Class getTeClass( + final int meta, final MutableObject[]> ctorArgTypes, final MutableObject ctorArgs) { + try { + switch (meta) { + case 0: + return TileEntityWindKineticGenerator.class; + } + } catch (final Exception e) { + e.printStackTrace(); + } + return null; + } - @Override - public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int side, final float a, final float b, final float c) - { - if (entityPlayer.isSneaking()) { - return false; - } - final TileEntity te = this.getOwnTe(world, x, y, z); - if ((te != null) && ((te instanceof TileEntityManualKineticGenerator))) { - return ((TileEntityManualKineticGenerator)te).playerKlicked(entityPlayer); - } - return super.onBlockActivated(world, x, y, z, entityPlayer, side, a, b, c); - } + @Override + public boolean onBlockActivated( + final World world, + final int x, + final int y, + final int z, + final EntityPlayer entityPlayer, + final int side, + final float a, + final float b, + final float c) { + if (entityPlayer.isSneaking()) { + return false; + } + final TileEntity te = this.getOwnTe(world, x, y, z); + if ((te != null) && ((te instanceof TileEntityManualKineticGenerator))) { + return ((TileEntityManualKineticGenerator) te).playerKlicked(entityPlayer); + } + return super.onBlockActivated(world, x, y, z, entityPlayer, side, a, b, c); + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_TEComponent.java b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_TEComponent.java index 2c4c2e1d16..6b851e2666 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_TEComponent.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/IC2_TEComponent.java @@ -1,48 +1,40 @@ package gtPlusPlus.xmod.ic2.block.kieticgenerator; +import ic2.core.block.TileEntityBlock; import java.io.DataInput; import java.io.IOException; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; -import ic2.core.block.TileEntityBlock; - -public abstract class IC2_TEComponent -{ - protected final TileEntityBlock parent; +public abstract class IC2_TEComponent { + protected final TileEntityBlock parent; - public IC2_TEComponent(final TileEntityBlock parent) - { - this.parent = parent; - } + public IC2_TEComponent(final TileEntityBlock parent) { + this.parent = parent; + } - public abstract String getDefaultName(); + public abstract String getDefaultName(); - public void readFromNbt(final NBTTagCompound nbt) {} + public void readFromNbt(final NBTTagCompound nbt) {} - public NBTTagCompound writeToNbt() - { - return null; - } + public NBTTagCompound writeToNbt() { + return null; + } - public void onLoaded() {} + public void onLoaded() {} - public void onUnloaded() {} + public void onUnloaded() {} - public void onNeighborUpdate(final Block srcBlock) {} + public void onNeighborUpdate(final Block srcBlock) {} - public void onContainerUpdate(final String name, final EntityPlayerMP player) {} + public void onContainerUpdate(final String name, final EntityPlayerMP player) {} - public void onNetworkUpdate(final DataInput is) - throws IOException - {} + public void onNetworkUpdate(final DataInput is) throws IOException {} - public boolean enableWorldTick() - { - return false; - } + public boolean enableWorldTick() { + return false; + } - public void onWorldTick() {} + public void onWorldTick() {} } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/ContainerKineticWindgenerator.java b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/ContainerKineticWindgenerator.java index 2a5b4dc9ae..6bc79849c3 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/ContainerKineticWindgenerator.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/ContainerKineticWindgenerator.java @@ -1,28 +1,23 @@ package gtPlusPlus.xmod.ic2.block.kieticgenerator.container; -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; - import ic2.core.ContainerFullInv; import ic2.core.block.kineticgenerator.tileentity.TileEntityWindKineticGenerator; import ic2.core.slot.SlotInvSlot; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; -public class ContainerKineticWindgenerator -extends ContainerFullInv -{ - public ContainerKineticWindgenerator(final EntityPlayer entityPlayer, final TileEntityWindKineticGenerator tileEntity1) - { - super(entityPlayer, tileEntity1, 166); +public class ContainerKineticWindgenerator extends ContainerFullInv { + public ContainerKineticWindgenerator( + final EntityPlayer entityPlayer, final TileEntityWindKineticGenerator tileEntity1) { + super(entityPlayer, tileEntity1, 166); - this.addSlotToContainer(new SlotInvSlot(tileEntity1.rotorSlot, 0, 80, 26)); - } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.rotorSlot, 0, 80, 26)); + } - @Override - public List getNetworkedFields() - { - final List ret = super.getNetworkedFields(); - ret.add("windStrength"); - return ret; - } + @Override + public List getNetworkedFields() { + final List ret = super.getNetworkedFields(); + ret.add("windStrength"); + return ret; + } } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/IC2_ContainerBase.java b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/IC2_ContainerBase.java index 740991c5d3..b432bf4e15 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/IC2_ContainerBase.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/container/IC2_ContainerBase.java @@ -1,5 +1,3 @@ package gtPlusPlus.xmod.ic2.block.kieticgenerator.container; -public class IC2_ContainerBase { - -} +public class IC2_ContainerBase {} diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/gui/GuiKineticWindGenerator.java b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/gui/GuiKineticWindGenerator.java index 44053ed2e0..27d4f014bb 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/gui/GuiKineticWindGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/gui/GuiKineticWindGenerator.java @@ -1,78 +1,87 @@ package gtPlusPlus.xmod.ic2.block.kieticgenerator.gui; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - import ic2.core.IC2; import ic2.core.block.kineticgenerator.container.ContainerWindKineticGenerator; import ic2.core.util.GuiTooltipHelper; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class GuiKineticWindGenerator -extends GuiContainer -{ - public ContainerWindKineticGenerator container; - public String name; +public class GuiKineticWindGenerator extends GuiContainer { + public ContainerWindKineticGenerator container; + public String name; - public GuiKineticWindGenerator(final ContainerWindKineticGenerator container1) - { - super(container1); + public GuiKineticWindGenerator(final ContainerWindKineticGenerator container1) { + super(container1); - this.container = container1; - this.name = StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.name"); - } + this.container = container1; + this.name = StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.name"); + } - @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) - { - this.fontRendererObj.drawString(this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 6, 4210752); - if (this.container.base.checkrotor()) - { - if (!this.container.base.rotorspace()) - { - this.fontRendererObj.drawString(StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotorspace"), 20, 52, 2157374); - } - else if ((this.container.base.checkrotor()) && (!this.container.base.guiisminWindStrength())) - { - this.fontRendererObj.drawString(StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.windweak1"), 27, 52, 2157374); - this.fontRendererObj.drawString(StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.windweak2"), 24, 69, 2157374); - } - else - { - this.fontRendererObj.drawString(StatCollector.translateToLocalFormatted("ic2.WindKineticGenerator.gui.output", new Object[] { Integer.valueOf(this.container.base.getKuOutput()) }), 55, 52, 2157374); - this.fontRendererObj.drawString(this.container.base.getRotorhealth() + " %", 46, 70, 2157374); - if (this.container.base.guiisoverload()) - { - GuiTooltipHelper.drawAreaTooltip(par1 - this.guiLeft, par2 - this.guiTop, StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload"), 44, 20, 79, 45); - GuiTooltipHelper.drawAreaTooltip(par1 - this.guiLeft, par2 - this.guiTop, StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload2"), 102, 20, 131, 45); - } - } - } - else { - this.fontRendererObj.drawString(StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotormiss"), 27, 52, 2157374); - } - } + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + this.fontRendererObj.drawString( + this.name, (this.xSize - this.fontRendererObj.getStringWidth(this.name)) / 2, 6, 4210752); + if (this.container.base.checkrotor()) { + if (!this.container.base.rotorspace()) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotorspace"), 20, 52, 2157374); + } else if ((this.container.base.checkrotor()) && (!this.container.base.guiisminWindStrength())) { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.windweak1"), 27, 52, 2157374); + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.windweak2"), 24, 69, 2157374); + } else { + this.fontRendererObj.drawString( + StatCollector.translateToLocalFormatted( + "ic2.WindKineticGenerator.gui.output", + new Object[] {Integer.valueOf(this.container.base.getKuOutput())}), + 55, + 52, + 2157374); + this.fontRendererObj.drawString(this.container.base.getRotorhealth() + " %", 46, 70, 2157374); + if (this.container.base.guiisoverload()) { + GuiTooltipHelper.drawAreaTooltip( + par1 - this.guiLeft, + par2 - this.guiTop, + StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload"), + 44, + 20, + 79, + 45); + GuiTooltipHelper.drawAreaTooltip( + par1 - this.guiLeft, + par2 - this.guiTop, + StatCollector.translateToLocal("ic2.WindKineticGenerator.error.overload2"), + 102, + 20, + 131, + 45); + } + } + } else { + this.fontRendererObj.drawString( + StatCollector.translateToLocal("ic2.WindKineticGenerator.gui.rotormiss"), 27, 52, 2157374); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(background); - final int j = (this.width - this.xSize) / 2; - final int k = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); - if ((this.container.base.guiisoverload()) && (this.container.base.checkrotor())) - { - this.drawTexturedModalRect(j + 44, k + 20, 176, 0, 30, 26); - this.drawTexturedModalRect(j + 102, k + 20, 176, 0, 30, 26); - } - } + @Override + protected void drawGuiContainerBackgroundLayer(final float f, final int x, final int y) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(background); + final int j = (this.width - this.xSize) / 2; + final int k = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); + if ((this.container.base.guiisoverload()) && (this.container.base.checkrotor())) { + this.drawTexturedModalRect(j + 44, k + 20, 176, 0, 30, 26); + this.drawTexturedModalRect(j + 102, k + 20, 176, 0, 30, 26); + } + } - private static final ResourceLocation background = new ResourceLocation(IC2.textureDomain, "textures/gui/GUIWindKineticGenerator.png"); + private static final ResourceLocation background = + new ResourceLocation(IC2.textureDomain, "textures/gui/GUIWindKineticGenerator.png"); } diff --git a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/tileentity/TileEntityKineticWindGenerator.java b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/tileentity/TileEntityKineticWindGenerator.java index a2c39cb17b..1f9ebcc8bd 100644 --- a/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/tileentity/TileEntityKineticWindGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/ic2/block/kieticgenerator/tileentity/TileEntityKineticWindGenerator.java @@ -1,19 +1,7 @@ package gtPlusPlus.xmod.ic2.block.kieticgenerator.tileentity; -import java.util.List; -import java.util.Vector; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.block.Block; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import net.minecraft.world.ChunkCache; - import ic2.api.energy.tile.IKineticSource; import ic2.api.item.IKineticRotor; import ic2.api.item.IKineticRotor.GearboxType; @@ -23,367 +11,336 @@ import ic2.core.block.kineticgenerator.container.ContainerWindKineticGenerator; import ic2.core.block.kineticgenerator.gui.GuiWindKineticGenerator; import ic2.core.block.kineticgenerator.tileentity.TileEntityWindKineticGenerator; import ic2.core.util.Util; +import java.util.List; +import java.util.Vector; +import net.minecraft.block.Block; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.ChunkCache; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityKineticWindGenerator -extends TileEntityWindKineticGenerator -implements IKineticSource, IHasGui -{ - public final InvSlotConsumableKineticRotor rotorSlot; - private double windStrength; - private int obstructedCrossSection; - private int crossSection; - private int updateTicker; - private float rotationSpeed; - private static final double efficiencyRollOffExponent = 2.0D; - private static final int nominalRotationPeriod = 500; - - public TileEntityKineticWindGenerator() - { - this.updateTicker = IC2.random.nextInt(this.getTickRate()); - this.rotorSlot = new InvSlotConsumableKineticRotor(this, "rotorslot", 0, null, 1, null, GearboxType.WIND); - } - - - public void update2Entity() - { - super.updateEntity(); - - assert (IC2.platform.isSimulating()); - if ((this.updateTicker++ % this.getTickRate()) != 0) { - return; - } - boolean needsInvUpdate = false; - if (!this.rotorSlot.isEmpty()) - { - if (this.checkSpace(1, true) == 0) - { - if (this.getActive() != true) { - this.setActive(true); - } - needsInvUpdate = true; - } - else - { - if (this.getActive()) { - this.setActive(false); - } - needsInvUpdate = true; - } - } - else - { - if (this.getActive()) { - this.setActive(false); - } - needsInvUpdate = true; - } - if (this.getActive()) - { - this.crossSection = (((this.getRotorDiameter() / 2) * 2 * 2) + 1); - - this.crossSection *= this.crossSection; - this.obstructedCrossSection = this.checkSpace(this.getRotorDiameter() * 3, false); - if ((this.obstructedCrossSection > 0) && (this.obstructedCrossSection <= ((this.getRotorDiameter() + 1) / 2))) { - this.obstructedCrossSection = 0; - } else if (this.obstructedCrossSection < 0) { - this.obstructedCrossSection = this.crossSection; - } - this.windStrength = this.calcWindStrength(); - - final float speed = (float)Util.limit((this.windStrength - this.getMinWindStrength()) / this.getMaxWindStrength(), 0.0D, 2.0D); - - - this.setRotationSpeed(speed*2); - if (this.windStrength >= this.getMinWindStrength()) { - if (this.windStrength <= this.getMaxWindStrength()) { - this.rotorSlot.damage(1, false); - } else { - this.rotorSlot.damage(4, false); - } - } - } - } - - - - @Override - public List getNetworkedFields() - { - final List ret = new Vector<>(1); - - ret.add("rotationSpeed"); - ret.add("rotorSlot"); - ret.addAll(super.getNetworkedFields()); - - return ret; - } - - @Override - public ContainerBase getGuiContainer(final EntityPlayer entityPlayer) - { - return new ContainerWindKineticGenerator(entityPlayer, this); - } - - @Override - @SideOnly(Side.CLIENT) - public GuiScreen getGui(final EntityPlayer entityPlayer, final boolean isAdmin) - { - return new GuiWindKineticGenerator(new ContainerWindKineticGenerator(entityPlayer, this)); - } - - @Override - public boolean facingMatchesDirection(final ForgeDirection direction) - { - return direction.ordinal() == this.getFacing(); - } - - @Override - public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side) - { - if ((side == 0) || (side == 1)) { - return false; - } - return this.getFacing() != side; - } - - @Override - public void setFacing(final short side) - { - super.setFacing(side); - } - - public boolean enableUpdateEntity() - { - return IC2.platform.isSimulating(); - } - - @Override - public String getRotorhealth() - { - if (!this.rotorSlot.isEmpty()) { - return StatCollector.translateToLocalFormatted("ic2.WindKineticGenerator.gui.rotorhealth", new Object[] { Integer.valueOf((int)(100.0F - ((this.rotorSlot.get().getItemDamage() / this.rotorSlot.get().getMaxDamage()) * 100.0F))) }); - } - return ""; - } - - @Override - public int maxrequestkineticenergyTick(final ForgeDirection directionFrom) - { - return this.getKuOutput(); - } - - @Override - public int requestkineticenergy(final ForgeDirection directionFrom, final int requestkineticenergy) - { - if (this.facingMatchesDirection(directionFrom.getOpposite())) { - return Math.min(requestkineticenergy, this.getKuOutput()); - } - return 0; - } - - @Override - public String getInventoryName() - { - return "Advanced Kinetic Wind Generator"; - } - - @Override - public void onGuiClosed(final EntityPlayer entityPlayer) {} - - @Override - public boolean shouldRenderInPass(final int pass) - { - return pass == 0; - } - - @Override - public int checkSpace(int length, final boolean onlyrotor) - { - int box = this.getRotorDiameter() / 2; - int lentemp = 0; - if (onlyrotor) - { - length = 1; - lentemp = length + 1; - } - if (!onlyrotor) { - box *= 2; - } - final ForgeDirection fwdDir = ForgeDirection.VALID_DIRECTIONS[this.getFacing()]; - final ForgeDirection rightDir = fwdDir.getRotation(ForgeDirection.DOWN); - - final int xMaxDist = Math.abs((length * fwdDir.offsetX) + (box * rightDir.offsetX)); - - final int zMaxDist = Math.abs((length * fwdDir.offsetZ) + (box * rightDir.offsetZ)); - - - final ChunkCache chunkCache = new ChunkCache(this.worldObj, this.xCoord - xMaxDist, this.yCoord - box, this.zCoord - zMaxDist, this.xCoord + xMaxDist, this.yCoord + box, this.zCoord + zMaxDist, 0); - - - - int ret = 0; - for (int up = -box; up <= box; up++) - { - final int y = this.yCoord + up; - for (int right = -box; right <= box; right++) - { - boolean occupied = false; - for (int fwd = lentemp - length; fwd <= length; fwd++) - { - final int x = this.xCoord + (fwd * fwdDir.offsetX) + (right * rightDir.offsetX); - - final int z = this.zCoord + (fwd * fwdDir.offsetZ) + (right * rightDir.offsetZ); - - - assert (Math.abs(x - this.xCoord) <= xMaxDist); - assert (Math.abs(z - this.zCoord) <= zMaxDist); - - final Block block = chunkCache.getBlock(x, y, z); - if (!block.isAir(chunkCache, x, y, z)) - { - occupied = true; - if (((up != 0) || (right != 0) || (fwd != 0)) && ((chunkCache.getTileEntity(x, y, z) instanceof TileEntityKineticWindGenerator)) && (!onlyrotor)) { - return -1; - } - } - } - if (occupied) { - ret++; - } - } - } - return ret; - } - - @Override - public boolean checkrotor() - { - return !this.rotorSlot.isEmpty(); - } - - @Override - public boolean rotorspace() - { - return this.checkSpace(1, true) == 0; - } - - private void setRotationSpeed(final float speed) - { - if (this.rotationSpeed != speed) - { - this.rotationSpeed = speed; - IC2.network.get().updateTileEntityField(this, "rotationSpeed"); - } - } - - @Override - public int getTickRate() - { - return 32; - } - - @Override - public double calcWindStrength() - { - double windStr = WorldData.get(this.worldObj).windSim.getWindAt(this.yCoord); - - windStr *= (1.0D - Math.pow(this.obstructedCrossSection / this.crossSection, 2.0D)); - - - return Math.max(0.0D, windStr); - } - - @Override - public float getAngle() - { - if (this.rotationSpeed > 0.0F) - { - final long period = (long) (5.0E+008F / this.rotationSpeed); - - - return ((float)(System.nanoTime() % period) / (float)period) * 360.0F; - } - return 0.0F; - } - - @Override - public float getefficiency() - { - final ItemStack stack = this.rotorSlot.get(); - if ((stack != null) && ((stack.getItem() instanceof IKineticRotor))) { - return (float) (((IKineticRotor)stack.getItem()).getEfficiency(stack)*1.5); - } - return 0.0F; - } - - @Override - public int getMinWindStrength() - { - final ItemStack stack = this.rotorSlot.get(); - if ((stack != null) && ((stack.getItem() instanceof IKineticRotor))) { - return ((IKineticRotor)stack.getItem()).getMinWindStrength(stack)/2; - } - return 0; - } - - @Override - public int getMaxWindStrength() - { - final ItemStack stack = this.rotorSlot.get(); - if ((stack != null) && ((stack.getItem() instanceof IKineticRotor))) { - return ((IKineticRotor)stack.getItem()).getMaxWindStrength(stack)*2; - } - return 0; - } - - @Override - public int getRotorDiameter() - { - final ItemStack stack = this.rotorSlot.get(); - if ((stack != null) && ((stack.getItem() instanceof IKineticRotor))) { - return ((IKineticRotor)stack.getItem()).getDiameter(stack)/2; - } - return 0; - } - - @Override - public ResourceLocation getRotorRenderTexture() - { - final ItemStack stack = this.rotorSlot.get(); - if ((stack != null) && ((stack.getItem() instanceof IKineticRotor))) { - return ((IKineticRotor)stack.getItem()).getRotorRenderTexture(stack); - } - return new ResourceLocation(IC2.textureDomain, "textures/items/rotors/rotorWoodmodel.png"); - } - - @Override - public boolean guiisoverload() - { - if (this.windStrength > this.getMaxWindStrength()) { - return true; - } - return false; - } - - @Override - public boolean guiisminWindStrength() - { - return this.windStrength >= this.getMinWindStrength(); - } - - @Override - public int getKuOutput() - { - if ((this.windStrength >= this.getMinWindStrength()) && (this.getActive())) { - return (int)(this.windStrength * 50.0D * this.getefficiency()); - } - return 0; - } - - @Override - public int getWindStrength() - { - return (int)this.windStrength; - } +public class TileEntityKineticWindGenerator extends TileEntityWindKineticGenerator implements IKineticSource, IHasGui { + public final InvSlotConsumableKineticRotor rotorSlot; + private double windStrength; + private int obstructedCrossSection; + private int crossSection; + private int updateTicker; + private float rotationSpeed; + private static final double efficiencyRollOffExponent = 2.0D; + private static final int nominalRotationPeriod = 500; + + public TileEntityKineticWindGenerator() { + this.updateTicker = IC2.random.nextInt(this.getTickRate()); + this.rotorSlot = new InvSlotConsumableKineticRotor(this, "rotorslot", 0, null, 1, null, GearboxType.WIND); + } + + public void update2Entity() { + super.updateEntity(); + + assert (IC2.platform.isSimulating()); + if ((this.updateTicker++ % this.getTickRate()) != 0) { + return; + } + boolean needsInvUpdate = false; + if (!this.rotorSlot.isEmpty()) { + if (this.checkSpace(1, true) == 0) { + if (this.getActive() != true) { + this.setActive(true); + } + needsInvUpdate = true; + } else { + if (this.getActive()) { + this.setActive(false); + } + needsInvUpdate = true; + } + } else { + if (this.getActive()) { + this.setActive(false); + } + needsInvUpdate = true; + } + if (this.getActive()) { + this.crossSection = (((this.getRotorDiameter() / 2) * 2 * 2) + 1); + + this.crossSection *= this.crossSection; + this.obstructedCrossSection = this.checkSpace(this.getRotorDiameter() * 3, false); + if ((this.obstructedCrossSection > 0) + && (this.obstructedCrossSection <= ((this.getRotorDiameter() + 1) / 2))) { + this.obstructedCrossSection = 0; + } else if (this.obstructedCrossSection < 0) { + this.obstructedCrossSection = this.crossSection; + } + this.windStrength = this.calcWindStrength(); + + final float speed = (float) + Util.limit((this.windStrength - this.getMinWindStrength()) / this.getMaxWindStrength(), 0.0D, 2.0D); + + this.setRotationSpeed(speed * 2); + if (this.windStrength >= this.getMinWindStrength()) { + if (this.windStrength <= this.getMaxWindStrength()) { + this.rotorSlot.damage(1, false); + } else { + this.rotorSlot.damage(4, false); + } + } + } + } + + @Override + public List getNetworkedFields() { + final List ret = new Vector<>(1); + + ret.add("rotationSpeed"); + ret.add("rotorSlot"); + ret.addAll(super.getNetworkedFields()); + + return ret; + } + + @Override + public ContainerBase getGuiContainer(final EntityPlayer entityPlayer) { + return new ContainerWindKineticGenerator(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(final EntityPlayer entityPlayer, final boolean isAdmin) { + return new GuiWindKineticGenerator(new ContainerWindKineticGenerator(entityPlayer, this)); + } + + @Override + public boolean facingMatchesDirection(final ForgeDirection direction) { + return direction.ordinal() == this.getFacing(); + } + + @Override + public boolean wrenchCanSetFacing(final EntityPlayer entityPlayer, final int side) { + if ((side == 0) || (side == 1)) { + return false; + } + return this.getFacing() != side; + } + + @Override + public void setFacing(final short side) { + super.setFacing(side); + } + + public boolean enableUpdateEntity() { + return IC2.platform.isSimulating(); + } + + @Override + public String getRotorhealth() { + if (!this.rotorSlot.isEmpty()) { + return StatCollector.translateToLocalFormatted("ic2.WindKineticGenerator.gui.rotorhealth", new Object[] { + Integer.valueOf((int) (100.0F + - ((this.rotorSlot.get().getItemDamage() + / this.rotorSlot.get().getMaxDamage()) + * 100.0F))) + }); + } + return ""; + } + + @Override + public int maxrequestkineticenergyTick(final ForgeDirection directionFrom) { + return this.getKuOutput(); + } + + @Override + public int requestkineticenergy(final ForgeDirection directionFrom, final int requestkineticenergy) { + if (this.facingMatchesDirection(directionFrom.getOpposite())) { + return Math.min(requestkineticenergy, this.getKuOutput()); + } + return 0; + } + + @Override + public String getInventoryName() { + return "Advanced Kinetic Wind Generator"; + } + + @Override + public void onGuiClosed(final EntityPlayer entityPlayer) {} + + @Override + public boolean shouldRenderInPass(final int pass) { + return pass == 0; + } + + @Override + public int checkSpace(int length, final boolean onlyrotor) { + int box = this.getRotorDiameter() / 2; + int lentemp = 0; + if (onlyrotor) { + length = 1; + lentemp = length + 1; + } + if (!onlyrotor) { + box *= 2; + } + final ForgeDirection fwdDir = ForgeDirection.VALID_DIRECTIONS[this.getFacing()]; + final ForgeDirection rightDir = fwdDir.getRotation(ForgeDirection.DOWN); + + final int xMaxDist = Math.abs((length * fwdDir.offsetX) + (box * rightDir.offsetX)); + + final int zMaxDist = Math.abs((length * fwdDir.offsetZ) + (box * rightDir.offsetZ)); + + final ChunkCache chunkCache = new ChunkCache( + this.worldObj, + this.xCoord - xMaxDist, + this.yCoord - box, + this.zCoord - zMaxDist, + this.xCoord + xMaxDist, + this.yCoord + box, + this.zCoord + zMaxDist, + 0); + + int ret = 0; + for (int up = -box; up <= box; up++) { + final int y = this.yCoord + up; + for (int right = -box; right <= box; right++) { + boolean occupied = false; + for (int fwd = lentemp - length; fwd <= length; fwd++) { + final int x = this.xCoord + (fwd * fwdDir.offsetX) + (right * rightDir.offsetX); + + final int z = this.zCoord + (fwd * fwdDir.offsetZ) + (right * rightDir.offsetZ); + + assert (Math.abs(x - this.xCoord) <= xMaxDist); + assert (Math.abs(z - this.zCoord) <= zMaxDist); + + final Block block = chunkCache.getBlock(x, y, z); + if (!block.isAir(chunkCache, x, y, z)) { + occupied = true; + if (((up != 0) || (right != 0) || (fwd != 0)) + && ((chunkCache.getTileEntity(x, y, z) instanceof TileEntityKineticWindGenerator)) + && (!onlyrotor)) { + return -1; + } + } + } + if (occupied) { + ret++; + } + } + } + return ret; + } + + @Override + public boolean checkrotor() { + return !this.rotorSlot.isEmpty(); + } + + @Override + public boolean rotorspace() { + return this.checkSpace(1, true) == 0; + } + + private void setRotationSpeed(final float speed) { + if (this.rotationSpeed != speed) { + this.rotationSpeed = speed; + IC2.network.get().updateTileEntityField(this, "rotationSpeed"); + } + } + + @Override + public int getTickRate() { + return 32; + } + + @Override + public double calcWindStrength() { + double windStr = WorldData.get(this.worldObj).windSim.getWindAt(this.yCoord); + + windStr *= (1.0D - Math.pow(this.obstructedCrossSection / this.crossSection, 2.0D)); + + return Math.max(0.0D, windStr); + } + + @Override + public float getAngle() {