diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/gregtech/api/util/LaserRenderingUtil.java | 102 | ||||
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialLaserEngraver.java | 41 | ||||
-rw-r--r-- | src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EMS.png | bin | 426 -> 800 bytes | |||
-rw-r--r-- | src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_LASER.png | bin | 373 -> 671 bytes |
4 files changed, 18 insertions, 125 deletions
diff --git a/src/main/java/gregtech/api/util/LaserRenderingUtil.java b/src/main/java/gregtech/api/util/LaserRenderingUtil.java deleted file mode 100644 index e42d23bc85..0000000000 --- a/src/main/java/gregtech/api/util/LaserRenderingUtil.java +++ /dev/null @@ -1,102 +0,0 @@ -package gregtech.api.util; - -import java.util.function.Consumer; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; - -import com.gtnewhorizon.structurelib.StructureLibAPI; -import com.gtnewhorizon.structurelib.structure.ICustomBlockSetting; -import com.gtnewhorizon.structurelib.structure.IItemSource; -import com.gtnewhorizon.structurelib.structure.IStructureElement; -import com.gtnewhorizon.structurelib.structure.StructureUtility; - -public class LaserRenderingUtil { - // This code is shamelessly ripped from GTNH-Intergalactic - - public interface IBlockAdder<T> { - - /** - * Callback on block added, needs to check if block is valid (and add it) - * - * @param block block attempted to add - * @param meta meta of block attempted to add - * @param world World of the block - * @param x X coordinate of the block - * @param y Y coordinate of the block - * @param z Z coordinate of the block - * @return is structure still valid - */ - boolean apply(T t, Block block, int meta, World world, int x, int y, int z); - } - - public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder, Block defaultBlock, - int defaultMeta) { - if (iBlockAdder == null || defaultBlock == null) { - throw new IllegalArgumentException(); - } - if (defaultBlock instanceof ICustomBlockSetting) { - return new IStructureElement<T>() { - - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z), world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - - @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, - IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { - if (check(t, world, x, y, z)) return PlaceResult.SKIP; - return StructureUtility - .survivalPlaceBlock(defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter); - } - }; - } else { - return new IStructureElement<T>() { - - @Override - public boolean check(T t, World world, int x, int y, int z) { - Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder - .apply(t, worldBlock, ((Block) worldBlock).getDamageValue(world, x, y, z), world, x, y, z); - } - - @Override - public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); - return true; - } - - @Override - public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, defaultBlock, defaultMeta); - return true; - } - - @Override - public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger, - IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { - if (check(t, world, x, y, z)) return IStructureElement.PlaceResult.SKIP; - return StructureUtility - .survivalPlaceBlock(defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter); - } - }; - } - } -} diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialLaserEngraver.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialLaserEngraver.java index e79244f881..1516695a88 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialLaserEngraver.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEIndustrialLaserEngraver.java @@ -16,7 +16,6 @@ import java.util.Map; import javax.annotation.Nonnull; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -55,7 +54,6 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; -import gregtech.api.util.LaserRenderingUtil; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.common.blocks.BlockCasings10; import gregtech.common.tileentities.render.TileEntityLaser; @@ -88,10 +86,7 @@ public class MTEIndustrialLaserEngraver extends MTEExtendedPowerMultiBlockBase<M 'g', BorosilicateGlass .ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glassTier = t, te -> te.glassTier)) - .addElement( - 'r', - LaserRenderingUtil - .ofBlockAdder(MTEIndustrialLaserEngraver::laserRendererAdder, GregTechAPI.sLaserRender, 0)) + .addElement('r', ofBlock(GregTechAPI.sLaserRender, 0)) .addElement( 's', buildHatchAdder(MTEIndustrialLaserEngraver.class).adder(MTEIndustrialLaserEngraver::addLaserSource) @@ -136,19 +131,6 @@ public class MTEIndustrialLaserEngraver extends MTEExtendedPowerMultiBlockBase<M return false; } - private boolean laserRendererAdder(Block block, int meta, World world, int x, int y, int z) { - if (block != GregTechAPI.sLaserRender || world == null) { - return false; - } - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TileEntityLaser) { - renderer = (TileEntityLaser) te; - renderer.setRotationFields(getDirection(), getRotation(), getFlip()); - return true; - } - return false; - } - public MTEIndustrialLaserEngraver(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -273,7 +255,7 @@ public class MTEIndustrialLaserEngraver extends MTEExtendedPowerMultiBlockBase<M .addSeparator() .beginStructureBlock(5, 5, 5, false) .addController("Front Center") - .addCasingInfoMin("Laser Containment Casing", 45, false) + .addCasingInfoMin("Laser Containment Casing", 35, false) .addCasingInfoExactly("Tungstensteel Frame Box", 9, false) .addOtherStructurePart("Laser Resistant Plate", "x1") .addOtherStructurePart("Borosilicate Glass", "x3") @@ -305,15 +287,28 @@ public class MTEIndustrialLaserEngraver extends MTEExtendedPowerMultiBlockBase<M mCasingAmount++; } + private boolean findLaserRenderer(World w, int x, int y, int z) { + ForgeDirection opposite = getDirection().getOpposite(); + x = x + opposite.offsetX; + y = y + opposite.offsetY; + z = z + opposite.offsetZ; + if (w.getTileEntity(x, y, z) instanceof TileEntityLaser laser) { + renderer = laser; + renderer.setRotationFields(getDirection(), getRotation(), getFlip()); + return true; + } + return false; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasingAmount = 0; - mEnergyHatches.clear(); + IGregTechTileEntity base = getBaseMetaTileEntity(); if (!checkPiece(STRUCTURE_PIECE_MAIN, 2, 4, 0)) return false; - if (mCasingAmount < 45) return false; + if (mCasingAmount < 35) return false; if (laserSource == null) return false; - if (renderer == null) return false; + if (!findLaserRenderer(base.getWorld(), base.getXCoord(), base.getYCoord(), base.getZCoord())) return false; if (glassTier < VoltageIndex.UMV && laserSource.mTier > glassTier) return false; return true; diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EMS.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EMS.png Binary files differindex ab7bce0f92..92d02bbdcd 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EMS.png +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_EMS.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_LASER.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_LASER.png Binary files differindex a678849976..a18bf1dab8 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_LASER.png +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/MACHINE_CASING_LASER.png |