diff --git a/src/main/java/supersymmetry/api/integration/theoneprobe/TheOneProbeCompatibility.java b/src/main/java/supersymmetry/api/integration/theoneprobe/TheOneProbeCompatibility.java deleted file mode 100644 index 73f48d0f9..000000000 --- a/src/main/java/supersymmetry/api/integration/theoneprobe/TheOneProbeCompatibility.java +++ /dev/null @@ -1,13 +0,0 @@ -package supersymmetry.api.integration.theoneprobe; - -import mcjty.theoneprobe.TheOneProbe; -import mcjty.theoneprobe.api.ITheOneProbe; -import supersymmetry.api.integration.EvaporationPoolInfoProvider; - -public class TheOneProbeCompatibility { - - public static void registerCompatibility() { - ITheOneProbe oneProbe = TheOneProbe.theOneProbeImp; - oneProbe.registerProvider(new EvaporationPoolInfoProvider()); - } -} diff --git a/src/main/java/supersymmetry/api/metatileentity/logistics/IDelegator.java b/src/main/java/supersymmetry/api/metatileentity/logistics/IDelegator.java new file mode 100644 index 000000000..65b57f757 --- /dev/null +++ b/src/main/java/supersymmetry/api/metatileentity/logistics/IDelegator.java @@ -0,0 +1,14 @@ +package supersymmetry.api.metatileentity.logistics; + +import net.minecraft.util.EnumFacing; +import org.jetbrains.annotations.Nullable; + +// Mostly a marker interface +public interface IDelegator { + + /** + * @return the facing that the input facing in delegating + */ + @Nullable + EnumFacing getDelegatingFacing(EnumFacing facing); +} diff --git a/src/main/java/supersymmetry/api/metatileentity/logistics/MetaTileEntityDelegator.java b/src/main/java/supersymmetry/api/metatileentity/logistics/MetaTileEntityDelegator.java new file mode 100644 index 000000000..7197ed31d --- /dev/null +++ b/src/main/java/supersymmetry/api/metatileentity/logistics/MetaTileEntityDelegator.java @@ -0,0 +1,169 @@ +package supersymmetry.api.metatileentity.logistics; + +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.pipeline.ColourMultiplier; +import codechicken.lib.render.pipeline.IVertexOperation; +import codechicken.lib.vec.Cuboid6; +import codechicken.lib.vec.Matrix4; +import gregtech.api.capability.GregtechCapabilities; +import gregtech.api.capability.IEnergyContainer; +import gregtech.api.gui.ModularUI; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.MetaTileEntityHolder; +import gregtech.api.util.GTUtility; +import gregtech.client.renderer.texture.Textures; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.ItemStackHandler; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.function.Predicate; + + +public abstract class MetaTileEntityDelegator extends MetaTileEntity implements IDelegator { + + protected final Predicate> capFilter; + protected final int baseColor; + + public MetaTileEntityDelegator(ResourceLocation metaTileEntityId, Predicate> capFilter, int baseColor) { + super(metaTileEntityId); + this.capFilter = capFilter; + this.baseColor = baseColor; + } + + @Override + public T getCapability(Capability capability, EnumFacing side) { + T delegatedCapability = getDelegatedCapability(capability, side); + return delegatedCapability == null ? getDefaultCapability(capability, side) : delegatedCapability; + } + + protected T getDefaultCapability(Capability capability, EnumFacing side) { + return side != null && capFilter.test(capability) && DefaultCapabilities.hasCapability(capability) ? DefaultCapabilities.getCapability(capability) : super.getCapability(capability, side); + } + + protected T getDelegatedCapability(Capability capability, EnumFacing side) { + if (capability == null || !capFilter.test(capability) || side == null) return null; + EnumFacing delegatingFacing = getDelegatingFacing(side); + if (delegatingFacing == null) return null; + TileEntity te = getWorld().getTileEntity(getPos().offset(delegatingFacing)); + if (te == null || (te instanceof MetaTileEntityHolder holder && holder.getMetaTileEntity() instanceof IDelegator)) + return null; + // TODO: make IDelegator a capability when Jet Wingsuit PR gets merged + return te.getCapability(capability, delegatingFacing.getOpposite()); + } + + @Override + public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { + IVertexOperation[] colouredPipeline = ArrayUtils.add(pipeline, + new ColourMultiplier(GTUtility.convertRGBtoOpaqueRGBA_CL(this.getPaintingColorForRendering()))); + for (EnumFacing facing : EnumFacing.values()) { + Textures.renderFace(renderState, translation, colouredPipeline, facing, Cuboid6.full, this.getBaseTexture(), BlockRenderLayer.CUTOUT_MIPPED); + } + } + + @SideOnly(Side.CLIENT) + protected TextureAtlasSprite getBaseTexture() { + return Textures.PIPE_SIDE; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, @Nullable World world, @NotNull List tooltip, boolean advanced) { + super.addInformation(stack, world, tooltip, advanced); + tooltip.add(I18n.format("gregtech.machine.delegator.tooltip.non_recursion")); + } + + @SideOnly(Side.CLIENT) + public Pair getParticleTexture() { + return Pair.of(getBaseTexture(), getPaintingColorForRendering()); + } + + @Override + public int getDefaultPaintingColor() { + return this.baseColor; + } + + @Override + protected boolean openGUIOnRightClick() { + return false; + } + + @Override + protected ModularUI createUI(EntityPlayer entityPlayer) { + return null; + } + + public static class DefaultCapabilities { + + private static final Object2ObjectArrayMap, ?> DEFAULT_CAPABILITIES = new Object2ObjectArrayMap<>(); + + static { + // Item + addCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(new ItemStackHandler(1) { + + @NotNull + @Override + public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { + return stack; + } + + @NotNull + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) { + return ItemStack.EMPTY; + } + })); + + // Fluid + addCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(new FluidTank(10000) { + + @Override + public int fill(FluidStack resource, boolean doFill) { + return 0; + } + + @Override + @Nullable + public FluidStack drainInternal(int maxDrain, boolean doDrain) { + return null; + } + })); + + // GTEU + addCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER.cast(IEnergyContainer.DEFAULT)); + } + + public static boolean hasCapability(@NotNull Capability capability) { + return DEFAULT_CAPABILITIES.containsKey(capability); + } + + @Nullable + @SuppressWarnings("unchecked") + public static T getCapability(@NotNull Capability capability) { + return (T) DEFAULT_CAPABILITIES.getOrDefault(capability, null); + } + + public static void addCapability(@NotNull Capability capability, @NotNull T value) { + DEFAULT_CAPABILITIES.put(capability, capability.cast(value)); + } + } +} diff --git a/src/main/java/supersymmetry/client/ClientProxy.java b/src/main/java/supersymmetry/client/ClientProxy.java index 780c8b74a..bc7bcdf77 100644 --- a/src/main/java/supersymmetry/client/ClientProxy.java +++ b/src/main/java/supersymmetry/client/ClientProxy.java @@ -18,7 +18,6 @@ import net.minecraftforge.fml.relauncher.SideOnly; import org.jetbrains.annotations.NotNull; import supersymmetry.Supersymmetry; -import supersymmetry.api.integration.theoneprobe.TheOneProbeCompatibility; import supersymmetry.api.recipes.catalysts.CatalystGroup; import supersymmetry.api.recipes.catalysts.CatalystInfo; import supersymmetry.common.CommonProxy; @@ -49,7 +48,6 @@ public void load() { super.load(); SuSyMetaBlocks.registerColors(); SuSyFluidTooltipLoader.registerTooltips(); - TheOneProbeCompatibility.registerCompatibility(); } @SubscribeEvent diff --git a/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java b/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java index 25c11f9fa..fa465778c 100644 --- a/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java +++ b/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java @@ -4,6 +4,7 @@ import gregtech.client.renderer.texture.cube.SimpleCubeRenderer; import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer; import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer; +import supersymmetry.client.renderer.textures.custom.ExtenderRender; import gregtech.client.renderer.texture.custom.DrumRenderer; public class SusyTextures { @@ -13,6 +14,15 @@ public SusyTextures(){ public static final SimpleSidedCubeRenderer WOODEN_COAGULATION_TANK_WALL = new SimpleSidedCubeRenderer("casings/wooden_coagulation_tank_wall"); public static final SimpleSidedCubeRenderer PLASTIC_CAN_OVERLAY = new SimpleSidedCubeRenderer("storage/drums/plastic_can_top"); + public static final SimpleSidedCubeRenderer INV_BRIDGE = new SimpleSidedCubeRenderer("logistics/bridges/inv"); + public static final SimpleSidedCubeRenderer TANK_BRIDGE = new SimpleSidedCubeRenderer("logistics/bridges/tank"); + public static final SimpleSidedCubeRenderer INV_TANK_BRIDGE = new SimpleSidedCubeRenderer("logistics/bridges/inv_tank"); + public static final SimpleSidedCubeRenderer UNIVERSAL_BRIDGE = new SimpleSidedCubeRenderer("logistics/bridges/universal"); + + public static final ExtenderRender INV_EXTENDER = new ExtenderRender("logistics/extenders/inv"); + public static final ExtenderRender TANK_EXTENDER = new ExtenderRender("logistics/extenders/tank"); + public static final ExtenderRender INV_TANK_EXTENDER = new ExtenderRender("logistics/extenders/inv_tank"); + public static final ExtenderRender UNIVERSAL_EXTENDER = new ExtenderRender("logistics/extenders/universal"); public static final OrientedOverlayRenderer VULCANIZING_PRESS_OVERLAY = new OrientedOverlayRenderer("machines/vulcanizing_press"); public static final OrientedOverlayRenderer LATEX_COLLECTOR_OVERLAY = new OrientedOverlayRenderer("machines/latex_collector"); diff --git a/src/main/java/supersymmetry/client/renderer/textures/custom/ExtenderRender.java b/src/main/java/supersymmetry/client/renderer/textures/custom/ExtenderRender.java new file mode 100644 index 000000000..fdc5906a5 --- /dev/null +++ b/src/main/java/supersymmetry/client/renderer/textures/custom/ExtenderRender.java @@ -0,0 +1,55 @@ +package supersymmetry.client.renderer.textures.custom; + +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.pipeline.IVertexOperation; +import codechicken.lib.texture.TextureUtils.IIconRegister; +import codechicken.lib.vec.Cuboid6; +import codechicken.lib.vec.Matrix4; +import gregtech.api.GTValues; +import gregtech.client.renderer.texture.Textures; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class ExtenderRender implements IIconRegister { + + private final String basePath; + + @SideOnly(Side.CLIENT) + private TextureAtlasSprite[] textures; + + public ExtenderRender(String basePath) { + this.basePath = basePath; + Textures.iconRegisters.add(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(TextureMap textureMap) { + String formattedBase = GTValues.MODID + ":blocks/" + basePath; + this.textures = new TextureAtlasSprite[3]; + this.textures[0] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/in")); + this.textures[1] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/side")); + this.textures[2] = textureMap.registerSprite(new ResourceLocation(formattedBase + "/out")); + } + + @SideOnly(Side.CLIENT) + public void render(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline, + EnumFacing outFace, EnumFacing inFace) { + for (EnumFacing renderSide : EnumFacing.VALUES) { + TextureAtlasSprite baseSprite = renderSide == inFace ? textures[0] : + renderSide == outFace ? textures[2] : textures[1]; + Textures.renderFace(renderState, translation, pipeline, renderSide, Cuboid6.full, baseSprite, + BlockRenderLayer.CUTOUT_MIPPED); + } + } + + @SideOnly(Side.CLIENT) + public TextureAtlasSprite getParticleTexture() { + return textures[0]; + } +} diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index 2a1b78a3d..7c4e2bb15 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -16,6 +16,8 @@ import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiFluidHatch; import gregtech.common.metatileentities.storage.MetaTileEntityDrum; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.items.CapabilityItemHandler; import org.jetbrains.annotations.NotNull; import supersymmetry.api.SusyLog; import supersymmetry.api.metatileentity.CatalystMachineMetaTileEntity; @@ -27,6 +29,8 @@ import supersymmetry.api.recipes.SuSyRecipeMaps; import supersymmetry.api.util.SuSyUtility; import supersymmetry.client.renderer.textures.SusyTextures; +import supersymmetry.common.metatileentities.logistics.MetaTileEntityBridge; +import supersymmetry.common.metatileentities.logistics.MetaTileEntityExtender; import supersymmetry.common.metatileentities.multi.electric.*; import supersymmetry.common.metatileentities.multi.primitive.MetaTileEntityCoagulationTank; import supersymmetry.common.metatileentities.multi.primitive.MetaTileEntityPrimitiveMudPump; @@ -41,6 +45,7 @@ import supersymmetry.common.metatileentities.single.steam.SuSySimpleSteamMetaTileEntity; import supersymmetry.common.metatileentities.storage.MetaTileEntityPlasticCan; +import java.util.ArrayList; import java.util.function.Function; import static gregtech.api.util.GTUtility.gregtechId; @@ -164,6 +169,16 @@ public class SuSyMetaTileEntities { public static MetaTileEntitySieveDistillationTower SIEVE_DISTILLATION_TOWER; + public static MetaTileEntityBridge INV_BRIDGE; + public static MetaTileEntityBridge TANK_BRIDGE; + public static MetaTileEntityBridge INV_TANK_BRIDGE; + public static MetaTileEntityBridge UNIVERSAL_BRIDGE; + + public static MetaTileEntityExtender INV_EXTENDER; + public static MetaTileEntityExtender TANK_EXTENDER; + public static MetaTileEntityExtender INV_TANK_EXTENDER; + public static MetaTileEntityExtender UNIVERSAL_EXTENDER; + public static final MetaTileEntityMultiFluidHatch[] SUSY_QUADRUPLE_IMPORT_HATCH = new MetaTileEntityMultiFluidHatch[3]; // LV-HV public static final MetaTileEntityMultiFluidHatch[] SUSY_NONUPLE_IMPORT_HATCH = new MetaTileEntityMultiFluidHatch[3]; // LV-HV public static final MetaTileEntityMultiFluidHatch[] SUSY_QUADRUPLE_EXPORT_HATCH = new MetaTileEntityMultiFluidHatch[3]; // LV-HV @@ -221,6 +236,16 @@ public static void init() { ELECTROLYTIC_CELL = registerMetaTileEntity(14634, new MetaTileEntityElectrolyticCell(susyId("electrolytic_cell"))); GRAVITY_SEPARATOR = registerMetaTileEntity(15052, new MetaTileEntityGravitySeparator(susyId("gravity_separator"))); + INV_BRIDGE = registerMetaTileEntity(14733, new MetaTileEntityBridge(susyId("bridge.inv"), cap -> cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, SusyTextures.INV_BRIDGE, Materials.Steel)); + TANK_BRIDGE = registerMetaTileEntity(14734, new MetaTileEntityBridge(susyId("bridge.tank"), cap -> cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, SusyTextures.TANK_BRIDGE, Materials.Steel)); + INV_TANK_BRIDGE = registerMetaTileEntity(14735, new MetaTileEntityBridge(susyId("bridge.inv_tank"), cap -> cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, SusyTextures.INV_TANK_BRIDGE, Materials.Steel)); + UNIVERSAL_BRIDGE = registerMetaTileEntity(14736, new MetaTileEntityBridge(susyId("bridge.universal"), cap -> true, SusyTextures.UNIVERSAL_BRIDGE, Materials.Aluminium)); + + INV_EXTENDER = registerMetaTileEntity(14737, new MetaTileEntityExtender(susyId("extender.inv"), cap -> cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, SusyTextures.INV_EXTENDER, Materials.Steel)); + TANK_EXTENDER = registerMetaTileEntity(14738, new MetaTileEntityExtender(susyId("extender.tank"), cap -> cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, SusyTextures.TANK_EXTENDER, Materials.Steel)); + INV_TANK_EXTENDER = registerMetaTileEntity(14739, new MetaTileEntityExtender(susyId("extender.inv_tank"), cap -> cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || cap == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, SusyTextures.INV_TANK_EXTENDER, Materials.Steel)); + UNIVERSAL_EXTENDER = registerMetaTileEntity(14740, new MetaTileEntityExtender(susyId("extender.universal"), cap -> true, SusyTextures.UNIVERSAL_EXTENDER, Materials.Aluminium)); + PRIMITIVE_SMELTER = registerMetaTileEntity(14800, new MetaTileEntityPrimitiveSmelter(susyId("primitive_smelter"))); PRIMITIVE_ITEM_IMPORT = registerMetaTileEntity(14801, new MetaTileEntityPrimitiveItemBus(susyId("primitive_item_import"), false)); PRIMITIVE_ITEM_EXPORT = registerMetaTileEntity(14802, new MetaTileEntityPrimitiveItemBus(susyId("primitive_item_export"), true)); @@ -237,9 +262,11 @@ public static void init() { registerSimpleMTE(CVD, 12, 14653, "cvd", SuSyRecipeMaps.CVD_RECIPES, SusyTextures.CVD_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(ION_IMPLANTER, 12, 14666, "ion_implanter", SuSyRecipeMaps.ION_IMPLANTATION_RECIPES, SusyTextures.ION_IMPLANTER_OVERLAY, true, GTUtility.defaultTankSizeFunction); - int id = 14500; - while (GregTechAPI.MTE_REGISTRY.getObjectById(id) != null) id++; - SusyLog.logger.debug("The next available ID is: " + id); + ArrayList ids = new ArrayList<>(); + for (int id = 14500; id < 15000; id++) { + if (GregTechAPI.MTE_REGISTRY.getObjectById(id) == null) ids.add(id); + } + SusyLog.logger.debug("Available ID(s) are: {}", ids); //thermodynamic stuff registerSimpleMTE(FLUID_COMPRESSOR, 12, 15000, "fluid_compressor", SuSyRecipeMaps.FLUID_COMPRESSOR_RECIPES, SusyTextures.FLUID_COMPRESSOR_OVERLAY, true, GTUtility.defaultTankSizeFunction); diff --git a/src/main/java/supersymmetry/common/metatileentities/logistics/MetaTileEntityBridge.java b/src/main/java/supersymmetry/common/metatileentities/logistics/MetaTileEntityBridge.java new file mode 100644 index 000000000..37b2b7fed --- /dev/null +++ b/src/main/java/supersymmetry/common/metatileentities/logistics/MetaTileEntityBridge.java @@ -0,0 +1,52 @@ +package supersymmetry.common.metatileentities.logistics; + +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.pipeline.IVertexOperation; +import codechicken.lib.vec.Matrix4; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.unification.material.Material; +import gregtech.client.renderer.ICubeRenderer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.capabilities.Capability; +import org.jetbrains.annotations.Nullable; +import supersymmetry.api.metatileentity.logistics.MetaTileEntityDelegator; + +import java.util.function.Predicate; + +public class MetaTileEntityBridge extends MetaTileEntityDelegator { + + protected final ICubeRenderer renderer; + + public MetaTileEntityBridge(ResourceLocation metaTileEntityId, Predicate> capFilter, ICubeRenderer renderer, Material baseMaterial) { + this(metaTileEntityId, capFilter, renderer, baseMaterial.getMaterialRGB()); + } + + public MetaTileEntityBridge(ResourceLocation metaTileEntityId, Predicate> capFilter, ICubeRenderer renderer, int baseColor) { + super(metaTileEntityId, capFilter, baseColor); + this.renderer = renderer; + } + + @Override + public MetaTileEntity createMetaTileEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MetaTileEntityBridge(metaTileEntityId, capFilter, renderer, baseColor); + } + + @Override + @Nullable + public EnumFacing getDelegatingFacing(EnumFacing facing) { + return facing == null ? null : facing.getOpposite(); + } + + @Override + public boolean hasFrontFacing() { + return false; + } + + @Override + public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { + super.renderMetaTileEntity(renderState, translation, pipeline); + this.renderer.render(renderState, translation, pipeline); + } +} diff --git a/src/main/java/supersymmetry/common/metatileentities/logistics/MetaTileEntityExtender.java b/src/main/java/supersymmetry/common/metatileentities/logistics/MetaTileEntityExtender.java new file mode 100644 index 000000000..2812863de --- /dev/null +++ b/src/main/java/supersymmetry/common/metatileentities/logistics/MetaTileEntityExtender.java @@ -0,0 +1,146 @@ +package supersymmetry.common.metatileentities.logistics; + +import codechicken.lib.raytracer.CuboidRayTraceResult; +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.pipeline.IVertexOperation; +import codechicken.lib.vec.Matrix4; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.unification.material.Material; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import supersymmetry.api.metatileentity.logistics.MetaTileEntityDelegator; +import supersymmetry.client.renderer.textures.custom.ExtenderRender; + +import java.util.List; +import java.util.function.Predicate; + +import static gregtech.api.capability.GregtechDataCodes.UPDATE_OUTPUT_FACING; + +public class MetaTileEntityExtender extends MetaTileEntityDelegator { + + protected final ExtenderRender renderer; + protected EnumFacing inputFacing; + + public MetaTileEntityExtender(ResourceLocation metaTileEntityId, Predicate> capFilter, ExtenderRender renderer, Material baseMaterial) { + this(metaTileEntityId, capFilter, renderer, baseMaterial.getMaterialRGB()); + } + + public MetaTileEntityExtender(ResourceLocation metaTileEntityId, Predicate> capFilter, ExtenderRender renderer, int baseColor) { + super(metaTileEntityId, capFilter, baseColor); + this.renderer = renderer; + } + + @Override + public MetaTileEntity createMetaTileEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MetaTileEntityExtender(metaTileEntityId, capFilter, renderer, baseColor); + } + + @Override + @Nullable + public EnumFacing getDelegatingFacing(EnumFacing facing) { + return facing == getFrontFacing() ? inputFacing : getFrontFacing(); + } + + @Override + public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { + super.renderMetaTileEntity(renderState, translation, pipeline); + this.renderer.render(renderState, translation, pipeline, getFrontFacing(), inputFacing); + } + + @Override + public boolean onWrenchClick(EntityPlayer playerIn, EnumHand hand, EnumFacing facing, + CuboidRayTraceResult hitResult) { + if (!playerIn.isSneaking()) { + if (getInputFacing() == facing || facing == getFrontFacing()) return false; + if (!getWorld().isRemote) { + setInputFacing(facing); + } + return true; + } + return super.onWrenchClick(playerIn, hand, facing, hitResult); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound data) { + super.writeToNBT(data); + data.setInteger("InputFacing", getInputFacing().getIndex()); + return data; + } + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + this.inputFacing = EnumFacing.VALUES[data.getInteger("InputFacing")]; + } + + @Override + public void writeInitialSyncData(@NotNull PacketBuffer buf) { + super.writeInitialSyncData(buf); + buf.writeByte(getInputFacing().getIndex()); + } + + @Override + public void receiveInitialSyncData(@NotNull PacketBuffer buf) { + super.receiveInitialSyncData(buf); + this.inputFacing = EnumFacing.VALUES[buf.readByte()]; + } + + + @Override + public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) { + super.receiveCustomData(dataId, buf); + if (dataId == UPDATE_OUTPUT_FACING) { + this.inputFacing = EnumFacing.VALUES[buf.readByte()]; + scheduleRenderUpdate(); + } + } + + @Override + public boolean isValidFrontFacing(EnumFacing facing) { + return facing != getFrontFacing() && facing != inputFacing; + } + + @Override + public void setFrontFacing(EnumFacing frontFacing) { + super.setFrontFacing(frontFacing); + if (this.inputFacing == null) { + // set initial input facing as opposite to output (front) + setInputFacing(frontFacing.getOpposite()); + } + } + + public EnumFacing getInputFacing() { + return inputFacing == null ? EnumFacing.SOUTH : inputFacing; + } + + public void setInputFacing(EnumFacing inputFacing) { + this.inputFacing = inputFacing; + if (!getWorld().isRemote) { + notifyBlockUpdate(); + writeCustomData(UPDATE_OUTPUT_FACING, buf -> buf.writeByte(inputFacing.getIndex())); + markDirty(); + } + } + + @Override + public boolean needsSneakToRotate() { + return true; + } + + @Override + public void addToolUsages(ItemStack stack, @Nullable World world, List tooltip, boolean advanced) { + tooltip.add(I18n.format("gregtech.tool_action.wrench.set_facing")); + super.addToolUsages(stack, world, tooltip, advanced); + } +} diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityEvaporationPool.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityEvaporationPool.java index e5a766a65..fe1f2d76a 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityEvaporationPool.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityEvaporationPool.java @@ -35,7 +35,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; -import net.minecraft.util.*; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; @@ -47,11 +50,11 @@ import org.jetbrains.annotations.NotNull; import supersymmetry.api.SusyLog; import supersymmetry.api.capability.impl.EvapRecipeLogic; -import supersymmetry.api.integration.EvaporationPoolInfoProvider; import supersymmetry.api.recipes.SuSyRecipeMaps; import supersymmetry.api.recipes.properties.EvaporationEnergyProperty; import supersymmetry.common.blocks.BlockEvaporationBed; import supersymmetry.common.blocks.SuSyBlocks; +import supersymmetry.integration.theoneprobe.provider.EvaporationPoolInfoProvider; import javax.annotation.Nonnull; import java.util.*; diff --git a/src/main/java/supersymmetry/integration/theoneprobe/TheOneProbeModule.java b/src/main/java/supersymmetry/integration/theoneprobe/TheOneProbeModule.java new file mode 100644 index 000000000..9ee608bbf --- /dev/null +++ b/src/main/java/supersymmetry/integration/theoneprobe/TheOneProbeModule.java @@ -0,0 +1,29 @@ +package supersymmetry.integration.theoneprobe; + +import gregtech.api.modules.GregTechModule; +import gregtech.api.util.Mods; +import gregtech.integration.IntegrationSubmodule; +import mcjty.theoneprobe.TheOneProbe; +import mcjty.theoneprobe.api.ITheOneProbe; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import supersymmetry.Supersymmetry; +import supersymmetry.integration.theoneprobe.provider.DelegatorInfoProvider; +import supersymmetry.integration.theoneprobe.provider.EvaporationPoolInfoProvider; +import supersymmetry.modules.SuSyModules; + +@GregTechModule( + moduleID = SuSyModules.MODULE_TOP, + containerID = Supersymmetry.MODID, + modDependencies = Mods.Names.THE_ONE_PROBE, + name = "SuSy TheOneProbe Integration", + description = "SuSy TheOneProbe Integration Module") +public class TheOneProbeModule extends IntegrationSubmodule { + + @Override + public void init(FMLInitializationEvent event) { + getLogger().info("TheOneProbe found. Enabling SuSy top integration..."); + ITheOneProbe oneProbe = TheOneProbe.theOneProbeImp; + oneProbe.registerProvider(new EvaporationPoolInfoProvider()); + oneProbe.registerProvider(new DelegatorInfoProvider()); + } +} diff --git a/src/main/java/supersymmetry/integration/theoneprobe/provider/DelegatorInfoProvider.java b/src/main/java/supersymmetry/integration/theoneprobe/provider/DelegatorInfoProvider.java new file mode 100644 index 000000000..412b4e613 --- /dev/null +++ b/src/main/java/supersymmetry/integration/theoneprobe/provider/DelegatorInfoProvider.java @@ -0,0 +1,38 @@ +package supersymmetry.integration.theoneprobe.provider; + +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import mcjty.theoneprobe.api.IProbeHitData; +import mcjty.theoneprobe.api.IProbeInfo; +import mcjty.theoneprobe.api.IProbeInfoProvider; +import mcjty.theoneprobe.api.ProbeMode; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import supersymmetry.Supersymmetry; +import supersymmetry.api.metatileentity.logistics.IDelegator; + +public class DelegatorInfoProvider implements IProbeInfoProvider { + + @Override + public String getID() { + return Supersymmetry.MODID + ":delegator_info_provider"; + } + + @Override + public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState state, + IProbeHitData data) { + if (state.getBlock().hasTileEntity(state)) { + TileEntity te = world.getTileEntity(data.getPos()); + if (te instanceof IGregTechTileEntity igtte) { + MetaTileEntity mte = igtte.getMetaTileEntity(); + if (mte instanceof IDelegator delegator) { + probeInfo.text(I18n.format("gregtech.top.delegator.delegating_face", + delegator.getDelegatingFacing(data.getSideHit()))); + } + } + } + } +} diff --git a/src/main/java/supersymmetry/api/integration/EvaporationPoolInfoProvider.java b/src/main/java/supersymmetry/integration/theoneprobe/provider/EvaporationPoolInfoProvider.java similarity index 97% rename from src/main/java/supersymmetry/api/integration/EvaporationPoolInfoProvider.java rename to src/main/java/supersymmetry/integration/theoneprobe/provider/EvaporationPoolInfoProvider.java index 48d6b42f0..a5df2c75a 100644 --- a/src/main/java/supersymmetry/api/integration/EvaporationPoolInfoProvider.java +++ b/src/main/java/supersymmetry/integration/theoneprobe/provider/EvaporationPoolInfoProvider.java @@ -1,4 +1,4 @@ -package supersymmetry.api.integration; +package supersymmetry.integration.theoneprobe.provider; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; diff --git a/src/main/java/supersymmetry/modules/SuSyModules.java b/src/main/java/supersymmetry/modules/SuSyModules.java index 3924cd29a..b8731b7a9 100644 --- a/src/main/java/supersymmetry/modules/SuSyModules.java +++ b/src/main/java/supersymmetry/modules/SuSyModules.java @@ -10,6 +10,7 @@ public class SuSyModules implements IModuleContainer { public static final String MODULE_CORE = "susy_core"; public static final String MODULE_BDSAndM = "bdsandm_integration"; public static final String MODULE_BAUBLES = "baubles_integration"; + public static final String MODULE_TOP = "susy_top_integration"; @Override public String getID() { diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/bottom.png new file mode 100644 index 000000000..74e85c7c4 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/bottom.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/side.png new file mode 100644 index 000000000..74e85c7c4 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/top.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/top.png new file mode 100644 index 000000000..74e85c7c4 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv/top.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/bottom.png new file mode 100644 index 000000000..b646bcaec Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/bottom.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/side.png new file mode 100644 index 000000000..b646bcaec Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/top.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/top.png new file mode 100644 index 000000000..b646bcaec Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/inv_tank/top.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/bottom.png new file mode 100644 index 000000000..880e4b753 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/bottom.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/side.png new file mode 100644 index 000000000..880e4b753 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/top.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/top.png new file mode 100644 index 000000000..880e4b753 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/tank/top.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/bottom.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/bottom.png new file mode 100644 index 000000000..3a0018f98 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/bottom.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/side.png new file mode 100644 index 000000000..3a0018f98 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/top.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/top.png new file mode 100644 index 000000000..3a0018f98 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/bridges/universal/top.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/in.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/in.png new file mode 100644 index 000000000..74e85c7c4 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/in.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/out.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/out.png new file mode 100644 index 000000000..d3820edf5 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/out.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/side.png new file mode 100644 index 000000000..06a796bbe Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/in.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/in.png new file mode 100644 index 000000000..b646bcaec Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/in.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/out.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/out.png new file mode 100644 index 000000000..aaaa00625 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/out.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/side.png new file mode 100644 index 000000000..06a796bbe Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/inv_tank/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/in.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/in.png new file mode 100644 index 000000000..880e4b753 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/in.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/out.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/out.png new file mode 100644 index 000000000..1c5a639fe Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/out.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/side.png new file mode 100644 index 000000000..06a796bbe Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/tank/side.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/in.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/in.png new file mode 100644 index 000000000..3a0018f98 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/in.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/out.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/out.png new file mode 100644 index 000000000..b98e184e9 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/out.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/side.png b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/side.png new file mode 100644 index 000000000..c0c0a3709 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/logistics/extenders/universal/side.png differ diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 7ba59e461..a54598ef5 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -756,10 +756,31 @@ gregtech.machine.fluid_hatch.export_9x.mv.name=MV Nonuple Output Hatch gregtech.machine.fluid_hatch.export_9x.hv.name=HV Nonuple Output Hatch # Other multiblock parts - gregtech.machine.dumping_hatch=Dumping Hatch gregtech.machine.dumping_hatch.lv.name=Dumping Hatch +# Logistics +gregtech.machine.delegator.tooltip.non_recursion=§6Cannot be attached to other Delegators! +gregtech.top.delegator.delegating_face=Delegating: %s + +gregtech.machine.bridge.inv.name=Inventory Bridge +gregtech.machine.bridge.inv.tooltip=§bRelays Inventories +gregtech.machine.bridge.tank.name=Tank Bridge +gregtech.machine.bridge.tank.tooltip=§bRelays Tanks +gregtech.machine.bridge.inv_tank.name=Inventory and Tank Bridge +gregtech.machine.bridge.inv_tank.tooltip=§bRelays Inventories and Tanks +gregtech.machine.bridge.universal.name=Universal Bridge +gregtech.machine.bridge.universal.tooltip=§bRelays Everything + +gregtech.machine.extender.inv.name=Inventory Extender +gregtech.machine.extender.inv.tooltip=§bRelays Inventories +gregtech.machine.extender.tank.name=Tank Extender +gregtech.machine.extender.tank.tooltip=§bRelays Tanks +gregtech.machine.extender.inv_tank.name=Inventory and Tank Extender +gregtech.machine.extender.inv_tank.tooltip=§bRelays Inventories and Tanks +gregtech.machine.extender.universal.name=Universal Extender +gregtech.machine.extender.universal.tooltip=§bRelays Everything + # Metaitems metaitem.catalyst_bed_support_grid.name=Catalyst Bed Support Grid metaitem.conveyor.steam.name=Steam Conveyor