Merge branch '1.12' into nonnull-network

This commit is contained in:
Aidan authored and GitHub committed 2017-11-16 12:09:46 -05:00
commit bed953f0f0
61 files changed
+709 -85

No files matched your search

+35 -19
View File
@@ -1,6 +1,9 @@
package mekanism.api;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
/**
@@ -10,25 +13,25 @@ import net.minecraft.util.text.translation.I18n;
*/
public enum EnumColor implements IStringSerializable
{
BLACK("\u00a70", "black", "Black", new int[] {0, 0, 0}, 0),
DARK_BLUE("\u00a71", "darkBlue", "Blue", new int[] {0, 0, 170}, 4),
DARK_GREEN("\u00a72", "darkGreen", "Green", new int[] {0, 170, 0}, 2),
DARK_AQUA("\u00a73", "darkAqua", "Cyan", new int[] {0, 255, 255}, 6),
DARK_RED("\u00a74", "darkRed", null, new int[] {170, 0, 0}, -1),
PURPLE("\u00a75", "purple", "Purple", new int[] {170, 0, 170}, 5),
ORANGE("\u00a76", "orange", "Orange", new int[] {255, 170, 0}, 14),
GREY("\u00a77", "grey", "LightGray", new int[] {170, 170, 170}, 7),
DARK_GREY("\u00a78", "darkGrey", "Gray", new int[] {85, 85, 85}, 8),
INDIGO("\u00a79", "indigo", "LightBlue", new int[] {85, 85, 255}, 12),
BRIGHT_GREEN("\u00a7a", "brightGreen", "Lime", new int[] {85, 255, 85}, 10),
AQUA("\u00a7b", "aqua", null, new int[] {85, 255, 255}, -1),
RED("\u00a7c", "red", "Red", new int[] {255, 0, 0}, 1),
PINK("\u00a7d", "pink", "Magenta", new int[] {255, 85, 255}, 13),
YELLOW("\u00a7e", "yellow", "Yellow", new int[] {255, 255, 85}, 11),
WHITE("\u00a7f", "white", "White", new int[] {255, 255, 255}, 15),
BLACK("\u00a70", "black", "Black", new int[] {0, 0, 0}, 0, TextFormatting.BLACK),
DARK_BLUE("\u00a71", "darkBlue", "Blue", new int[] {0, 0, 170}, 4, TextFormatting.DARK_BLUE),
DARK_GREEN("\u00a72", "darkGreen", "Green", new int[] {0, 170, 0}, 2, TextFormatting.DARK_GREEN),
DARK_AQUA("\u00a73", "darkAqua", "Cyan", new int[] {0, 255, 255}, 6, TextFormatting.DARK_AQUA),
DARK_RED("\u00a74", "darkRed", null, new int[] {170, 0, 0}, -1, TextFormatting.DARK_RED),
PURPLE("\u00a75", "purple", "Purple", new int[] {170, 0, 170}, 5, TextFormatting.DARK_PURPLE),
ORANGE("\u00a76", "orange", "Orange", new int[] {255, 170, 0}, 14, TextFormatting.GOLD),
GREY("\u00a77", "grey", "LightGray", new int[] {170, 170, 170}, 7, TextFormatting.GRAY),
DARK_GREY("\u00a78", "darkGrey", "Gray", new int[] {85, 85, 85}, 8, TextFormatting.DARK_GRAY),
INDIGO("\u00a79", "indigo", "LightBlue", new int[] {85, 85, 255}, 12, TextFormatting.BLUE),
BRIGHT_GREEN("\u00a7a", "brightGreen", "Lime", new int[] {85, 255, 85}, 10, TextFormatting.GREEN),
AQUA("\u00a7b", "aqua", null, new int[] {85, 255, 255}, -1, TextFormatting.AQUA),
RED("\u00a7c", "red", "Red", new int[] {255, 0, 0}, 1, TextFormatting.RED),
PINK("\u00a7d", "pink", "Magenta", new int[] {255, 85, 255}, 13, TextFormatting.LIGHT_PURPLE),
YELLOW("\u00a7e", "yellow", "Yellow", new int[] {255, 255, 85}, 11, TextFormatting.YELLOW),
WHITE("\u00a7f", "white", "White", new int[] {255, 255, 255}, 15, TextFormatting.WHITE),
//Extras for dye-completeness
BROWN("\u00a76", "brown", "Brown", new int[] {150, 75, 0}, 3),
BRIGHT_PINK("\u00a7d", "brightPink", "Pink", new int[] {255, 192, 203}, 9);
BROWN("\u00a76", "brown", "Brown", new int[] {150, 75, 0}, 3, TextFormatting.GOLD),
BRIGHT_PINK("\u00a7d", "brightPink", "Pink", new int[] {255, 192, 203}, 9, TextFormatting.LIGHT_PURPLE);
public static EnumColor[] DYES = new EnumColor[] {BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, INDIGO, PINK, ORANGE, WHITE};
@@ -44,13 +47,16 @@ public enum EnumColor implements IStringSerializable
public String dyeName;
EnumColor(String s, String n, String dye, int[] rgb, int meta)
public final TextFormatting textFormatting;
EnumColor(String s, String n, String dye, int[] rgb, int meta, TextFormatting tf)
{
code = s;
unlocalizedName = n;
dyeName = dye;
rgbCode = rgb;
mcMeta = meta;
textFormatting = tf;
}
/**
@@ -62,6 +68,10 @@ public enum EnumColor implements IStringSerializable
return I18n.translateToLocal("color." + unlocalizedName);
}
public String getUnlocalizedName(){
return "color." + unlocalizedName;
}
public String getDyeName()
{
return I18n.translateToLocal("dye." + unlocalizedName);
@@ -81,6 +91,12 @@ public enum EnumColor implements IStringSerializable
return code + getLocalizedName();
}
public ITextComponent getTranslatedColouredComponent(){
ITextComponent t = new TextComponentTranslation(getUnlocalizedName());
t.getStyle().setColor(textFormatting);
return t;
}
public String getDyedName()
{
return code + getDyeName();
+21
View File
@@ -31,6 +31,8 @@ public class Gas
private boolean from_fluid = false;
private int tint = 0xFFFFFF;
/**
* Creates a new Gas object with a defined name or key value.
* @param s - name or key to associate this Gas with
@@ -50,6 +52,7 @@ public class Gas
iconLocation = f.getStill();
fluid = f;
from_fluid = true;
tint = f.getColor() & 0xFFFFFF;
}
/**
@@ -255,4 +258,22 @@ public class Gas
{
return name;
}
/**
* Get the tint for rendering the gas
* @return int representation of color in 0xRRGGBB format
*/
public int getTint()
{
return tint;
}
/**
* Sets the tint for the gas
* @param tint int representation of color in 0xRRGGBB format
*/
public void setTint(int tint)
{
this.tint = tint;
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
* @author aidancbrady
*
*/
public class GasTank
public class GasTank implements GasTankInfo
{
public GasStack stored;
@@ -0,0 +1,28 @@
package mekanism.api.gas;
import javax.annotation.Nullable;
/**
* Created by Thiakil on 11/11/2017.
*/
public interface GasTankInfo
{
/**
* Retrieve the stored gas stack. DO NOT MODIFY.
* @return the stored gas, or null
*/
@Nullable
GasStack getGas();
/**
* Gets the amount of gas stored by this GasTank.
* @return amount of gas stored
*/
int getStored();
/**
* Gets the maximum amount of gas this tank can hold.
* @return - max gas
*/
int getMaxGas();
}
@@ -2,6 +2,8 @@ package mekanism.api.gas;
import net.minecraft.util.EnumFacing;
import javax.annotation.Nonnull;
/**
* Implement this if your tile entity accepts gas from an external source.
* @author AidanBrady
@@ -38,4 +40,13 @@ public interface IGasHandler
* @return if block can be drawn of gas
*/
boolean canDrawGas(EnumFacing side, Gas type);
static GasTankInfo[] NONE = new GasTankInfo[0];
/**
* Gets the tanks present on this handler. READ ONLY. DO NOT MODIFY.
* @return an array of GasTankInfo elements corresponding to all tanks.
*/
@Nonnull
default GasTankInfo[] getTankInfo(){ return NONE; }
}
@@ -13,6 +13,8 @@ public class OreGas extends Gas
super(s, "mekanism:blocks/liquid/Liquid" + (s.contains("clean") ? "Clean" : "") + "Ore");
oreName = name;
setTint(0xf2cd67);//default old tint
}
public boolean isClean()
@@ -30,7 +30,7 @@ public class MekanismClient extends Mekanism
public static void updateKey(KeyBinding key, int type)
{
boolean down = Minecraft.getMinecraft().currentScreen == null && key.isPressed();
boolean down = Minecraft.getMinecraft().currentScreen == null && key.isKeyDown();
if(down != keyMap.has(Minecraft.getMinecraft().player, type))
{
@@ -116,4 +116,15 @@ public class GuiGasGauge extends GuiGauge<Gas>
{
GasTank getTank();
}
@Override
public int getRenderColor()
{
if(dummy)
{
return dummyType.getTint();
}
return (infoHandler.getTank().getGas() != null) ? infoHandler.getTank().getGas().getGas().getTint() : super.getRenderColor();
}
}
@@ -104,7 +104,7 @@ public class RenderTickHandler
ClientTickHandler.wheelStatus = 0;
}
if(mc.currentScreen == null && !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty())
if(mc.currentScreen == null && !mc.gameSettings.hideGUI && !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty())
{
ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
@@ -10,6 +10,7 @@ import mekanism.common.ColourRGBA;
import mekanism.common.config.MekanismConfig.client;
import mekanism.common.tile.transmitter.TileEntityMechanicalPipe;
import mekanism.common.tile.transmitter.TileEntitySidedPipe.ConnectionType;
import mekanism.common.transmitters.grid.FluidNetwork;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -17,6 +18,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
public class RenderMechanicalPipe extends RenderTransmitterBase<TileEntityMechanicalPipe>
@@ -59,13 +61,16 @@ public class RenderMechanicalPipe extends RenderTransmitterBase<TileEntityMechan
}
Fluid fluid;
FluidStack fluidStack;
if(pipe.getTransmitter().hasTransmitterNetwork())
{
fluid = pipe.getTransmitter().getTransmitterNetwork().refFluid;
fluidStack = pipe.getTransmitter().getTransmitterNetwork().buffer;
}
else {
fluid = pipe.getBuffer() == null ? null : pipe.getBuffer().getFluid();
fluidStack = pipe.getBuffer();
fluid = fluidStack == null ? null : pipe.getBuffer().getFluid();
}
float scale = Math.min(pipe.currentScale, 1);
@@ -75,7 +80,7 @@ public class RenderMechanicalPipe extends RenderTransmitterBase<TileEntityMechan
push();
MekanismRenderer.glowOn(fluid.getLuminosity());
MekanismRenderer.colorFluid(fluid);
MekanismRenderer.color(fluidStack != null ? fluidStack.getFluid().getColor(fluidStack) : fluid.getColor());
bindTexture(MekanismRenderer.getBlocksTexture());
GL11.glTranslated(x, y, z);
@@ -263,18 +268,24 @@ public class RenderMechanicalPipe extends RenderTransmitterBase<TileEntityMechan
return displays;
}
public boolean renderFluidInOut(BufferBuilder renderer, EnumFacing side, TileEntityMechanicalPipe pipe)
{
if(pipe != null && pipe.getTransmitter() != null && pipe.getTransmitter().getTransmitterNetwork() != null)
{
bindTexture(MekanismRenderer.getBlocksTexture());
TextureAtlasSprite tex = MekanismRenderer.getFluidTexture(pipe.getTransmitter().getTransmitterNetwork().refFluid, FluidType.STILL);
renderTransparency(renderer, tex, getModelForSide(pipe, side), new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale));
FluidNetwork fn = pipe.getTransmitter().getTransmitterNetwork();
int color = fn.buffer != null ? fn.buffer.getFluid().getColor(fn.buffer) : fn.refFluid.getColor();
ColourRGBA c = new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale);
if (color != 0xFFFFFFFF){
c.setRGBFromInt(color);
}
renderTransparency(renderer, tex, getModelForSide(pipe, side), c);
return true;
}
return false;
}
@@ -1,5 +1,6 @@
package mekanism.client.render.transmitter;
import mekanism.api.gas.Gas;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.ColourRGBA;
import mekanism.common.config.MekanismConfig.client;
@@ -47,6 +48,9 @@ public class RenderPressurizedTube extends RenderTransmitterBase<TileEntityPress
public void renderGasSide(BufferBuilder renderer, EnumFacing side, TileEntityPressurizedTube tube)
{
bindTexture(MekanismRenderer.getBlocksTexture());
renderTransparency(renderer, tube.getTransmitter().getTransmitterNetwork().refGas.getSprite(), getModelForSide(tube, side), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale));
Gas gas = tube.getTransmitter().getTransmitterNetwork().refGas;
ColourRGBA c = new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale);
c.setRGBFromInt(gas.getTint());
renderTransparency(renderer, gas.getSprite(), getModelForSide(tube, side), c);
}
}
@@ -32,4 +32,10 @@ public class ColourRGBA
{
return (valA & 0xFF) << 24 | (valR & 0xFF) << 16 | (valG & 0xFF) << 8 | (valB & 0xFF);
}
public void setRGBFromInt(int color){
valR = (byte)((color >> 16) & 0xFF);
valG = (byte)((color >> 8) & 0xFF);
valB = (byte)( color & 0xFF);
}
}
@@ -799,6 +799,9 @@ public class Mekanism
//Integrate with Waila
FMLInterModComms.sendMessage(MekanismHooks.WAILA_MOD_ID, "register", "mekanism.common.integration.WailaDataProvider.register");
//Register TOP handler
FMLInterModComms.sendFunctionMessage("theoneprobe", "getTheOneProbe", "mekanism.common.integration.TOPProvider");
//Integrate with OpenComputers
if(Loader.isModLoaded(MekanismHooks.OPENCOMPUTERS_MOD_ID))
{
@@ -57,9 +57,16 @@ public class MekanismFluids
for(Resource resource : Resource.values())
{
String name = resource.getName();
String nameLower = name.toLowerCase();
OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false));
GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false));
OreGas clean = new OreGas("clean" + name, "oregas." + nameLower);
clean.setVisible(false).setTint(resource.tint);
OreGas dirty = new OreGas(nameLower, "oregas." + nameLower).setCleanGas(clean);
dirty.setVisible(false).setTint(resource.tint);
GasRegistry.register(clean);
GasRegistry.register(dirty);
}
FluidRegistry.enableUniversalBucket();
+10 -8
View File
@@ -2,19 +2,21 @@ package mekanism.common;
public enum Resource
{
IRON("Iron"),
GOLD("Gold"),
OSMIUM("Osmium"),
COPPER("Copper"),
TIN("Tin"),
SILVER("Silver"),
LEAD("Lead");
IRON("Iron", 0xccccd9),
GOLD("Gold", 0xf2cd67),
OSMIUM("Osmium", 0x1e79c3),
COPPER("Copper", 0xaa4b19),
TIN("Tin", 0xccccd9),
SILVER("Silver", 0xccccd9),
LEAD("Lead", 0x3d3d41);
private String name;
public final int tint;
Resource(String s)
Resource(String s, int t)
{
name = s;
tint = t;
}
public static Resource getFromName(String s)
@@ -2,10 +2,13 @@ package mekanism.common.base;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.capability.FluidTankProperties;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import java.util.Arrays;
public class FluidHandlerWrapper implements IFluidHandler
{
public IFluidHandlerWrapper wrapper;
@@ -21,6 +24,9 @@ public class FluidHandlerWrapper implements IFluidHandler
@Override
public IFluidTankProperties[] getTankProperties()
{
if (side == null){
return convertReadOnly(wrapper.getAllTanks());
}
return wrapper.getTankInfo(side) != null ? FluidTankProperties.convert(wrapper.getTankInfo(side))
: new IFluidTankProperties[]{};
}
@@ -28,6 +34,9 @@ public class FluidHandlerWrapper implements IFluidHandler
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (side == null){
return 0;
}
if(wrapper.canFill(side, resource != null ? resource.getFluid() : null))
{
return wrapper.fill(side, resource, doFill);
@@ -39,6 +48,10 @@ public class FluidHandlerWrapper implements IFluidHandler
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if(side == null)
{
return null;
}
if(wrapper.canDrain(side, resource != null ? resource.getFluid() : null))
{
return wrapper.drain(side, resource, doDrain);
@@ -50,6 +63,10 @@ public class FluidHandlerWrapper implements IFluidHandler
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if(side == null)
{
return null;
}
if(wrapper.canDrain(side, null))
{
return wrapper.drain(side, maxDrain, doDrain);
@@ -57,4 +74,8 @@ public class FluidHandlerWrapper implements IFluidHandler
return null;
}
private static IFluidTankProperties[] convertReadOnly(FluidTankInfo[] fluidTankInfos){
return Arrays.stream(fluidTankInfos).map(t->new FluidTankProperties(t.fluid, t.capacity, false, false)).toArray(IFluidTankProperties[]::new);
}
}
@@ -18,4 +18,6 @@ public interface IFluidHandlerWrapper
boolean canDrain(EnumFacing from, Fluid fluid);
FluidTankInfo[] getTankInfo(EnumFacing from);
FluidTankInfo[] getAllTanks();
}
@@ -712,6 +712,10 @@ public abstract class BlockMachine extends BlockContainer
{
itemStack.shrink(1);
}
else {
player.dropItem(copyStack, false, true);
itemStack.shrink(1);
}
if(tileEntity.tier != FluidTankTier.CREATIVE)
{
@@ -2,11 +2,14 @@ package mekanism.common.capabilities;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.common.capabilities.DefaultStorageHelper.NullStorage;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.CapabilityManager;
import javax.annotation.Nonnull;
public class DefaultGasHandler implements IGasHandler
{
@Override
@@ -37,4 +40,11 @@ public class DefaultGasHandler implements IGasHandler
{
CapabilityManager.INSTANCE.register(IGasHandler.class, new NullStorage<>(), DefaultGasHandler.class);
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return IGasHandler.NONE;
}
}
@@ -0,0 +1,61 @@
package mekanism.common.integration;
import mcjty.theoneprobe.api.IProbeHitData;
import mcjty.theoneprobe.api.IProbeInfo;
import mcjty.theoneprobe.api.IProbeInfoProvider;
import mcjty.theoneprobe.api.IProgressStyle;
import mcjty.theoneprobe.api.ITheOneProbe;
import mcjty.theoneprobe.api.ProbeMode;
import mcjty.theoneprobe.api.TextStyleClass;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.common.capabilities.Capabilities;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.function.Function;
@SuppressWarnings("unused")//IMC bound
public class TOPProvider implements Function<ITheOneProbe, Void>, IProbeInfoProvider
{
@Override
public Void apply(ITheOneProbe iTheOneProbe)
{
iTheOneProbe.registerProvider(this);
return null;
}
@Override
public String getID()
{
return "mekanism";
}
@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data)
{
if (mode != ProbeMode.EXTENDED){
return;
}
final TileEntity tile = world.getTileEntity( data.getPos() );
if (tile != null){
if (tile.hasCapability(Capabilities.GAS_HANDLER_CAPABILITY, null)){
IGasHandler handler = tile.getCapability(Capabilities.GAS_HANDLER_CAPABILITY, null);
if (handler != null){
GasTankInfo[] tanks = handler.getTankInfo();
for (GasTankInfo tank : tanks){
if (tank.getGas() != null){
probeInfo.text(TextStyleClass.NAME + "Gas: " + tank.getGas().getGas().getLocalizedName());
}
IProgressStyle style = probeInfo.defaultProgressStyle().suffix("mB");
probeInfo.progress(tank.getStored(), tank.getMaxGas(), style);
}
}
}
}
}
}
@@ -7,6 +7,7 @@ import java.util.Random;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.base.TileNetworkList;
@@ -19,6 +20,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityAmbientAccumulator extends TileEntityContainerBlock implements IGasHandler, ITubeConnection
{
public GasTank collectedGas = new GasTank(1000);
@@ -77,6 +80,13 @@ public class TileEntityAmbientAccumulator extends TileEntityContainerBlock imple
return type == collectedGas.getGasType();
}
@Override
@Nonnull
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{collectedGas};
}
@Override
public boolean canTubeConnect(EnumFacing side)
{
@@ -83,6 +83,12 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return new FluidTankInfo[] { steamTank.getInfo(), waterTank.getInfo() };
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
@@ -8,6 +8,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -38,6 +39,8 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine implements IGasHandler, ITubeConnection, ISideConfiguration, ISustainedData, ITankManager, IConfigCardAccess
{
public static final int MAX_GAS = 10000;
@@ -247,7 +250,14 @@ public class TileEntityChemicalCrystallizer extends TileEntityOperationalMachine
{
return false;
}
@Override
@Nonnull
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{inputTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -6,6 +6,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -36,6 +37,8 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityChemicalDissolutionChamber extends TileEntityMachine implements ITubeConnection, IGasHandler, ISustainedData, ITankManager
{
public GasTank injectTank = new GasTank(MAX_GAS);
@@ -332,7 +335,14 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
{
return false;
}
@Override
@Nonnull
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{injectTank, outputTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -8,6 +8,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -40,6 +41,8 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityChemicalInfuser extends TileEntityMachine implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile
{
public GasTank leftTank = new GasTank(MAX_GAS);
@@ -287,6 +290,13 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas
return null;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{leftTank, centerTank, rightTank};
}
@Override
public boolean canTubeConnect(EnumFacing side)
{
@@ -8,6 +8,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -51,6 +52,8 @@ import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityChemicalWasher extends TileEntityMachine implements IGasHandler, ITubeConnection, IFluidHandlerWrapper, ISustainedData, IUpgradeInfoHandler, ITankManager
{
public FluidTank fluidTank = new FluidTank(MAX_FLUID);
@@ -337,6 +340,13 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
return getTank(side) == outputTank && getTank(side).canDraw(type);
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{inputTank, outputTank};
}
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
@@ -455,6 +465,12 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return new FluidTankInfo[] {fluidTank.getInfo()};
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
@@ -225,7 +225,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
IBlockState state = coord.getBlockState(world);
Block block = state.getBlock();
int meta = block.getMetaFromState(state);
int meta = block.damageDropped(state);
if(block == null || coord.isAirBlock(world))
{
@@ -242,10 +242,11 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
}
boolean hasFilter = false;
ItemStack is = new ItemStack(block, 1, meta);
for(MinerFilter filter : filters)
{
if(filter.canFilter(new ItemStack(block, 1, meta)))
if(filter.canFilter(is))
{
hasFilter = true;
break;
@@ -28,6 +28,12 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl
return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
@@ -453,6 +453,12 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(EnumFacing.UP);
}
@Override
public void setFluidStack(FluidStack fluidStack, Object... data)
{
@@ -8,6 +8,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -52,6 +53,8 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import javax.annotation.Nonnull;
public class TileEntityElectrolyticSeparator extends TileEntityMachine implements IFluidHandlerWrapper, IComputerIntegration, ITubeConnection, ISustainedData, IGasHandler, IUpgradeInfoHandler, ITankManager
{
/** This separator's water slot. */
@@ -554,6 +557,12 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
return new FluidTankInfo[] {fluidTank.getInfo()};
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
{
@@ -595,7 +604,14 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
return false;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{leftTank, rightTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -12,6 +12,7 @@ import mekanism.api.Range4D;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -68,6 +69,8 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
public class TileEntityFactory extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, IGasHandler, ITubeConnection, ISpecialConfigData, ITierUpgradeable
{
/** This Factory's tier. */
@@ -1036,7 +1039,14 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
{
return false;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{gasTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -608,7 +608,13 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
{
return new FluidTankInfo[] {fluidTank.getInfo()};
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public void setFluidStack(FluidStack fluidStack, Object... data)
{
@@ -417,6 +417,12 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(EnumFacing.UP);
}
@Override
public void setFluidStack(FluidStack fluidStack, Object... data)
{
@@ -11,6 +11,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -45,6 +46,8 @@ import net.minecraft.util.math.MathHelper;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable, IComputerIntegration
{
public enum GasMode
@@ -252,7 +255,14 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
return false;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{gasTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -9,6 +9,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
@@ -50,6 +51,8 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, PressurizedOutput, PressurizedRecipe> implements IFluidHandlerWrapper, IGasHandler, ITubeConnection, ISustainedData, ITankManager
{
public FluidTank inputFluidTank = new FluidTank(10000);
@@ -402,6 +405,12 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
return data.getFluidTankInfo(this);
}
@Override
public FluidTankInfo[] getAllTanks()
{
return new FluidTankInfo[]{inputFluidTank.getInfo()};
}
@Override
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
{
@@ -441,7 +450,14 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
{
return configComponent.getOutput(TransmissionType.GAS, side, facing).hasSlot(1, 2);
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{inputGasTank, outputGasTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -12,6 +12,7 @@ import mekanism.api.Coord4D;
import mekanism.api.IHeatTransfer;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
@@ -61,6 +62,8 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock implements ISideConfiguration, ITankManager, IFluidHandlerWrapper, IFrequencyHandler, IGasHandler, IHeatTransfer, ITubeConnection, IComputerIntegration, ISecurityTile, IChunkLoader, IUpgradeTile
{
public InventoryFrequency frequency;
@@ -528,6 +531,12 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return hasFrequency() ? new FluidTankInfo[] { frequency.storedFluid.getInfo() } : PipeUtils.EMPTY;
}
@Override
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
{
@@ -561,7 +570,14 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
return false;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return hasFrequency() ? new GasTankInfo[]{frequency.storedGas} : IGasHandler.NONE;
}
@Override
public boolean handleInventory()
{
@@ -10,6 +10,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism;
@@ -48,6 +49,8 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import javax.annotation.Nonnull;
public class TileEntityRotaryCondensentrator extends TileEntityMachine implements ISustainedData, IFluidHandlerWrapper, IGasHandler, ITubeConnection, IUpgradeInfoHandler, ITankManager
{
public GasTank gasTank = new GasTank(MAX_FLUID);
@@ -319,7 +322,14 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement
{
return (mode == 0 && side == MekanismUtils.getLeft(facing)) && gasTank.canReceive(type);
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{gasTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -409,6 +419,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return new FluidTankInfo[]{fluidTank.getInfo()};
}
@Override
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
{
@@ -11,6 +11,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism;
@@ -48,6 +49,8 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nonnull;
public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, ITubeConnection, IActiveState, ISustainedData, ITankManager, ISecurityTile, IUpgradeTile, IUpgradeInfoHandler
{
public GasTank inputTank = new GasTank(MAX_GAS);
@@ -324,7 +327,14 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
{
return side == facing && outputTank.canDraw(type);
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{inputTank, outputTank};
}
@Override
public boolean canTubeConnect(EnumFacing side)
{
@@ -101,6 +101,12 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat
return new FluidTankInfo[] {new FluidTankInfo(controller.inputTank), new FluidTankInfo(controller.outputTank)};
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public double getTemp()
{
@@ -6,6 +6,7 @@ import mekanism.api.EnumColor;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.api.transmitters.TransmissionType;
@@ -37,6 +38,8 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedMachineRecipe<RECIPE>> extends TileEntityBasicMachine<AdvancedMachineInput, ItemStackOutput, RECIPE> implements IGasHandler, ITubeConnection, ITierUpgradeable
{
/** How much secondary energy (fuel) this machine uses per tick, not including upgrades. */
@@ -426,7 +429,14 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
{
return false;
}
@Override
@Nonnull
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{gasTank};
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
@@ -20,6 +20,10 @@ import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import javax.annotation.Nonnull;
public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory, ITickable
{
@@ -291,12 +295,40 @@ public abstract class TileEntityContainerBlock extends TileEntityBasicBlock impl
private CapabilityWrapperManager<ISidedInventory, ItemHandlerWrapper> itemManager = new CapabilityWrapperManager<>(ISidedInventory.class, ItemHandlerWrapper.class);
/**
* Read only itemhandler for the null facing.
*/
private IItemHandler nullHandler = new InvWrapper(this){
@Nonnull
@Override
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
return stack;
}
@Nonnull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
return ItemStack.EMPTY;
}
@Override
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{
//no
}
};
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
{
return (T)itemManager.getWrapper(this, facing);
if(facing == null){
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(nullHandler);
}
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemManager.getWrapper(this, facing));
}
return super.getCapability(capability, facing);
@@ -27,8 +27,8 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.transmitters.TransporterImpl;
import mekanism.common.transmitters.grid.InventoryNetwork;
import mekanism.common.util.CapabilityUtils;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.TextComponentGroup;
import mekanism.common.util.TransporterUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@@ -37,7 +37,7 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.util.Constants.NBT;
@@ -352,7 +352,19 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<TileE
onPartChanged(null);
PathfinderCache.onChanged(new Coord4D(getPos(), getWorld()));
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(new Coord4D(getPos(), getWorld()), getNetworkedData(new TileNetworkList())), new Range4D(new Coord4D(getPos(), getWorld())));
player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.toggleColor") + ": " + (getTransmitter().getColor() != null ? getTransmitter().getColor().getColoredName() : EnumColor.BLACK + LangUtils.localize("gui.none"))));
TextComponentGroup msg = new TextComponentGroup(TextFormatting.GRAY)
.string("[Mekanism] ", TextFormatting.DARK_BLUE)
.translation("tooltip.configurator.toggleColor")
.string(": " );
if (getTransmitter().getColor() != null)
{
msg.appendSibling(getTransmitter().getColor().getTranslatedColouredComponent());
} else {
msg.translation("gui.none", TextFormatting.BLACK);
}
player.sendMessage(msg);
return EnumActionResult.SUCCESS;
}
@@ -361,7 +373,17 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<TileE
public EnumActionResult onRightClick(EntityPlayer player, EnumFacing side)
{
super.onRightClick(player, side);
player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.viewColor") + ": " + (getTransmitter().getColor() != null ? getTransmitter().getColor().getColoredName() : "None")));
TextComponentGroup msg = new TextComponentGroup(TextFormatting.GRAY)
.string("[Mekanism] ", TextFormatting.DARK_BLUE)
.translation("tooltip.configurator.viewColor");
if (getTransmitter().getColor() != null)
{
msg.appendSibling(getTransmitter().getColor().getTranslatedColouredComponent());
} else {
msg.translation("gui.none");
}
player.sendMessage(msg);
return EnumActionResult.SUCCESS;
}
@@ -266,6 +266,12 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
return PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return new FluidTankInfo[]{buffer.getInfo()};
}
public int getPullAmount()
{
return tier.pipePullAmount;
@@ -7,6 +7,7 @@ import java.util.Collection;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.Tier;
@@ -23,6 +24,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import javax.annotation.Nonnull;
public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler, GasNetwork> implements IGasHandler
{
public Tier.TubeTier tier = Tier.TubeTier.BASIC;
@@ -264,7 +267,14 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
return buffer.receive(gasStack, doEmit);
}
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{buffer};
}
@Override
public IGasHandler getCachedAcceptor(EnumFacing side)
{
@@ -29,6 +29,7 @@ import mekanism.common.util.CapabilityUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MultipartUtils;
import mekanism.common.util.MultipartUtils.AdvancedRayTraceResult;
import mekanism.common.util.TextComponentGroup;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@@ -610,7 +611,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
sendDesc = true;
onModeChange(EnumFacing.getFront(hitSide.ordinal()));
player.sendMessage(new TextComponentString("Connection type changed to " + connectionTypes[hitSide.ordinal()].toString()));
player.sendMessage(new TextComponentGroup().translation("tooltip.configurator.modeChange").string(" ").translation(connectionTypes[hitSide.ordinal()].translationKey()));
return EnumActionResult.SUCCESS;
}
@@ -749,5 +750,9 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
{
return name().toLowerCase();
}
public String translationKey(){
return "mekanism.pipe.connectiontype."+getName();
}
}
}
@@ -3,6 +3,7 @@ package mekanism.common.util;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -38,10 +39,10 @@ public final class MinerUtils
if(block == null || block.isAir(state, world, obj.getPos()))
{
return new LinkedList<>();
return Collections.EMPTY_LIST;
}
if(silk && block.canSilkHarvest(world, obj.getPos(), state, null))
if(silk && (block.canSilkHarvest(world, obj.getPos(), state, null) || specialSilkIDs.contains(block)))
{
List<ItemStack> ret = new ArrayList<>();
if (getSilkTouchDrop != null)
@@ -55,37 +56,38 @@ public final class MinerUtils
}
} catch (InvocationTargetException|IllegalAccessException e){
Mekanism.logger.error("Block.getSilkTouchDrop errored", e);
fallbackGetSilkTouch(block, state, ret);
}
}
else//fallback to old method
{
Item item = Item.getItemFromBlock(block);
if (item != null && item != Items.AIR)
{
int meta = item.getHasSubtypes() ? block.getMetaFromState(state) : 0;
ret.add(new ItemStack(item, 1, meta));
}
fallbackGetSilkTouch(block, state, ret);
}
if (ret.size() > 0)
{
List<ItemStack> blockDrops = block.getDrops(world, obj.getPos(), state, 0);
if(specialSilkIDs.contains(block) || (blockDrops != null && blockDrops.size() > 0))
{
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ret, world, obj.getPos(), state, 0, 1.0f, true, null);
return ret;
}
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ret, world, obj.getPos(), state, 0, 1.0f, true, null);
return ret;
}
} else {
@SuppressWarnings("deprecation")
List<ItemStack> blockDrops = block.getDrops(world, obj.getPos(), state, 0);
if (blockDrops.size() > 0)
{
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(blockDrops, world, obj.getPos(), state, 0, 1.0f, true, null);
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(blockDrops, world, obj.getPos(), state, 0, 1.0f, false, null);
}
return blockDrops;
}
return new LinkedList<>();
return Collections.emptyList();
}
private static void fallbackGetSilkTouch(Block block, IBlockState state, List<ItemStack> ret){
Item item = Item.getItemFromBlock(block);
if (item != null && item != Items.AIR)
{
int meta = item.getHasSubtypes() ? block.getMetaFromState(state) : 0;
ret.add(new ItemStack(item, 1, meta));
}
}
}
@@ -0,0 +1,66 @@
package mekanism.common.util;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentBase;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
/**
* Created by Thiakil on 8/11/2017.
*/
public class TextComponentGroup extends TextComponentBase
{
public TextComponentGroup(){
}
public TextComponentGroup(TextFormatting color)
{
getStyle().setColor(color);
}
@Override
public String getUnformattedComponentText()
{
return "";
}
@Override
public ITextComponent createCopy()
{
TextComponentGroup textcomponentstring = new TextComponentGroup();
textcomponentstring.setStyle(this.getStyle().createShallowCopy());
for (ITextComponent itextcomponent : this.getSiblings())
{
textcomponentstring.appendSibling(itextcomponent.createCopy());
}
return textcomponentstring;
}
public TextComponentGroup string(String s){
this.appendSibling(new TextComponentString(s));
return this;
}
public TextComponentGroup string(String s, TextFormatting color){
ITextComponent t = new TextComponentString(s);
t.getStyle().setColor(color);
this.appendSibling(t);
return this;
}
public TextComponentGroup translation(String key){
this.appendSibling(new TextComponentTranslation(key));
return this;
}
public TextComponentGroup translation(String key, TextFormatting color){
ITextComponent t = new TextComponentTranslation(key);
t.getStyle().setColor(color);
this.appendSibling(t);
return this;
}
}
@@ -324,4 +324,12 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
return super.getCapability(capability, side);
}
private static FluidTankInfo[] ALL_TANKS = new FluidTankInfo[0];
@Override
public FluidTankInfo[] getAllTanks()
{
return ALL_TANKS;
}
}
@@ -6,6 +6,7 @@ import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
@@ -26,6 +27,8 @@ import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData
{
/** The maximum amount of gas this block can store. */
@@ -298,6 +301,13 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
return 0;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return new GasTankInfo[]{fuelTank};
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
@@ -353,6 +353,12 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
return new FluidTankInfo[] {lavaTank.getInfo()};
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
@@ -11,6 +11,7 @@ import mekanism.api.IHeatTransfer;
import mekanism.api.Range4D;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTankInfo;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism;
@@ -46,6 +47,8 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nonnull;
public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandlerWrapper, IGasHandler, ITubeConnection, IHeatTransfer, IConfigurable
{
public boolean fluidEject;
@@ -173,6 +176,12 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
return new FluidTankInfo[] {getReactor().getWaterTank().getInfo(), getReactor().getSteamTank().getInfo()};
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer)
{
@@ -213,6 +222,13 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
return false;
}
@Nonnull
@Override
public GasTankInfo[] getTankInfo()
{
return getReactor() != null ? new GasTankInfo[]{getReactor().getDeuteriumTank(), getReactor().getTritiumTank(), getReactor().getFuelTank()} : IGasHandler.NONE;
}
@Override
public boolean canTubeConnect(EnumFacing side)
{
@@ -360,6 +360,12 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{
@@ -56,6 +56,12 @@ public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IF
return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fakeInfo} : PipeUtils.EMPTY;
}
@Override
public FluidTankInfo[] getAllTanks()
{
return getTankInfo(null);
}
@Override
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
{