diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-10-31 17:09:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-31 17:09:23 +0100 |
commit | 973c7c450512224722cebbd62c817bfb96bc3784 (patch) | |
tree | 85868c3433c81d943aa4579b668f7080bcfc906a /src/main | |
parent | 0093be04e46484d89f1c55eaee4d83e50833ca5e (diff) | |
download | GT5-Unofficial-973c7c450512224722cebbd62c817bfb96bc3784.tar.gz GT5-Unofficial-973c7c450512224722cebbd62c817bfb96bc3784.tar.bz2 GT5-Unofficial-973c7c450512224722cebbd62c817bfb96bc3784.zip |
EIG: Fix stocking input bus exploit (#230)
* Disgusting
* Fix exploit
* Maybe fix black wheat blocks inside
* Ok we will fight then
* Cosmetics
* Proper fix
Former-commit-id: 75e23bbf8e9abce88b1a4108a9dc1aa85a6f2ff6
Diffstat (limited to 'src/main')
3 files changed, 25 insertions, 11 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_CropVisualizer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_CropVisualizer.java index c1880bfca0..7fb7c82463 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_CropVisualizer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_CropVisualizer.java @@ -2,6 +2,7 @@ package com.github.bartimaeusnek.bartworks.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Field; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; @@ -12,6 +13,7 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class BW_CropVisualizer extends EntityFX { int meta; + Field tessellatorHasBrightnessField = null; public BW_CropVisualizer(World world, int x, int y, int z, int meta, int age) { super(world, (double) x, ((double) y - 0.0625d), (double) z); @@ -39,10 +41,19 @@ public class BW_CropVisualizer extends EntityFX { Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); + double f11 = this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX; + double f12 = this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY; + double f13 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ; + try { + if (tessellatorHasBrightnessField == null) { + tessellatorHasBrightnessField = Tessellator.class.getDeclaredField("hasBrightness"); + tessellatorHasBrightnessField.setAccessible(true); + } + tessellatorHasBrightnessField.set(tessellator, false); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } tessellator.setColorRGBA(255, 255, 255, 255); - float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX); - float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY); - float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ); RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta, f11, f12, f13); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ExtremeIndustrialGreenhouse.java index f5eb642046..7ab04ae24b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ExtremeIndustrialGreenhouse.java @@ -19,6 +19,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_VIA_BARTWORKS; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_Values.AuthorKuba; import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -205,6 +206,7 @@ public class GT_TileEntity_ExtremeIndustrialGreenhouse GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Crop Farm") .addInfo("Controller block for the Extreme Industrial Greenhouse") + .addInfo(AuthorKuba) .addInfo("Grow your crops like a chad !") .addInfo("Use screwdriver to enable/change/disable setup mode") .addInfo("Use screwdriver while sneaking to enable/disable IC2 mode") @@ -563,14 +565,12 @@ public class GT_TileEntity_ExtremeIndustrialGreenhouse public boolean addCrop(ItemStack input) { if (!isIC2Mode) for (GreenHouseSlot g : mStorage) - if (GT_Utility.areStacksEqual(g.input, input)) { + if (g.input.stackSize < 64 && GT_Utility.areStacksEqual(g.input, input)) { g.addAll(this.getBaseMetaTileEntity().getWorld(), input); if (input.stackSize == 0) return true; } - GreenHouseSlot h = new GreenHouseSlot(this, input.copy(), true, isIC2Mode); + GreenHouseSlot h = new GreenHouseSlot(this, input, true, isIC2Mode); if (h.isValid) { - if (isIC2Mode) input.stackSize--; - else input.stackSize = 0; mStorage.add(h); return true; } @@ -724,7 +724,7 @@ public class GT_TileEntity_ExtremeIndustrialGreenhouse if (i == Items.reeds) b = Blocks.reeds; else { b = Block.getBlockFromItem(i); - if (!(b == Blocks.cactus)) return; + if (b != Blocks.cactus) return; } needsreplanting = false; } @@ -746,7 +746,9 @@ public class GT_TileEntity_ExtremeIndustrialGreenhouse crop = b; isIC2Crop = false; - if (addDrops(world, input.stackSize, autocraft) == 0 && !drops.isEmpty()) { + int toUse = Math.min(64, input.stackSize); + if (addDrops(world, toUse, autocraft) == 0 && !drops.isEmpty()) { + input.stackSize -= toUse; this.isValid = true; } } @@ -840,8 +842,7 @@ public class GT_TileEntity_ExtremeIndustrialGreenhouse int dur = cc.growthDuration(te); int rate = te.calcGrowthRate(); - if (rate == 0) // should not be possible with those stats - return; + if (rate == 0) return; // should not be possible with those stats growthticks = dur / rate; if (growthticks < 1) growthticks = 1; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java index 2442089032..9c0fdecd74 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_HTGR.java @@ -19,6 +19,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_VIA_BARTWORKS; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_Values.AuthorKuba; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.github.bartimaeusnek.bartworks.common.items.SimpleSubItemClass; @@ -285,6 +286,7 @@ public class GT_TileEntity_HTGR extends GT_MetaTileEntity_EnhancedMultiBlockBase GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Breeder Reactor") .addInfo("Controller block for the High Temperature Gas-cooled Reactor (HTGR)") + .addInfo(AuthorKuba) .addInfo("You can clear internal buffer by changing the mode with a screwdriver") .addInfo("Needs a constant supply of coolant while running") .addInfo("Needs at least 72k Fuel pebbles to start operation (can hold up to 720k pebbles)") |