diff options
author | NotAPenguin <michiel.vandeginste@gmail.com> | 2024-08-24 15:12:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-24 15:12:00 +0200 |
commit | c2e8f2754f8b5868e7b2110c6442410ce686ff0a (patch) | |
tree | 3c5b2b33065fdb0578abaebc6384662bb496d8fe | |
parent | f89d122ce4492281981140fd9e1612cea08313cf (diff) | |
download | GT5-Unofficial-c2e8f2754f8b5868e7b2110c6442410ce686ff0a.tar.gz GT5-Unofficial-c2e8f2754f8b5868e7b2110c6442410ce686ff0a.tar.bz2 GT5-Unofficial-c2e8f2754f8b5868e7b2110c6442410ce686ff0a.zip |
Make frame boxes no longer TileEntities (#2799)
* fiddling around with frame boxes
* more fiddling
* am trying
* frames exist
* fix frame rendering in inventory
* Fix in world frame rendering
* Apply cover to dumb frame
* continue work on frames
* apply covers to correct side and fix crash on load
* Test permissions
* fix oredict for new frames and create recipes
* fix waila names and drops (kind of)
* fix drops
* mostly all working
* remove old comment
* fix structurecheck using new frames
* create the TE transformer
* it didnt work
* dont modify tes we dont want to modify (needs future postea update)
* it works!
* item transformer works too
* spotless
* add more method overrides from generic gt block?
* update postea
* fix postea transforming items in reserved frame range that were not frame boxes
* fix tesla tower structurecheck + capacitor hatch crash
* Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
* Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
* Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
* Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
* Spotless apply for branch dumb-frames for #2799 (#2953)
spotlessApply
Co-authored-by: GitHub GTNH Actions <>
* remove extra null check
* Update src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
* remove more messy instanceof checks
* Spotless apply for branch dumb-frames for #2799 (#2954)
spotlessApply
Co-authored-by: GitHub GTNH Actions <>
* remove unnecessary null check
* try fixing facade color
* Update src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
* small cleanup in framebox gen code
* swap material for frame box block
* fix description
* make getMaterial static and add fix AE cover color
* nicer casts + localize tooltip in frame block instead of stealing old localization
* draw grid on cover hover
* add a null check in getTexture() that hopefully fixes crash in full pack when interacting with frame boxes
* also draw grid when hovering with wrench
* add chemical element back to tooltip
* fix breaking frame not causing structure update
---------
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: Alexander Anishin <14104815+OneEyeMaker@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
13 files changed, 685 insertions, 130 deletions
diff --git a/dependencies.gradle b/dependencies.gradle index 9384198e4f..fc0843c37c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -45,6 +45,7 @@ dependencies { api("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-433-GTNH:dev") api("com.github.GTNewHorizons:AE2FluidCraft-Rework:1.3.24-gtnh:dev") api('com.github.GTNewHorizons:Yamcl:0.6.0:dev') + api("com.github.GTNewHorizons:Postea:1.0.8:dev") compileOnlyApi('com.github.GTNewHorizons:ThaumicTinkerer:2.10.1:dev') compileOnlyApi("com.github.GTNewHorizons:Mobs-Info:0.4.2-GTNH:dev") diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 4bf5b8f868..410d045a20 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -28,16 +28,15 @@ import static gregtech.api.enums.GT_HatchElement.Maintenance; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; +import static gregtech.api.util.GT_StructureUtility.ofFrame; import static gregtech.api.util.GT_Utility.filterValidMTEs; import static java.lang.Math.min; import static net.minecraft.util.StatCollector.translateToLocal; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -45,15 +44,9 @@ import javax.annotation.Nonnull; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; @@ -78,26 +71,19 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_Rend import com.github.technus.tectech.util.CommonValues; import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; -import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.IStructureElement; -import com.gtnewhorizon.structurelib.structure.StructureUtility; -import com.gtnewhorizon.structurelib.util.ItemStackPredicate; import com.gtnewhorizon.structurelib.util.Vec3Impl; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; @@ -107,11 +93,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; import gregtech.api.util.IGT_HatchAdder; import gregtech.api.util.shutdown.ShutDownReason; -import gregtech.common.blocks.GT_Item_Machines; public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements ISurvivalConstructable, ITeslaConnectable { @@ -245,63 +228,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock .dot(1) .casingIndex(textureOffset + 16 + 6) .buildAndChain(sBlockCasingsBA0, 6)) - .addElement('F', new IStructureElement<GT_MetaTileEntity_TM_teslaCoil>() { - - private IIcon[] mIcons; - - @Override - public boolean check(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z) { - TileEntity tBase = world.getTileEntity(x, y, z); - if (tBase instanceof BaseMetaPipeEntity tPipeBase) { - if (tPipeBase.isInvalidTileEntity()) return false; - return tPipeBase.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame; - } - return false; - } - - @Override - public boolean spawnHint(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z, - ItemStack trigger) { - if (mIcons == null) { - mIcons = new IIcon[6]; - Arrays - .fill(mIcons, Materials._NULL.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon()); - } - StructureLibAPI.hintParticleTinted(world, x, y, z, mIcons, Materials._NULL.mRGBa); - return true; - } - - @Override - public boolean placeBlock(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z, - ItemStack trigger) { - ItemStack tFrameStack = GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Titanium, 1); - if (!GT_Utility.isStackValid(tFrameStack) - || !(tFrameStack.getItem() instanceof ItemBlock tFrameStackItem)) return false; - return tFrameStackItem - .placeBlockAt(tFrameStack, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrameStack)); - } - - @Override - public PlaceResult survivalPlaceBlock(GT_MetaTileEntity_TM_teslaCoil t, World world, int x, int y, int z, - ItemStack trigger, IItemSource source, EntityPlayerMP actor, Consumer<IChatComponent> chatter) { - if (check(t, world, x, y, z)) return PlaceResult.SKIP; - ItemStack tFrameStack = source - .takeOne(s -> GT_Item_Machines.getMetaTileEntity(s) instanceof GT_MetaPipeEntity_Frame, true); - if (tFrameStack == null) return PlaceResult.REJECT; - return StructureUtility.survivalPlaceBlock( - tFrameStack, - ItemStackPredicate.NBTMode.IGNORE_KNOWN_INSIGNIFICANT_TAGS, - null, - false, - world, - x, - y, - z, - source, - actor, - chatter); - } - }) + .addElement('F', ofFrame(Materials.Titanium)) .build(); // endregion @@ -815,7 +742,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public void stopMachine(@Nonnull ShutDownReason reason) { super.stopMachine(reason); - for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { + for (GT_MetaTileEntity_Hatch_Capacitor cap : filterValidMTEs(eCapacitorHatches)) { cap.getBaseMetaTileEntity() .setActive(false); } diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index d66ac29f4c..a90d36b3bb 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -110,6 +110,7 @@ import gregtech.loaders.postload.GT_PostLoad; import gregtech.loaders.postload.GT_RecyclerBlacklistLoader; import gregtech.loaders.postload.GT_ScrapboxDropLoader; import gregtech.loaders.postload.GT_Worldgenloader; +import gregtech.loaders.postload.PosteaTransformers; import gregtech.loaders.preload.GT_Loader_CircuitBehaviors; import gregtech.loaders.preload.GT_Loader_ItemData; import gregtech.loaders.preload.GT_Loader_Item_Block_And_Fluid; @@ -505,6 +506,9 @@ public class GT_Mod implements IGT_Mod { GT_PostLoad.nerfVanillaTools(); + // Register postea transformers + new PosteaTransformers().run(); + /* * Until this point most crafting recipe additions, and removals, have been buffered. Go through, execute the * removals in bulk, and then any deferred additions. The bulk removals in particular significantly speed up the diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index 62727f4b62..c382e90fef 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -249,6 +249,7 @@ public class GregTech_API { sBlockCasings8, sBlockCasings9, sBlockCasings10, sBlockCasings11, sSolenoidCoilCasings; public static Block sBlockLongDistancePipes; public static Block sDroneRender; + public static Block sBlockFrames; public static Block sBlockGlass1; public static Block sBlockTintedGlass; public static Block sLaserRender; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java index 399c536b9f..7cb2b3a9bd 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java @@ -1,30 +1,18 @@ package gregtech.api.metatileentity.implementations; -import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; -import static gregtech.api.util.GT_RecipeBuilder.SECONDS; -import static gregtech.api.util.GT_RecipeBuilder.TICKS; -import static gregtech.api.util.GT_Utility.calculateRecipeEU; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.Dyes; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; -import gregtech.api.enums.TierEU; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_ModHandler.RecipeBits; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { @@ -35,27 +23,8 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { public GT_MetaPipeEntity_Frame(int aID, String aName, String aNameRegional, Materials aMaterial) { super(aID, aName, aNameRegional, 0); mMaterial = aMaterial; - - GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, getStackForm(1)); - if (aMaterial.getProcessingMaterialTierEU() < TierEU.IV) { - GT_ModHandler.addCraftingRecipe( - getStackForm(2), - RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, - new Object[] { "SSS", "SwS", "SSS", 'S', OrePrefixes.stick.get(mMaterial) }); - } - - if (!aMaterial.contains(SubTag.NO_RECIPES) - && GT_OreDictUnificator.get(OrePrefixes.stick, aMaterial, 1) != null) { - // Auto generate frame box recipe in an assembler. - GT_Values.RA.stdBuilder() - .itemInputs( - GT_OreDictUnificator.get(OrePrefixes.stick, aMaterial, 4), - GT_Utility.getIntegratedCircuit(4)) - .itemOutputs(getStackForm(1)) - .duration(3 * SECONDS + 4 * TICKS) - .eut(calculateRecipeEU(aMaterial, 7)) - .addTo(assemblerRecipes); - } + // Hide TileEntity frame in NEI, since we have the block version now that should always be used + codechicken.nei.api.API.hideItem(this.getStackForm(1)); } public GT_MetaPipeEntity_Frame(String aName, Materials aMaterial) { diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index d3c4c10a0d..ad3e4e9876 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -44,10 +44,9 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.common.blocks.GT_Block_Casings5; +import gregtech.common.blocks.GT_Block_FrameBox; import gregtech.common.blocks.GT_Item_Machines; public class GT_StructureUtility { @@ -74,11 +73,11 @@ public class GT_StructureUtility { @Override public boolean check(T t, World world, int x, int y, int z) { - TileEntity tBase = world.getTileEntity(x, y, z); - if (tBase instanceof BaseMetaPipeEntity tPipeBase) { - if (tPipeBase.isInvalidTileEntity()) return false; - if (tPipeBase.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame) - return aFrameMaterial == ((GT_MetaPipeEntity_Frame) tPipeBase.getMetaTileEntity()).mMaterial; + Block block = world.getBlock(x, y, z); + if (block instanceof GT_Block_FrameBox frameBox) { + int meta = world.getBlockMetadata(x, y, z); + Materials material = frameBox.getMaterial(meta); + return aFrameMaterial == material; } return false; } diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 79c8256c04..b93060ba59 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -90,6 +90,7 @@ import gregtech.api.util.GT_PlayedSound; import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.client.SeekingOggCodec; +import gregtech.common.blocks.GT_Block_FrameBox; import gregtech.common.blocks.GT_Item_Machines; import gregtech.common.render.GT_CapeRenderer; import gregtech.common.render.GT_FlaskRenderer; @@ -842,8 +843,16 @@ public class GT_Client extends GT_Proxy implements Runnable { if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { if (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable - || (aTileEntity instanceof IOrientable orientable && orientable.canBeRotated())) - drawGrid(aEvent, false, true, aEvent.player.isSneaking()); + || (aTileEntity instanceof IOrientable orientable && orientable.canBeRotated()) + || (aBlock instanceof GT_Block_FrameBox)) drawGrid(aEvent, false, true, aEvent.player.isSneaking()); + return; + } + + // If there is no tile entity and the block is a frame box block, still draw the grid if a cover is held + if (aTileEntity == null && aBlock instanceof GT_Block_FrameBox) { + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) { + drawGrid(aEvent, true, false, aEvent.player.isSneaking()); + } return; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java b/src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java new file mode 100644 index 0000000000..76e3180d58 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java @@ -0,0 +1,446 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.GT_Values.W; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.CoverableTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import gregtech.common.render.GT_Renderer_Block; + +public class GT_Block_FrameBox extends BlockContainer { + + protected final String mUnlocalizedName; + + private static final String DOT_NAME = ".name"; + private static final String DOT_TOOLTIP = ".tooltip"; + + // We need to keep around a temporary TE to preserve this TE after breaking the block, so we can + // properly call getDrops() on it + private static final ThreadLocal<IGregTechTileEntity> mTemporaryTileEntity = new ThreadLocal<>(); + + public GT_Block_FrameBox() { + super(new GT_Material_Machines()); + this.mUnlocalizedName = "gt.blockframes"; + setBlockName(this.mUnlocalizedName); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + W + ".name", "Any Sub Block of this one"); + + GameRegistry.registerBlock(this, GT_Item_Frames.class, getUnlocalizedName()); + + for (int meta = 1; meta < GregTech_API.sGeneratedMaterials.length; meta++) { + Materials material = GregTech_API.sGeneratedMaterials[meta]; + if (material != null && (material.mTypes & 0x02) != 0) { + GT_LanguageManager.addStringLocalization( + getUnlocalizedName() + "." + meta + DOT_NAME, + GT_LanguageManager.i18nPlaceholder ? getLocalizedNameFormat(material) : getLocalizedName(material)); + GT_LanguageManager + .addStringLocalization(getUnlocalizedName() + "." + meta + DOT_TOOLTIP, material.getToolTip()); + } + } + } + + public ItemStack getStackForm(int amount, int meta) { + return new ItemStack(this, amount, meta); + } + + public String getLocalizedNameFormat(Materials aMaterial) { + return switch (aMaterial.mName) { + case "InfusedAir", "InfusedDull", "InfusedEarth", "InfusedEntropy", "InfusedFire", "InfusedOrder", "InfusedVis", "InfusedWater" -> "%material Infused Stone"; + case "Vermiculite", "Bentonite", "Kaolinite", "Talc", "BasalticMineralSand", "GraniticMineralSand", "GlauconiteSand", "CassiteriteSand", "GarnetSand", "QuartzSand", "Pitchblende", "FullersEarth" -> "%material"; + default -> "%material" + " Frame Box"; + }; + } + + @Override + public String getUnlocalizedName() { + return mUnlocalizedName; + } + + public String getLocalizedName(Materials aMaterial) { + return aMaterial.getDefaultLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); + } + + private boolean isCover(ItemStack item) { + return GT_Utility.isStackInList(item, GregTech_API.sCovers.keySet()); + } + + private void createFrame(World worldIn, int x, int y, int z, BaseMetaPipeEntity baseMte) { + // Obtain metadata to grab proper material identifier + int meta = worldIn.getBlockMetadata(x, y, z); + Materials material = getMaterial(meta); + GT_MetaPipeEntity_Frame frame = new GT_MetaPipeEntity_Frame("GT_Frame_" + material, material); + baseMte.setMetaTileEntity(frame); + frame.setBaseMetaTileEntity(baseMte); + } + + private BaseMetaPipeEntity spawnFrameEntity(World worldIn, int x, int y, int z) { + // Spawn a TE frame box at this location, then apply the cover + BaseMetaPipeEntity newTileEntity = new BaseMetaPipeEntity(); + createFrame(worldIn, x, y, z, newTileEntity); + worldIn.setTileEntity(x, y, z, newTileEntity); + return newTileEntity; + } + + // Get the material that this frame box is made of + public static Materials getMaterial(int meta) { + return GregTech_API.sGeneratedMaterials[meta]; + } + + @Override + public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + // Get ForgeDirection from side identifier. + ForgeDirection direction = ForgeDirection.getOrientation(side); + // If this block already holds a TE, just forward the call + TileEntity te = worldIn.getTileEntity(x, y, z); + if (te instanceof BaseMetaPipeEntity baseTileEntity) { + // If this baseTileEntity has no MetaTileEntity associated with it, we need to create it + // This happens on world load for some reason + if (baseTileEntity.getMetaTileEntity() == null) { + createFrame(worldIn, x, y, z, baseTileEntity); + } + return baseTileEntity.onRightclick(player, direction, subX, subY, subZ); + } + + // If there was no TileEntity yet, we need to check if the player was holding a cover item and if so + // spawn a new frame box to apply the cover to + ItemStack item = player.getHeldItem(); + if (isCover(item)) { + BaseMetaPipeEntity newTileEntity = spawnFrameEntity(worldIn, x, y, z); + newTileEntity.onRightclick(player, direction, subX, subY, subZ); + return true; + } + + return false; + } + + @Override + public int getRenderType() { + if (GT_Renderer_Block.INSTANCE == null) { + return super.getRenderType(); + } + return GT_Renderer_Block.mRenderID; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aTab, List<ItemStack> aList) { + for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) { + Materials tMaterial = GregTech_API.sGeneratedMaterials[i]; + // If material is not null and has a frame box item associated with it + if ((tMaterial != null) && ((tMaterial.mTypes & 0x02) != 0)) { + aList.add(new ItemStack(aItem, 1, i)); + } + } + } + + @Override + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return aMeta % 4; + } + + @Override + public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + ForgeDirection forgeSide = switch (ordinalSide) { + case (-2) -> ForgeDirection.DOWN; + case (-1) -> ForgeDirection.UP; + case (0) -> ForgeDirection.NORTH; + case (2) -> ForgeDirection.SOUTH; + case (3) -> ForgeDirection.WEST; + case (1) -> ForgeDirection.EAST; + default -> ForgeDirection.UNKNOWN; + }; + final TileEntity frameEntity = aWorld.getTileEntity(aX, aY, aZ); + return frameEntity instanceof CoverableTileEntity cte && cte.getCoverInfoAtSide(forgeSide) + .getCoverID() != 0; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onBlockDestroyed(); + mTemporaryTileEntity.set(gtTE); + } + // Cause structure update + GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); + super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetadata); + } + + @Override + public void onBlockAdded(World worldIn, int x, int y, int z) { + // Cause structure update + GregTech_API.causeMachineUpdate(worldIn, x, y, z); + super.onBlockAdded(worldIn, x, y, z); + } + + @Override + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + gtTE.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + return; + } + super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } + + @Override + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return (tTileEntity instanceof BaseMetaTileEntity baseMTE) && baseMTE.privateAccess() + && !baseMTE.playerOwnsThis(aPlayer, true) ? -1.0F + : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); + } + + @Override + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseTileEntity baseTE) { + baseTE.onAdjacentBlockChange(aTileX, aTileY, aTileZ); + } + } + + @Override + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaPipeEntity baseMetaPipe) { + baseMetaPipe.onNeighborBlockChange(aX, aY, aZ); + } + } + + @Override + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, Entity collider) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + gtTE.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + return; + } + super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + return gtTE.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + return gtTE.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @Override + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { + if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { + return true; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaTileEntity) { + return true; + } + if (tTileEntity instanceof BaseMetaPipeEntity baseMetaPipe && (baseMetaPipe.mConnections & 0xFFFFFFC0) != 0) { + return true; + } + return (tTileEntity instanceof ICoverable coverable) && coverable.getCoverIDAtSide(side) != 0; + } + + @Override // THIS + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { + final TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + final AxisAlignedBB bbb = gtTE.getCollisionBoundingBoxFromPool(gtTE.getWorld(), 0, 0, 0); + minX = bbb.minX; // This essentially sets block bounds + minY = bbb.minY; + minZ = bbb.minZ; + maxX = bbb.maxX; + maxY = bbb.maxY; + maxZ = bbb.maxZ; + return; + } + super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); + } + + @Override + public void setBlockBoundsForItemRender() { + super.setBlockBounds(0, 0, 0, 1, 1, 1); + } + + @Override + public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + @Override + public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { + return false; + } + + @Override + public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean hasTileEntity(int aMeta) { + return true; + } + + @Override + public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { + super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { + // Find temporary TE if there was one + final IGregTechTileEntity tempTe = mTemporaryTileEntity.get(); + ArrayList<ItemStack> drops = new ArrayList<>(); + drops.add(getStackForm(1, metadata)); + // If there is one, grab all attached covers and drop them + if (tempTe != null) { + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + ItemStack cover = tempTe.getCoverItemAtSide(direction); + if (cover != null) drops.add(cover); + } + } + // Make sure to clear the temporary TE + mTemporaryTileEntity.remove(); + return drops; + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { + return 0; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); + } + return 0; + } + + @Override + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { + return 0; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getStrongOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); + } + return 0; + } + + @Override + public IIcon getIcon(int side, int meta) { + Materials material = GregTech_API.sGeneratedMaterials[meta]; + if (material == null) return null; + return material.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon(); + } + + public ITexture[] getTexture(int meta) { + Materials material = getMaterial(meta); + if (material == null) return null; + return new ITexture[] { TextureFactory.of( + material.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], + Dyes.getModulation(-1, material.mRGBa)) }; + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return null; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Frames.java b/src/main/java/gregtech/common/blocks/GT_Item_Frames.java new file mode 100644 index 0000000000..002e19f5a6 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Frames.java @@ -0,0 +1,60 @@ +package gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_LanguageManager; + +public class GT_Item_Frames extends ItemBlock { + + public GT_Item_Frames(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); + } + + private Block block() { + return this.field_150939_a; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.block() + .getUnlocalizedName() + "." + + getDamage(aStack); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + if (this.block() instanceof GT_Block_FrameBox) { + aName = Materials.getLocalizedNameForItem(aName, aStack.getItemDamage()); + } + return aName; + } + + @Override + public int getColorFromItemStack(ItemStack aStack, int aPass) { + int meta = aStack.getItemDamage(); + Materials material = GT_Block_FrameBox.getMaterial(meta); + return (material.mRGBa[0] << 16) | (material.mRGBa[1] << 8) | material.mRGBa[2]; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + aList.add(GT_LanguageManager.getTranslation("gt.blockframes." + aStack.getItemDamage() + ".tooltip")); + aList.add(GT_LanguageManager.getTranslation("gt.blockmachines.gt_frame.desc.format")); + } + + @Override + public int getMetadata(int meta) { + return meta; + } +} diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java index da0d68d555..aa61cc125e 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -52,6 +52,7 @@ import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.XSTR; +import gregtech.common.blocks.GT_Block_FrameBox; import gregtech.common.blocks.GT_Block_Machines; import gregtech.common.blocks.GT_Block_Ores_Abstract; import gregtech.common.blocks.GT_TileEntity_Ores; @@ -108,6 +109,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { textureArray[5] = texturedTileEntity.getTexture(aBlock, EAST); return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, textureArray); } + return false; } @@ -569,6 +571,18 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { && (GregTech_API.METATILEENTITIES[aMeta] != null) && (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } else if (aBlock instanceof GT_Block_FrameBox) { + ITexture[] texture = ((GT_Block_FrameBox) aBlock).getTexture(aMeta); + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + // spotless:off + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true); + // spotless:on } aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); @@ -714,7 +728,25 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { aRenderer.useInventoryTint = false; final TileEntity tileEntity = aWorld.getTileEntity(aX, aY, aZ); + + // If this block does not have a TE, render it as a normal block. + // Otherwise, render the TE instead. + if (tileEntity == null && aBlock instanceof GT_Block_FrameBox frameBlock) { + int meta = aWorld.getBlockMetadata(aX, aY, aZ); + ITexture[] texture = frameBlock.getTexture(meta); + if (texture == null) return false; + textureArray[0] = texture; + textureArray[1] = texture; + textureArray[2] = texture; + textureArray[3] = texture; + textureArray[4] = texture; + textureArray[5] = texture; + renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, textureArray); + return true; + } + if (tileEntity == null) return false; + if (tileEntity instanceof IGregTechTileEntity) { final IMetaTileEntity metaTileEntity; if ((metaTileEntity = ((IGregTechTileEntity) tileEntity).getMetaTileEntity()) != null diff --git a/src/main/java/gregtech/loaders/postload/PosteaTransformers.java b/src/main/java/gregtech/loaders/postload/PosteaTransformers.java new file mode 100644 index 0000000000..ae24de26e8 --- /dev/null +++ b/src/main/java/gregtech/loaders/postload/PosteaTransformers.java @@ -0,0 +1,76 @@ +package gregtech.loaders.postload; + +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; + +import com.gtnewhorizons.postea.api.ItemStackReplacementManager; +import com.gtnewhorizons.postea.api.TileEntityReplacementManager; +import com.gtnewhorizons.postea.utility.BlockInfo; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import vexatos.tgregworks.reference.Mods; + +public class PosteaTransformers implements Runnable { + + @Override + public void run() { + registerFrameboxTransformers(); + } + + private static NBTTagCompound passthrough(NBTTagCompound tag) { + return tag; + } + + private void registerFrameboxTransformers() { + // These are used to convert old TileEntity frame boxes into the new system + // that does not use TEs by default + + TileEntityReplacementManager.tileEntityTransformer("BaseMetaPipeEntity", (tag, world) -> { + // Read the MTE ID from the NBT data and try to figure out if this is a frame box + int id = tag.getInteger("mID"); + // Framebox IDs start at 4096 + int indexInMaterialList = id - 4096; + // The offset from 4096 is the index in the material list, so if this is outside the valid range then this + // is not a valid frame box, and we don't want to modify it + if (indexInMaterialList < 0 || indexInMaterialList >= GregTech_API.sGeneratedMaterials.length) { + // Do not modify this TE, so return null + return null; + } + + // Now we know for sure that the tileentity is a frame box + // If this frame has a cover on it, we need to keep it, but we still need to make sure the block + // is the new frame block. We can make sure to keep the TE using a pass-through transformer. + // This works because between the old and new frame systems, the TileEntity used for covered frames + // is still the same + if (tag.hasKey(GT_Values.NBT.COVERS)) { + return new BlockInfo(GregTech_API.sBlockFrames, indexInMaterialList, PosteaTransformers::passthrough); + } + + // If this frame has no covers, simply return a block and delete the TileEntity + return new BlockInfo(GregTech_API.sBlockFrames, indexInMaterialList); + }); + + ItemStackReplacementManager.addItemReplacement("gregtech:gt.blockmachines", (tag) -> { + // Get item meta id and see if this is a frame box, this works pretty much identically to the TE transformer + int id = tag.getInteger("Damage"); + int indexInMaterialList = id - 4096; + // Not a frame box + if (indexInMaterialList < 0 || indexInMaterialList >= GregTech_API.sGeneratedMaterials.length) { + return tag; + } + // Not a frame box if the material for this id does not have a frame box associated with it. + // Apparently the DEFC ID overlaps with the material ID for a Bastnasite frame box for example + if ((GregTech_API.sGeneratedMaterials[indexInMaterialList].mTypes & 0x2) == 0) { + return tag; + } + Item frameItem = GameRegistry.findItem(Mods.GregTech, "gt.blockframes"); + int itemId = Item.getIdFromItem(frameItem); + // Change this item into the correct frame item (make sure to keep amount) + tag.setInteger("id", itemId); + tag.setInteger("Damage", indexInMaterialList); + return tag; + }); + } +} diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index ecede7ebb9..ce69a4fa27 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -64,6 +64,7 @@ import gregtech.common.blocks.GT_Block_Casings8; import gregtech.common.blocks.GT_Block_Casings9; import gregtech.common.blocks.GT_Block_Concretes; import gregtech.common.blocks.GT_Block_Drone; +import gregtech.common.blocks.GT_Block_FrameBox; import gregtech.common.blocks.GT_Block_Glass1; import gregtech.common.blocks.GT_Block_Granites; import gregtech.common.blocks.GT_Block_Laser; @@ -554,6 +555,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { GregTech_API.sBlockConcretes = new GT_Block_Concretes(); GregTech_API.sBlockStones = new GT_Block_Stones(); GregTech_API.sBlockOres1 = new GT_Block_Ores(); + GregTech_API.sBlockFrames = new GT_Block_FrameBox(); GregTech_API.sDroneRender = new GT_Block_Drone(); GregTech_API.sBlockGlass1 = new GT_Block_Glass1(); GregTech_API.sBlockTintedGlass = new GT_Block_TintedIndustrialGlass(); diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java index bbfe7538b2..918251d265 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_MetaTileEntities.java @@ -43,6 +43,9 @@ import static gregtech.api.recipe.RecipeMaps.sifterRecipes; import static gregtech.api.recipe.RecipeMaps.slicerRecipes; import static gregtech.api.recipe.RecipeMaps.thermalCentrifugeRecipes; import static gregtech.api.recipe.RecipeMaps.wiremillRecipes; +import static gregtech.api.util.GT_RecipeBuilder.SECONDS; +import static gregtech.api.util.GT_RecipeBuilder.TICKS; +import static gregtech.api.util.GT_Utility.calculateRecipeEU; import net.minecraft.util.EnumChatFormatting; @@ -54,6 +57,8 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.MaterialsUEVplus; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SoundResource; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.TierEU; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; @@ -80,7 +85,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Wireless_Ha import gregtech.api.recipe.RecipeMaps; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.common.blocks.GT_Block_FrameBox; import gregtech.common.tileentities.automation.GT_MetaTileEntity_ChestBuffer; import gregtech.common.tileentities.automation.GT_MetaTileEntity_Filter; import gregtech.common.tileentities.automation.GT_MetaTileEntity_ItemDistributor; @@ -11886,19 +11894,40 @@ public class GT_Loader_MetaTileEntities implements Runnable { // TODO CHECK CIRC } private static void generateWiresAndPipes() { - for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) { - if (((GregTech_API.sGeneratedMaterials[i] != null) - && ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x2) != 0)) - || (GregTech_API.sGeneratedMaterials[i] == Materials.Wood)) { + for (int meta = 0; meta < GregTech_API.sGeneratedMaterials.length; meta++) { + Materials material = GregTech_API.sGeneratedMaterials[meta]; + // This check is separated out because IntelliJ thinks Materials.Wood can be null. + if (material == null) continue; + if ((material.mTypes & 0x2) != 0 || material == Materials.Wood) { new GT_MetaPipeEntity_Frame( - 4096 + i, - "GT_Frame_" + GregTech_API.sGeneratedMaterials[i], - (GT_LanguageManager.i18nPlaceholder ? "%material" - : GregTech_API.sGeneratedMaterials[i] != null - ? GregTech_API.sGeneratedMaterials[i].mDefaultLocalName - : "") - + " Frame Box", - GregTech_API.sGeneratedMaterials[i]); + 4096 + meta, + "GT_Frame_" + material, + (GT_LanguageManager.i18nPlaceholder ? "%material" : material.mDefaultLocalName) + + " Frame Box (TileEntity)", + material); + + // Generate recipes for frame box + GT_Block_FrameBox block = (GT_Block_FrameBox) GregTech_API.sBlockFrames; + GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, material, block.getStackForm(1, meta)); + if (material.getProcessingMaterialTierEU() < TierEU.IV) { + GT_ModHandler.addCraftingRecipe( + block.getStackForm(2, meta), + GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] { "SSS", "SwS", "SSS", 'S', OrePrefixes.stick.get(material) }); + } + + if (!material.contains(SubTag.NO_RECIPES) + && GT_OreDictUnificator.get(OrePrefixes.stick, material, 1) != null) { + // Auto generate frame box recipe in an assembler. + GT_Values.RA.stdBuilder() + .itemInputs( + GT_OreDictUnificator.get(OrePrefixes.stick, material, 4), + GT_Utility.getIntegratedCircuit(4)) + .itemOutputs(block.getStackForm(1, meta)) + .duration(3 * SECONDS + 4 * TICKS) + .eut(calculateRecipeEU(material, 7)) + .addTo(assemblerRecipes); + } } } |