Glowing components like the indicator light actuall glow in the dark now
Some bugfixes Complete code reformatting
This commit is contained in:
parent
06d8ddfff9
commit
23c1afc44b
2
IEIssues.txt
Normal file
2
IEIssues.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
LV conn=rel item model
|
||||
RS conns don't update color instantly
|
|
@ -20,7 +20,7 @@ package malte0811.industrialWires;
|
|||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.Config.Comment;
|
||||
|
||||
@Config(modid=IndustrialWires.MODID)
|
||||
@Config(modid = IndustrialWires.MODID)
|
||||
public class IWConfig {
|
||||
@Comment({"The maximum length of a single connection.", "Order: Tin, Copper, Gold, HV, Glass Fiber"})
|
||||
public static int[] maxLengthPerConn = {16, 16, 16, 32, 32};
|
||||
|
@ -29,14 +29,15 @@ public class IWConfig {
|
|||
|
||||
@Comment({"Set this to false to completely disable any conversion between IF and EU (default: true)"})
|
||||
public static boolean enableConversion = true;
|
||||
|
||||
public static MechConversion mc = new MechConversion();
|
||||
|
||||
public static MechConversion mech;
|
||||
|
||||
public static class MechConversion {
|
||||
@Comment({"The amount of EU that would be produced by an ideal converter from 1 IF (default: 0.25)"})
|
||||
public static double euPerIf = .25;
|
||||
@Comment({"The amount of IC2 kinetic energy that an ideal converter produces from 1 EU"})
|
||||
public static double kinPerEu = 4;
|
||||
|
||||
|
||||
@Comment({"The maximum amount of IF that can be converted to rotational energy", "by one motor in one tick (default: 100)"})
|
||||
public static int maxIfToMech = 100;
|
||||
@Comment({"The efficiency of the IF motor. The default value of 0.9 means that 10% of the energy are lost in the conversion."})
|
||||
|
@ -46,16 +47,18 @@ public class IWConfig {
|
|||
public static double maxRotToKin = 50;
|
||||
@Comment({"The efficiency of the conversion from IE rotational energy to IC2 kinetic energy"})
|
||||
public static double rotToKinEfficiency = .7;
|
||||
|
||||
|
||||
@Comment({"The maximum amount of IC2 kinetic energy that can be converted into IE rotational energy", "by one converter in one tick"})
|
||||
public static int maxKinToRot = 2400;
|
||||
@Comment({"The efficiency of the conversion from IC2 kinetic energy to IE rotational energy"})
|
||||
public static double kinToRotEfficiency = .8;
|
||||
}
|
||||
public static HVStuff hv = new HVStuff();
|
||||
|
||||
public static HVStuff hv;
|
||||
|
||||
public static class HVStuff {
|
||||
@Comment({"The amount of Eu a Jacobs Ladder uses per tick, sorted by size of the ladder"})
|
||||
public static double[] jacobsUsageEU = {10, 20, 50};
|
||||
@Comment({"The amount of EU a Jacobs Ladder uses per tick, sorted by size of the ladder"})
|
||||
public static double[] jacobsUsageEU = {20, 50, 100};
|
||||
@Comment({"The damage dealt by a small Jacobs Ladder. Normal Ladders deal twice this damage, huge ones 3 times as much"})
|
||||
public static float jacobsBaseDmg = 5;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class IndustrialWires {
|
|||
return new ItemStack(coil, 1, 2);
|
||||
}
|
||||
};
|
||||
@SidedProxy(clientSide="malte0811.industrialWires.client.ClientProxy", serverSide="malte0811.industrialWires.CommonProxy")
|
||||
@SidedProxy(clientSide = "malte0811.industrialWires.client.ClientProxy", serverSide = "malte0811.industrialWires.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
|
@ -102,16 +102,16 @@ public class IndustrialWires {
|
|||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, MODID + "ic2ConnectorGold");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, MODID + "ic2ConnectorHV");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, MODID + "ic2ConnectorGlass");
|
||||
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, MODID+":jacobsLadder");
|
||||
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID+":control_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID+":control_panel_rs");
|
||||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID+":panel_creator");
|
||||
if (mechConv!=null) {
|
||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID+":ieMotor");
|
||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID+":mechIcToIe");
|
||||
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID+":mechIeToIc");
|
||||
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, MODID + ":jacobsLadder");
|
||||
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
|
||||
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
|
||||
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
|
||||
if (mechConv != null) {
|
||||
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
|
||||
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
|
||||
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID + ":mechIeToIc");
|
||||
}
|
||||
if (IC2Wiretype.IC2_TYPES==null) {
|
||||
if (IC2Wiretype.IC2_TYPES == null) {
|
||||
throw new IllegalStateException("No IC2 wires registered");
|
||||
}
|
||||
proxy.preInit();
|
||||
|
@ -125,7 +125,7 @@ public class IndustrialWires {
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 2), " c ", "rcr", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 4), " g ", "rgr", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 6), " i ", "rir", "rir", 'i', "ingotIron", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 8), " c ", "rcr", "rcr",'c', glassCable, 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 8), " c ", "rcr", "rcr", 'c', glassCable, 'r', "itemRubber"));
|
||||
//RELAYS
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 1), " t ", "rtr", 't', "ingotTin", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 3), " c ", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
|
||||
|
@ -134,12 +134,12 @@ public class IndustrialWires {
|
|||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 2, 9), " c ", "grg", "grg", 'r', "itemRubber", 'c', glassCable, 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
|
||||
//WIRES
|
||||
RecipeSorter.register("industrialwires:coilLength", RecipeCoilLength.class, Category.SHAPELESS, "after:forge:shapelessore");
|
||||
for (int i = 0;i<IC2Wiretype.IC2_TYPES.length;i++) {
|
||||
for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) {
|
||||
GameRegistry.addRecipe(new RecipeCoilLength(i));
|
||||
}
|
||||
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new CoilLengthAdapter());
|
||||
// MECH CONVERTERS
|
||||
if (mechConv!=null) {
|
||||
if (mechConv != null) {
|
||||
ItemStack shaftIron = IC2Items.getItem("crafting", "iron_shaft");
|
||||
ItemStack shaftSteel = IC2Items.getItem("crafting", "steel_shaft");
|
||||
ItemStack ironMechComponent = new ItemStack(IEContent.itemMaterial, 1, 8);
|
||||
|
@ -200,10 +200,12 @@ public class IndustrialWires {
|
|||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
proxy.postInit();
|
||||
}
|
||||
|
||||
private class CoilLengthAdapter implements IRecipeAdapter<RecipeCoilLength> {
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength recipe, NonNullList<ItemStack> in) {
|
||||
|
@ -223,6 +225,7 @@ public class IndustrialWires {
|
|||
}
|
||||
return ret.toArray(new RecipeQuery[ret.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength arg0) {
|
||||
return new RecipeQuery[0];
|
||||
|
|
|
@ -50,20 +50,21 @@ import java.util.Set;
|
|||
|
||||
public abstract class BlockIWBase extends Block {
|
||||
private IProperty[] properties;
|
||||
|
||||
public BlockIWBase(Material mat, String name) {
|
||||
super(mat);
|
||||
setHardness(3.0F);
|
||||
setResistance(15.0F);
|
||||
GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name));
|
||||
GameRegistry.register(new ItemBlockIW(this), new ResourceLocation(IndustrialWires.MODID, name));
|
||||
setUnlocalizedName(IndustrialWires.MODID+"."+name);
|
||||
setUnlocalizedName(IndustrialWires.MODID + "." + name);
|
||||
setCreativeTab(IndustrialWires.creativeTab);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
if (properties==null) {
|
||||
if (properties == null) {
|
||||
properties = getProperties();
|
||||
}
|
||||
BlockStateContainer cont = super.createBlockState();
|
||||
|
@ -82,8 +83,8 @@ public abstract class BlockIWBase extends Block {
|
|||
if (tile instanceof IHasDummyBlocksIW) {
|
||||
state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((IHasDummyBlocksIW) tile).isDummy());
|
||||
}
|
||||
if (tile instanceof IEBlockInterfaces.IDirectionalTile&&((IEBlockInterfaces.IDirectionalTile) tile).getFacingLimitation()>=0) {
|
||||
if (((IEBlockInterfaces.IDirectionalTile) tile).getFacingLimitation()==2) {
|
||||
if (tile instanceof IEBlockInterfaces.IDirectionalTile && ((IEBlockInterfaces.IDirectionalTile) tile).getFacingLimitation() >= 0) {
|
||||
if (((IEBlockInterfaces.IDirectionalTile) tile).getFacingLimitation() == 2) {
|
||||
state = state.withProperty(IEProperties.FACING_HORIZONTAL, ((IEBlockInterfaces.IDirectionalTile) tile).getFacing());
|
||||
} else {
|
||||
state = state.withProperty(IEProperties.FACING_ALL, ((IEBlockInterfaces.IDirectionalTile) tile).getFacing());
|
||||
|
@ -106,7 +107,7 @@ public abstract class BlockIWBase extends Block {
|
|||
return state;
|
||||
}
|
||||
|
||||
protected <V extends Comparable<V>> IBlockState applyProperty(IBlockState in, IProperty<V> prop, V val) {
|
||||
protected <V extends Comparable<V>> IBlockState applyProperty(IBlockState in, IProperty<V> prop, V val) {
|
||||
return in.withProperty(prop, val);
|
||||
}
|
||||
|
||||
|
@ -116,9 +117,9 @@ public abstract class BlockIWBase extends Block {
|
|||
if (te instanceof IHasDummyBlocksIW) {
|
||||
((IHasDummyBlocksIW) te).breakDummies();
|
||||
}
|
||||
if(te instanceof IImmersiveConnectable) {
|
||||
if(!worldIn.isRemote||!Minecraft.getMinecraft().isSingleplayer())
|
||||
ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(Utils.toCC(te), worldIn, !worldIn.isRemote&&worldIn.getGameRules().getBoolean("doTileDrops"));
|
||||
if (te instanceof IImmersiveConnectable) {
|
||||
if (!worldIn.isRemote || !Minecraft.getMinecraft().isSingleplayer())
|
||||
ImmersiveNetHandler.INSTANCE.clearAllConnectionsFor(Utils.toCC(te), worldIn, !worldIn.isRemote && worldIn.getGameRules().getBoolean("doTileDrops"));
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
worldIn.removeTileEntity(pos);
|
||||
|
@ -130,7 +131,7 @@ public abstract class BlockIWBase extends Block {
|
|||
TileEntity te = source.getTileEntity(pos);
|
||||
if (te instanceof IBlockBoundsIW) {
|
||||
AxisAlignedBB ret = ((IBlockBoundsIW) te).getBoundingBox();
|
||||
if (ret!=null) {
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -143,24 +144,24 @@ public abstract class BlockIWBase extends Block {
|
|||
EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
if(te instanceof IEBlockInterfaces.IDirectionalTile && Utils.isHammer(heldItem) && !world.isRemote) {
|
||||
if (te instanceof IEBlockInterfaces.IDirectionalTile && Utils.isHammer(heldItem) && !world.isRemote) {
|
||||
IEBlockInterfaces.IDirectionalTile directionalTe = (IEBlockInterfaces.IDirectionalTile) te;
|
||||
if (directionalTe.canHammerRotate(side, hitX, hitY, hitZ, player)) {
|
||||
EnumFacing f = directionalTe.getFacing();
|
||||
final EnumFacing original = f;
|
||||
int limit = directionalTe.getFacingLimitation();
|
||||
|
||||
if(limit==0) {
|
||||
if (limit == 0) {
|
||||
f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length];
|
||||
} else if(limit==1) {
|
||||
f = player.isSneaking()?f.rotateAround(side.getAxis()).getOpposite():f.rotateAround(side.getAxis());
|
||||
} else if(limit == 2 || limit == 5) {
|
||||
f = player.isSneaking()?f.rotateYCCW():f.rotateY();
|
||||
} else if (limit == 1) {
|
||||
f = player.isSneaking() ? f.rotateAround(side.getAxis()).getOpposite() : f.rotateAround(side.getAxis());
|
||||
} else if (limit == 2 || limit == 5) {
|
||||
f = player.isSneaking() ? f.rotateYCCW() : f.rotateY();
|
||||
}
|
||||
if (f!=original) {
|
||||
if (f != original) {
|
||||
directionalTe.setFacing(f);
|
||||
te.markDirty();
|
||||
world.notifyBlockUpdate(pos,state,state,3);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
world.addBlockEvent(pos, this, 255, 0);
|
||||
}
|
||||
return true;
|
||||
|
@ -176,7 +177,7 @@ public abstract class BlockIWBase extends Block {
|
|||
@Override
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
boolean def = super.eventReceived(state, worldIn, pos, id, param);
|
||||
if ((id&255)==255) {
|
||||
if ((id & 255) == 255) {
|
||||
IBlockState s = worldIn.getBlockState(pos);
|
||||
worldIn.notifyBlockUpdate(pos, s, s, 3);
|
||||
return true;
|
||||
|
@ -205,5 +206,6 @@ public abstract class BlockIWBase extends Block {
|
|||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
protected abstract IProperty[] getProperties();
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
|
|||
@Override
|
||||
public boolean canPlaceBlockAt(World w, BlockPos pos, ItemStack stack) {
|
||||
int dummyCount = LadderSize.values()[stack.getMetadata()].dummyCount;
|
||||
for (int i = 1;i<=dummyCount;i++) {
|
||||
for (int i = 1; i <= dummyCount; i++) {
|
||||
if (!w.isAirBlock(pos.up(i))) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class EnergyAdapter implements IEnergyStorage {
|
|||
private IFluxProvider prov;
|
||||
|
||||
private EnumFacing dir;
|
||||
|
||||
public EnergyAdapter(IFluxConnection te, EnumFacing f) {
|
||||
dir = f;
|
||||
if (te instanceof IFluxReceiver) {
|
||||
|
@ -41,10 +42,10 @@ public class EnergyAdapter implements IEnergyStorage {
|
|||
prov = (IFluxProvider) te;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
if (rec==null) {
|
||||
if (rec == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return rec.receiveEnergy(dir, maxReceive, simulate);
|
||||
|
@ -53,7 +54,7 @@ public class EnergyAdapter implements IEnergyStorage {
|
|||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
if (prov==null) {
|
||||
if (prov == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return prov.extractEnergy(dir, maxExtract, simulate);
|
||||
|
@ -62,9 +63,9 @@ public class EnergyAdapter implements IEnergyStorage {
|
|||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
if (prov!=null) {
|
||||
if (prov != null) {
|
||||
return prov.getEnergyStored(dir);
|
||||
} else if (rec!=null) {
|
||||
} else if (rec != null) {
|
||||
return rec.getEnergyStored(dir);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -73,9 +74,9 @@ public class EnergyAdapter implements IEnergyStorage {
|
|||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
if (prov!=null) {
|
||||
if (prov != null) {
|
||||
return prov.getMaxEnergyStored(dir);
|
||||
} else if (rec!=null) {
|
||||
} else if (rec != null) {
|
||||
return rec.getMaxEnergyStored(dir);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -84,11 +85,11 @@ public class EnergyAdapter implements IEnergyStorage {
|
|||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return prov!=null;
|
||||
return prov != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return rec!=null;
|
||||
return rec != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import net.minecraft.block.state.IBlockState;
|
|||
|
||||
public interface IHasDummyBlocksIW {
|
||||
void placeDummies(IBlockState state);
|
||||
|
||||
void breakDummies();
|
||||
|
||||
boolean isDummy();
|
||||
}
|
||||
|
|
|
@ -32,10 +32,11 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public class ItemBlockIW extends ItemBlock {
|
||||
private final Object[] values;
|
||||
|
||||
public ItemBlockIW(Block b) {
|
||||
super(b);
|
||||
if (b instanceof IMetaEnum) {
|
||||
values = ((IMetaEnum)b).getValues();
|
||||
values = ((IMetaEnum) b).getValues();
|
||||
} else {
|
||||
values = null;
|
||||
}
|
||||
|
@ -46,12 +47,13 @@ public class ItemBlockIW extends ItemBlock {
|
|||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = stack.getMetadata();
|
||||
if (values!=null) {
|
||||
if (values != null) {
|
||||
return block.getUnlocalizedName() + "." + values[meta].toString().toLowerCase();
|
||||
} else {
|
||||
return block.getUnlocalizedName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
|
@ -60,7 +62,7 @@ public class ItemBlockIW extends ItemBlock {
|
|||
@Override
|
||||
public boolean placeBlockAt(@Nonnull ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos,
|
||||
EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull IBlockState newState) {
|
||||
if (block instanceof IPlacementCheck&&!((IPlacementCheck) block).canPlaceBlockAt(world, pos, stack)) {
|
||||
if (block instanceof IPlacementCheck && !((IPlacementCheck) block).canPlaceBlockAt(world, pos, stack)) {
|
||||
return false;
|
||||
}
|
||||
boolean ret = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
|
||||
|
|
|
@ -36,6 +36,7 @@ public abstract class TileEntityIWBase extends TileEntity {
|
|||
writeNBT(nbt, true);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
return new SPacketUpdateTileEntity(pos, getBlockMetadata(), getUpdateTag());
|
||||
|
@ -47,18 +48,21 @@ public abstract class TileEntityIWBase extends TileEntity {
|
|||
writeNBT(compound, false);
|
||||
return super.writeToNBT(compound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
readNBT(compound, false);
|
||||
super.readFromNBT(compound);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
super.onDataPacket(net, pkt);
|
||||
readNBT(pkt.getNbtCompound(), true);
|
||||
}
|
||||
|
||||
public abstract void writeNBT(NBTTagCompound out, boolean updatePacket);
|
||||
|
||||
public abstract void readNBT(NBTTagCompound in, boolean updatePacket);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
} else if (timeTillActive == 0 && t < 1) {
|
||||
t += tStep;
|
||||
if (salt > 0) {
|
||||
salt -= 1D/(20*20);//20 seconds per item of salt
|
||||
salt -= 1D / (20 * 20);//20 seconds per item of salt
|
||||
} else if (salt < 0) {
|
||||
salt = 0;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
public boolean isActive() {
|
||||
if (isDummy()) {
|
||||
TileEntity master = world.getTileEntity(pos.down(dummy));
|
||||
return master instanceof TileEntityJacobsLadder&&((TileEntityJacobsLadder) master).isActive();
|
||||
return master instanceof TileEntityJacobsLadder && ((TileEntityJacobsLadder) master).isActive();
|
||||
}
|
||||
return timeTillActive == 0 && t < 1;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
}
|
||||
if (!world.isRemote) {
|
||||
EnumFacing targetDir = facing.rotateAround(EnumFacing.Axis.Y);
|
||||
for (int i = -dummy;i<size.dummyCount-dummy+1;i++) {
|
||||
for (int i = -dummy; i < size.dummyCount - dummy + 1; i++) {
|
||||
BlockPos currPos = pos.up(i);
|
||||
TileEntity te = world.getTileEntity(currPos);
|
||||
if (te instanceof TileEntityJacobsLadder) {
|
||||
|
@ -380,7 +380,7 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl
|
|||
teJacobs.facing = targetDir;
|
||||
teJacobs.markDirty();
|
||||
IBlockState state = world.getBlockState(currPos).getActualState(world, currPos);
|
||||
world.notifyBlockUpdate(currPos,state,state,3);
|
||||
world.notifyBlockUpdate(currPos, state, state, 3);
|
||||
world.addBlockEvent(currPos, state.getBlock(), 255, 0);
|
||||
world.notifyNeighborsOfStateChange(currPos, state.getBlock(), true);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
||||
public static final PropertyEnum<BlockTypes_Panel> type = PropertyEnum.create("type", BlockTypes_Panel.class);
|
||||
|
||||
public BlockPanel() {
|
||||
super(Material.IRON, "control_panel");
|
||||
lightOpacity = 0;
|
||||
|
@ -57,9 +58,9 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
|
||||
switch (state.getValue(type)) {
|
||||
case TOP:
|
||||
return layer==BlockRenderLayer.CUTOUT;
|
||||
return layer == BlockRenderLayer.CUTOUT;
|
||||
case RS_WIRE:
|
||||
return layer==BlockRenderLayer.TRANSLUCENT||layer==BlockRenderLayer.SOLID;
|
||||
return layer == BlockRenderLayer.TRANSLUCENT || layer == BlockRenderLayer.SOLID;
|
||||
default:
|
||||
return super.canRenderInLayer(state, layer);
|
||||
}
|
||||
|
@ -67,7 +68,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
switch(state.getValue(type)) {
|
||||
switch (state.getValue(type)) {
|
||||
case TOP:
|
||||
return new TileEntityPanel();
|
||||
case RS_WIRE:
|
||||
|
@ -147,18 +148,22 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
list.add(new ItemStack(itemIn, 1, 2));
|
||||
list.add(new ItemStack(itemIn, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullBlock(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
|
@ -173,7 +178,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (!super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ) && hand == EnumHand.MAIN_HAND) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityRSPanelConn){
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
if (!world.isRemote) {
|
||||
player.openGui(IndustrialWires.instance, 0, te.getWorld(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ());
|
||||
}
|
||||
|
@ -187,13 +192,13 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
return state.getValue(type)==BlockTypes_Panel.TOP;
|
||||
return state.getValue(type) == BlockTypes_Panel.TOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) {
|
||||
if (state.getValue(type)==BlockTypes_Panel.TOP) {
|
||||
if (state.getValue(type) == BlockTypes_Panel.TOP) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
return ((TileEntityPanel) te).getTileDrop(player, state);
|
||||
|
|
|
@ -22,7 +22,7 @@ import net.minecraft.util.IStringSerializable;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum BlockTypes_Panel implements IStringSerializable {
|
||||
public enum BlockTypes_Panel implements IStringSerializable {
|
||||
TOP,
|
||||
RS_WIRE,
|
||||
DUMMY,
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.ArrayList;
|
|||
|
||||
public class PropertyComponents implements IUnlistedProperty<PropertyComponents.PanelRenderProperties> {
|
||||
public static PropertyComponents INSTANCE = new PropertyComponents();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "components";
|
||||
|
@ -34,7 +35,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
|
||||
@Override
|
||||
public boolean isValid(PanelRenderProperties value) {
|
||||
return value!=null;
|
||||
return value != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,26 +52,31 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
public EnumFacing facing = EnumFacing.NORTH;
|
||||
public float height = .5F;
|
||||
public EnumFacing top = EnumFacing.UP;
|
||||
|
||||
public PanelRenderProperties() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PanelRenderProperties(int length) {
|
||||
super(length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder ret = new StringBuilder("[");
|
||||
for (int i = 0;i<size();i++) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
ret.append(get(i));
|
||||
if (i<size()-1) {
|
||||
if (i < size() - 1) {
|
||||
ret.append(", ");
|
||||
}
|
||||
}
|
||||
return ret+"]";
|
||||
return ret + "]";
|
||||
}
|
||||
|
||||
public Matrix4 getPanelTopTransform() {
|
||||
return getPanelBaseTransform().translate(0, height, 0);
|
||||
}
|
||||
|
||||
public Matrix4 getPanelBaseTransform() {
|
||||
Matrix4 ret = new Matrix4();
|
||||
ret.translate(.5, .5, .5);
|
||||
|
@ -84,7 +90,7 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
case SOUTH:
|
||||
case WEST:
|
||||
case EAST:
|
||||
ret.rotate(Math.PI/2, 1, 0, 0);
|
||||
ret.rotate(Math.PI / 2, 1, 0, 0);
|
||||
ret.rotate(top.getHorizontalAngle() * Math.PI / 180, 0, 0, 1);
|
||||
break;
|
||||
}
|
||||
|
@ -94,18 +100,18 @@ public class PropertyComponents implements IUnlistedProperty<PropertyComponents.
|
|||
|
||||
public float getMaxHeight() {
|
||||
float ret = 0;
|
||||
for (PanelComponent pc:this) {
|
||||
for (PanelComponent pc : this) {
|
||||
float hHere = pc.getHeight();
|
||||
if (hHere>ret) {
|
||||
if (hHere > ret) {
|
||||
ret = hHere;
|
||||
}
|
||||
}
|
||||
return ret+height;
|
||||
return ret + height;
|
||||
}
|
||||
|
||||
public PanelRenderProperties copyOf() {
|
||||
PanelRenderProperties ret = new PanelRenderProperties(size());
|
||||
for (PanelComponent pc:this) {
|
||||
for (PanelComponent pc : this) {
|
||||
ret.add(pc.copyOf());
|
||||
}
|
||||
ret.facing = facing;
|
||||
|
|
|
@ -90,7 +90,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos);
|
||||
for (BlockPos bp : parts) {
|
||||
TileEntity te = world.getTileEntity(bp);
|
||||
if (te instanceof TileEntityRSPanelConn&&!rsPorts.contains(te)) {
|
||||
if (te instanceof TileEntityRSPanelConn && !rsPorts.contains(te)) {
|
||||
((TileEntityRSPanelConn) te).registerPanel(this);
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
}
|
||||
|
||||
public void readFromItemNBT(@Nullable NBTTagCompound nbt) {
|
||||
if (nbt!=null) {
|
||||
if (nbt != null) {
|
||||
NBTTagList l = nbt.getTagList("components", 10);
|
||||
PanelUtils.readListFromNBT(l, components);
|
||||
components.height = nbt.getFloat("height");
|
||||
|
@ -231,7 +231,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
Vec3d playerPos = Minecraft.getMinecraft().player.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
for (PanelComponent pc : components) {
|
||||
AxisAlignedBB box = pc.getBlockRelativeAABB();
|
||||
if (box.maxY>box.minY) {
|
||||
if (box.maxY > box.minY) {
|
||||
box = apply(mat, box.expandXyz(.002));
|
||||
Vec3d hitVec = hitAbs ? hit.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hit;
|
||||
hitVec = hitVec.scale(2).subtract(playerPos);
|
||||
|
@ -295,7 +295,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
for (PanelComponent pc:components) {
|
||||
for (PanelComponent pc : components) {
|
||||
pc.invalidate(this);
|
||||
}
|
||||
for (TileEntityRSPanelConn rs : rsPorts) {
|
||||
|
@ -306,7 +306,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
for (PanelComponent pc:components) {
|
||||
for (PanelComponent pc : components) {
|
||||
pc.invalidate(this);
|
||||
}
|
||||
for (TileEntityRSPanelConn rs : rsPorts) {
|
||||
|
|
|
@ -39,7 +39,6 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
//TODO I no longer implement IEInventory!
|
||||
public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI, IBlockBoundsIW {
|
||||
public List<PanelComponent> components = new ArrayList<>();
|
||||
public float height = 0.5F;
|
||||
|
@ -102,7 +101,7 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
|||
break;
|
||||
case REMOVE:
|
||||
int id = nbt.getInteger("id");
|
||||
if (id >= 0 && id < components.size() && !p.inventory.getItemStack().isEmpty()) {
|
||||
if (id >= 0 && id < components.size() && p.inventory.getItemStack().isEmpty()) {
|
||||
PanelComponent removed = components.get(id);
|
||||
ItemStack remItem = ItemPanelComponent.stackFromComponent(removed);
|
||||
p.inventory.setItemStack(remItem);
|
||||
|
@ -149,7 +148,8 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements INetGUI,
|
|||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
}
|
||||
|
||||
private static final AxisAlignedBB aabb = new AxisAlignedBB(0, 0,0, 1, 14/16D, 1);
|
||||
private static final AxisAlignedBB aabb = new AxisAlignedBB(0, 0, 0, 1, 14 / 16D, 1);
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
return aabb;
|
||||
|
|
|
@ -59,11 +59,13 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
private RedstoneWireNetwork network = new RedstoneWireNetwork().add(this);
|
||||
private boolean hasConn = false;
|
||||
private int id;
|
||||
|
||||
{
|
||||
for (int i = 0;i<16;i++) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
oldInput[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +76,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
// completely reload the network
|
||||
network.removeFromNetwork(null);
|
||||
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos);
|
||||
for (BlockPos bp:parts) {
|
||||
for (BlockPos bp : parts) {
|
||||
TileEntity te = world.getTileEntity(bp);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
registerPanel(((TileEntityPanel) te));
|
||||
|
@ -87,6 +89,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
super.writeCustomNBT(out, updatePacket);
|
||||
|
@ -106,8 +109,8 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
aabb = null;
|
||||
}
|
||||
|
||||
private BiConsumer<Integer, Byte> rsOut = (channel, value)->{
|
||||
if (value!=out[channel]) {
|
||||
private BiConsumer<Integer, Byte> rsOut = (channel, value) -> {
|
||||
if (value != out[channel]) {
|
||||
dirty = true;
|
||||
out[channel] = value;
|
||||
}
|
||||
|
@ -115,9 +118,9 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
|
||||
public void registerPanel(TileEntityPanel panel) {
|
||||
PropertyComponents.PanelRenderProperties p = panel.getComponents();
|
||||
for (PanelComponent pc:p) {
|
||||
for (PanelComponent pc : p) {
|
||||
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
|
||||
if (listener!=null) {
|
||||
if (listener != null) {
|
||||
changeListeners.add(listener);
|
||||
}
|
||||
pc.registerRSOutput(id, rsOut);
|
||||
|
@ -128,9 +131,9 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
|
||||
public void unregisterPanel(TileEntityPanel panel, boolean remove) {
|
||||
PropertyComponents.PanelRenderProperties p = panel.getComponents();
|
||||
for (PanelComponent pc:p) {
|
||||
for (PanelComponent pc : p) {
|
||||
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
|
||||
if (listener!=null) {
|
||||
if (listener != null) {
|
||||
changeListeners.remove(listener);
|
||||
}
|
||||
pc.unregisterRSOutput(id, rsOut);
|
||||
|
@ -156,7 +159,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
public void onChange() {
|
||||
if (!Arrays.equals(oldInput, network.channelValues)) {
|
||||
oldInput = Arrays.copyOf(network.channelValues, 16);
|
||||
for (Consumer<byte[]> c:changeListeners) {
|
||||
for (Consumer<byte[]> c : changeListeners) {
|
||||
c.accept(oldInput);
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +167,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
|
||||
@Override
|
||||
public void updateInput(byte[] currIn) {
|
||||
for (int i = 0;i<16;i++) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
currIn[i] = (byte) Math.max(currIn[i], out[i]);
|
||||
}
|
||||
}
|
||||
|
@ -176,13 +179,13 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType wire, TargetingInfo targetingInfo) {
|
||||
return wire==WireType.REDSTONE&&!hasConn;
|
||||
return wire == WireType.REDSTONE && !hasConn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectCable(WireType wireType, TargetingInfo targetingInfo, IImmersiveConnectable other) {
|
||||
hasConn = true;
|
||||
if (other instanceof IRedstoneConnector&&((IRedstoneConnector) other).getNetwork()!=network) {
|
||||
if (other instanceof IRedstoneConnector && ((IRedstoneConnector) other).getNetwork() != network) {
|
||||
network.mergeNetwork(((IRedstoneConnector) other).getNetwork());
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +227,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
for (TileEntityPanel panel:connectedPanels) {
|
||||
for (TileEntityPanel panel : connectedPanels) {
|
||||
unregisterPanel(panel, false);
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +235,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
for (TileEntityPanel panel:connectedPanels) {
|
||||
for (TileEntityPanel panel : connectedPanels) {
|
||||
unregisterPanel(panel, false);
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +245,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
if (nbt.hasKey("rsId")) {
|
||||
List<BlockPos> parts = PanelUtils.discoverPanelParts(world, pos);
|
||||
List<TileEntityPanel> tes = new ArrayList<>(parts.size());
|
||||
for (BlockPos bp:parts) {
|
||||
for (BlockPos bp : parts) {
|
||||
TileEntity te = world.getTileEntity(bp);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
tes.add((TileEntityPanel) te);
|
||||
|
@ -251,7 +254,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
}
|
||||
id = nbt.getInteger("rsId");
|
||||
out = new byte[16];
|
||||
for (TileEntityPanel panel:tes) {
|
||||
for (TileEntityPanel panel : tes) {
|
||||
registerPanel(panel);
|
||||
}
|
||||
network.updateValues();
|
||||
|
@ -302,28 +305,29 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
}
|
||||
|
||||
private AxisAlignedBB aabb;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
if (aabb==null) {
|
||||
if (aabb == null) {
|
||||
double h = 9 / 16D;
|
||||
switch (facing) {
|
||||
case DOWN:
|
||||
aabb = new AxisAlignedBB(0, 0, 0, 1, h, 1);
|
||||
break;
|
||||
case UP:
|
||||
aabb = new AxisAlignedBB(0, 1-h, 0, 1, 1, 1);
|
||||
aabb = new AxisAlignedBB(0, 1 - h, 0, 1, 1, 1);
|
||||
break;
|
||||
case NORTH:
|
||||
aabb = new AxisAlignedBB(0, 0, 0, 1, 1, h);
|
||||
break;
|
||||
case SOUTH:
|
||||
aabb = new AxisAlignedBB(0, 0, 1-h, 1, 1, 1);
|
||||
aabb = new AxisAlignedBB(0, 0, 1 - h, 1, 1, 1);
|
||||
break;
|
||||
case WEST:
|
||||
aabb = new AxisAlignedBB(0, 0, 0, h, 1, 1);
|
||||
break;
|
||||
case EAST:
|
||||
aabb = new AxisAlignedBB(1-h, 0, 0, 1, 1, 1);
|
||||
aabb = new AxisAlignedBB(1 - h, 0, 0, 1, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,14 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public class BlockMechanicalConverter extends BlockIWBase implements IMetaEnum {
|
||||
private static PropertyEnum<MechanicalBlockType> type = PropertyEnum.create("type", MechanicalBlockType.class);
|
||||
|
||||
public BlockMechanicalConverter() {
|
||||
super(Material.IRON, "mechanical_converter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (int i = 0;i<3;i++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
list.add(new ItemStack(itemIn, 1, i));
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +91,7 @@ public class BlockMechanicalConverter extends BlockIWBase implements IMetaEnum {
|
|||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(type).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IBlockState getStateForPlacement(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, float hitX, float hitY,
|
||||
|
@ -109,11 +111,12 @@ public class BlockMechanicalConverter extends BlockIWBase implements IMetaEnum {
|
|||
EntityPlayer player) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) {
|
||||
boolean def = super.eventReceived(state, worldIn, pos, id, param);
|
||||
if ((id&255)==255) {
|
||||
if ((id & 255) == 255) {
|
||||
IBlockState s = worldIn.getBlockState(pos);
|
||||
worldIn.notifyBlockUpdate(pos, s, s, 3);
|
||||
return true;
|
||||
|
|
|
@ -37,28 +37,29 @@ import net.minecraftforge.energy.CapabilityEnergy;
|
|||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IFluxReceiver, IDirectionalTile {
|
||||
public final double bufferMax = 2*MechConversion.maxIfToMech*ConversionUtil.rotPerIf();
|
||||
public final double bufferMax = 2 * MechConversion.maxIfToMech * ConversionUtil.rotPerIf();
|
||||
|
||||
private double rotBuffer = 0;
|
||||
private FluxStorage energy = new FluxStorage(20*MechConversion.maxIfToMech, 2*MechConversion.maxIfToMech);
|
||||
private FluxStorage energy = new FluxStorage(20 * MechConversion.maxIfToMech, 2 * MechConversion.maxIfToMech);
|
||||
private EnumFacing dir = EnumFacing.DOWN;
|
||||
private BlockPos receiver;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isRemote) {
|
||||
if (receiver==null) {
|
||||
if (receiver == null) {
|
||||
receiver = pos.offset(dir);
|
||||
}
|
||||
int max = MechConversion.maxIfToMech;
|
||||
boolean dirty = false;
|
||||
if (rotBuffer<bufferMax&&energy.extractEnergy(max, true)>0) {
|
||||
if (rotBuffer < bufferMax && energy.extractEnergy(max, true) > 0) {
|
||||
int extracted = energy.extractEnergy(max, false);
|
||||
rotBuffer += extracted*ConversionUtil.rotPerIf()*MechConversion.ifMotorEfficiency;
|
||||
rotBuffer += extracted * ConversionUtil.rotPerIf() * MechConversion.ifMotorEfficiency;
|
||||
dirty = true;
|
||||
}
|
||||
TileEntity te = world.getTileEntity(receiver);
|
||||
if (te instanceof IRotationAcceptor) {
|
||||
((IRotationAcceptor)te).inputRotation(rotBuffer, dir);
|
||||
((IRotationAcceptor) te).inputRotation(rotBuffer, dir);
|
||||
rotBuffer = 0;
|
||||
dirty = true;
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
|
@ -74,6 +76,7 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
receiver = null;
|
||||
rotBuffer = in.getDouble(BUFFER_TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
|
@ -86,8 +89,9 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
// Flux energy
|
||||
@Override
|
||||
public boolean canConnectEnergy(EnumFacing from) {
|
||||
return from==dir.getOpposite()||from==null;
|
||||
return from == dir.getOpposite() || from == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(EnumFacing from, int energyIn, boolean simulate) {
|
||||
if (canConnectEnergy(from)) {
|
||||
|
@ -98,10 +102,12 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(EnumFacing from) {
|
||||
return energy.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(EnumFacing from) {
|
||||
return energy.getMaxEnergyStored();
|
||||
|
@ -113,35 +119,41 @@ public class TileEntityIEMotor extends TileEntityIWBase implements ITickable, IF
|
|||
public EnumFacing getFacing() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
dir = facing;
|
||||
receiver = null;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY&&canConnectEnergy(facing)) {
|
||||
if (capability == CapabilityEnergy.ENERGY && canConnectEnergy(facing)) {
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY&&canConnectEnergy(facing)) {
|
||||
if (capability == CapabilityEnergy.ENERGY && canConnectEnergy(facing)) {
|
||||
return (T) new EnergyAdapter(this, facing);
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
|
|
|
@ -35,32 +35,33 @@ import javax.annotation.Nonnull;
|
|||
public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirectionalTile, ITickable {
|
||||
EnumFacing dir = EnumFacing.DOWN;
|
||||
int kinBuffer = 0;
|
||||
private final int kinBufMax = 2*MechConversion.maxKinToRot;
|
||||
private final double maxInsert = ConversionUtil.rotPerKin()*MechConversion.maxKinToRot;
|
||||
private final int kinBufMax = 2 * MechConversion.maxKinToRot;
|
||||
private final double maxInsert = ConversionUtil.rotPerKin() * MechConversion.maxKinToRot;
|
||||
BlockPos to;
|
||||
BlockPos from;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!world.isRemote) {
|
||||
if (to==null) {
|
||||
if (to == null) {
|
||||
to = pos.offset(dir);
|
||||
}
|
||||
if (from==null) {
|
||||
if (from == null) {
|
||||
from = pos.offset(dir, -1);
|
||||
}
|
||||
TileEntity teFrom = world.getTileEntity(from);
|
||||
if (teFrom instanceof IKineticSource) {
|
||||
int sourceMax = ((IKineticSource) teFrom).maxrequestkineticenergyTick(dir);
|
||||
int draw = Math.min(kinBufMax-kinBuffer, sourceMax);
|
||||
if (draw>0) {
|
||||
kinBuffer += ((IKineticSource) teFrom).requestkineticenergy(dir, draw)*MechConversion.kinToRotEfficiency;
|
||||
int draw = Math.min(kinBufMax - kinBuffer, sourceMax);
|
||||
if (draw > 0) {
|
||||
kinBuffer += ((IKineticSource) teFrom).requestkineticenergy(dir, draw) * MechConversion.kinToRotEfficiency;
|
||||
}
|
||||
}
|
||||
TileEntity teTo = world.getTileEntity(to);
|
||||
if (kinBuffer>0&&teTo instanceof IRotationAcceptor) {
|
||||
double out = Math.min(maxInsert, ConversionUtil.rotPerKin()*kinBuffer);
|
||||
if (kinBuffer > 0 && teTo instanceof IRotationAcceptor) {
|
||||
double out = Math.min(maxInsert, ConversionUtil.rotPerKin() * kinBuffer);
|
||||
((IRotationAcceptor) teTo).inputRotation(out, dir);
|
||||
kinBuffer -= out*ConversionUtil.kinPerRot();
|
||||
kinBuffer -= out * ConversionUtil.kinPerRot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,12 +79,14 @@ public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirection
|
|||
to = null;
|
||||
from = null;
|
||||
}
|
||||
|
||||
// Directional
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
dir = facing;
|
||||
|
@ -91,18 +94,22 @@ public class TileEntityMechICtoIE extends TileEntityIWBase implements IDirection
|
|||
from = null;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return true;
|
||||
|
|
|
@ -32,9 +32,9 @@ import javax.annotation.Nonnull;
|
|||
public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirectionalTile, IRotationAcceptor, IKineticSource {
|
||||
EnumFacing dir = EnumFacing.DOWN;
|
||||
double rotBuffer = 0;
|
||||
private final double rotBufMax = 2*MechConversion.maxRotToKin;
|
||||
private final int maxOutput = (int)(ConversionUtil.kinPerRot()*MechConversion.maxRotToKin);
|
||||
|
||||
private final double rotBufMax = 2 * MechConversion.maxRotToKin;
|
||||
private final int maxOutput = (int) (ConversionUtil.kinPerRot() * MechConversion.maxRotToKin);
|
||||
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
out.setByte(DIR_TAG, (byte) dir.getIndex());
|
||||
|
@ -46,33 +46,39 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
dir = EnumFacing.VALUES[in.getByte(DIR_TAG)];
|
||||
rotBuffer = in.getDouble(BUFFER_TAG);
|
||||
}
|
||||
|
||||
// Directional
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getFacing() {
|
||||
return dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(@Nonnull EnumFacing facing) {
|
||||
dir = facing;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFacingLimitation() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mirrorFacingOnPlacement(@Nonnull EntityLivingBase placer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHammerRotate(@Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EntityLivingBase entity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//IC2 kinetic
|
||||
@Override
|
||||
public int maxrequestkineticenergyTick(EnumFacing f) {
|
||||
if (f==dir) {
|
||||
if (f == dir) {
|
||||
return maxOutput;
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -81,24 +87,25 @@ public class TileEntityMechIEtoIC extends TileEntityIWBase implements IDirection
|
|||
|
||||
@Override
|
||||
public int requestkineticenergy(EnumFacing f, int requested) {
|
||||
if (f==dir) {
|
||||
int stored = (int) (ConversionUtil.kinPerRot()*rotBuffer);
|
||||
if (f == dir) {
|
||||
int stored = (int) (ConversionUtil.kinPerRot() * rotBuffer);
|
||||
int out = Math.min(maxOutput, stored);
|
||||
out = Math.min(requested, out);
|
||||
rotBuffer -= out*ConversionUtil.rotPerKin();
|
||||
return (int)(out*MechConversion.rotToKinEfficiency);
|
||||
rotBuffer -= out * ConversionUtil.rotPerKin();
|
||||
return (int) (out * MechConversion.rotToKinEfficiency);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//IE rotation
|
||||
@Override
|
||||
public void inputRotation(double rotation, @Nonnull EnumFacing side) {
|
||||
if (side==dir) {
|
||||
rotBuffer = Math.min(rotBufMax, rotBuffer+rotation);
|
||||
if (side == dir) {
|
||||
rotBuffer = Math.min(rotBufMax, rotBuffer + rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return true;
|
||||
|
|
|
@ -21,12 +21,15 @@ import blusunrize.immersiveengineering.api.IEProperties;
|
|||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -41,9 +44,11 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
||||
private static PropertyEnum<BlockTypes_IC2_Connector> type = PropertyEnum.create("type", BlockTypes_IC2_Connector.class);
|
||||
|
||||
public BlockIC2Connector() {
|
||||
super(Material.IRON, "ic2_connector");
|
||||
setHardness(3.0F);
|
||||
|
@ -55,9 +60,9 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
@Override
|
||||
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos posNeighbor) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if(te instanceof TileEntityIC2ConnectorTin) {
|
||||
if (te instanceof TileEntityIC2ConnectorTin) {
|
||||
TileEntityIC2ConnectorTin connector = (TileEntityIC2ConnectorTin) te;
|
||||
if(world.isAirBlock(pos.offset(connector.f))) {
|
||||
if (world.isAirBlock(pos.offset(connector.f))) {
|
||||
this.dropBlockAsItem(connector.getWorld(), pos, world.getBlockState(pos), 0);
|
||||
connector.getWorld().setBlockToAir(pos);
|
||||
}
|
||||
|
@ -66,7 +71,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
|
||||
@Override
|
||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for (int i = 0;i<type.getAllowedValues().size();i++) {
|
||||
for (int i = 0; i < type.getAllowedValues().size(); i++) {
|
||||
list.add(new ItemStack(itemIn, 1, i));
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +81,8 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
protected BlockStateContainer createBlockState() {
|
||||
BlockStateContainer base = super.createBlockState();
|
||||
IUnlistedProperty<?>[] unlisted = (base instanceof ExtendedBlockState) ? ((ExtendedBlockState) base).getUnlistedProperties().toArray(new IUnlistedProperty[0]) : new IUnlistedProperty[0];
|
||||
unlisted = Arrays.copyOf(unlisted, unlisted.length+1);
|
||||
unlisted[unlisted.length-1] = IEProperties.CONNECTIONS;
|
||||
unlisted = Arrays.copyOf(unlisted, unlisted.length + 1);
|
||||
unlisted[unlisted.length - 1] = IEProperties.CONNECTIONS;
|
||||
return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), unlisted);
|
||||
}
|
||||
|
||||
|
@ -139,22 +144,37 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
if (!stack.isEmpty() && stack.getMetadata() % 2 == 0) {
|
||||
int type = stack.getMetadata() / 2;
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.power_tier", type + 1));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.eu_per_tick", IC2Wiretype.IC2_TYPES[type].getTransferRate() / 8));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) {
|
||||
return layer==BlockRenderLayer.TRANSLUCENT||layer==BlockRenderLayer.SOLID;
|
||||
return layer == BlockRenderLayer.TRANSLUCENT || layer == BlockRenderLayer.SOLID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullBlock(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
|
|
|
@ -30,6 +30,7 @@ public enum BlockTypes_IC2_Connector implements IBlockEnum {
|
|||
HV_RELAY,
|
||||
GLASS_CONN,
|
||||
GLASS_RELAY;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString().toLowerCase();
|
||||
|
|
|
@ -26,15 +26,17 @@ public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
|
|||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorCopper() {}
|
||||
|
||||
public TileEntityIC2ConnectorCopper() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 2;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[1].getTransferRate()/8;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[1].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t==IC2Wiretype.IC2_TYPES[1];
|
||||
return t == IC2Wiretype.IC2_TYPES[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,14 +25,16 @@ public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
|||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGlass() {}
|
||||
public TileEntityIC2ConnectorGlass() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 5;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[4].getTransferRate()/8;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[4].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t==IC2Wiretype.IC2_TYPES[4];
|
||||
return t == IC2Wiretype.IC2_TYPES[4];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,26 +30,29 @@ public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
|
|||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGold() {}
|
||||
|
||||
public TileEntityIC2ConnectorGold() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 3;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[2].getTransferRate()/8;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[2].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t==IC2Wiretype.IC2_TYPES[2];
|
||||
return t == IC2Wiretype.IC2_TYPES[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = f.getOpposite();
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*.125, .5+side.getFrontOffsetY()*.125, .5+side.getFrontOffsetZ()*.125);
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .125, .5 + side.getFrontOffsetY() * .125, .5 + side.getFrontOffsetZ() * .125);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = f.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter()/2;
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*(.0625-conRadius), .5+side.getFrontOffsetY()*(.0625-conRadius), .5+side.getFrontOffsetZ()*(.0625-conRadius));
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.0625 - conRadius), .5 + side.getFrontOffsetY() * (.0625 - conRadius), .5 + side.getFrontOffsetZ() * (.0625 - conRadius));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,34 +30,37 @@ public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
|
|||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorHV() {}
|
||||
public TileEntityIC2ConnectorHV() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 4;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[3].getTransferRate()/8;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[3].getTransferRate() / 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t==IC2Wiretype.IC2_TYPES[3];
|
||||
return t == IC2Wiretype.IC2_TYPES[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = f.getOpposite();
|
||||
if (relay) {
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*.4375, .5+side.getFrontOffsetY()*.4375, .5+side.getFrontOffsetZ()*.4375);
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .4375, .5 + side.getFrontOffsetY() * .4375, .5 + side.getFrontOffsetZ() * .4375);
|
||||
} else {
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*.3125, .5+side.getFrontOffsetY()*.3125, .5+side.getFrontOffsetZ()*.3125);
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .3125, .5 + side.getFrontOffsetY() * .3125, .5 + side.getFrontOffsetZ() * .3125);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = f.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter()/2;
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
if (relay) {
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*(.375-conRadius), .5+side.getFrontOffsetY()*(.375-conRadius), .5+side.getFrontOffsetZ()*(.375-conRadius));
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.375 - conRadius), .5 + side.getFrontOffsetY() * (.375 - conRadius), .5 + side.getFrontOffsetZ() * (.375 - conRadius));
|
||||
} else {
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*(.25-conRadius), .5+side.getFrontOffsetY()*(.25-conRadius), .5+side.getFrontOffsetZ()*(.25-conRadius));
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.25 - conRadius), .5 + side.getFrontOffsetY() * (.25 - conRadius), .5 + side.getFrontOffsetZ() * (.25 - conRadius));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,12 +61,16 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
//IE net to IC2 net buffer
|
||||
private double outBuffer = 0;
|
||||
private double maxToMachine = 0;
|
||||
protected double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate()/8;
|
||||
protected double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate() / 8;
|
||||
int tier = 1;
|
||||
|
||||
public TileEntityIC2ConnectorTin(boolean rel) {
|
||||
relay = rel;
|
||||
}
|
||||
public TileEntityIC2ConnectorTin() {}
|
||||
|
||||
public TileEntityIC2ConnectorTin() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (first) {
|
||||
|
@ -77,73 +81,76 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
if (!world.isRemote && inBuffer > .1)
|
||||
transferPower();
|
||||
}
|
||||
|
||||
public void transferPower() {
|
||||
Set<AbstractConnection> conns = new HashSet<>(ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world));
|
||||
Map<AbstractConnection, Pair<IIC2Connector, Double>> maxOutputs = new HashMap<>();
|
||||
double outputMax = Math.min(inBuffer, maxToNet);
|
||||
double sum = 0;
|
||||
for (AbstractConnection c:conns) {
|
||||
for (AbstractConnection c : conns) {
|
||||
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
|
||||
if (iic instanceof IIC2Connector) {
|
||||
double tmp = inBuffer-((IIC2Connector)iic).insertEnergy(outputMax, true);
|
||||
if (tmp>.00000001) {
|
||||
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector)iic, tmp));
|
||||
sum+=tmp;
|
||||
double tmp = inBuffer - ((IIC2Connector) iic).insertEnergy(outputMax, true);
|
||||
if (tmp > .00000001) {
|
||||
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector) iic, tmp));
|
||||
sum += tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sum<.0001) {
|
||||
if (sum < .0001) {
|
||||
return;
|
||||
}
|
||||
final double oldInBuf = outputMax;
|
||||
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension());
|
||||
for (AbstractConnection c:maxOutputs.keySet()) {
|
||||
for (AbstractConnection c : maxOutputs.keySet()) {
|
||||
Pair<IIC2Connector, Double> p = maxOutputs.get(c);
|
||||
double out = oldInBuf*p.getRight()/sum;
|
||||
double out = oldInBuf * p.getRight() / sum;
|
||||
double loss = getAverageLossRate(c);
|
||||
double inserted = out-p.getLeft().insertEnergy(out-loss, false);
|
||||
inBuffer-=inserted;
|
||||
double inserted = out - p.getLeft().insertEnergy(out - loss, false);
|
||||
inBuffer -= inserted;
|
||||
float intermediaryLoss = 0;
|
||||
HashSet<IImmersiveConnectable> passedConnectors = new HashSet<>();
|
||||
double energyAtConn = inserted+loss;
|
||||
for(Connection sub : c.subConnections)
|
||||
{
|
||||
double energyAtConn = inserted + loss;
|
||||
for (Connection sub : c.subConnections) {
|
||||
int transferredPerCon = transferedPerConn.getOrDefault(sub, 0);
|
||||
energyAtConn-=sub.cableType.getLossRatio()*sub.length;
|
||||
energyAtConn -= sub.cableType.getLossRatio() * sub.length;
|
||||
ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension()).put(sub, (int) (transferredPerCon + energyAtConn));
|
||||
IImmersiveConnectable subStart = ApiUtils.toIIC(sub.start, world);
|
||||
IImmersiveConnectable subEnd = ApiUtils.toIIC(sub.end, world);
|
||||
if(subStart!=null && passedConnectors.add(subStart))
|
||||
subStart.onEnergyPassthrough((int)(inserted-inserted*intermediaryLoss));
|
||||
if(subEnd!=null && passedConnectors.add(subEnd))
|
||||
subEnd.onEnergyPassthrough((int)(inserted-inserted*intermediaryLoss));
|
||||
if (subStart != null && passedConnectors.add(subStart))
|
||||
subStart.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
if (subEnd != null && passedConnectors.add(subEnd))
|
||||
subEnd.onEnergyPassthrough((int) (inserted - inserted * intermediaryLoss));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getAverageLossRate(AbstractConnection conn) {
|
||||
double f = 0;
|
||||
for(Connection c : conn.subConnections) {
|
||||
f += c.length*c.cableType.getLossRatio();
|
||||
for (Connection c : conn.subConnections) {
|
||||
f += c.length * c.cableType.getLossRatio();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
//Input through the net
|
||||
@Override
|
||||
public double insertEnergy(double eu, boolean simulate) {
|
||||
final double insert = Math.min(maxStored-outBuffer, eu);
|
||||
if (insert>0) {
|
||||
if (outBuffer<maxToMachine) {
|
||||
final double insert = Math.min(maxStored - outBuffer, eu);
|
||||
if (insert > 0) {
|
||||
if (outBuffer < maxToMachine) {
|
||||
maxToMachine = outBuffer;
|
||||
}
|
||||
if (eu>maxToMachine) {
|
||||
if (eu > maxToMachine) {
|
||||
maxToMachine = eu;
|
||||
}
|
||||
}
|
||||
if (!simulate) {
|
||||
outBuffer+=insert;
|
||||
outBuffer += insert;
|
||||
}
|
||||
return eu-insert;
|
||||
return eu - insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (!world.isRemote && !first)
|
||||
|
@ -151,6 +158,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
first = true;
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
|
@ -162,28 +170,33 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = f.getOpposite();
|
||||
return new Vec3d(.5+side.getFrontOffsetX()*.0625, .5+side.getFrontOffsetY()*.0625, .5+side.getFrontOffsetZ()*.0625);
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .0625, .5 + side.getFrontOffsetY() * .0625, .5 + side.getFrontOffsetZ() * .0625);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
EnumFacing side = f.getOpposite();
|
||||
double conRadius = con.cableType.getRenderDiameter()/2;
|
||||
return new Vec3d(.5-conRadius*side.getFrontOffsetX(), .5-conRadius*side.getFrontOffsetY(), .5-conRadius*side.getFrontOffsetZ());
|
||||
double conRadius = con.cableType.getRenderDiameter() / 2;
|
||||
return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnergyOutput() {
|
||||
return !relay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target) {
|
||||
return (limitType==null||(this.isRelay() && limitType==cableType))&&canConnect(cableType);
|
||||
return (limitType == null || (this.isRelay() && limitType == cableType)) && canConnect(cableType);
|
||||
}
|
||||
|
||||
public boolean canConnect(WireType t) {
|
||||
return t==IC2Wiretype.IC2_TYPES[0];
|
||||
return t == IC2Wiretype.IC2_TYPES[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -193,18 +206,18 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing side) {
|
||||
return !relay&&side==f;
|
||||
return !relay && side == f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing side) {
|
||||
return !relay&&side==f;
|
||||
return !relay && side == f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDemandedEnergy() {
|
||||
double ret = maxStored-inBuffer;
|
||||
if (ret<.1)
|
||||
double ret = maxStored + .5 - inBuffer;
|
||||
if (ret < .1)
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
|
@ -216,12 +229,12 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
|
||||
@Override
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
if (inBuffer<maxStored) {
|
||||
if (inBuffer<maxToNet) {
|
||||
if (inBuffer < maxStored) {
|
||||
if (inBuffer < maxToNet) {
|
||||
maxToNet = inBuffer;
|
||||
}
|
||||
inBuffer += amount;
|
||||
if (amount>maxToNet) {
|
||||
if (amount > maxToNet) {
|
||||
maxToNet = amount;
|
||||
}
|
||||
markDirty();
|
||||
|
@ -304,26 +317,26 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
float length = this instanceof TileEntityIC2ConnectorHV?(relay?.875f:.75f): this instanceof TileEntityIC2ConnectorGold?.5625f: .5f;
|
||||
float length = this instanceof TileEntityIC2ConnectorHV ? (relay ? .875f : .75f) : this instanceof TileEntityIC2ConnectorGold ? .5625f : .5f;
|
||||
float wMin = .3125f;
|
||||
float wMax = .6875f;
|
||||
switch(f.getOpposite() )
|
||||
{
|
||||
switch (f.getOpposite()) {
|
||||
case UP:
|
||||
return new AxisAlignedBB(wMin,0,wMin, wMax,length,wMax);
|
||||
return new AxisAlignedBB(wMin, 0, wMin, wMax, length, wMax);
|
||||
case DOWN:
|
||||
return new AxisAlignedBB(wMin,1-length,wMin, wMax,1,wMax);
|
||||
return new AxisAlignedBB(wMin, 1 - length, wMin, wMax, 1, wMax);
|
||||
case SOUTH:
|
||||
return new AxisAlignedBB(wMin,wMin,0, wMax,wMax,length);
|
||||
return new AxisAlignedBB(wMin, wMin, 0, wMax, wMax, length);
|
||||
case NORTH:
|
||||
return new AxisAlignedBB(wMin,wMin,1-length, wMax,wMax,1);
|
||||
return new AxisAlignedBB(wMin, wMin, 1 - length, wMax, wMax, 1);
|
||||
case EAST:
|
||||
return new AxisAlignedBB(0,wMin,wMin, length,wMax,wMax);
|
||||
return new AxisAlignedBB(0, wMin, wMin, length, wMax, wMax);
|
||||
case WEST:
|
||||
return new AxisAlignedBB(1-length,wMin,wMin, 1,wMax,wMax);
|
||||
return new AxisAlignedBB(1 - length, wMin, wMin, 1, wMax, wMax);
|
||||
}
|
||||
return new AxisAlignedBB(0,0,0,1,1,1);
|
||||
return new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* regarding equals+hashCode
|
||||
* TE's are considered equal if they have the same pos+dimension id
|
||||
|
@ -333,18 +346,19 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int ret = world.provider.getDimension();
|
||||
ret = 31*ret+pos.hashCode();
|
||||
ret = 31 * ret + pos.hashCode();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj==this) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof TileEntityIC2ConnectorTin)) {
|
||||
return false;
|
||||
}
|
||||
if (obj.getClass()!=getClass()) {
|
||||
if (obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
TileEntityIC2ConnectorTin te = (TileEntityIC2ConnectorTin) obj;
|
||||
|
@ -356,6 +370,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return false;
|
||||
|
|
|
@ -48,30 +48,30 @@ public class ClientEventHandler {
|
|||
if (ClientUtils.mc().player != null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
|
||||
EntityPlayer player = ClientUtils.mc().player;
|
||||
|
||||
for(EnumHand hand : EnumHand.values()) {
|
||||
for (EnumHand hand : EnumHand.values()) {
|
||||
if (!player.getHeldItem(hand).isEmpty()) {
|
||||
ItemStack equipped = player.getHeldItem(hand);
|
||||
if(OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
|
||||
if (OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
|
||||
IC2Wiretype type = IC2Wiretype.IC2_TYPES[equipped.getItemDamage()];
|
||||
int color = type.getColour(null);
|
||||
String s = I18n.format(IndustrialWires.MODID+".desc.wireLength", ItemIC2Coil.getLength(equipped));
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth()/2 - ClientUtils.font().getStringWidth(s)/2, e.getResolution().getScaledHeight()-GuiIngameForge.left_height-40, color, true);
|
||||
if(ItemNBTHelper.hasKey(equipped, "linkingPos")) {
|
||||
String s = I18n.format(IndustrialWires.MODID + ".desc.wireLength", ItemIC2Coil.getLength(equipped));
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 40, color, true);
|
||||
if (ItemNBTHelper.hasKey(equipped, "linkingPos")) {
|
||||
int[] link = ItemNBTHelper.getIntArray(equipped, "linkingPos");
|
||||
if(link!=null&&link.length>3) {
|
||||
s = I18n.format(Lib.DESC_INFO+"attachedTo", link[1],link[2],link[3]);
|
||||
if (link != null && link.length > 3) {
|
||||
s = I18n.format(Lib.DESC_INFO + "attachedTo", link[1], link[2], link[3]);
|
||||
RayTraceResult focussedBlock = ClientUtils.mc().objectMouseOver;
|
||||
double distSquared;
|
||||
if (focussedBlock != null && focussedBlock.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
distSquared = focussedBlock.getBlockPos().distanceSq(link[1],link[2],link[3]);
|
||||
distSquared = focussedBlock.getBlockPos().distanceSq(link[1], link[2], link[3]);
|
||||
} else {
|
||||
distSquared = player.getDistanceSq(link[1],link[2],link[3]);
|
||||
distSquared = player.getDistanceSq(link[1], link[2], link[3]);
|
||||
}
|
||||
int length = Math.min(ItemIC2Coil.getLength(equipped), type.getMaxLength());
|
||||
if (length*length<distSquared) {
|
||||
if (length * length < distSquared) {
|
||||
color = 0xdd3333;
|
||||
}
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth()/2 - ClientUtils.font().getStringWidth(s)/2, e.getResolution().getScaledHeight()-GuiIngameForge.left_height-20, color, true);
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth() / 2 - ClientUtils.font().getStringWidth(s) / 2, e.getResolution().getScaledHeight() - GuiIngameForge.left_height - 20, color, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +94,9 @@ public class ClientEventHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void bakeModel(ModelBakeEvent event) {
|
||||
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID+":control_panel", "inventory,type=top"), new PanelModel());
|
||||
event.getModelRegistry().putObject(new ModelResourceLocation(IndustrialWires.MODID + ":control_panel", "inventory,type=top"), new PanelModel());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
ClientUtils.mc().getItemColors().registerItemColorHandler((stack, pass) -> {
|
||||
if (pass==1) {
|
||||
if (pass == 1) {
|
||||
PanelComponent pc = ItemPanelComponent.componentFromStack(stack);
|
||||
if (pc != null) {
|
||||
return 0xff000000 | pc.getColor();
|
||||
|
@ -248,6 +248,7 @@ public class ClientProxy extends CommonProxy {
|
|||
private static ResourceLocation jacobsStart = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_start");//~470 ms ~=9 ticks
|
||||
private static ResourceLocation jacobsMiddle = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_middle");
|
||||
private static ResourceLocation jacobsEnd = new ResourceLocation(IndustrialWires.MODID, "jacobs_ladder_end");//~210 ms ~= 4 ticks
|
||||
|
||||
@Override
|
||||
public void playJacobsLadderSound(TileEntityJacobsLadder te, int phase, Vec3d soundPos) {
|
||||
if (playingSounds.containsKey(te.getPos())) {
|
||||
|
@ -268,14 +269,14 @@ public class ClientProxy extends CommonProxy {
|
|||
default:
|
||||
return;
|
||||
}
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(event, SoundCategory.BLOCKS, te.size.soundVolume, 1, false, 0, ISound.AttenuationType.LINEAR, (float)soundPos.xCoord, (float)soundPos.yCoord, (float) soundPos.zCoord);
|
||||
PositionedSoundRecord sound = new PositionedSoundRecord(event, SoundCategory.BLOCKS, te.size.soundVolume, 1, false, 0, ISound.AttenuationType.LINEAR, (float) soundPos.xCoord, (float) soundPos.yCoord, (float) soundPos.zCoord);
|
||||
ClientUtils.mc().getSoundHandler().playSound(sound);
|
||||
playingSounds.put(te.getPos(), sound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (ID==0) {
|
||||
if (ID == 0) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new GuiRSPanelConn((TileEntityRSPanelConn) te);
|
||||
|
@ -283,7 +284,7 @@ public class ClientProxy extends CommonProxy {
|
|||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
}
|
||||
} else if (ID==1) {
|
||||
} else if (ID == 1) {
|
||||
EnumHand h = z == 1 ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
|
||||
ItemStack held = player.getHeldItem(h);
|
||||
if (!held.isEmpty() && held.getItem() == IndustrialWires.panelComponent) {
|
||||
|
|
|
@ -32,16 +32,24 @@ public class RawQuad {
|
|||
public final float[] colorA;
|
||||
public final Vector3f normal;
|
||||
public final float[] uvs;
|
||||
public int light;
|
||||
|
||||
public RawQuad(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f v3,
|
||||
EnumFacing facing, TextureAtlasSprite tex, float[] colorA,
|
||||
Vector3f normal, float[] uvs) {
|
||||
this(v0, v1, v2, v3, facing, tex, colorA, normal, uvs, -1);
|
||||
}
|
||||
|
||||
public RawQuad(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f v3,
|
||||
EnumFacing facing, TextureAtlasSprite tex, float[] colorA,
|
||||
Vector3f normal, float[] uvs, int light) {
|
||||
vertices[0] = v0;
|
||||
vertices[1] = v1;
|
||||
vertices[2] = v2;
|
||||
vertices[3] = v3;
|
||||
this.facing = facing;
|
||||
this.tex = tex;
|
||||
if (colorA.length==3) {
|
||||
if (colorA.length == 3) {
|
||||
this.colorA = Arrays.copyOf(colorA, 4);
|
||||
this.colorA[3] = 1;
|
||||
} else {
|
||||
|
@ -49,7 +57,9 @@ public class RawQuad {
|
|||
}
|
||||
this.normal = normal;
|
||||
this.uvs = uvs;
|
||||
this.light = light;
|
||||
}
|
||||
|
||||
public RawQuad apply(Matrix4 mat) {
|
||||
Matrix4 matNormal = mat.copy().transpose();
|
||||
matNormal.invert();
|
||||
|
|
|
@ -53,9 +53,9 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
confComp = (IConfigurableComponent) component;
|
||||
IConfigurableComponent.BoolConfig[] bools = confComp.getBooleanOptions();
|
||||
boolButtons.clear();
|
||||
int componentLeft = this.guiLeft+5;
|
||||
int componentTop = this.guiTop+5;
|
||||
for (int i = 0;i<bools.length;i++) {
|
||||
int componentLeft = this.guiLeft + 5;
|
||||
int componentTop = this.guiTop + 5;
|
||||
for (int i = 0; i < bools.length; i++) {
|
||||
IConfigurableComponent.BoolConfig bc = bools[i];
|
||||
boolButtons.add(new GuiButtonCheckbox(0, componentLeft + bc.x, componentTop + bc.y, confComp.fomatConfigName(IConfigurableComponent.ConfigType.BOOL, i), bc.value));
|
||||
}
|
||||
|
@ -78,22 +78,23 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
intChoosers.clear();
|
||||
IConfigurableComponent.IntConfig[] is = confComp.getIntegerOptions();
|
||||
for (IConfigurableComponent.IntConfig ic : is) {
|
||||
intChoosers.add(new GuiIntChooser(componentLeft+ic.x, componentTop+ic.y, ic.allowNegative, ic.value, ic.digits));
|
||||
intChoosers.add(new GuiIntChooser(componentLeft + ic.x, componentTop + ic.y, ic.allowNegative, ic.value, ic.digits));
|
||||
}
|
||||
floatSliders.clear();
|
||||
IConfigurableComponent.FloatConfig[] fs = confComp.getFloatOptions();
|
||||
for (int i = 0;i<fs.length;i++) {
|
||||
for (int i = 0; i < fs.length; i++) {
|
||||
IConfigurableComponent.FloatConfig fc = fs[i];
|
||||
floatSliders.add(new GuiSliderIE(0, componentLeft+fc.x, componentTop+fc.y, fc.width,
|
||||
floatSliders.add(new GuiSliderIE(0, componentLeft + fc.x, componentTop + fc.y, fc.width,
|
||||
confComp.fomatConfigName(IConfigurableComponent.ConfigType.FLOAT, i), fc.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ResourceLocation textureLoc = new ResourceLocation(IndustrialWires.MODID, "textures/gui/panel_component.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1,1,1,1);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
mc.getTextureManager().bindTexture(textureLoc);
|
||||
Gui.drawModalRectWithCustomSizedTexture(guiLeft, guiTop, 0, 0, xSize, ySize, 150, 150);
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) throws IOException {
|
||||
boolean superCall = true;
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
for (int i = 0; i < stringTexts.size(); i++) {
|
||||
GuiTextField field = stringTexts.get(i);
|
||||
if (field.isFocused() && keyCode == 28) {
|
||||
sync(i, field.getText());
|
||||
|
@ -125,7 +126,7 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
for (int i = 0;i<rsChannelChoosers.size();i++) {
|
||||
for (int i = 0; i < rsChannelChoosers.size(); i++) {
|
||||
GuiChannelPicker picker = rsChannelChoosers.get(i);
|
||||
int old = picker.getSelected();
|
||||
boolean stopNow = picker.click(mouseX, mouseY);
|
||||
|
@ -136,35 +137,35 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
for (int i = 0; i < stringTexts.size(); i++) {
|
||||
GuiTextField field = stringTexts.get(i);
|
||||
boolean focus = field.isFocused();
|
||||
field.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
if (focus&&!field.isFocused()) {
|
||||
if (focus && !field.isFocused()) {
|
||||
sync(i, field.getText());
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<boolButtons.size();i++) {
|
||||
for (int i = 0; i < boolButtons.size(); i++) {
|
||||
GuiButtonCheckbox box = boolButtons.get(i);
|
||||
boolean on = box.state;
|
||||
box.mousePressed(mc, mouseX, mouseY);
|
||||
if (on!=box.state) {
|
||||
if (on != box.state) {
|
||||
sync(i, box.state);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<intChoosers.size();i++) {
|
||||
for (int i = 0; i < intChoosers.size(); i++) {
|
||||
GuiIntChooser chooser = intChoosers.get(i);
|
||||
int oldV = chooser.getValue();
|
||||
chooser.click(mouseX, mouseY);
|
||||
if (oldV!=chooser.getValue()) {
|
||||
if (oldV != chooser.getValue()) {
|
||||
sync(i, chooser.getValue());
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
GuiSliderIE slider = floatSliders.get(i);
|
||||
double oldV = slider.getValue();
|
||||
slider.mousePressed(mc, mouseX, mouseY);
|
||||
if (oldV!=slider.getValue()) {
|
||||
if (oldV != slider.getValue()) {
|
||||
sync(i, (float) slider.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -173,11 +174,11 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
GuiSliderIE slider = floatSliders.get(i);
|
||||
double oldV = slider.getValue();
|
||||
slider.mouseReleased(mouseX, mouseY);
|
||||
if (oldV!=slider.getValue()) {
|
||||
if (oldV != slider.getValue()) {
|
||||
sync(i, (float) slider.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -204,39 +205,39 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
choose.drawButton(mc, mouseX, mouseY);
|
||||
}
|
||||
//TOOLTIPS
|
||||
for (int i = 0;i<rsChannelChoosers.size();i++) {
|
||||
for (int i = 0; i < rsChannelChoosers.size(); i++) {
|
||||
GuiChannelPicker pick = rsChannelChoosers.get(i);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.RS_CHANNEL, i);
|
||||
if (tooltip!=null&&pick.isHovered(mouseX, mouseY)) {
|
||||
if (tooltip != null && pick.isHovered(mouseX, mouseY)) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<boolButtons.size();i++) {
|
||||
for (int i = 0; i < boolButtons.size(); i++) {
|
||||
GuiButtonCheckbox box = boolButtons.get(i);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.BOOL, i);
|
||||
if (tooltip!=null&&box.isMouseOver()) {
|
||||
if (tooltip != null && box.isMouseOver()) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
for (int i = 0; i < stringTexts.size(); i++) {
|
||||
GuiTextField field = stringTexts.get(i);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.STRING, i);
|
||||
if (tooltip!=null&&mouseX>=field.xPosition&&mouseX<field.xPosition+field.width&&
|
||||
mouseY>=field.yPosition&&mouseY<field.yPosition+field.height) {
|
||||
if (tooltip != null && mouseX >= field.xPosition && mouseX < field.xPosition + field.width &&
|
||||
mouseY >= field.yPosition && mouseY < field.yPosition + field.height) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<intChoosers.size();i++) {
|
||||
for (int i = 0; i < intChoosers.size(); i++) {
|
||||
GuiIntChooser choose = intChoosers.get(i);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.INT, i);
|
||||
if (tooltip!=null&&choose.isMouseOver(mouseX, mouseY)) {
|
||||
if (tooltip != null && choose.isMouseOver(mouseX, mouseY)) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
GuiSliderIE choose = floatSliders.get(i);
|
||||
String tooltip = confComp.fomatConfigDescription(IConfigurableComponent.ConfigType.FLOAT, i);
|
||||
if (tooltip!=null&&choose.isMouseOver()) {
|
||||
if (tooltip != null && choose.isMouseOver()) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
|
@ -249,6 +250,7 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
update.setString(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, boolean value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
|
@ -256,6 +258,7 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
update.setBoolean(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, byte value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
|
@ -263,6 +266,7 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
update.setByte(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, int value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
|
@ -270,6 +274,7 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
update.setInteger(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void sync(int id, float value) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
|
@ -277,37 +282,38 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
update.setFloat(MessageComponentSync.VALUE, value);
|
||||
syncSingle(update);
|
||||
}
|
||||
|
||||
private void syncAll() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (int i = 0;i<stringTexts.size();i++) {
|
||||
for (int i = 0; i < stringTexts.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.STRING.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setString(MessageComponentSync.VALUE, stringTexts.get(i).getText());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<boolButtons.size();i++) {
|
||||
for (int i = 0; i < boolButtons.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.BOOL.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setBoolean(MessageComponentSync.VALUE, boolButtons.get(i).state);
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<rsChannelChoosers.size();i++) {
|
||||
for (int i = 0; i < rsChannelChoosers.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.RS_CHANNEL.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setByte(MessageComponentSync.VALUE, rsChannelChoosers.get(i).getSelected());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<intChoosers.size();i++) {
|
||||
for (int i = 0; i < intChoosers.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.INT.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
update.setInteger(MessageComponentSync.VALUE, intChoosers.get(i).getValue());
|
||||
list.appendTag(update);
|
||||
}
|
||||
for (int i = 0;i<floatSliders.size();i++) {
|
||||
for (int i = 0; i < floatSliders.size(); i++) {
|
||||
NBTTagCompound update = new NBTTagCompound();
|
||||
update.setInteger(MessageComponentSync.TYPE, IConfigurableComponent.ConfigType.FLOAT.ordinal());
|
||||
update.setInteger(MessageComponentSync.ID, i);
|
||||
|
@ -316,11 +322,13 @@ public class GuiPanelComponent extends GuiContainer {
|
|||
}
|
||||
sync(list);
|
||||
}
|
||||
|
||||
private void syncSingle(NBTTagCompound nbt) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(nbt);
|
||||
sync(list);
|
||||
}
|
||||
|
||||
private void sync(NBTTagList list) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setTag("data", list);
|
||||
|
|
|
@ -55,22 +55,22 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1,1,1,1);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
mc.getTextureManager().bindTexture(textureLoc);
|
||||
this.drawTexturedModalRect(guiLeft,guiTop, 0, 0, xSize, ySize);
|
||||
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
int x0 = getX0();
|
||||
int y0 = getY0();
|
||||
int xRel = mouseX - x0;
|
||||
int yRel = mouseY - y0;
|
||||
if (snapToGrid) {
|
||||
xRel = (int) Math.floor(xRel*16/panelSize)*panelSize/16;
|
||||
yRel = (int) Math.floor(yRel*16/panelSize)*panelSize/16;
|
||||
xRel = (int) Math.floor(xRel * 16 / panelSize) * panelSize / 16;
|
||||
yRel = (int) Math.floor(yRel * 16 / panelSize) * panelSize / 16;
|
||||
}
|
||||
for (PanelComponent pc : container.tile.components) {
|
||||
drawPanelComponent(pc, -1, -1);
|
||||
}
|
||||
PanelComponent curr = getFloatingPC();
|
||||
if (curr!=null && 0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
|
||||
if (curr != null && 0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
|
||||
drawPanelComponent(curr, xRel, yRel);
|
||||
}
|
||||
}
|
||||
|
@ -80,20 +80,20 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
String tooltip = null;
|
||||
if (buttonList.get(0).isMouseOver()) {
|
||||
tooltip = I18n.format(IndustrialWires.MODID+".desc.create_panel");
|
||||
tooltip = I18n.format(IndustrialWires.MODID + ".desc.create_panel");
|
||||
ClientUtils.drawHoveringText(ImmutableList.of("Create a new panel"), mouseX, mouseY, mc.fontRenderer);
|
||||
} else if (buttonList.get(1).isMouseOver()) {
|
||||
tooltip = I18n.format(IndustrialWires.MODID+".desc.remove_all");
|
||||
tooltip = I18n.format(IndustrialWires.MODID + ".desc.remove_all");
|
||||
} else if (buttonList.get(2).isMouseOver()) {
|
||||
if (snapToGrid) {
|
||||
tooltip = I18n.format(IndustrialWires.MODID+".desc.disable_snap");
|
||||
tooltip = I18n.format(IndustrialWires.MODID + ".desc.disable_snap");
|
||||
} else {
|
||||
tooltip = I18n.format(IndustrialWires.MODID+".desc.enable_snap");
|
||||
tooltip = I18n.format(IndustrialWires.MODID + ".desc.enable_snap");
|
||||
}
|
||||
} else if (buttonList.get(3).isMouseOver()) {
|
||||
tooltip = I18n.format(IndustrialWires.MODID+".desc.disassemble");
|
||||
tooltip = I18n.format(IndustrialWires.MODID + ".desc.disassemble");
|
||||
}
|
||||
if (tooltip!=null) {
|
||||
if (tooltip != null) {
|
||||
ClientUtils.drawHoveringText(ImmutableList.of(tooltip), mouseX, mouseY, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
|
@ -105,10 +105,10 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
}
|
||||
if (!pc.isValidPos(container.tile.components)) {
|
||||
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
|
||||
int left = (int) (getX0()+aabb.minX*panelSize)-1;
|
||||
int top = (int) (getY0()+aabb.minZ*panelSize)-1;
|
||||
int right = (int) (getX0()+aabb.maxX*panelSize)+1;
|
||||
int bottom = (int) (getY0()+aabb.maxZ*panelSize)+1;
|
||||
int left = (int) (getX0() + aabb.minX * panelSize) - 1;
|
||||
int top = (int) (getY0() + aabb.minZ * panelSize) - 1;
|
||||
int right = (int) (getX0() + aabb.maxX * panelSize) + 1;
|
||||
int bottom = (int) (getY0() + aabb.maxZ * panelSize) + 1;
|
||||
Gui.drawRect(left, top, right, bottom, 0xffff0000);
|
||||
}
|
||||
pc.renderInGUI(this);
|
||||
|
@ -119,11 +119,11 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
int buttonTop = guiTop+62;
|
||||
buttonList.add(new GuiButton(0, guiLeft+2, buttonTop, 20, 20, "C"));
|
||||
buttonList.add(new GuiButton(1, guiLeft+2, buttonTop+22, 20, 20, "R"));
|
||||
buttonList.add(new GuiButton(2, guiLeft+2, buttonTop+44, 20, 20, "S"));
|
||||
buttonList.add(new GuiButton(3, guiLeft+2, buttonTop-54, 20, 20, "D"));
|
||||
int buttonTop = guiTop + 62;
|
||||
buttonList.add(new GuiButton(0, guiLeft + 2, buttonTop, 20, 20, "C"));
|
||||
buttonList.add(new GuiButton(1, guiLeft + 2, buttonTop + 22, 20, 20, "R"));
|
||||
buttonList.add(new GuiButton(2, guiLeft + 2, buttonTop + 44, 20, 20, "S"));
|
||||
buttonList.add(new GuiButton(3, guiLeft + 2, buttonTop - 54, 20, 20, "D"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,12 +154,12 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
}
|
||||
}
|
||||
} else if (mc.player.inventory.getItemStack().isEmpty()) {
|
||||
float xRelFloat = xRel/(float) panelSize;
|
||||
float yRelFloat = yRel/(float) panelSize;
|
||||
for (int i = 0;i<components.size();i++) {
|
||||
float xRelFloat = xRel / (float) panelSize;
|
||||
float yRelFloat = yRel / (float) panelSize;
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
PanelComponent pc = components.get(i);
|
||||
AxisAlignedBB aabb = pc.getBlockRelativeAABB();
|
||||
if (aabb.minX<=xRelFloat&&aabb.maxX>xRelFloat&&aabb.minZ<=yRelFloat&&aabb.maxZ>yRelFloat) {
|
||||
if (aabb.minX <= xRelFloat && aabb.maxX > xRelFloat && aabb.minZ <= yRelFloat && aabb.maxZ > yRelFloat) {
|
||||
PanelComponent removed = components.get(i);
|
||||
ItemStack remItem = ItemPanelComponent.stackFromComponent(removed);
|
||||
mc.player.inventory.setItemStack(remItem);
|
||||
|
@ -175,11 +175,11 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
}
|
||||
|
||||
public int getX0() {
|
||||
return 30+guiLeft;
|
||||
return 30 + guiLeft;
|
||||
}
|
||||
|
||||
public int getY0() {
|
||||
return 6+guiTop;
|
||||
return 6 + guiTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -207,6 +207,7 @@ public class GuiPanelCreator extends GuiContainer {
|
|||
|
||||
private ItemStack lastFloating = ItemStack.EMPTY;
|
||||
private PanelComponent lastFloatingPC;
|
||||
|
||||
private PanelComponent getFloatingPC() {
|
||||
ItemStack floating = mc.player.inventory.getItemStack();
|
||||
if (floating.isEmpty() || floating.getItem() != IndustrialWires.panelComponent) {
|
||||
|
|
|
@ -35,18 +35,20 @@ import java.io.IOException;
|
|||
public class GuiRSPanelConn extends GuiContainer {
|
||||
private TileEntityRSPanelConn te;
|
||||
private GuiIntChooser chooser;
|
||||
|
||||
public GuiRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
super(new ContainerRSPanelConn(tile));
|
||||
te = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
chooser = new GuiIntChooser((width-32)/2, (height-4)/2, false, te.getRsId(), 2);
|
||||
chooser = new GuiIntChooser((width - 32) / 2, (height - 4) / 2, false, te.getRsId(), 2);
|
||||
xSize = 64;
|
||||
ySize = 64;
|
||||
guiLeft = (width-xSize)/2;
|
||||
guiTop = (height-ySize)/2;
|
||||
guiLeft = (width - xSize) / 2;
|
||||
guiTop = (height - ySize) / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,9 +67,10 @@ public class GuiRSPanelConn extends GuiContainer {
|
|||
}
|
||||
|
||||
private ResourceLocation textureLoc = new ResourceLocation(IndustrialWires.MODID, "textures/gui/rs_wire_controller.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1,1,1,1);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
mc.getTextureManager().bindTexture(textureLoc);
|
||||
Gui.drawModalRectWithCustomSizedTexture(guiLeft, guiTop, 0, 0, xSize, ySize, 64, 64);
|
||||
}
|
||||
|
@ -84,7 +87,7 @@ public class GuiRSPanelConn extends GuiContainer {
|
|||
}
|
||||
|
||||
private void onChange() {
|
||||
if (chooser.getValue()!=te.getRsId()) {
|
||||
if (chooser.getValue() != te.getRsId()) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("rsId", chooser.getValue());
|
||||
IndustrialWires.packetHandler.sendToServer(new MessageGUIInteract(te, nbt));
|
||||
|
|
|
@ -10,6 +10,7 @@ import javax.annotation.Nonnull;
|
|||
public class GuiChannelPicker extends GuiButton {
|
||||
protected byte selected;
|
||||
protected byte currHovered;
|
||||
|
||||
public GuiChannelPicker(int id, int x, int y, int size, byte selectedChannel) {
|
||||
super(id, x, y, size, size, "");
|
||||
selected = selectedChannel;
|
||||
|
@ -21,33 +22,33 @@ public class GuiChannelPicker extends GuiButton {
|
|||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
mouseX-=xPosition;
|
||||
mouseY-=yPosition;
|
||||
mouseX -= xPosition;
|
||||
mouseY -= yPosition;
|
||||
currHovered = -1;
|
||||
for (byte i = 0;i<16;i++) {
|
||||
int xMin = width/4*(i%4);
|
||||
int yMin = height/4*(i/4);
|
||||
int xMax = xMin+width/4;
|
||||
int yMax = yMin+height/4;
|
||||
for (byte i = 0; i < 16; i++) {
|
||||
int xMin = width / 4 * (i % 4);
|
||||
int yMin = height / 4 * (i / 4);
|
||||
int xMax = xMin + width / 4;
|
||||
int yMax = yMin + height / 4;
|
||||
EnumDyeColor color = EnumDyeColor.byMetadata(i);
|
||||
int colorVal = color.getMapColor().colorValue|0xff000000;
|
||||
if (mouseX>=xMin&&mouseX<xMax&&mouseY>=yMin&&mouseY<yMax) {
|
||||
int colorVal = color.getMapColor().colorValue | 0xff000000;
|
||||
if (mouseX >= xMin && mouseX < xMax && mouseY >= yMin && mouseY < yMax) {
|
||||
currHovered = i;
|
||||
}
|
||||
if (selected==i) {
|
||||
drawRect(xMin+xPosition, yMin+yPosition, xMax+xPosition, yMax+yPosition, 0xff000000|~colorVal);
|
||||
if (selected == i) {
|
||||
drawRect(xMin + xPosition, yMin + yPosition, xMax + xPosition, yMax + yPosition, 0xff000000 | ~colorVal);
|
||||
}
|
||||
if (currHovered==i) {
|
||||
drawRect(xMin+xPosition, yMin+yPosition, xMax+xPosition, yMax+yPosition, colorVal);
|
||||
if (currHovered == i) {
|
||||
drawRect(xMin + xPosition, yMin + yPosition, xMax + xPosition, yMax + yPosition, colorVal);
|
||||
} else {
|
||||
final int offset = width/20;
|
||||
drawRect(xMin+offset+xPosition, yMin+offset+yPosition, xMax-offset+xPosition, yMax-offset+yPosition, colorVal);
|
||||
final int offset = width / 20;
|
||||
drawRect(xMin + offset + xPosition, yMin + offset + yPosition, xMax - offset + xPosition, yMax - offset + yPosition, colorVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean click(int x, int y) {
|
||||
if (xPosition<=x&&xPosition+width>=x&&yPosition<=y&&yPosition+height>=y) {
|
||||
if (xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y) {
|
||||
select();
|
||||
return true;
|
||||
}
|
||||
|
@ -55,14 +56,16 @@ public class GuiChannelPicker extends GuiButton {
|
|||
}
|
||||
|
||||
protected void select() {
|
||||
if (currHovered>=0) {
|
||||
if (currHovered >= 0) {
|
||||
selected = currHovered;
|
||||
}
|
||||
}
|
||||
|
||||
public byte getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public boolean isHovered(int x, int y) {
|
||||
return xPosition<=x&&xPosition+width>=x&&yPosition<=y&&yPosition+height>=y;
|
||||
return xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.annotation.Nonnull;
|
|||
public class GuiChannelPickerSmall extends GuiChannelPicker {
|
||||
private boolean open = false;
|
||||
private int offSize, onSize;
|
||||
|
||||
public GuiChannelPickerSmall(int id, int x, int y, int offSize, int onSize, byte selectedChannel) {
|
||||
super(id, x, y, offSize, selectedChannel);
|
||||
selected = selectedChannel;
|
||||
|
@ -45,14 +46,14 @@ public class GuiChannelPickerSmall extends GuiChannelPicker {
|
|||
} else {
|
||||
EnumDyeColor color = EnumDyeColor.byMetadata(selected);
|
||||
int colorVal = color.getMapColor().colorValue | 0xff000000;
|
||||
drawRect(xPosition, yPosition, xPosition+width, yPosition+height, colorVal);
|
||||
drawRect(xPosition, yPosition, xPosition + width, yPosition + height, colorVal);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean click(int x, int y) {
|
||||
if (!open) {
|
||||
if (xPosition<=x&&xPosition+width>=x&&yPosition<=y&&yPosition+height>=y) {
|
||||
if (xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y) {
|
||||
open = true;
|
||||
width = onSize;
|
||||
height = onSize;
|
||||
|
@ -61,7 +62,7 @@ public class GuiChannelPickerSmall extends GuiChannelPicker {
|
|||
return false;
|
||||
} else {
|
||||
boolean ret = false;
|
||||
if (xPosition<=x&&xPosition+width>=x&&yPosition<=y&&yPosition+height>=y) {
|
||||
if (xPosition <= x && xPosition + width >= x && yPosition <= y && yPosition + height >= y) {
|
||||
select();
|
||||
ret = true;
|
||||
}
|
||||
|
|
|
@ -11,20 +11,22 @@ public class GuiIntChooser extends Gui {
|
|||
private int max;
|
||||
private String format;
|
||||
private Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public GuiIntChooser(int x, int y, boolean neg, int initialValue, int digits) {
|
||||
allowNegative = neg;
|
||||
value = initialValue;
|
||||
xPos = x;
|
||||
yPos = y;
|
||||
max = (int) Math.pow(10, digits)-1;
|
||||
max = (int) Math.pow(10, digits) - 1;
|
||||
xPlus = x + mc.fontRenderer.getCharWidth('0') * (digits + (allowNegative ? 1 : 0)) + mc.fontRenderer.getCharWidth('-') + 2;
|
||||
format = "%"+digits+"s";
|
||||
format = "%" + digits + "s";
|
||||
}
|
||||
|
||||
public void drawChooser() {
|
||||
int color = 0xE0E0E0;
|
||||
String val = String.format(format, Integer.toString(value)).replace(' ', '0');
|
||||
if (value>=0&&allowNegative) {
|
||||
val = "+"+val;
|
||||
if (value >= 0 && allowNegative) {
|
||||
val = "+" + val;
|
||||
}
|
||||
mc.fontRenderer.drawStringWithShadow(val, xPos + mc.fontRenderer.getCharWidth('-') + 1, yPos, color);
|
||||
mc.fontRenderer.drawStringWithShadow("-", xPos, yPos, color);
|
||||
|
|
|
@ -49,6 +49,7 @@ public class PanelModel implements IBakedModel {
|
|||
.maximumSize(100)
|
||||
.expireAfterAccess(60, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
static {
|
||||
IEApi.renderCacheClearers.add(modelCache::invalidateAll);
|
||||
IEApi.renderCacheClearers.add(PanelItemOverride.ITEM_MODEL_CACHE::invalidateAll);
|
||||
|
@ -57,7 +58,7 @@ public class PanelModel implements IBakedModel {
|
|||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||
if (side!=null) {
|
||||
if (side != null) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
if (state instanceof IExtendedBlockState) {
|
||||
|
@ -179,6 +180,7 @@ public class PanelModel implements IBakedModel {
|
|||
.maximumSize(100)
|
||||
.expireAfterAccess(60, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
public PanelItemOverride() {
|
||||
super(ImmutableList.of());
|
||||
}
|
||||
|
@ -188,7 +190,7 @@ public class PanelModel implements IBakedModel {
|
|||
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
if (stack != null && stack.getItem() == PanelUtils.PANEL_ITEM && stack.getMetadata() == BlockTypes_Panel.TOP.ordinal()) {
|
||||
try {
|
||||
return ITEM_MODEL_CACHE.get(stack, ()-> {
|
||||
return ITEM_MODEL_CACHE.get(stack, () -> {
|
||||
TileEntityPanel te = new TileEntityPanel();
|
||||
te.readFromItemNBT(stack.getTagCompound());
|
||||
return new AssembledBakedModel(te.getComponents());
|
||||
|
|
|
@ -50,7 +50,7 @@ public class PanelModelLoader implements ICustomModelLoader {
|
|||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation) {
|
||||
return modelLocation.getResourcePath().contains(RESOURCE_BASE+RESOURCE_LOCATION);
|
||||
return modelLocation.getResourcePath().contains(RESOURCE_BASE + RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,7 @@ public class PanelModelLoader implements ICustomModelLoader {
|
|||
String resourcePath = modelLocation.getResourcePath();
|
||||
int pos = resourcePath.indexOf(RESOURCE_LOCATION);
|
||||
if (pos >= 0) {
|
||||
return new PanelModelBase();
|
||||
return new PanelModelBase();
|
||||
}
|
||||
return ModelLoaderRegistry.getMissingModel();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class PanelModelLoader implements ICustomModelLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
|
||||
try {
|
||||
return new PanelModel();
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RawModelFontRenderer extends FontRenderer {
|
|||
|
||||
public RawModelFontRenderer(GameSettings settings, ResourceLocation font, TextureManager manager, boolean isUnicode, float scale) {
|
||||
super(settings, font, manager, isUnicode);
|
||||
this.scale = scale/(9*16);
|
||||
this.scale = scale / (9 * 16);
|
||||
onResourceManagerReload(null);
|
||||
}
|
||||
|
||||
|
@ -52,22 +52,23 @@ public class RawModelFontRenderer extends FontRenderer {
|
|||
float y = (pos / 16);
|
||||
float w = charWidth[pos] - 1.01f;
|
||||
float h = FONT_HEIGHT - 1.01f;
|
||||
float wt = w / 128f*16;
|
||||
float ht = h / 128f*16;
|
||||
float wt = w / 128f * 16;
|
||||
float ht = h / 128f * 16;
|
||||
float h0 = .01F;
|
||||
Vector3f v0 = new Vector3f(posX, h0, posY);
|
||||
v0.scale(scale);
|
||||
Vector3f v1 = new Vector3f(posX, h0, posY+h);
|
||||
Vector3f v1 = new Vector3f(posX, h0, posY + h);
|
||||
v1.scale(scale);
|
||||
Vector3f v2 = new Vector3f(posX+w, h0, posY+h);
|
||||
Vector3f v2 = new Vector3f(posX + w, h0, posY + h);
|
||||
v2.scale(scale);
|
||||
Vector3f v3 = new Vector3f(posX+w, h0, posY);
|
||||
Vector3f v3 = new Vector3f(posX + w, h0, posY);
|
||||
v3.scale(scale);
|
||||
builder.add(new RawQuad(v0, v1, v2, v3,
|
||||
EnumFacing.UP, sprite, new float[]{1, 0, 0, 1}, new Vector3f(0, 1, 0),
|
||||
new float[]{x, y, x+wt, y+ht}));
|
||||
EnumFacing.UP, sprite, colorA, new Vector3f(0, 1, 0),
|
||||
new float[]{x, y, x + wt, y + ht}));
|
||||
return charWidth[pos];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
super.onResourceManagerReload(resourceManager);
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package malte0811.industrialWires.client.panelmodel;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumType;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.pipeline.IVertexConsumer;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
import net.minecraftforge.client.model.pipeline.QuadGatheringTransformer;
|
||||
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
//Yes, this is copied from the IE version. But I wrote that one, so...
|
||||
public class SmartLightingQuadIW extends BakedQuad {
|
||||
private static Field parent;
|
||||
|
||||
static {
|
||||
try {
|
||||
parent = QuadGatheringTransformer.class.getDeclaredField("parent");
|
||||
parent.setAccessible(true);
|
||||
} catch (Exception x) {
|
||||
x.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private int brightness;
|
||||
|
||||
public SmartLightingQuadIW(int[] vertexDataIn, int tintIndexIn, EnumFacing faceIn, TextureAtlasSprite spriteIn, VertexFormat format, int brightness) {
|
||||
super(vertexDataIn, tintIndexIn, faceIn, spriteIn, false, format);
|
||||
this.brightness = brightness;
|
||||
}
|
||||
|
||||
public SmartLightingQuadIW(BakedQuad ret, int light) {
|
||||
super(ret.getVertexData(), ret.getTintIndex(), ret.getFace(), ret.getSprite(), false, ret.getFormat());
|
||||
this.brightness = light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pipe(IVertexConsumer consumer) {
|
||||
if (consumer instanceof VertexLighterFlat) {
|
||||
try {
|
||||
consumer = (IVertexConsumer) parent.get(consumer);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
consumer.setQuadOrientation(this.getFace());
|
||||
if (this.hasTintIndex()) {
|
||||
consumer.setQuadTint(this.getTintIndex());
|
||||
}
|
||||
float[] data = new float[4];
|
||||
VertexFormat format = consumer.getVertexFormat();
|
||||
int count = format.getElementCount();
|
||||
int[] eMap = LightUtil.mapFormats(format, DefaultVertexFormats.ITEM);
|
||||
int itemCount = DefaultVertexFormats.ITEM.getElementCount();
|
||||
eMap[eMap.length - 1] = 2;
|
||||
for (int v = 0; v < 4; v++) {
|
||||
for (int e = 0; e < count; e++) {
|
||||
if (eMap[e] != itemCount) {
|
||||
if (format.getElement(e).getUsage() == EnumUsage.UV && format.getElement(e).getType() == EnumType.SHORT)//lightmap is UV with 2 shorts
|
||||
{
|
||||
data[0] = ((float) ((brightness >> 0x04) & 0xF) * 0x20) / 0xFFFF;
|
||||
data[1] = ((float) ((brightness >> 0x14) & 0xF) * 0x20) / 0xFFFF;
|
||||
} else {
|
||||
LightUtil.unpack(this.getVertexData(), data, DefaultVertexFormats.ITEM, v, eMap[e]);
|
||||
}
|
||||
consumer.put(e, data);
|
||||
} else {
|
||||
consumer.put(e, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,23 +25,21 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntityJacobsLadder> {
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntityJacobsLadder tile, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
super.renderTileEntityAt(tile, x, y, z, partialTicks, destroyStage);
|
||||
if (!tile.isDummy()&&tile.timeTillActive==0&&tile.controls[0] != null) {
|
||||
if (!tile.isDummy() && tile.timeTillActive == 0 && tile.controls[0] != null) {
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x + .5, y + tile.size.heightOffset, z + .5);
|
||||
GlStateManager.rotate(tile.facing.getHorizontalAngle(), 0, 1, 0);
|
||||
GlStateManager.translate( - tile.size.bottomDistance / 2, 0, 0);
|
||||
GlStateManager.translate(-tile.size.bottomDistance / 2, 0, 0);
|
||||
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.disableLighting();
|
||||
|
@ -89,47 +87,50 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
|
|||
Vec3d radZ = new Vec3d(0, 0, diameter / 2);
|
||||
Tessellator tes = Tessellator.getInstance();
|
||||
VertexBuffer vertBuffer = tes.getBuffer();
|
||||
float[][] colors = new float[steps+1][];
|
||||
float[][] colors = new float[steps + 1][];
|
||||
vertBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
|
||||
Vec3d last = Beziers.getPoint(0, controls);
|
||||
colors[0] = getColor(0, salt, size);
|
||||
for (int i = 1;i<=steps;i++) {
|
||||
double d = i/(double)steps;
|
||||
for (int i = 1; i <= steps; i++) {
|
||||
double d = i / (double) steps;
|
||||
colors[i] = getColor(d, salt, size);
|
||||
Vec3d pos = Beziers.getPoint(d, controls);
|
||||
drawQuad(last, pos, radY, colors[i-1], colors[i], vertBuffer);
|
||||
drawQuad(last, pos, radZ, colors[i-1], colors[i], vertBuffer);
|
||||
drawQuad(last, pos, radY, colors[i - 1], colors[i], vertBuffer);
|
||||
drawQuad(last, pos, radZ, colors[i - 1], colors[i], vertBuffer);
|
||||
last = pos;
|
||||
}
|
||||
tes.draw();
|
||||
}
|
||||
private final float[] saltColor = {1, 190/255F, 50/255F};
|
||||
|
||||
private final float[] saltColor = {1, 190 / 255F, 50 / 255F};
|
||||
private final float[] airColor = {1, .85F, 1};
|
||||
|
||||
private float[] getColor(double t, double salt, LadderSize size) {
|
||||
salt = Math.min(salt, 1);
|
||||
int factor = 20;
|
||||
double smallMin = Math.exp(-.5);
|
||||
double normalMin = Math.exp(-.25*factor);
|
||||
double hugeMin = Math.exp(-.75*factor);
|
||||
double normalMin = Math.exp(-.25 * factor);
|
||||
double hugeMin = Math.exp(-.75 * factor);
|
||||
double saltyness = 0;
|
||||
double t2 = t-.5;
|
||||
double t2 = t - .5;
|
||||
switch (size) {
|
||||
case SMALL:
|
||||
saltyness = salt*(1-.9*(Math.exp(-Math.abs(t2))-smallMin));
|
||||
saltyness = salt * (1 - .9 * (Math.exp(-Math.abs(t2)) - smallMin));
|
||||
break;
|
||||
case NORMAL:
|
||||
saltyness = salt*(1-.9*(Math.exp(-factor*t2*t2)-normalMin));
|
||||
saltyness = salt * (1 - .9 * (Math.exp(-factor * t2 * t2) - normalMin));
|
||||
break;
|
||||
case HUGE:
|
||||
saltyness = salt*(1-.9*(Math.exp(-Math.abs(factor*t2*t2*t2))-hugeMin));
|
||||
saltyness = salt * (1 - .9 * (Math.exp(-Math.abs(factor * t2 * t2 * t2)) - hugeMin));
|
||||
break;
|
||||
}
|
||||
return interpolate(saltyness, saltColor, 1-saltyness, airColor);
|
||||
return interpolate(saltyness, saltColor, 1 - saltyness, airColor);
|
||||
}
|
||||
|
||||
private float[] interpolate(double a, float[] cA, double b, float[] cB) {
|
||||
float[] ret = new float[cA.length];
|
||||
for (int i = 0;i<ret.length;i++) {
|
||||
ret[i] = (float) (a*cA[i]+b*cB[i]);
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = (float) (a * cA[i] + b * cB[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -145,6 +146,7 @@ public class TileRenderJacobsLadder extends TileEntitySpecialRenderer<TileEntity
|
|||
color(color0, vertexBuffer.pos(v0.xCoord - rad.xCoord, v0.yCoord - rad.yCoord, v0.zCoord - rad.zCoord)).endVertex();
|
||||
color(color1, vertexBuffer.pos(v1.xCoord - rad.xCoord, v1.yCoord - rad.yCoord, v1.zCoord - rad.zCoord)).endVertex();
|
||||
}
|
||||
|
||||
private VertexBuffer color(float[] color, VertexBuffer vb) {
|
||||
vb.color(color[0], color[1], color[2], 1);
|
||||
return vb;
|
||||
|
|
|
@ -28,9 +28,11 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public class ContainerPanelComponent extends Container {
|
||||
public EnumHand hand;
|
||||
|
||||
public ContainerPanelComponent(EnumHand h) {
|
||||
hand = h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
|
||||
ItemStack held = playerIn.getHeldItem(hand);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import blusunrize.immersiveengineering.api.ApiUtils;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.controlpanel.PanelUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -30,7 +31,6 @@ import net.minecraft.util.text.ITextComponent;
|
|||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
@ -38,6 +38,7 @@ import java.util.function.Supplier;
|
|||
public class ContainerPanelCreator extends Container {
|
||||
public TileEntityPanelCreator tile;
|
||||
private IInventory inv;
|
||||
|
||||
public ContainerPanelCreator(InventoryPlayer inventoryPlayer, TileEntityPanelCreator tile) {
|
||||
int slotH = 150;
|
||||
int slotX = 14;
|
||||
|
@ -50,16 +51,16 @@ public class ContainerPanelCreator extends Container {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(@Nullable ItemStack stack) {
|
||||
return stack != null && (ItemStack.areItemStacksEqual(stack, PanelUtils.getPanelBase()) || stack.getItem() == PanelUtils.PANEL_ITEM);
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return ItemStack.areItemStacksEqual(ApiUtils.copyStackWithAmount(stack, 1), PanelUtils.getPanelBase()) || stack.getItem() == PanelUtils.PANEL_ITEM;
|
||||
}
|
||||
|
||||
});
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 9; j++)
|
||||
addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, slotX+j*18, slotH+i*18));
|
||||
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, slotX + j * 18, slotH + i * 18));
|
||||
for (int i = 0; i < 9; i++)
|
||||
addSlotToContainer(new Slot(inventoryPlayer, i, slotX+i*18, slotH+58));
|
||||
addSlotToContainer(new Slot(inventoryPlayer, i, slotX + i * 18, slotH + 58));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,6 +68,26 @@ public class ContainerPanelCreator extends Container {
|
|||
return player.getDistanceSq(tile.getPos()) < 100;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
Slot clicked = getSlot(index);
|
||||
if (index == 0) {
|
||||
boolean change = mergeItemStack(clicked.getStack(), 1, 37, false);
|
||||
if (change) {
|
||||
clicked.onSlotChanged();
|
||||
}
|
||||
} else {
|
||||
ItemStack inSlot = clicked.getStack();
|
||||
Slot slot0 = getSlot(0);
|
||||
if (slot0.isItemValid(inSlot) && slot0.getStack().getCount() < slot0.getSlotStackLimit()) {
|
||||
slot0.putStack(inSlot.splitStack(slot0.getSlotStackLimit()));
|
||||
clicked.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static class SingleSlotInventory implements IInventory {
|
||||
Consumer<ItemStack> set;
|
||||
Supplier<ItemStack> get;
|
||||
|
|
|
@ -26,11 +26,13 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public class ContainerRSPanelConn extends Container {
|
||||
private final TileEntityRSPanelConn te;
|
||||
|
||||
public ContainerRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
te = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(@Nonnull EntityPlayer playerIn) {
|
||||
return playerIn.getDistanceSq(te.getPos())<64;
|
||||
return playerIn.getDistanceSq(te.getPos()) < 64;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,18 +50,18 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
Matrix4 rot = null;
|
||||
if (state.open) {
|
||||
rot = new Matrix4();
|
||||
rot.rotate(-Math.PI*.4, 1, 0, 0);
|
||||
rot.rotate(-Math.PI * .4, 1, 0, 0);
|
||||
}
|
||||
PanelUtils.addColoredBox(color, color, null, new Vector3f(0, 0, 0), new Vector3f(sizeX, getHeight(), sizeY), ret,
|
||||
false, rot, true);
|
||||
ret.remove(ret.size()-2);//remove front face
|
||||
ret.remove(ret.size()-1);//remove front face
|
||||
ret.remove(ret.size() - 2);//remove front face
|
||||
ret.remove(ret.size() - 1);//remove front face
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
if (player.isSneaking()&&state==SwitchState.OPEN) {
|
||||
if (player.isSneaking() && state == SwitchState.OPEN) {
|
||||
state = SwitchState.CLOSED;
|
||||
} else {
|
||||
state = state.next();
|
||||
|
@ -73,7 +73,7 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
|
||||
@Override
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
super.renderInGUIDefault(gui, 0xff000000|this.color);
|
||||
super.renderInGUIDefault(gui, 0xff000000 | this.color);
|
||||
super.renderInGUI(gui);
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,7 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
ret.state = state;
|
||||
ret.rsOutputChannel = rsOutputChannel;
|
||||
ret.rsOutputId = rsOutputId;
|
||||
ret.active = active;
|
||||
ret.setX(getX());
|
||||
ret.setY(getY());
|
||||
ret.setPanelHeight(panelHeight);
|
||||
|
@ -117,30 +118,30 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
int yOffset = 10;
|
||||
return new FloatConfig[]{
|
||||
new FloatConfig("red", x, yOffset, color[0], 60),
|
||||
new FloatConfig("green", x, yOffset+20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset+40, color[2], 60)
|
||||
new FloatConfig("green", x, yOffset + 20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset + 40, color[2], 60)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
super.applyConfigOption(type, id, value);
|
||||
if (type==ConfigType.FLOAT) {
|
||||
if (type == ConfigType.FLOAT) {
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
if (type==ConfigType.FLOAT) {
|
||||
return I18n.format(IndustrialWires.MODID+".desc."+(id==0?"red":(id==1?"green":"blue")));
|
||||
if (type == ConfigType.FLOAT) {
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
}
|
||||
return super.fomatConfigName(type, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
if (type==ConfigType.FLOAT) {
|
||||
if (type == ConfigType.FLOAT) {
|
||||
return null;
|
||||
}
|
||||
return super.fomatConfigDescription(type, id);
|
||||
|
@ -159,7 +160,6 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
|
||||
CoveredToggleSwitch that = (CoveredToggleSwitch) o;
|
||||
|
||||
if (active != that.active) return false;
|
||||
if (rsOutputId != that.rsOutputId) return false;
|
||||
if (rsOutputChannel != that.rsOutputChannel) return false;
|
||||
if (color != that.color) return false;
|
||||
|
@ -183,12 +183,14 @@ public class CoveredToggleSwitch extends ToggleSwitch {
|
|||
ACTIVE(true, true);
|
||||
public boolean active;
|
||||
public boolean open;
|
||||
|
||||
SwitchState(boolean active, boolean open) {
|
||||
this.open = open;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
SwitchState next() {
|
||||
return values()[(ordinal()+1)%values().length];
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,9 +85,11 @@ public interface IConfigurableComponent {
|
|||
|
||||
class RSChannelConfig extends UniversalConfig<Byte> {
|
||||
public boolean small;
|
||||
|
||||
public RSChannelConfig(String name, int x, int y, Byte value) {
|
||||
this(name, x, y, value, false);
|
||||
}
|
||||
|
||||
public RSChannelConfig(String name, int x, int y, Byte value, boolean small) {
|
||||
super(name, x, y, value);
|
||||
this.small = small;
|
||||
|
@ -113,6 +115,7 @@ public interface IConfigurableComponent {
|
|||
this.width = width;
|
||||
}
|
||||
}
|
||||
|
||||
enum ConfigType {
|
||||
BOOL,
|
||||
STRING,
|
||||
|
|
|
@ -44,9 +44,11 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
private byte rsInputChannel;
|
||||
private int colorA = 0xff00;
|
||||
private byte rsInput;
|
||||
|
||||
public IndicatorLight() {
|
||||
super("indicator_light");
|
||||
}
|
||||
|
||||
public IndicatorLight(int rsId, byte rsChannel, int color) {
|
||||
this();
|
||||
colorA = color;
|
||||
|
@ -74,15 +76,19 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
|
||||
private static final float size = .0625F;
|
||||
private static final float antiZOffset = .001F;
|
||||
|
||||
@Override
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = new float[4];
|
||||
color[3] = 1;
|
||||
for (int i = 0;i<3;i++) {
|
||||
color[i] = ((this.colorA>>(8*(2-i)))&255)/255F*(rsInput+15F)/30F;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
color[i] = ((this.colorA >> (8 * (2 - i))) & 255) / 255F * (rsInput + 15F) / 30F;
|
||||
}
|
||||
List<RawQuad> ret = new ArrayList<>(1);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(), new Vector3f(0, antiZOffset, size), new Vector3f(size, antiZOffset, size), new Vector3f(size, antiZOffset, 0), EnumFacing.UP, color);
|
||||
if (rsInput>0) {
|
||||
ret.get(ret.size()-1).light = 0xff0ff;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -100,8 +106,8 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb==null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x+size, 0, y+size);
|
||||
if (aabb == null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x + size, 0, y + size);
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
@ -114,18 +120,20 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
public void update(TileEntityPanel tile) {
|
||||
|
||||
}
|
||||
|
||||
private TileEntityPanel panel;
|
||||
private Consumer<byte[]> handler = (input)->{
|
||||
if (input[rsInputChannel]!=rsInput) {
|
||||
private Consumer<byte[]> handler = (input) -> {
|
||||
if (input[rsInputChannel] != rsInput) {
|
||||
rsInput = input[rsInputChannel];
|
||||
panel.markDirty();
|
||||
panel.triggerRenderUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Consumer<byte[]> getRSInputHandler(int id, TileEntityPanel panel) {
|
||||
if (id==rsInputId) {
|
||||
if (id == rsInputId) {
|
||||
this.panel = panel;
|
||||
return handler;
|
||||
}
|
||||
|
@ -166,10 +174,10 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
rsInputChannel = ((NBTTagByte)value).getByte();
|
||||
rsInputChannel = ((NBTTagByte) value).getByte();
|
||||
break;
|
||||
case INT:
|
||||
rsInputId = ((NBTTagInt)value).getInt();
|
||||
rsInputId = ((NBTTagInt) value).getInt();
|
||||
break;
|
||||
case FLOAT:
|
||||
colorA = PanelUtils.setColor(colorA, id, value);
|
||||
|
@ -182,7 +190,7 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc."+(id==0?"red":(id==1?"green":"blue")));
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
default:
|
||||
|
@ -197,9 +205,9 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
case FLOAT:
|
||||
return null;
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rschannel_info");
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rsid_info");
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rsid_info");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -207,14 +215,14 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
|
||||
@Override
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[] {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsInputChannel)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[] {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 45, rsInputId, 2, false)
|
||||
};
|
||||
}
|
||||
|
@ -226,8 +234,8 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
|
|||
int yOffset = 10;
|
||||
return new FloatConfig[]{
|
||||
new FloatConfig("red", x, yOffset, color[0], 60),
|
||||
new FloatConfig("green", x, yOffset+20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset+40, color[2], 60)
|
||||
new FloatConfig("green", x, yOffset + 20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset + 40, color[2], 60)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
this.text = text;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public Label() {
|
||||
super("label");
|
||||
}
|
||||
|
@ -68,7 +69,7 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
@Override
|
||||
public List<RawQuad> getQuads() {
|
||||
RawModelFontRenderer render = fontRenderer();
|
||||
render.drawString(text, 0, 0, 0xff000000|color);
|
||||
render.drawString(text, 0, 0, 0xff000000 | color);
|
||||
return render.build();
|
||||
}
|
||||
|
||||
|
@ -114,17 +115,17 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
}
|
||||
|
||||
private RawModelFontRenderer fontRenderer() {
|
||||
if (renderer==null) {
|
||||
if (renderer == null) {
|
||||
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, font, Minecraft.getMinecraft().getTextureManager(),
|
||||
false, 1);
|
||||
false, 1);
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
int left = (int) (gui.getX0()+getX()*gui.panelSize);
|
||||
int top = (int) (gui.getY0()+getY()*gui.panelSize);
|
||||
int left = (int) (gui.getX0() + getX() * gui.panelSize);
|
||||
int top = (int) (gui.getY0() + getY() * gui.panelSize);
|
||||
GlStateManager.pushMatrix();
|
||||
float scale = gui.mc.fontRenderer.FONT_HEIGHT * gui.panelSize / (16F * 9F * 9F);
|
||||
GlStateManager.translate(left, top, 0);
|
||||
|
@ -137,7 +138,7 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case STRING:
|
||||
text = ((NBTTagString)value).getString();
|
||||
text = ((NBTTagString) value).getString();
|
||||
break;
|
||||
case FLOAT:
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
|
@ -150,7 +151,7 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc."+(id==0?"red":(id==1?"green":"blue")));
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -161,7 +162,7 @@ public class Label extends PanelComponent implements IConfigurableComponent {
|
|||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case STRING:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.label_text");
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.label_text");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -47,9 +47,11 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
public int rsOutputChannel;
|
||||
private int ticksTillOff;
|
||||
private Set<BiConsumer<Integer, Byte>> rsOut = new HashSet<>();
|
||||
|
||||
public LightedButton() {
|
||||
super("lighted_button");
|
||||
}
|
||||
|
||||
public LightedButton(int color, boolean active, boolean latching, int rsOutputId, int rsOutputChannel) {
|
||||
this();
|
||||
this.color = color;
|
||||
|
@ -80,12 +82,18 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
rsOutputChannel = nbt.getInteger(RS_CHANNEL);
|
||||
rsOutputId = nbt.getInteger(RS_ID);
|
||||
}
|
||||
|
||||
private final static float size = .0625F;
|
||||
|
||||
@Override
|
||||
public List<RawQuad> getQuads() {
|
||||
float[] color = PanelUtils.getFloatColor(active, this.color);
|
||||
List<RawQuad> ret = new ArrayList<>(5);
|
||||
PanelUtils.addColoredBox(color, GRAY, null, new Vector3f(0, 0, 0), new Vector3f(size, size/2, size), ret, false);
|
||||
PanelUtils.addColoredBox(color, GRAY, null, new Vector3f(0, 0, 0), new Vector3f(size, size / 2, size), ret, false);
|
||||
if (active) {
|
||||
ret.get(0).light = 0xff0ff;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -102,15 +110,15 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb==null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x+size, getHeight(), y+size);
|
||||
if (aabb == null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x + size, getHeight(), y + size);
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
if (!latching&&active) {
|
||||
if (!latching && active) {
|
||||
return;
|
||||
}
|
||||
setOut(!active, tile);
|
||||
|
@ -123,10 +131,10 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
|
||||
@Override
|
||||
public void update(TileEntityPanel tile) {
|
||||
if (!latching&&ticksTillOff>0) {
|
||||
if (!latching && ticksTillOff > 0) {
|
||||
ticksTillOff--;
|
||||
tile.markDirty();
|
||||
if (ticksTillOff==0) {
|
||||
if (ticksTillOff == 0) {
|
||||
setOut(false, tile);
|
||||
}
|
||||
}
|
||||
|
@ -134,27 +142,27 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
if (id==rsOutputId) {
|
||||
if (id == rsOutputId) {
|
||||
rsOut.add(out);
|
||||
out.accept(rsOutputChannel, (byte) (active?15:0));
|
||||
out.accept(rsOutputChannel, (byte) (active ? 15 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
if (id==rsOutputId) {
|
||||
if (id == rsOutputId) {
|
||||
rsOut.remove(out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return size/2;
|
||||
return size / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, 0xff000000|color);
|
||||
renderInGUIDefault(gui, 0xff000000 | color);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,8 +174,8 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
active = on;
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
for (BiConsumer<Integer, Byte> rs:rsOut) {
|
||||
rs.accept(rsOutputChannel, (byte)(active?15:0));
|
||||
for (BiConsumer<Integer, Byte> rs : rsOut) {
|
||||
rs.accept(rsOutputChannel, (byte) (active ? 15 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,61 +204,61 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
if (id==0) {
|
||||
latching = ((NBTTagByte)value).getByte()!=0;
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id==0) {
|
||||
rsOutputChannel = ((NBTTagByte)value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id==0) {
|
||||
rsOutputId = ((NBTTagInt)value).getInt();
|
||||
}
|
||||
break;
|
||||
case FLOAT:
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
break;
|
||||
case BOOL:
|
||||
if (id == 0) {
|
||||
latching = ((NBTTagByte) value).getByte() != 0;
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
rsOutputChannel = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
rsOutputId = ((NBTTagInt) value).getInt();
|
||||
}
|
||||
break;
|
||||
case FLOAT:
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.latching");
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
return null;
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc."+(id==0?"red":(id==1?"green":"blue")));
|
||||
default:
|
||||
return "INVALID";
|
||||
case BOOL:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.latching");
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
return null;
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
default:
|
||||
return "INVALID";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.latching_info");
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rsid_info");
|
||||
case FLOAT:
|
||||
return null;
|
||||
default:
|
||||
return "INVALID?";
|
||||
case BOOL:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.latching_info");
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rsid_info");
|
||||
case FLOAT:
|
||||
return null;
|
||||
default:
|
||||
return "INVALID?";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte)rsOutputChannel)};
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte) rsOutputChannel)};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -270,8 +278,8 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
|
|||
int yOffset = 10;
|
||||
return new FloatConfig[]{
|
||||
new FloatConfig("red", x, yOffset, color[0], 60),
|
||||
new FloatConfig("green", x, yOffset+20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset+40, color[2], 60)
|
||||
new FloatConfig("green", x, yOffset + 20, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset + 40, color[2], 60)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,11 @@ public abstract class PanelComponent {
|
|||
private final String type;
|
||||
protected final static float[] GRAY = {.8F, .8F, .8F};
|
||||
protected final static int GRAY_INT = 0xFFD0D0D0;
|
||||
|
||||
protected PanelComponent(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static final Map<String, Supplier<PanelComponent>> baseCreaters = new HashMap<>();
|
||||
public final static String COLOR = "color";
|
||||
public final static String RS_CHANNEL = "rsChannel";
|
||||
|
@ -58,6 +60,7 @@ public abstract class PanelComponent {
|
|||
public static final String HORIZONTAL = "horizontal";
|
||||
public static final String LENGTH = "length";
|
||||
public static final String LATCHING = "latching";
|
||||
|
||||
static {
|
||||
baseCreaters.put("lighted_button", LightedButton::new);
|
||||
baseCreaters.put("label", Label::new);
|
||||
|
@ -67,10 +70,14 @@ public abstract class PanelComponent {
|
|||
baseCreaters.put("toggle_switch", ToggleSwitch::new);
|
||||
baseCreaters.put("toggle_switch_covered", CoveredToggleSwitch::new);
|
||||
}
|
||||
|
||||
protected abstract void writeCustomNBT(NBTTagCompound nbt, boolean toItem);
|
||||
|
||||
protected abstract void readCustomNBT(NBTTagCompound nbt);
|
||||
|
||||
// DON'T OFFSET BY x, y IN THIS METHOD!
|
||||
public abstract List<RawQuad> getQuads();
|
||||
|
||||
@Nonnull
|
||||
public abstract PanelComponent copyOf();
|
||||
|
||||
|
@ -89,11 +96,14 @@ public abstract class PanelComponent {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void registerRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {}
|
||||
public void registerRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
}
|
||||
|
||||
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {}
|
||||
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
}
|
||||
|
||||
public void invalidate(TileEntityPanel te) {}
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
|
@ -126,6 +136,7 @@ public abstract class PanelComponent {
|
|||
nbt.setFloat("panelHeight", panelHeight);
|
||||
nbt.setString("type", type);
|
||||
}
|
||||
|
||||
public static PanelComponent read(NBTTagCompound nbt) {
|
||||
String type = nbt.getString("type");
|
||||
if (baseCreaters.containsKey(type)) {
|
||||
|
@ -136,19 +147,20 @@ public abstract class PanelComponent {
|
|||
ret.setPanelHeight(nbt.getFloat("panelHeight"));
|
||||
return ret;
|
||||
} else {
|
||||
IELogger.info("(IndustrialWires) Unknown panel component: "+type);//TODO own logger?
|
||||
IELogger.info("(IndustrialWires) Unknown panel component: " + type);//TODO own logger?
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void renderBox(TileEntityPanel te) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.glLineWidth(2.0F);
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.depthMask(false);
|
||||
double px = te.getPos().getX()-TileEntityRendererDispatcher.staticPlayerX;
|
||||
double py = te.getPos().getY()-TileEntityRendererDispatcher.staticPlayerY;
|
||||
double pz = te.getPos().getZ()-TileEntityRendererDispatcher.staticPlayerZ;
|
||||
double px = te.getPos().getX() - TileEntityRendererDispatcher.staticPlayerX;
|
||||
double py = te.getPos().getY() - TileEntityRendererDispatcher.staticPlayerY;
|
||||
double pz = te.getPos().getZ() - TileEntityRendererDispatcher.staticPlayerZ;
|
||||
RenderGlobal.drawSelectionBoundingBox(te.apply(te.getComponents().getPanelTopTransform(), getBlockRelativeAABB()).expandXyz(0.002).offset(px, py, pz),
|
||||
0.0F, 0.0F, 0.0F, 0.4F);
|
||||
GlStateManager.depthMask(true);
|
||||
|
@ -161,28 +173,28 @@ public abstract class PanelComponent {
|
|||
public void renderInGUIDefault(GuiPanelCreator gui, int color) {
|
||||
color |= 0xff000000;
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
int left = (int) (gui.getX0()+aabb.minX*gui.panelSize);
|
||||
int top = (int) (gui.getY0()+aabb.minZ*gui.panelSize);
|
||||
int right = (int) (gui.getX0()+aabb.maxX*gui.panelSize);
|
||||
int bottom = (int) (gui.getY0()+aabb.maxZ*gui.panelSize);
|
||||
int left = (int) (gui.getX0() + aabb.minX * gui.panelSize);
|
||||
int top = (int) (gui.getY0() + aabb.minZ * gui.panelSize);
|
||||
int right = (int) (gui.getX0() + aabb.maxX * gui.panelSize);
|
||||
int bottom = (int) (gui.getY0() + aabb.maxZ * gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, color);
|
||||
}
|
||||
|
||||
|
||||
public boolean isValidPos(List<PanelComponent> components) {
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB().offset(0, panelHeight, 0);
|
||||
if (aabb.minX<0||aabb.maxX>1) {
|
||||
if (aabb.minX < 0 || aabb.maxX > 1) {
|
||||
return false;
|
||||
}
|
||||
if (aabb.minY<0||aabb.maxY>1) {
|
||||
if (aabb.minY < 0 || aabb.maxY > 1) {
|
||||
return false;
|
||||
}
|
||||
if (aabb.minZ<0||aabb.maxZ>1) {
|
||||
if (aabb.minZ < 0 || aabb.maxZ > 1) {
|
||||
return false;
|
||||
}
|
||||
aabb = getBlockRelativeAABB();
|
||||
for (PanelComponent pc:components) {
|
||||
if (pc==this) {
|
||||
for (PanelComponent pc : components) {
|
||||
if (pc == this) {
|
||||
continue;
|
||||
}
|
||||
AxisAlignedBB otherBB = pc.getBlockRelativeAABB();
|
||||
|
|
|
@ -26,6 +26,7 @@ import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
|
|||
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
|
||||
import malte0811.industrialWires.blocks.controlpanel.PropertyComponents.PanelRenderProperties;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.panelmodel.SmartLightingQuadIW;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
|
@ -137,7 +138,11 @@ public final class PanelUtils {
|
|||
raw.colorA);
|
||||
putVertexData(format, builder, transform.apply(vertices[3]), faceNormal, uvs[flip ? 0 : 2], uvs[flip ? 3 : 1], raw.tex,
|
||||
raw.colorA);
|
||||
return builder.build();
|
||||
BakedQuad ret = builder.build();
|
||||
if (raw.light>0) {
|
||||
ret = new SmartLightingQuadIW(ret, raw.light);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//mostly copied from IE's ClientUtils, it has protected access there...
|
||||
|
@ -192,7 +197,7 @@ public final class PanelUtils {
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void addBox(float[] colorTop, float[] colorSides, float[] colorBottom, Vector3f min, Vector3f size, List<RawQuad> out, boolean doBottom, float[] uvs, TextureAtlasSprite tex,
|
||||
@Nullable Matrix4 mat, boolean inside) {
|
||||
@Nullable Matrix4 mat, boolean inside) {
|
||||
addQuad(out, new Vector3f(min.x, min.y + size.y, min.z), new Vector3f(min.x, min.y + size.y, min.z + size.z),
|
||||
new Vector3f(min.x + size.x, min.y + size.y, min.z + size.z), new Vector3f(min.x + size.x, min.y + size.y, min.z),
|
||||
EnumFacing.UP, colorTop, tex, uvs, mat, inside);
|
||||
|
@ -230,7 +235,7 @@ public final class PanelUtils {
|
|||
Vec3i dirV = dir.getDirectionVec();
|
||||
RawQuad quad = new RawQuad(v0, v1, v2, v3, dir, tex,
|
||||
color, new Vector3f(dirV.getX(), dirV.getY(), dirV.getZ()), uvs);
|
||||
if (mat!=null) {
|
||||
if (mat != null) {
|
||||
quad = quad.apply(mat);
|
||||
}
|
||||
out.add(quad);
|
||||
|
@ -318,6 +323,7 @@ public final class PanelUtils {
|
|||
public static boolean intersectXZ(AxisAlignedBB aabb1, AxisAlignedBB aabb2) {
|
||||
return aabb1.minX < aabb2.maxX && aabb1.maxX > aabb2.minX && aabb1.minZ < aabb2.maxZ && aabb1.maxZ > aabb2.minZ;
|
||||
}
|
||||
|
||||
public static void readListFromNBT(NBTTagList list, @Nonnull List<PanelComponent> base) {
|
||||
base.clear();
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
|
@ -329,7 +335,7 @@ public final class PanelUtils {
|
|||
}
|
||||
|
||||
public static ItemStack getPanelBase() {
|
||||
if (panelBase==null) {
|
||||
if (panelBase == null) {
|
||||
panelBase = IC2Items.getItem("resource", "machine");
|
||||
}
|
||||
return panelBase;
|
||||
|
|
|
@ -47,6 +47,7 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
private byte rsChannel;
|
||||
private int rsId;
|
||||
private Set<BiConsumer<Integer, Byte>> outputs = new HashSet<>();
|
||||
|
||||
public Slider(float length, int color, boolean horizontal, int rsId, byte rsChannel) {
|
||||
this();
|
||||
this.color = color;
|
||||
|
@ -55,9 +56,11 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
this.rsChannel = rsChannel;
|
||||
this.rsId = rsId;
|
||||
}
|
||||
|
||||
public Slider() {
|
||||
super("slider");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeCustomNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
nbt.setInteger(COLOR, color);
|
||||
|
@ -84,23 +87,26 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
final float yOff = .001F;
|
||||
float xSize = horizontal?length:WIDTH;
|
||||
float ySize = horizontal?WIDTH:length;
|
||||
float xSize = horizontal ? length : WIDTH;
|
||||
float ySize = horizontal ? WIDTH : length;
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(0, yOff, 0), new Vector3f(0, yOff, ySize), new Vector3f(xSize, yOff, ySize), new Vector3f(xSize, yOff, 0),
|
||||
EnumFacing.UP, GRAY);
|
||||
float[] color = new float[4];
|
||||
color[3] = 1;
|
||||
for (int i = 0;i<3;i++) {
|
||||
color[i] = ((this.color>>(8*(2-i)))&255)/255F*(.5F+out/30F);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
color[i] = ((this.color >> (8 * (2 - i))) & 255) / 255F * (.5F + out / 30F);
|
||||
}
|
||||
float val;
|
||||
if (horizontal) {
|
||||
val = (out/15F)*(length-.0625F);
|
||||
val = (out / 15F) * (length - .0625F);
|
||||
} else {
|
||||
val = (1-out/15F)*(length-.0625F);
|
||||
val = (1 - out / 15F) * (length - .0625F);
|
||||
}
|
||||
PanelUtils.addColoredBox(color, GRAY, null, new Vector3f(horizontal?val:0, 0, horizontal?0:val),
|
||||
PanelUtils.addColoredBox(color, GRAY, null, new Vector3f(horizontal ? val : 0, 0, horizontal ? 0 : val),
|
||||
new Vector3f(.0625F, getHeight(), .0625F), ret, false);
|
||||
if (out>0) {
|
||||
ret.get(1).light = 0xff0ff;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -118,19 +124,19 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb==null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x+(horizontal?length:WIDTH), getHeight(), y+(horizontal?WIDTH:length));
|
||||
if (aabb == null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x + (horizontal ? length : WIDTH), getHeight(), y + (horizontal ? WIDTH : length));
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interactWith(Vec3d hitRelative, TileEntityPanel tile, EntityPlayerMP player) {
|
||||
double pos = horizontal?hitRelative.xCoord:(length-hitRelative.zCoord);
|
||||
byte newLevel = (byte)(Math.min(pos*16/length, 15));
|
||||
if (newLevel!=out) {
|
||||
for (BiConsumer<Integer, Byte> output:outputs) {
|
||||
output.accept((int)rsChannel, newLevel);
|
||||
double pos = horizontal ? hitRelative.xCoord : (length - hitRelative.zCoord);
|
||||
byte newLevel = (byte) (Math.min(pos * 16 / length, 15));
|
||||
if (newLevel != out) {
|
||||
for (BiConsumer<Integer, Byte> output : outputs) {
|
||||
output.accept((int) rsChannel, newLevel);
|
||||
}
|
||||
out = newLevel;
|
||||
tile.markDirty();
|
||||
|
@ -140,15 +146,15 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
if (id==rsId) {
|
||||
if (id == rsId) {
|
||||
outputs.add(out);
|
||||
out.accept((int)rsChannel, this.out);
|
||||
out.accept((int) rsChannel, this.out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
if (id==rsId) {
|
||||
if (id == rsId) {
|
||||
outputs.remove(out);
|
||||
}
|
||||
}
|
||||
|
@ -160,25 +166,25 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return .0625F/2;
|
||||
return .0625F / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
renderInGUIDefault(gui, GRAY_INT);
|
||||
double middleX = (getX()+(horizontal?length:.0625)/2);
|
||||
double middleY = (getY()+(horizontal?.0625:length)/2);
|
||||
int left = gui.getX0()+(int) ((middleX-.0625/2)*gui.panelSize);
|
||||
int right = gui.getX0()+(int) ((middleX+.0625/2)*gui.panelSize);
|
||||
int top = gui.getY0()+(int) ((middleY-.0625/2)*gui.panelSize);
|
||||
int bottom = gui.getY0()+(int) ((middleY+.0625/2)*gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, 0xff000000|color);
|
||||
double middleX = (getX() + (horizontal ? length : .0625) / 2);
|
||||
double middleY = (getY() + (horizontal ? .0625 : length) / 2);
|
||||
int left = gui.getX0() + (int) ((middleX - .0625 / 2) * gui.panelSize);
|
||||
int right = gui.getX0() + (int) ((middleX + .0625 / 2) * gui.panelSize);
|
||||
int top = gui.getY0() + (int) ((middleY - .0625 / 2) * gui.panelSize);
|
||||
int bottom = gui.getY0() + (int) ((middleY + .0625 / 2) * gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, 0xff000000 | color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(TileEntityPanel te) {
|
||||
for (BiConsumer<Integer, Byte> out:outputs) {
|
||||
out.accept((int)rsChannel, (byte) 0);
|
||||
for (BiConsumer<Integer, Byte> out : outputs) {
|
||||
out.accept((int) rsChannel, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,19 +220,19 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
horizontal = ((NBTTagByte)value).getByte()!=0;
|
||||
horizontal = ((NBTTagByte) value).getByte() != 0;
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
rsChannel = ((NBTTagByte)value).getByte();
|
||||
rsChannel = ((NBTTagByte) value).getByte();
|
||||
break;
|
||||
case INT:
|
||||
rsId = ((NBTTagInt)value).getInt();
|
||||
rsId = ((NBTTagInt) value).getInt();
|
||||
break;
|
||||
case FLOAT:
|
||||
if (id<3) {
|
||||
if (id < 3) {
|
||||
color = PanelUtils.setColor(color, id, value);
|
||||
} else {
|
||||
length = scaleToRangePercent(((NBTTagFloat)value).getFloat(), .125F, 1);
|
||||
length = scaleToRangePercent(((NBTTagFloat) value).getFloat(), .125F, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -240,12 +246,12 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case BOOL:
|
||||
return I18n.format(IndustrialWires.MODID+".tooltip.horizontal");
|
||||
return I18n.format(IndustrialWires.MODID + ".tooltip.horizontal");
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
return null;
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc."+(id==0?"red":(id==1?"green":id==2?"blue":"length")));
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : id == 2 ? "blue" : "length")));
|
||||
default:
|
||||
return "INVALID";
|
||||
}
|
||||
|
@ -257,9 +263,9 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
case BOOL:
|
||||
return null;
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rschannel_info");
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rsid_info");
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rsid_info");
|
||||
case FLOAT:
|
||||
return null;
|
||||
default:
|
||||
|
@ -269,21 +275,21 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
|
||||
@Override
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[] {
|
||||
return new RSChannelConfig[]{
|
||||
new RSChannelConfig("channel", 0, 0, rsChannel)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntConfig[] getIntegerOptions() {
|
||||
return new IntConfig[] {
|
||||
return new IntConfig[]{
|
||||
new IntConfig("rsId", 0, 50, rsId, 2, false)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoolConfig[] getBooleanOptions() {
|
||||
return new BoolConfig[] {
|
||||
return new BoolConfig[]{
|
||||
new BoolConfig("horizontal", 0, 70, horizontal)
|
||||
};
|
||||
}
|
||||
|
@ -294,10 +300,10 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
|
|||
int x = 70;
|
||||
int yOffset = 10;
|
||||
return new FloatConfig[]{
|
||||
new FloatConfig("red", x, yOffset+20, color[0], 60),
|
||||
new FloatConfig("green", x, yOffset+40, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset+60, color[2], 60),
|
||||
new FloatConfig("length", x, yOffset, (length-.125F)/(1-.125F), 60)
|
||||
new FloatConfig("red", x, yOffset + 20, color[0], 60),
|
||||
new FloatConfig("green", x, yOffset + 40, color[1], 60),
|
||||
new FloatConfig("blue", x, yOffset + 60, color[2], 60),
|
||||
new FloatConfig("length", x, yOffset, (length - .125F) / (1 - .125F), 60)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,15 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
public int rsOutputId;
|
||||
public byte rsOutputChannel;
|
||||
private Set<BiConsumer<Integer, Byte>> rsOut = new HashSet<>();
|
||||
|
||||
public ToggleSwitch() {
|
||||
super("toggle_switch");
|
||||
}
|
||||
|
||||
public ToggleSwitch(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public ToggleSwitch(boolean active, int rsOutputId, byte rsOutputChannel) {
|
||||
this();
|
||||
this.active = active;
|
||||
|
@ -75,22 +78,24 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
rsOutputChannel = nbt.getByte(RS_CHANNEL);
|
||||
rsOutputId = nbt.getInteger(RS_ID);
|
||||
}
|
||||
|
||||
protected float sizeX = .0625F;
|
||||
protected float sizeY = 1.5F*sizeX;
|
||||
protected float rodRadius = sizeX*.25F;
|
||||
protected float rodLength = 3/32F;
|
||||
protected float sizeY = 1.5F * sizeX;
|
||||
protected float rodRadius = sizeX * .25F;
|
||||
protected float rodLength = 3 / 32F;
|
||||
protected float yOffset = .0001F;
|
||||
|
||||
@Override
|
||||
public List<RawQuad> getQuads() {
|
||||
List<RawQuad> ret = new ArrayList<>();
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(sizeX, yOffset, (sizeY-sizeX)/2),
|
||||
new Vector3f(0, yOffset, (sizeY-sizeX)/2),
|
||||
new Vector3f(0, yOffset, (sizeY+sizeX)/2),
|
||||
new Vector3f(sizeX, yOffset, (sizeY+sizeX)/2), EnumFacing.UP, GRAY);
|
||||
PanelUtils.addColoredQuad(ret, new Vector3f(sizeX, yOffset, (sizeY - sizeX) / 2),
|
||||
new Vector3f(0, yOffset, (sizeY - sizeX) / 2),
|
||||
new Vector3f(0, yOffset, (sizeY + sizeX) / 2),
|
||||
new Vector3f(sizeX, yOffset, (sizeY + sizeX) / 2), EnumFacing.UP, GRAY);
|
||||
Matrix4 rot = new Matrix4();
|
||||
rot.translate((sizeX)/2, -.01F, sizeY/2);
|
||||
rot.rotate(Math.PI*1/16*(active?-1:1), 1, 0, 0);
|
||||
PanelUtils.addColoredBox(GRAY, GRAY, null, new Vector3f(-rodRadius, 0, -rodRadius), new Vector3f(2*rodRadius, rodLength, 2*rodRadius), ret,
|
||||
rot.translate((sizeX) / 2, -.01F, sizeY / 2);
|
||||
rot.rotate(Math.PI * 1 / 16 * (active ? -1 : 1), 1, 0, 0);
|
||||
PanelUtils.addColoredBox(GRAY, GRAY, null, new Vector3f(-rodRadius, 0, -rodRadius), new Vector3f(2 * rodRadius, rodLength, 2 * rodRadius), ret,
|
||||
false, rot);
|
||||
return ret;
|
||||
}
|
||||
|
@ -108,8 +113,8 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb==null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x+sizeX, getHeight(), y +sizeY);
|
||||
if (aabb == null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x + sizeX, getHeight(), y + sizeY);
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
@ -128,39 +133,39 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
|
||||
@Override
|
||||
public void registerRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
if (id==rsOutputId) {
|
||||
if (id == rsOutputId) {
|
||||
rsOut.add(out);
|
||||
out.accept((int) rsOutputChannel, (byte) (active?15:0));
|
||||
out.accept((int) rsOutputChannel, (byte) (active ? 15 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
|
||||
if (id==rsOutputId) {
|
||||
if (id == rsOutputId) {
|
||||
rsOut.remove(out);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHeight() {
|
||||
return .0625F*3/2;
|
||||
return .0625F * 3 / 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
double zOffset = (aabb.maxZ-aabb.minZ-sizeX)/2;
|
||||
int left = (int) (gui.getX0()+aabb.minX*gui.panelSize);
|
||||
int top = (int) Math.ceil(gui.getY0()+(aabb.minZ+zOffset)*gui.panelSize);
|
||||
int right = (int) (gui.getX0()+aabb.maxX*gui.panelSize);
|
||||
int bottom = (int) Math.floor(gui.getY0()+(aabb.maxZ-zOffset)*gui.panelSize);
|
||||
double zOffset = (aabb.maxZ - aabb.minZ - sizeX) / 2;
|
||||
int left = (int) (gui.getX0() + aabb.minX * gui.panelSize);
|
||||
int top = (int) Math.ceil(gui.getY0() + (aabb.minZ + zOffset) * gui.panelSize);
|
||||
int right = (int) (gui.getX0() + aabb.maxX * gui.panelSize);
|
||||
int bottom = (int) Math.floor(gui.getY0() + (aabb.maxZ - zOffset) * gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, GRAY_INT);
|
||||
double xOffset = (aabb.maxX-aabb.minX-rodRadius)/2;
|
||||
left = (int) (gui.getX0()+(aabb.minX+xOffset)*gui.panelSize);
|
||||
top = (int) Math.floor(gui.getY0()+(aabb.minZ+aabb.maxZ)/2*gui.panelSize);
|
||||
right = (int) (gui.getX0()+(aabb.maxX-xOffset)*gui.panelSize);
|
||||
bottom = (int) Math.ceil(gui.getY0()+aabb.maxZ*gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, GRAY_INT+0x101010);
|
||||
double xOffset = (aabb.maxX - aabb.minX - rodRadius) / 2;
|
||||
left = (int) (gui.getX0() + (aabb.minX + xOffset) * gui.panelSize);
|
||||
top = (int) Math.floor(gui.getY0() + (aabb.minZ + aabb.maxZ) / 2 * gui.panelSize);
|
||||
right = (int) (gui.getX0() + (aabb.maxX - xOffset) * gui.panelSize);
|
||||
bottom = (int) Math.ceil(gui.getY0() + aabb.maxZ * gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, GRAY_INT + 0x101010);
|
||||
|
||||
}
|
||||
|
||||
|
@ -173,8 +178,8 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
active = on;
|
||||
tile.markDirty();
|
||||
tile.triggerRenderUpdate();
|
||||
for (BiConsumer<Integer, Byte> rs:rsOut) {
|
||||
rs.accept((int)rsOutputChannel, (byte)(active?15:0));
|
||||
for (BiConsumer<Integer, Byte> rs : rsOut) {
|
||||
rs.accept((int) rsOutputChannel, (byte) (active ? 15 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,49 +208,49 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
|
|||
@Override
|
||||
public void applyConfigOption(ConfigType type, int id, NBTBase value) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
if (id==0) {
|
||||
rsOutputChannel = ((NBTTagByte)value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id==0) {
|
||||
rsOutputId = ((NBTTagInt)value).getInt();
|
||||
}
|
||||
break;
|
||||
case RS_CHANNEL:
|
||||
if (id == 0) {
|
||||
rsOutputChannel = ((NBTTagByte) value).getByte();
|
||||
}
|
||||
break;
|
||||
case INT:
|
||||
if (id == 0) {
|
||||
rsOutputId = ((NBTTagInt) value).getInt();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigName(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
return null;
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc."+(id==0?"red":(id==1?"green":"blue")));
|
||||
default:
|
||||
return "INVALID";
|
||||
case RS_CHANNEL:
|
||||
case INT:
|
||||
return null;
|
||||
case FLOAT:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc." + (id == 0 ? "red" : (id == 1 ? "green" : "blue")));
|
||||
default:
|
||||
return "INVALID";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fomatConfigDescription(ConfigType type, int id) {
|
||||
switch (type) {
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID+".desc.rsid_info");
|
||||
case FLOAT:
|
||||
return null;
|
||||
default:
|
||||
return "INVALID?";
|
||||
case RS_CHANNEL:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rschannel_info");
|
||||
case INT:
|
||||
return I18n.format(IndustrialWires.MODID + ".desc.rsid_info");
|
||||
case FLOAT:
|
||||
return null;
|
||||
default:
|
||||
return "INVALID?";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RSChannelConfig[] getRSChannelOptions() {
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte)rsOutputChannel)};
|
||||
return new RSChannelConfig[]{new RSChannelConfig("channel", 0, 0, (byte) rsOutputChannel)};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,7 @@ public class RecipeCoilLength implements IRecipe {
|
|||
public final ItemStack coil;
|
||||
public final ItemStack cable;
|
||||
private final int maxLength;
|
||||
|
||||
public RecipeCoilLength(int meta) {
|
||||
coil = new ItemStack(IndustrialWires.coil, 1, meta);
|
||||
cable = ItemIC2Coil.getUninsulatedCable(coil);
|
||||
|
@ -41,7 +42,7 @@ public class RecipeCoilLength implements IRecipe {
|
|||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
|
||||
int l = getLength(inv);
|
||||
return l>0;
|
||||
return l > 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -71,8 +72,8 @@ public class RecipeCoilLength implements IRecipe {
|
|||
for (int i = 0; i < ret.size() && length > 0; i++) {
|
||||
ItemStack curr = inv.getStackInSlot(i);
|
||||
if (OreDictionary.itemMatches(curr, coil, false)) {
|
||||
length-=ItemIC2Coil.getLength(curr);
|
||||
if (length<0) {
|
||||
length -= ItemIC2Coil.getLength(curr);
|
||||
if (length < 0) {
|
||||
ItemStack currStack = new ItemStack(IndustrialWires.coil, 1);
|
||||
ret.set(i, currStack);
|
||||
ItemIC2Coil.setLength(currStack, -length);
|
||||
|
@ -83,12 +84,13 @@ public class RecipeCoilLength implements IRecipe {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getLength(InventoryCrafting inv) {
|
||||
int cableLength = 0;
|
||||
for (int i = 0;i<inv.getSizeInventory();i++) {
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack curr = inv.getStackInSlot(i);
|
||||
if (OreDictionary.itemMatches(curr, coil, false)) {
|
||||
cableLength+=ItemIC2Coil.getLength(curr);
|
||||
cableLength += ItemIC2Coil.getLength(curr);
|
||||
} else if (OreDictionary.itemMatches(curr, cable, false)) {
|
||||
cableLength++;
|
||||
} else if (!curr.isEmpty()) {
|
||||
|
|
|
@ -55,7 +55,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemIC2Coil extends Item implements IWireCoil{
|
||||
public class ItemIC2Coil extends Item implements IWireCoil {
|
||||
public final static String[] subNames = {"tin", "copper", "gold", "hv", "glass"};
|
||||
public final static String lengthKey = "wireLength";
|
||||
|
||||
|
@ -64,11 +64,12 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
setHasSubtypes(true);
|
||||
this.setCreativeTab(IndustrialWires.creativeTab);
|
||||
setMaxStackSize(64);
|
||||
ImmersiveEngineering.registerByFullName(this, IndustrialWires.MODID+":"+"ic2WireCoil");
|
||||
ImmersiveEngineering.registerByFullName(this, IndustrialWires.MODID + ":" + "ic2WireCoil");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
for (int i = 0;i<subNames.length;i++) {
|
||||
for (int i = 0; i < subNames.length; i++) {
|
||||
ItemStack tmp = new ItemStack(this, 1, i);
|
||||
setLength(tmp, getMaxWireLength(tmp));
|
||||
subItems.add(tmp);
|
||||
|
@ -78,23 +79,29 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return this.getUnlocalizedName()+"."+subNames[stack.getMetadata()];
|
||||
return this.getUnlocalizedName() + "." + subNames[stack.getMetadata()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public WireType getWireType(ItemStack stack) {
|
||||
return IC2Wiretype.IC2_TYPES[stack.getMetadata()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
|
||||
list.add(I18n.format(IndustrialWires.MODID+".desc.wireLength", getLength(stack)));
|
||||
list.add(I18n.format(IndustrialWires.MODID+".desc.recipe"));
|
||||
if(stack.getTagCompound()!=null && stack.getTagCompound().hasKey("linkingPos")) {
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".desc.wireLength", getLength(stack)));
|
||||
int transferRate = IC2Wiretype.IC2_TYPES[stack.getMetadata()].getTransferRate();
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate", transferRate));
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate", transferRate / 8));
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("linkingPos")) {
|
||||
int[] link = stack.getTagCompound().getIntArray("linkingPos");
|
||||
if (link.length > 3) {
|
||||
list.add(I18n.format(Lib.DESC_INFO+"attachedToDim", link[1],link[2],link[3],link[0]));
|
||||
list.add(I18n.format(Lib.DESC_INFO + "attachedToDim", link[1], link[2], link[3], link[0]));
|
||||
}
|
||||
}
|
||||
list.add(I18n.format(IndustrialWires.MODID + ".desc.recipe"));
|
||||
}
|
||||
|
||||
//mostly copied from IE
|
||||
@Nonnull
|
||||
@Override
|
||||
|
@ -106,50 +113,50 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
return EnumActionResult.FAIL;
|
||||
}
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if(tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable)tileEntity).canConnect()) {
|
||||
TargetingInfo target = new TargetingInfo(side, hitX,hitY,hitZ);
|
||||
if (tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable) tileEntity).canConnect()) {
|
||||
TargetingInfo target = new TargetingInfo(side, hitX, hitY, hitZ);
|
||||
WireType wire = getWireType(stack);
|
||||
BlockPos masterPos = ((IImmersiveConnectable)tileEntity).getConnectionMaster(wire, target);
|
||||
BlockPos masterPos = ((IImmersiveConnectable) tileEntity).getConnectionMaster(wire, target);
|
||||
tileEntity = world.getTileEntity(masterPos);
|
||||
if( !(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable)tileEntity).canConnect()) {
|
||||
if (!(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntity).canConnect()) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
if( !((IImmersiveConnectable)tileEntity).canConnectCable(wire, target)) {
|
||||
if (!((IImmersiveConnectable) tileEntity).canConnectCable(wire, target)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongCable"));
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if(!ItemNBTHelper.hasKey(stack, "linkingPos")) {
|
||||
ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(),masterPos.getX(),masterPos.getY(),masterPos.getZ()});
|
||||
if (!ItemNBTHelper.hasKey(stack, "linkingPos")) {
|
||||
ItemNBTHelper.setIntArray(stack, "linkingPos", new int[]{world.provider.getDimension(), masterPos.getX(), masterPos.getY(), masterPos.getZ()});
|
||||
target.writeToNBT(stack.getTagCompound());
|
||||
} else {
|
||||
WireType type = getWireType(stack);
|
||||
int[] array = ItemNBTHelper.getIntArray(stack, "linkingPos");
|
||||
BlockPos linkPos = new BlockPos(array[1],array[2],array[3]);
|
||||
BlockPos linkPos = new BlockPos(array[1], array[2], array[3]);
|
||||
TileEntity tileEntityLinkingPos = world.getTileEntity(linkPos);
|
||||
int distanceSq = (int) Math.ceil( linkPos.distanceSq(masterPos) );
|
||||
if(array[0]!=world.provider.getDimension()) {
|
||||
int distanceSq = (int) Math.ceil(linkPos.distanceSq(masterPos));
|
||||
if (array[0] != world.provider.getDimension()) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongDimension"));
|
||||
} else if(linkPos.equals(masterPos)) {
|
||||
} else if (linkPos.equals(masterPos)) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "sameConnection"));
|
||||
} else if( distanceSq > (type.getMaxLength()*type.getMaxLength())) {
|
||||
} else if (distanceSq > (type.getMaxLength() * type.getMaxLength())) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "tooFar"));
|
||||
} else if(!(tileEntityLinkingPos instanceof IImmersiveConnectable)||!((IImmersiveConnectable) tileEntityLinkingPos).canConnectCable(type, TargetingInfo.readFromNBT(stack.getTagCompound()))) {
|
||||
} else if (!(tileEntityLinkingPos instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntityLinkingPos).canConnectCable(type, TargetingInfo.readFromNBT(stack.getTagCompound()))) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "invalidPoint"));
|
||||
} else {
|
||||
IImmersiveConnectable nodeHere = (IImmersiveConnectable)tileEntity;
|
||||
IImmersiveConnectable nodeLink = (IImmersiveConnectable)tileEntityLinkingPos;
|
||||
IImmersiveConnectable nodeHere = (IImmersiveConnectable) tileEntity;
|
||||
IImmersiveConnectable nodeLink = (IImmersiveConnectable) tileEntityLinkingPos;
|
||||
boolean connectionExists = false;
|
||||
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(world, Utils.toCC(nodeHere));
|
||||
if(outputs!=null) {
|
||||
for(Connection con : outputs) {
|
||||
if(con.end.equals(Utils.toCC(nodeLink))) {
|
||||
if (outputs != null) {
|
||||
for (Connection con : outputs) {
|
||||
if (con.end.equals(Utils.toCC(nodeLink))) {
|
||||
connectionExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(connectionExists) {
|
||||
if (connectionExists) {
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "connectionExists"));
|
||||
} else {
|
||||
Vec3d rtOff0 = nodeHere.getRaytraceOffset(nodeLink).addVector(masterPos.getX(), masterPos.getY(), masterPos.getZ());
|
||||
|
@ -157,11 +164,11 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
Set<BlockPos> ignore = new HashSet<>();
|
||||
ignore.addAll(nodeHere.getIgnored(nodeLink));
|
||||
ignore.addAll(nodeLink.getIgnored(nodeHere));
|
||||
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore)==null;
|
||||
if(canSee) {
|
||||
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore) == null;
|
||||
if (canSee) {
|
||||
int lengthOnStack = getLength(stack);
|
||||
int length = (int)Math.sqrt(distanceSq);
|
||||
if (length<=lengthOnStack) {
|
||||
int length = (int) Math.sqrt(distanceSq);
|
||||
if (length <= lengthOnStack) {
|
||||
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), length, type);
|
||||
|
||||
|
@ -170,21 +177,21 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
IESaveData.setDirty(world.provider.getDimension());
|
||||
player.addStat(IEAchievements.connectWire);
|
||||
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
if (length<lengthOnStack) {
|
||||
setLength(stack, lengthOnStack-length);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (length < lengthOnStack) {
|
||||
setLength(stack, lengthOnStack - length);
|
||||
} else {
|
||||
player.setHeldItem(hand, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
((TileEntity)nodeHere).markDirty();
|
||||
((TileEntity) nodeHere).markDirty();
|
||||
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
|
||||
IBlockState state = world.getBlockState(masterPos);
|
||||
world.notifyBlockUpdate(masterPos, state,state, 3);
|
||||
((TileEntity)nodeLink).markDirty();
|
||||
world.notifyBlockUpdate(masterPos, state, state, 3);
|
||||
((TileEntity) nodeLink).markDirty();
|
||||
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
|
||||
state = world.getBlockState(linkPos);
|
||||
world.notifyBlockUpdate(linkPos, state,state, 3);
|
||||
world.notifyBlockUpdate(linkPos, state, state, 3);
|
||||
} else {
|
||||
player.sendMessage(new TextComponentTranslation(IndustrialWires.MODID + ".chat.tooLong"));
|
||||
}
|
||||
|
@ -204,18 +211,22 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
public static void setLength(ItemStack i, int blocks) {
|
||||
i.setTagInfo(lengthKey, new NBTTagInt(blocks));
|
||||
}
|
||||
|
||||
public static int getLength(ItemStack i) {
|
||||
if (i.getTagCompound()==null) {
|
||||
if (i.getTagCompound() == null) {
|
||||
setLength(i, 4);
|
||||
}
|
||||
return i.getTagCompound().getInteger(lengthKey);
|
||||
}
|
||||
|
||||
public static int getMaxWireLength(ItemStack i) {
|
||||
return IWConfig.maxLengthOnCoil[i.getItemDamage()];
|
||||
}
|
||||
|
||||
public static ItemStack getUninsulatedCable(ItemStack i) {
|
||||
switch (i.getMetadata()) {
|
||||
case 0:
|
||||
|
|
|
@ -100,7 +100,7 @@ public class ItemPanelComponent extends Item {
|
|||
outer.setTag("data", inner);
|
||||
int meta = getMetaFromPC(inner.getString("type"));
|
||||
removeIrrelevantTags(inner);
|
||||
if (meta>=0) {
|
||||
if (meta >= 0) {
|
||||
ItemStack ret = new ItemStack(IndustrialWires.panelComponent, 1, meta);
|
||||
ret.setTagCompound(outer);
|
||||
return ret;
|
||||
|
@ -116,7 +116,7 @@ public class ItemPanelComponent extends Item {
|
|||
}
|
||||
|
||||
private static int getMetaFromPC(String pc) {
|
||||
for (int i = 0;i<types.length;i++) {
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (pc.equals(types[i])) {
|
||||
return i;
|
||||
}
|
||||
|
@ -146,8 +146,8 @@ public class ItemPanelComponent extends Item {
|
|||
@Override
|
||||
@Nonnull
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) {
|
||||
if(!worldIn.isRemote) {
|
||||
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand==EnumHand.MAIN_HAND?1:0);
|
||||
if (!worldIn.isRemote) {
|
||||
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand == EnumHand.MAIN_HAND ? 1 : 0);
|
||||
}
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ public class MessageComponentSync implements IMessage {
|
|||
this.data = data;
|
||||
}
|
||||
|
||||
public MessageComponentSync() {}
|
||||
public MessageComponentSync() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
@ -66,6 +67,7 @@ public class MessageComponentSync implements IMessage {
|
|||
ctx.getServerHandler().player.getServerWorld().addScheduledTask(() -> handle(message, ctx.getServerHandler().player));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handle(MessageComponentSync msg, EntityPlayerMP player) {
|
||||
ItemStack held = player.getHeldItem(msg.hand);
|
||||
if (!held.isEmpty() && held.getItem() == IndustrialWires.panelComponent) {
|
||||
|
|
|
@ -38,7 +38,8 @@ public class MessageGUIInteract implements IMessage {
|
|||
this.data = data;
|
||||
}
|
||||
|
||||
public MessageGUIInteract() {}
|
||||
public MessageGUIInteract() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
@ -60,8 +61,9 @@ public class MessageGUIInteract implements IMessage {
|
|||
ctx.getServerHandler().player.getServerWorld().addScheduledTask(() -> handle(message, ctx.getServerHandler().player));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handle(MessageGUIInteract msg, EntityPlayerMP player) {
|
||||
if (player.getDistanceSqToCenter(msg.pos)<100) {//closer than 10 blocks
|
||||
if (player.getDistanceSqToCenter(msg.pos) < 100) {//closer than 10 blocks
|
||||
TileEntity te = player.world.getTileEntity(msg.pos);
|
||||
if (te instanceof INetGUI) {
|
||||
((INetGUI) te).onChange(msg.data, player);
|
||||
|
|
|
@ -39,7 +39,8 @@ public class MessagePanelInteract implements IMessage {
|
|||
hitRelative = hit;
|
||||
}
|
||||
|
||||
public MessagePanelInteract() {}
|
||||
public MessagePanelInteract() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
@ -63,8 +64,9 @@ public class MessagePanelInteract implements IMessage {
|
|||
ctx.getServerHandler().player.getServerWorld().addScheduledTask(() -> handle(message, ctx.getServerHandler().player));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handle(MessagePanelInteract msg, EntityPlayerMP player) {
|
||||
if (player.getDistanceSqToCenter(msg.pos)<100) {//closer than 10 blocks
|
||||
if (player.getDistanceSqToCenter(msg.pos) < 100) {//closer than 10 blocks
|
||||
TileEntity te = player.world.getTileEntity(msg.pos);
|
||||
if (te instanceof TileEntityPanel) {
|
||||
((TileEntityPanel) te).interactServer(msg.hitRelative, msg.pcId, player);
|
||||
|
|
|
@ -41,7 +41,8 @@ public class MessageTileSyncIW implements IMessage {
|
|||
this.nbt = nbt;
|
||||
}
|
||||
|
||||
public MessageTileSyncIW() {}
|
||||
public MessageTileSyncIW() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
|
|
@ -21,27 +21,31 @@ package malte0811.industrialWires.util;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public final class Beziers {
|
||||
private Beziers() {}
|
||||
private Beziers() {
|
||||
}
|
||||
|
||||
public static Vec3d getPoint(double t, Vec3d[] controls) {
|
||||
if (t==0) {
|
||||
if (t == 0) {
|
||||
return controls[0];
|
||||
} else if (t==1) {
|
||||
return controls[controls.length-1];
|
||||
} else if (t == 1) {
|
||||
return controls[controls.length - 1];
|
||||
}
|
||||
Vec3d ret = new Vec3d(0, 0, 0);
|
||||
int n = controls.length-1;
|
||||
for (int i = 0;i<=n;i++) {
|
||||
double coeff = binomialCoeff(n, i)*Math.pow(t, i)*Math.pow(1-t, n-i);
|
||||
ret = ret.addVector(coeff*controls[i].xCoord, coeff*controls[i].yCoord, coeff*controls[i].zCoord);
|
||||
int n = controls.length - 1;
|
||||
for (int i = 0; i <= n; i++) {
|
||||
double coeff = binomialCoeff(n, i) * Math.pow(t, i) * Math.pow(1 - t, n - i);
|
||||
ret = ret.addVector(coeff * controls[i].xCoord, coeff * controls[i].yCoord, coeff * controls[i].zCoord);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int binomialCoeff(int n, int k) {
|
||||
return factorial(n-k+1, n)/factorial(2, k);
|
||||
return factorial(n - k + 1, n) / factorial(2, k);
|
||||
}
|
||||
|
||||
public static int factorial(int start, int end) {
|
||||
int ret = 1;
|
||||
for (int i = start;i<=end;i++) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
ret *= i;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -21,29 +21,38 @@ import blusunrize.immersiveengineering.common.Config;
|
|||
import malte0811.industrialWires.IWConfig.MechConversion;
|
||||
|
||||
public class ConversionUtil {
|
||||
private ConversionUtil() {}
|
||||
public static double rotPerIf() {
|
||||
return 1/Config.IEConfig.Machines.dynamo_output;
|
||||
private ConversionUtil() {
|
||||
}
|
||||
|
||||
public static double rotPerIf() {
|
||||
return 1 / Config.IEConfig.Machines.dynamo_output;
|
||||
}
|
||||
|
||||
public static double ifPerRot() {
|
||||
return Config.IEConfig.Machines.dynamo_output;
|
||||
}
|
||||
|
||||
public static double euPerIfIdeal() {
|
||||
return MechConversion.euPerIf;
|
||||
}
|
||||
|
||||
public static double ifPerEuIdeal() {
|
||||
return 1/MechConversion.euPerIf;
|
||||
return 1 / MechConversion.euPerIf;
|
||||
}
|
||||
|
||||
public static double euPerKin() {
|
||||
return 1/euPerKin();
|
||||
return 1 / euPerKin();
|
||||
}
|
||||
|
||||
public static double kinPerEu() {
|
||||
return MechConversion.kinPerEu;
|
||||
}
|
||||
|
||||
public static double kinPerRot() {
|
||||
return kinPerEu()*euPerIfIdeal()*ifPerRot();
|
||||
return kinPerEu() * euPerIfIdeal() * ifPerRot();
|
||||
}
|
||||
|
||||
public static double rotPerKin() {
|
||||
return 1/kinPerRot();
|
||||
return 1 / kinPerRot();
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ public class DualEnergyStorage {
|
|||
public DualEnergyStorage(double maxEU, double maxInEU, double maxOutEU) {
|
||||
this(0, maxEU, maxInEU, maxOutEU);
|
||||
}
|
||||
|
||||
public DualEnergyStorage(double storedEU, double maxEU, double maxInEU, double maxOutEU) {
|
||||
this.maxEU = maxEU;
|
||||
this.maxInEU = maxInEU;
|
||||
|
@ -103,15 +104,16 @@ public class DualEnergyStorage {
|
|||
}
|
||||
|
||||
public void writeToNbt(NBTTagCompound nbtOuter, String key) {
|
||||
NBTTagCompound nbt = key==null?nbtOuter:new NBTTagCompound();
|
||||
NBTTagCompound nbt = key == null ? nbtOuter : new NBTTagCompound();
|
||||
nbt.setDouble("stored", storedEU);
|
||||
nbt.setDouble("maxStored", maxEU);
|
||||
nbt.setDouble("maxIn", maxInEU);
|
||||
nbt.setDouble("maxOut", maxOutEU);
|
||||
if (key!=null) {
|
||||
if (key != null) {
|
||||
nbtOuter.setTag(key, nbt);
|
||||
}
|
||||
}
|
||||
|
||||
public static DualEnergyStorage readFromNBT(NBTTagCompound nbt) {
|
||||
return new DualEnergyStorage(nbt.getDouble("stored"), nbt.getDouble("maxStored"), nbt.getDouble("maxIn"), nbt.getDouble("maxOut"));
|
||||
}
|
||||
|
|
|
@ -33,16 +33,15 @@ import java.util.Set;
|
|||
import java.util.function.BiPredicate;
|
||||
|
||||
public final class MiscUtils {
|
||||
private MiscUtils() {}
|
||||
public static Set<ImmersiveNetHandler.Connection> genConnBlockstate(Set<ImmersiveNetHandler.Connection> conns, World world)
|
||||
{
|
||||
private MiscUtils() {
|
||||
}
|
||||
|
||||
public static Set<ImmersiveNetHandler.Connection> genConnBlockstate(Set<ImmersiveNetHandler.Connection> conns, World world) {
|
||||
if (conns == null)
|
||||
return ImmutableSet.of();
|
||||
Set<ImmersiveNetHandler.Connection> ret = new HashSet<ImmersiveNetHandler.Connection>()
|
||||
{
|
||||
Set<ImmersiveNetHandler.Connection> ret = new HashSet<ImmersiveNetHandler.Connection>() {
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof HashSet))
|
||||
|
@ -56,10 +55,9 @@ public final class MiscUtils {
|
|||
return true;
|
||||
}
|
||||
};
|
||||
for (ImmersiveNetHandler.Connection c : conns)
|
||||
{
|
||||
for (ImmersiveNetHandler.Connection c : conns) {
|
||||
IImmersiveConnectable end = ApiUtils.toIIC(c.end, world, false);
|
||||
if (end==null)
|
||||
if (end == null)
|
||||
continue;
|
||||
// generate subvertices
|
||||
c.getSubVertices(world);
|
||||
|
@ -68,6 +66,7 @@ public final class MiscUtils {
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<BlockPos> discoverLocal(World w, BlockPos here, BiPredicate<BlockPos, Integer> isValid) {
|
||||
List<BlockPos> ret = new ArrayList<>();
|
||||
List<BlockPos> open = new ArrayList<>();
|
||||
|
@ -76,9 +75,9 @@ public final class MiscUtils {
|
|||
BlockPos curr = open.get(0);
|
||||
ret.add(curr);
|
||||
open.remove(0);
|
||||
for (EnumFacing f:EnumFacing.VALUES) {
|
||||
for (EnumFacing f : EnumFacing.VALUES) {
|
||||
BlockPos next = curr.offset(f);
|
||||
if (!open.contains(next)&&!ret.contains(next)&&isValid.test(next, ret.size())) {
|
||||
if (!open.contains(next) && !ret.contains(next) && isValid.test(next, ret.size())) {
|
||||
open.add(next);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,18 +28,20 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class IC2Wiretype extends WireType{
|
||||
public class IC2Wiretype extends WireType {
|
||||
final int type;
|
||||
final int[] ic2Rates = {32*8, 128*8, 512*8, 2048*8, 8192*8};
|
||||
final int[] ic2Rates = {32 * 8, 128 * 8, 512 * 8, 2048 * 8, 8192 * 8};
|
||||
final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
|
||||
final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass"};
|
||||
final double[] lossPerBlock = {.2, .2, .4, .8, .025};
|
||||
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625, .75*.03125};
|
||||
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625, .75 * .03125};
|
||||
public static final IC2Wiretype[] IC2_TYPES = {new IC2Wiretype(0), new IC2Wiretype(1), new IC2Wiretype(2), new IC2Wiretype(3), new IC2Wiretype(4)};
|
||||
|
||||
public IC2Wiretype(int ordinal) {
|
||||
super();
|
||||
this.type = ordinal;
|
||||
}
|
||||
|
||||
/**
|
||||
* In this case, this does not return the loss RATIO but the loss PER BLOCK
|
||||
*/
|
||||
|
@ -47,45 +49,55 @@ public class IC2Wiretype extends WireType{
|
|||
public double getLossRatio() {
|
||||
return lossPerBlock[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransferRate() {
|
||||
return ic2Rates[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour(Connection connection) {
|
||||
return ic2Colors[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getSlack() {
|
||||
return type==2?1.03:1.005;
|
||||
return type == 2 ? 1.03 : 1.005;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getIcon(Connection connection) {
|
||||
return iconDefaultWire;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLength() {
|
||||
return IWConfig.maxLengthPerConn[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWireCoil(ImmersiveNetHandler.Connection con) {
|
||||
ItemStack ret = getWireCoil();
|
||||
ItemIC2Coil.setLength(ret, con.length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWireCoil() {
|
||||
return new ItemStack(IndustrialWires.coil,1,type);
|
||||
return new ItemStack(IndustrialWires.coil, 1, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
return ic2Names[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRenderDiameter() {
|
||||
return ic2RenderDiameter[type];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnergyWire() {
|
||||
return true;
|
||||
|
|
|
@ -22,11 +22,11 @@ tile.industrialwires.control_panel.rs_wire.name=Redstone Wire Controller
|
|||
tile.industrialwires.control_panel.dummy.name=Panel Connector
|
||||
tile.industrialwires.control_panel.creator.name=Control Panel Creator
|
||||
|
||||
item.industrialwires.ic2wireCoil.tin.name=Tin Wire Coil
|
||||
item.industrialwires.ic2wireCoil.copper.name=Copper Wire Coil
|
||||
item.industrialwires.ic2wireCoil.gold.name=Gold Wire Coil
|
||||
item.industrialwires.ic2wireCoil.hv.name=IC2 HV Wire Coil
|
||||
item.industrialwires.ic2wireCoil.glass.name=Glass Fiber Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.tin.name=Tin Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.copper.name=Copper Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.gold.name=Gold Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.hv.name=IC2 HV Wire Coil
|
||||
item.industrialwires.ic2_wire_coil.glass.name=Glass Fiber Wire Coil
|
||||
|
||||
item.industrialwires.panel_component.lighted_button.name=Lighted Button
|
||||
item.industrialwires.panel_component.label.name=Label
|
||||
|
@ -53,6 +53,7 @@ industrialwires.desc.red=Red
|
|||
industrialwires.desc.green=Green
|
||||
industrialwires.desc.blue=Blue
|
||||
industrialwires.desc.length=Length
|
||||
industrialwires.tooltip.rsChannel_info=The color of the channel to output the signal to
|
||||
|
||||
industrialwires.tooltip.horizontal=Horizontal
|
||||
industrialwires.tooltip.vertical=Vertical
|
||||
|
@ -61,6 +62,11 @@ industrialwires.tooltip.text=Text: %1s
|
|||
industrialwires.tooltip.latching=Stays on indefinitely
|
||||
industrialwires.tooltip.instantaneous=Turns off after half a second
|
||||
industrialwires.tooltip.length=Length: %1s
|
||||
industrialwires.tooltip.power_tier=Power Tier: %s
|
||||
industrialwires.tooltip.eu_per_tick=%s EU/t
|
||||
industrialwires.tooltip.transfer_rate=Burns at %s EU/t
|
||||
industrialwires.tooltip.input_rate=%s EU/t per connector
|
||||
|
||||
|
||||
industrialwires.chat.tooLong=This coil does not contain enough wire for this connection
|
||||
industrialwires.chat.stackSize=Linking is only possible with a stack of size 1
|
||||
|
|
Loading…
Reference in a new issue