mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
power diodes with configurable throughput
This commit is contained in:
parent
bfdd790faf
commit
8c36f6e36d
@ -105,19 +105,24 @@ public class PowerNet implements IPowerNet {
|
|||||||
if(this.subscribers.isEmpty())
|
if(this.subscribers.isEmpty())
|
||||||
return power;
|
return power;
|
||||||
|
|
||||||
|
List<IEnergyConnector> subList = new ArrayList(subscribers);
|
||||||
|
|
||||||
List<Long> weight = new ArrayList();
|
List<Long> weight = new ArrayList();
|
||||||
long totalReq = 0;
|
long totalReq = 0;
|
||||||
|
|
||||||
for(IEnergyConnector con : this.subscribers) {
|
for(IEnergyConnector con : subList) {
|
||||||
long req = con.getTransferWeight();
|
long req = con.getTransferWeight();
|
||||||
weight.add(req);
|
weight.add(req);
|
||||||
totalReq += req;
|
totalReq += req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(totalReq == 0)
|
||||||
|
return power;
|
||||||
|
|
||||||
long totalGiven = 0;
|
long totalGiven = 0;
|
||||||
|
|
||||||
for(int i = 0; i < this.subscribers.size(); i++) {
|
for(int i = 0; i < subList.size(); i++) {
|
||||||
IEnergyConnector con = this.subscribers.get(i);
|
IEnergyConnector con = subList.get(i);
|
||||||
long req = weight.get(i);
|
long req = weight.get(i);
|
||||||
double fraction = (double)req / (double)totalReq;
|
double fraction = (double)req / (double)totalReq;
|
||||||
|
|
||||||
|
|||||||
@ -716,6 +716,7 @@ public class ModBlocks {
|
|||||||
public static Block substation;
|
public static Block substation;
|
||||||
public static Block cable_switch;
|
public static Block cable_switch;
|
||||||
public static Block cable_detector;
|
public static Block cable_detector;
|
||||||
|
public static Block cable_diode;
|
||||||
public static Block machine_detector;
|
public static Block machine_detector;
|
||||||
public static Block rf_cable;
|
public static Block rf_cable;
|
||||||
public static Block oil_duct_solid;
|
public static Block oil_duct_solid;
|
||||||
@ -1833,6 +1834,7 @@ public class ModBlocks {
|
|||||||
substation = new Substation(Material.iron).setBlockName("substation").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":substation");
|
substation = new Substation(Material.iron).setBlockName("substation").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":substation");
|
||||||
cable_switch = new CableSwitch(Material.iron).setBlockName("cable_switch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
cable_switch = new CableSwitch(Material.iron).setBlockName("cable_switch").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||||
cable_detector = new CableDetector(Material.iron).setBlockName("cable_detector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
cable_detector = new CableDetector(Material.iron).setBlockName("cable_detector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
|
||||||
|
cable_diode = new CableDiode(Material.iron).setBlockName("cable_diode").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":cable_diode");
|
||||||
machine_detector = new PowerDetector(Material.iron).setBlockName("machine_detector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_detector_off");
|
machine_detector = new PowerDetector(Material.iron).setBlockName("machine_detector").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_detector_off");
|
||||||
oil_duct_solid = new OilDuctSolid(Material.iron).setBlockName("oil_duct_solid").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":oil_duct_solid_alt");
|
oil_duct_solid = new OilDuctSolid(Material.iron).setBlockName("oil_duct_solid").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":oil_duct_solid_alt");
|
||||||
oil_duct = new BlockOilDuct(Material.iron).setBlockName("oil_duct").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":oil_duct_icon_alt");
|
oil_duct = new BlockOilDuct(Material.iron).setBlockName("oil_duct").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":oil_duct_icon_alt");
|
||||||
@ -2935,6 +2937,7 @@ public class ModBlocks {
|
|||||||
GameRegistry.registerBlock(substation, ItemBlockBase.class, substation.getUnlocalizedName());
|
GameRegistry.registerBlock(substation, ItemBlockBase.class, substation.getUnlocalizedName());
|
||||||
GameRegistry.registerBlock(cable_switch, cable_switch.getUnlocalizedName());
|
GameRegistry.registerBlock(cable_switch, cable_switch.getUnlocalizedName());
|
||||||
GameRegistry.registerBlock(cable_detector, cable_detector.getUnlocalizedName());
|
GameRegistry.registerBlock(cable_detector, cable_detector.getUnlocalizedName());
|
||||||
|
GameRegistry.registerBlock(cable_diode, cable_diode.getUnlocalizedName());
|
||||||
GameRegistry.registerBlock(machine_detector, machine_detector.getUnlocalizedName());
|
GameRegistry.registerBlock(machine_detector, machine_detector.getUnlocalizedName());
|
||||||
GameRegistry.registerBlock(rf_cable, rf_cable.getUnlocalizedName());
|
GameRegistry.registerBlock(rf_cable, rf_cable.getUnlocalizedName());
|
||||||
GameRegistry.registerBlock(oil_duct, oil_duct.getUnlocalizedName());
|
GameRegistry.registerBlock(oil_duct, oil_duct.getUnlocalizedName());
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
package com.hbm.blocks.machine;
|
package com.hbm.blocks.machine;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.lib.RefStrings;
|
import com.hbm.lib.RefStrings;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.machine.TileEntityDiFurnace;
|
import com.hbm.tileentity.machine.TileEntityDiFurnace;
|
||||||
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||||
|
import com.hbm.util.BobMathUtil;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@ -25,10 +30,11 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
|
|
||||||
public class MachineBattery extends BlockContainer {
|
public class MachineBattery extends BlockContainer implements ILookOverlay {
|
||||||
|
|
||||||
private final Random field_149933_a = new Random();
|
private final Random field_149933_a = new Random();
|
||||||
private static boolean keepInventory;
|
private static boolean keepInventory;
|
||||||
public long maxPower;
|
public long maxPower;
|
||||||
|
|
||||||
@ -83,10 +89,9 @@ public class MachineBattery extends BlockContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||||
{
|
return Item.getItemFromBlock(this);
|
||||||
return Item.getItemFromBlock(this);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockAdded(World world, int x, int y, int z) {
|
public void onBlockAdded(World world, int x, int y, int z) {
|
||||||
@ -95,8 +100,7 @@ public class MachineBattery extends BlockContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultDirection(World world, int x, int y, int z) {
|
private void setDefaultDirection(World world, int x, int y, int z) {
|
||||||
if(!world.isRemote)
|
if(!world.isRemote) {
|
||||||
{
|
|
||||||
Block block1 = world.getBlock(x, y, z - 1);
|
Block block1 = world.getBlock(x, y, z - 1);
|
||||||
Block block2 = world.getBlock(x, y, z + 1);
|
Block block2 = world.getBlock(x, y, z + 1);
|
||||||
Block block3 = world.getBlock(x - 1, y, z);
|
Block block3 = world.getBlock(x - 1, y, z);
|
||||||
@ -104,20 +108,16 @@ public class MachineBattery extends BlockContainer {
|
|||||||
|
|
||||||
byte b0 = 3;
|
byte b0 = 3;
|
||||||
|
|
||||||
if(block1.func_149730_j() && !block2.func_149730_j())
|
if(block1.func_149730_j() && !block2.func_149730_j()) {
|
||||||
{
|
|
||||||
b0 = 3;
|
b0 = 3;
|
||||||
}
|
}
|
||||||
if(block2.func_149730_j() && !block1.func_149730_j())
|
if(block2.func_149730_j() && !block1.func_149730_j()) {
|
||||||
{
|
|
||||||
b0 = 2;
|
b0 = 2;
|
||||||
}
|
}
|
||||||
if(block3.func_149730_j() && !block4.func_149730_j())
|
if(block3.func_149730_j() && !block4.func_149730_j()) {
|
||||||
{
|
|
||||||
b0 = 5;
|
b0 = 5;
|
||||||
}
|
}
|
||||||
if(block4.func_149730_j() && !block3.func_149730_j())
|
if(block4.func_149730_j() && !block3.func_149730_j()) {
|
||||||
{
|
|
||||||
b0 = 4;
|
b0 = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,26 +129,21 @@ public class MachineBattery extends BlockContainer {
|
|||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||||
|
|
||||||
if(i == 0)
|
if(i == 0) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||||
}
|
}
|
||||||
if(i == 1)
|
if(i == 1) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||||
}
|
}
|
||||||
if(i == 2)
|
if(i == 2) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||||
}
|
}
|
||||||
if(i == 3)
|
if(i == 3) {
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(itemStack.hasDisplayName())
|
if(itemStack.hasDisplayName()) {
|
||||||
{
|
((TileEntityDiFurnace) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||||
((TileEntityDiFurnace)world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +154,11 @@ public class MachineBattery extends BlockContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||||
if(world.isRemote)
|
if(world.isRemote) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
} else if(!player.isSneaking())
|
} else if(!player.isSneaking()) {
|
||||||
{
|
|
||||||
TileEntityMachineBattery entity = (TileEntityMachineBattery) world.getTileEntity(x, y, z);
|
TileEntityMachineBattery entity = (TileEntityMachineBattery) world.getTileEntity(x, y, z);
|
||||||
if(entity != null)
|
if(entity != null) {
|
||||||
{
|
|
||||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_battery, world, x, y, z);
|
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_battery, world, x, y, z);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -176,55 +168,62 @@ public class MachineBattery extends BlockContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
|
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) {
|
||||||
{
|
if(!keepInventory) {
|
||||||
if (!keepInventory)
|
TileEntityMachineBattery tileentityfurnace = (TileEntityMachineBattery) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
|
||||||
{
|
|
||||||
TileEntityMachineBattery tileentityfurnace = (TileEntityMachineBattery)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
|
|
||||||
|
|
||||||
if (tileentityfurnace != null)
|
if(tileentityfurnace != null) {
|
||||||
{
|
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
|
||||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
|
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||||
{
|
|
||||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
|
||||||
|
|
||||||
if (itemstack != null)
|
if(itemstack != null) {
|
||||||
{
|
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||||
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||||
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||||
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
|
||||||
|
|
||||||
while (itemstack.stackSize > 0)
|
while(itemstack.stackSize > 0) {
|
||||||
{
|
int j1 = this.field_149933_a.nextInt(21) + 10;
|
||||||
int j1 = this.field_149933_a.nextInt(21) + 10;
|
|
||||||
|
|
||||||
if (j1 > itemstack.stackSize)
|
if(j1 > itemstack.stackSize) {
|
||||||
{
|
j1 = itemstack.stackSize;
|
||||||
j1 = itemstack.stackSize;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
itemstack.stackSize -= j1;
|
itemstack.stackSize -= j1;
|
||||||
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||||
|
|
||||||
if (itemstack.hasTagCompound())
|
if(itemstack.hasTagCompound()) {
|
||||||
{
|
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float f3 = 0.05F;
|
float f3 = 0.05F;
|
||||||
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
|
entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3;
|
||||||
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
|
entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F;
|
||||||
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
|
entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3;
|
||||||
p_149749_1_.spawnEntityInWorld(entityitem);
|
p_149749_1_.spawnEntityInWorld(entityitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
|
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
|
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(!(te instanceof TileEntityMachineBattery))
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileEntityMachineBattery battery = (TileEntityMachineBattery) te;
|
||||||
|
|
||||||
|
List<String> text = new ArrayList();
|
||||||
|
text.add(BobMathUtil.getShortNumber(battery.getPower()) + " / " + BobMathUtil.getShortNumber(battery.getMaxPower()) + "HE");
|
||||||
|
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,6 +132,6 @@ public class MachineCatalyticCracker extends BlockDummyable implements ILookOver
|
|||||||
for(int i = 0; i < cracker.tanks.length; i++)
|
for(int i = 0; i < cracker.tanks.length; i++)
|
||||||
text.add((i < 2 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + cracker.tanks[i].getTankType().getName().toLowerCase()) + ": " + cracker.tanks[i].getFill() + "/" + cracker.tanks[i].getMaxFill() + "mB");
|
text.add((i < 2 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + cracker.tanks[i].getTankType().getName().toLowerCase()) + ": " + cracker.tanks[i].getFill() + "/" + cracker.tanks[i].getMaxFill() + "mB");
|
||||||
|
|
||||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x808000, text);
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,25 @@
|
|||||||
package com.hbm.blocks.machine;
|
package com.hbm.blocks.machine;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
import com.hbm.blocks.ModBlocks;
|
import com.hbm.blocks.ModBlocks;
|
||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
|
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
|
||||||
import com.hbm.tileentity.machine.storage.TileEntityMachineFENSU;
|
import com.hbm.tileentity.machine.storage.TileEntityMachineFENSU;
|
||||||
|
import com.hbm.util.BobMathUtil;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
|
|
||||||
public class MachineFENSU extends BlockDummyable {
|
public class MachineFENSU extends BlockDummyable implements ILookOverlay {
|
||||||
|
|
||||||
public MachineFENSU(Material mat) {
|
public MachineFENSU(Material mat) {
|
||||||
super(mat);
|
super(mat);
|
||||||
@ -58,4 +66,23 @@ public class MachineFENSU extends BlockDummyable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
int[] pos = this.findCore(world, x, y, z);
|
||||||
|
|
||||||
|
if(pos == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||||
|
|
||||||
|
if(!(te instanceof TileEntityMachineBattery))
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileEntityMachineBattery battery = (TileEntityMachineBattery) te;
|
||||||
|
|
||||||
|
List<String> text = new ArrayList();
|
||||||
|
text.add(BobMathUtil.getShortNumber(battery.getPower()) + " / " + BobMathUtil.getShortNumber(battery.getMaxPower()) + "HE");
|
||||||
|
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,6 @@ public class MachineFractionTower extends BlockDummyable implements ILookOverlay
|
|||||||
for(int i = 0; i < cracker.tanks.length; i++)
|
for(int i = 0; i < cracker.tanks.length; i++)
|
||||||
text.add((i == 0 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + cracker.tanks[i].getTankType().getName().toLowerCase()) + ": " + cracker.tanks[i].getFill() + "/" + cracker.tanks[i].getMaxFill() + "mB");
|
text.add((i == 0 ? (EnumChatFormatting.GREEN + "-> ") : (EnumChatFormatting.RED + "<- ")) + EnumChatFormatting.RESET + I18nUtil.resolveKey("hbmfluid." + cracker.tanks[i].getTankType().getName().toLowerCase()) + ": " + cracker.tanks[i].getFill() + "/" + cracker.tanks[i].getMaxFill() + "mB");
|
||||||
|
|
||||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x808000, text);
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
202
src/main/java/com/hbm/blocks/network/CableDiode.java
Normal file
202
src/main/java/com/hbm/blocks/network/CableDiode.java
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
package com.hbm.blocks.network;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.blocks.ILookOverlay;
|
||||||
|
import com.hbm.blocks.ITooltipProvider;
|
||||||
|
import com.hbm.util.BobMathUtil;
|
||||||
|
import com.hbm.util.I18nUtil;
|
||||||
|
|
||||||
|
import api.hbm.block.IToolable;
|
||||||
|
import api.hbm.energy.IEnergyUser;
|
||||||
|
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||||
|
import net.minecraft.block.BlockContainer;
|
||||||
|
import net.minecraft.block.BlockPistonBase;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.network.NetworkManager;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
|
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class CableDiode extends BlockContainer implements ILookOverlay, IToolable, ITooltipProvider {
|
||||||
|
|
||||||
|
public CableDiode(Material mat) {
|
||||||
|
super(mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRenderType() {
|
||||||
|
return renderID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpaqueCube() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean renderAsNormalBlock() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||||
|
int l = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
||||||
|
world.setBlockMetadataWithNotify(x, y, z, l, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||||
|
|
||||||
|
TileEntityDiode te = (TileEntityDiode)world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(world.isRemote)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(tool == ToolType.SCREWDRIVER) {
|
||||||
|
if(te.level < 11)
|
||||||
|
te.level++;
|
||||||
|
te.markDirty();
|
||||||
|
world.markBlockForUpdate(x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tool == ToolType.HAND_DRILL) {
|
||||||
|
if(te.level > 1)
|
||||||
|
te.level--;
|
||||||
|
te.markDirty();
|
||||||
|
world.markBlockForUpdate(x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||||
|
list.add(EnumChatFormatting.GOLD + "Limits throughput and restricts flow direction");
|
||||||
|
list.add(EnumChatFormatting.YELLOW + "Use screwdriver to increase throughput");
|
||||||
|
list.add(EnumChatFormatting.YELLOW + "Use hand drill to decrease throughput");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||||
|
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(!(te instanceof TileEntityDiode))
|
||||||
|
return;
|
||||||
|
|
||||||
|
TileEntityDiode diode = (TileEntityDiode) te;
|
||||||
|
|
||||||
|
List<String> text = new ArrayList();
|
||||||
|
text.add("Max.: " + BobMathUtil.getShortNumber(diode.getMaxPower()) + "HE/pulse");
|
||||||
|
|
||||||
|
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
|
return new TileEntityDiode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TileEntityDiode extends TileEntity implements IEnergyUser {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
level = nbt.getInteger("level");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
nbt.setInteger("level", level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket() {
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
this.writeToNBT(nbt);
|
||||||
|
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||||
|
this.readFromNBT(pkt.func_148857_g());
|
||||||
|
}
|
||||||
|
|
||||||
|
int level = 1;
|
||||||
|
|
||||||
|
private ForgeDirection getDir() {
|
||||||
|
return ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
|
||||||
|
if(!worldObj.isRemote) {
|
||||||
|
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
|
|
||||||
|
if(dir == getDir())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean recursionBrake = false;
|
||||||
|
private long subBuffer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long transferPower(long power) {
|
||||||
|
|
||||||
|
if(recursionBrake)
|
||||||
|
return power;
|
||||||
|
|
||||||
|
//this part turns "maxPower" from a glorified transfer weight into an actual transfer cap
|
||||||
|
long overShoot = Math.max(0, power - getMaxPower());
|
||||||
|
power = Math.min(power, getMaxPower());
|
||||||
|
|
||||||
|
recursionBrake = true;
|
||||||
|
this.subBuffer = power;
|
||||||
|
|
||||||
|
ForgeDirection dir = getDir();
|
||||||
|
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||||
|
long ret = this.subBuffer;
|
||||||
|
|
||||||
|
this.subBuffer = 0;
|
||||||
|
recursionBrake = false;
|
||||||
|
|
||||||
|
return ret + overShoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getMaxPower() {
|
||||||
|
return (long) Math.pow(10, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getPower() {
|
||||||
|
return subBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPower(long power) {
|
||||||
|
this.subBuffer = power;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
package com.hbm.inventory.container;
|
package com.hbm.inventory.container;
|
||||||
|
|
||||||
import com.hbm.tileentity.machine.TileEntityStorageDrum;
|
import com.hbm.tileentity.machine.TileEntityStorageDrum;
|
||||||
|
import com.hbm.util.InventoryUtil;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
@ -47,10 +48,11 @@ public class ContainerStorageDrum extends Container {
|
|||||||
var3 = var5.copy();
|
var3 = var5.copy();
|
||||||
|
|
||||||
if(par2 <= drum.getSizeInventory() - 1) {
|
if(par2 <= drum.getSizeInventory() - 1) {
|
||||||
if(!this.mergeItemStack(var5, drum.getSizeInventory(), this.inventorySlots.size(), true)) {
|
|
||||||
|
if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, drum.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if(!this.mergeItemStack(var5, 0, drum.getSizeInventory(), false)) {
|
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, drum.getSizeInventory(), false)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.hbm.inventory.container;
|
package com.hbm.inventory.container;
|
||||||
|
|
||||||
import com.hbm.tileentity.machine.TileEntityWasteDrum;
|
import com.hbm.tileentity.machine.TileEntityWasteDrum;
|
||||||
|
import com.hbm.util.InventoryUtil;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
@ -52,10 +53,10 @@ public class ContainerWasteDrum extends Container {
|
|||||||
var3 = var5.copy();
|
var3 = var5.copy();
|
||||||
|
|
||||||
if(par2 <= diFurnace.getSizeInventory() - 1) {
|
if(par2 <= diFurnace.getSizeInventory() - 1) {
|
||||||
if(!this.mergeItemStack(var5, diFurnace.getSizeInventory(), this.inventorySlots.size(), true)) {
|
if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, diFurnace.getSizeInventory(), this.inventorySlots.size(), true)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if(!this.mergeItemStack(var5, 0, 0, false)) {
|
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, 0, false)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -654,6 +654,7 @@ public class ClientProxy extends ServerProxy {
|
|||||||
RenderingRegistry.registerBlockHandler(new RenderBlockCT());
|
RenderingRegistry.registerBlockHandler(new RenderBlockCT());
|
||||||
RenderingRegistry.registerBlockHandler(new RenderDetCord());
|
RenderingRegistry.registerBlockHandler(new RenderDetCord());
|
||||||
RenderingRegistry.registerBlockHandler(new RenderBlockMultipass());
|
RenderingRegistry.registerBlockHandler(new RenderBlockMultipass());
|
||||||
|
RenderingRegistry.registerBlockHandler(new RenderDiode());
|
||||||
|
|
||||||
RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_dynamite.getRenderType(), ResourceManager.charge_dynamite));
|
RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_dynamite.getRenderType(), ResourceManager.charge_dynamite));
|
||||||
RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_c4.getRenderType(), ResourceManager.charge_c4));
|
RenderingRegistry.registerBlockHandler(new RenderBlockRotated(ModBlocks.charge_c4.getRenderType(), ResourceManager.charge_c4));
|
||||||
|
|||||||
@ -240,6 +240,7 @@ public class CraftingManager {
|
|||||||
addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.red_wire_coated), 16), new Object[] { "WRW", "RIR", "WRW", 'W', ModItems.plate_polymer, 'I', MINGRADE.ingot(), 'R', ModItems.wire_red_copper });
|
addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.red_wire_coated), 16), new Object[] { "WRW", "RIR", "WRW", 'W', ModItems.plate_polymer, 'I', MINGRADE.ingot(), 'R', ModItems.wire_red_copper });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.cable_switch, 1), new Object[] { "S", "W", 'S', Blocks.lever, 'W', ModBlocks.red_wire_coated });
|
addRecipeAuto(new ItemStack(ModBlocks.cable_switch, 1), new Object[] { "S", "W", 'S', Blocks.lever, 'W', ModBlocks.red_wire_coated });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.cable_detector, 1), new Object[] { "S", "W", 'S', REDSTONE.dust(), 'W', ModBlocks.red_wire_coated });
|
addRecipeAuto(new ItemStack(ModBlocks.cable_detector, 1), new Object[] { "S", "W", 'S', REDSTONE.dust(), 'W', ModBlocks.red_wire_coated });
|
||||||
|
addRecipeAuto(new ItemStack(ModBlocks.cable_diode, 1), new Object[] { " Q ", "CAC", " Q ", 'Q', NETHERQUARTZ.gem(), 'C', ModBlocks.red_cable, 'A', AL.ingot() });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.machine_detector, 1), new Object[] { "IRI", "CTC", "IRI", 'I', ModItems.plate_polymer, 'R', REDSTONE.dust(), 'C', ModItems.wire_red_copper, 'T', ModItems.coil_tungsten });
|
addRecipeAuto(new ItemStack(ModBlocks.machine_detector, 1), new Object[] { "IRI", "CTC", "IRI", 'I', ModItems.plate_polymer, 'R', REDSTONE.dust(), 'C', ModItems.wire_red_copper, 'T', ModItems.coil_tungsten });
|
||||||
addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.red_cable), 16), new Object[] { " W ", "RRR", " W ", 'W', ModItems.plate_polymer, 'R', ModItems.wire_red_copper });
|
addRecipeAuto(new ItemStack(Item.getItemFromBlock(ModBlocks.red_cable), 16), new Object[] { " W ", "RRR", " W ", 'W', ModItems.plate_polymer, 'R', ModItems.wire_red_copper });
|
||||||
addRecipeAuto(new ItemStack(ModBlocks.red_connector, 4), new Object[] { "C", "I", "S", 'C', ModItems.coil_copper, 'I', ModItems.plate_polymer, 'S', STEEL.ingot() });
|
addRecipeAuto(new ItemStack(ModBlocks.red_connector, 4), new Object[] { "C", "I", "S", 'C', ModItems.coil_copper, 'I', ModItems.plate_polymer, 'S', STEEL.ingot() });
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class RenderBlockMultipass implements ISimpleBlockRenderingHandler {
|
|||||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
Tessellator tessellator = Tessellator.instance;
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
//int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||||
|
|
||||||
|
|||||||
156
src/main/java/com/hbm/render/block/RenderDiode.java
Normal file
156
src/main/java/com/hbm/render/block/RenderDiode.java
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
package com.hbm.render.block;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.hbm.blocks.ModBlocks;
|
||||||
|
import com.hbm.blocks.network.CableDiode;
|
||||||
|
import com.hbm.lib.Library;
|
||||||
|
import com.hbm.main.ResourceManager;
|
||||||
|
import com.hbm.render.util.ObjUtil;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||||
|
|
||||||
|
public class RenderDiode implements ISimpleBlockRenderingHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
block.setBlockBoundsForItemRender();
|
||||||
|
renderer.setRenderBoundsFromBlock(block);
|
||||||
|
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glTranslatef(-0.5F, -0.625F, -0.5F);
|
||||||
|
|
||||||
|
IIcon iiconPad = ModBlocks.hadron_coil_alloy.getIcon(0, 0);
|
||||||
|
IIcon iconCable = ModBlocks.red_cable.getIcon(0, 0);
|
||||||
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
|
for(int i = 0; i< 2; i++) {
|
||||||
|
|
||||||
|
if(i == 0) {
|
||||||
|
renderer.setRenderBounds( 0D, 0.875D, 0D, 1D, 1D, 1D);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
renderer.setOverrideBlockTexture(iiconPad);
|
||||||
|
double radius = 0.375D;
|
||||||
|
renderer.setRenderBounds(0.5D - radius, 0.5D - radius, 0.5D - radius, 0.5D + radius, 0.5D + radius, 0.5D + radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, -1.0F, 0.0F);
|
||||||
|
renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, metadata));
|
||||||
|
tessellator.draw();
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||||
|
renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, metadata));
|
||||||
|
tessellator.draw();
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, 0.0F, -1.0F);
|
||||||
|
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, metadata));
|
||||||
|
tessellator.draw();
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||||
|
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, metadata));
|
||||||
|
tessellator.draw();
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(-1.0F, 0.0F, 0.0F);
|
||||||
|
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, metadata));
|
||||||
|
tessellator.draw();
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||||
|
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, metadata));
|
||||||
|
tessellator.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||||
|
GL11.glRotated(180, 0, 1, 0);
|
||||||
|
|
||||||
|
tessellator.startDrawingQuads();
|
||||||
|
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "posX", iconCable, tessellator, 0, false);
|
||||||
|
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "negX", iconCable, tessellator, 0, false);
|
||||||
|
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "negY", iconCable, tessellator, 0, false);
|
||||||
|
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "posZ", iconCable, tessellator, 0, false);
|
||||||
|
ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "negZ", iconCable, tessellator, 0, false);
|
||||||
|
tessellator.draw();
|
||||||
|
|
||||||
|
renderer.clearOverrideBlockTexture();
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||||
|
|
||||||
|
Tessellator tessellator = Tessellator.instance;
|
||||||
|
IIcon iiconPad = ModBlocks.hadron_coil_alloy.getIcon(0, 0);
|
||||||
|
IIcon iconCable = ModBlocks.red_cable.getIcon(0, 0);
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
|
double width = 0.875D;
|
||||||
|
renderer.setRenderBounds(
|
||||||
|
0D + (meta == 4 ? width : 0),
|
||||||
|
0D + (meta == 0 ? width : 0),
|
||||||
|
0D + (meta == 2 ? width : 0),
|
||||||
|
1D - (meta == 5 ? width : 0),
|
||||||
|
1D - (meta == 1 ? width : 0),
|
||||||
|
1D - (meta == 3 ? width : 0)
|
||||||
|
);
|
||||||
|
renderer.renderStandardBlock(block, x, y, z);
|
||||||
|
|
||||||
|
renderer.setOverrideBlockTexture(iiconPad);
|
||||||
|
double radius = 0.375D;
|
||||||
|
double minus = 0D;
|
||||||
|
renderer.setRenderBounds(
|
||||||
|
0.5D - radius + (meta == 4 ? minus : 0),
|
||||||
|
0.5D - radius + (meta == 0 ? minus : 0),
|
||||||
|
0.5D - radius + (meta == 2 ? minus : 0),
|
||||||
|
0.5D + radius - (meta == 5 ? minus : 0),
|
||||||
|
0.5D + radius - (meta == 1 ? minus : 0),
|
||||||
|
0.5D + radius - (meta == 3 ? minus : 0)
|
||||||
|
);
|
||||||
|
renderer.renderStandardBlock(block, x, y, z);
|
||||||
|
renderer.clearOverrideBlockTexture();
|
||||||
|
|
||||||
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||||
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
|
boolean pX = Library.canConnect(world, x + 1, y, z, Library.NEG_X);
|
||||||
|
boolean nX = Library.canConnect(world, x - 1, y, z, Library.POS_X);
|
||||||
|
boolean pY = Library.canConnect(world, x, y + 1, z, Library.NEG_Y);
|
||||||
|
boolean nY = Library.canConnect(world, x, y - 1, z, Library.POS_Y);
|
||||||
|
boolean pZ = Library.canConnect(world, x, y, z + 1, Library.NEG_Z);
|
||||||
|
boolean nZ = Library.canConnect(world, x, y, z - 1, Library.POS_Z);
|
||||||
|
|
||||||
|
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||||
|
|
||||||
|
//ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "Core", iconCable, tessellator, 0, true);
|
||||||
|
if(pX) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "posX", iconCable, tessellator, 0, true);
|
||||||
|
if(nX) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "negX", iconCable, tessellator, 0, true);
|
||||||
|
if(pY) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "posY", iconCable, tessellator, 0, true);
|
||||||
|
if(nY) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "negY", iconCable, tessellator, 0, true);
|
||||||
|
if(nZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "posZ", iconCable, tessellator, 0, true);
|
||||||
|
if(pZ) ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.cable_neo, "negZ", iconCable, tessellator, 0, true);
|
||||||
|
|
||||||
|
tessellator.addTranslation(-x - 0.5F, -y - 0.5F, -z - 0.5F);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldRender3DInInventory(int modelId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRenderId() {
|
||||||
|
return CableDiode.renderID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||||||
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
|
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
|
||||||
import com.hbm.blocks.generic.BlockEmitter.TileEntityEmitter;
|
import com.hbm.blocks.generic.BlockEmitter.TileEntityEmitter;
|
||||||
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
|
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
|
||||||
|
import com.hbm.blocks.network.CableDiode.TileEntityDiode;
|
||||||
import com.hbm.tileentity.bomb.*;
|
import com.hbm.tileentity.bomb.*;
|
||||||
import com.hbm.tileentity.conductor.*;
|
import com.hbm.tileentity.conductor.*;
|
||||||
import com.hbm.tileentity.deco.*;
|
import com.hbm.tileentity.deco.*;
|
||||||
@ -289,6 +290,7 @@ public class TileMappings {
|
|||||||
private static void putNetwork() {
|
private static void putNetwork() {
|
||||||
put(TileEntityCableBaseNT.class, "tileentity_cable", "tileentity_wirecoated");
|
put(TileEntityCableBaseNT.class, "tileentity_cable", "tileentity_wirecoated");
|
||||||
put(TileEntityCableSwitch.class, "tileentity_cable_switch");
|
put(TileEntityCableSwitch.class, "tileentity_cable_switch");
|
||||||
|
put(TileEntityDiode.class, "tileentity_cable_diode");
|
||||||
|
|
||||||
put(TileEntityConnector.class, "tileentity_connector_redwire");
|
put(TileEntityConnector.class, "tileentity_connector_redwire");
|
||||||
put(TileEntityPylon.class, "tileentity_pylon_redwire");
|
put(TileEntityPylon.class, "tileentity_pylon_redwire");
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
|
|||||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||||
|
|
||||||
if(!conductor.canConnect(dir.getOpposite()))
|
if(!conductor.canConnect(dir.getOpposite()))
|
||||||
break;
|
continue;
|
||||||
|
|
||||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||||
conductor.getPowerNet().joinLink(this);
|
conductor.getPowerNet().joinLink(this);
|
||||||
|
|||||||
@ -459,26 +459,33 @@ public class InventoryUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Slot slot;
|
Slot slot;
|
||||||
ItemStack currentStack;
|
ItemStack current;
|
||||||
|
|
||||||
if(stack.isStackable()) {
|
if(stack.isStackable()) {
|
||||||
|
|
||||||
while(stack.stackSize > 0 && (!reverse && index < end || reverse && index >= start)) {
|
while(stack.stackSize > 0 && (!reverse && index < end || reverse && index >= start)) {
|
||||||
slot = slots.get(index);
|
slot = slots.get(index);
|
||||||
currentStack = slot.getStack();
|
current = slot.getStack();
|
||||||
|
|
||||||
if(currentStack != null && currentStack.getItem() == stack.getItem() && (!stack.getHasSubtypes() || stack.getItemDamage() == currentStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, currentStack)) {
|
if(current != null) {
|
||||||
int l = currentStack.stackSize + stack.stackSize;
|
int max = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit());
|
||||||
|
int toRemove = Math.min(stack.stackSize, max);
|
||||||
|
|
||||||
if(l <= stack.getMaxStackSize()) {
|
if(slot.isItemValid(ItemStackUtil.carefulCopyWithSize(stack, toRemove)) && current.getItem() == stack.getItem() &&
|
||||||
stack.stackSize = 0;
|
(!stack.getHasSubtypes() || stack.getItemDamage() == current.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, current)) {
|
||||||
currentStack.stackSize = l;
|
|
||||||
slot.onSlotChanged();
|
int currentSize = current.stackSize + stack.stackSize;
|
||||||
success = true;
|
if(currentSize <= max) {
|
||||||
} else if(currentStack.stackSize < stack.getMaxStackSize()) {
|
stack.stackSize = 0;
|
||||||
stack.stackSize -= stack.getMaxStackSize() - currentStack.stackSize;
|
current.stackSize = currentSize;
|
||||||
currentStack.stackSize = stack.getMaxStackSize();
|
slot.putStack(current);
|
||||||
slot.onSlotChanged();
|
success = true;
|
||||||
success = true;
|
} else if(current.stackSize < max) {
|
||||||
|
stack.stackSize -= stack.getMaxStackSize() - current.stackSize;
|
||||||
|
current.stackSize = max;
|
||||||
|
slot.putStack(current);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,16 +504,20 @@ public class InventoryUtil {
|
|||||||
index = start;
|
index = start;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!reverse && index < end || reverse && index >= start) {
|
while((!reverse && index < end || reverse && index >= start) && stack.stackSize > 0) {
|
||||||
slot = slots.get(index);
|
slot = slots.get(index);
|
||||||
currentStack = slot.getStack();
|
current = slot.getStack();
|
||||||
|
|
||||||
if(currentStack == null) {
|
if(current == null) {
|
||||||
slot.putStack(stack.copy());
|
|
||||||
slot.onSlotChanged();
|
int max = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit());
|
||||||
stack.stackSize = 0;
|
int toRemove = Math.min(stack.stackSize, max);
|
||||||
success = true;
|
|
||||||
break;
|
if(slot.isItemValid(ItemStackUtil.carefulCopyWithSize(stack, toRemove))) {
|
||||||
|
current = stack.splitStack(toRemove);
|
||||||
|
slot.putStack(current);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reverse) {
|
if(reverse) {
|
||||||
|
|||||||
@ -3024,6 +3024,7 @@ tile.broadcaster_pc.name=Korrupter Sender
|
|||||||
tile.burning_earth.name=Brennendes Gras
|
tile.burning_earth.name=Brennendes Gras
|
||||||
tile.c4.name=C4
|
tile.c4.name=C4
|
||||||
tile.cable_detector.name=Redstone-Stromschalter
|
tile.cable_detector.name=Redstone-Stromschalter
|
||||||
|
tile.cable_diode.name=Rote Kupferdiode
|
||||||
tile.cable_switch.name=Stromschalter
|
tile.cable_switch.name=Stromschalter
|
||||||
tile.charge_c4.name=Abrissladung
|
tile.charge_c4.name=Abrissladung
|
||||||
tile.charge_dynamite.name=Zeitbombe
|
tile.charge_dynamite.name=Zeitbombe
|
||||||
|
|||||||
@ -3389,6 +3389,7 @@ tile.broadcaster_pc.name=Corrupted Broadcaster
|
|||||||
tile.burning_earth.name=Burning Grass
|
tile.burning_earth.name=Burning Grass
|
||||||
tile.c4.name=C-4
|
tile.c4.name=C-4
|
||||||
tile.cable_detector.name=Redstone Power Switch
|
tile.cable_detector.name=Redstone Power Switch
|
||||||
|
tile.cable_diode.name=Red Copper Diode
|
||||||
tile.cable_switch.name=Power Switch
|
tile.cable_switch.name=Power Switch
|
||||||
tile.charge_c4.name=Demolition Charge
|
tile.charge_c4.name=Demolition Charge
|
||||||
tile.charge_dynamite.name=Time Bomb
|
tile.charge_dynamite.name=Time Bomb
|
||||||
|
|||||||
BIN
src/main/resources/assets/hbm/textures/blocks/cable_diode.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/cable_diode.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 403 B |
Loading…
x
Reference in New Issue
Block a user