power diodes with configurable throughput

This commit is contained in:
Bob 2022-03-18 16:44:38 +01:00
parent bfdd790faf
commit 8c36f6e36d
19 changed files with 537 additions and 125 deletions

View File

@ -105,19 +105,24 @@ public class PowerNet implements IPowerNet {
if(this.subscribers.isEmpty())
return power;
List<IEnergyConnector> subList = new ArrayList(subscribers);
List<Long> weight = new ArrayList();
long totalReq = 0;
for(IEnergyConnector con : this.subscribers) {
for(IEnergyConnector con : subList) {
long req = con.getTransferWeight();
weight.add(req);
totalReq += req;
}
if(totalReq == 0)
return power;
long totalGiven = 0;
for(int i = 0; i < this.subscribers.size(); i++) {
IEnergyConnector con = this.subscribers.get(i);
for(int i = 0; i < subList.size(); i++) {
IEnergyConnector con = subList.get(i);
long req = weight.get(i);
double fraction = (double)req / (double)totalReq;

View File

@ -716,6 +716,7 @@ public class ModBlocks {
public static Block substation;
public static Block cable_switch;
public static Block cable_detector;
public static Block cable_diode;
public static Block machine_detector;
public static Block rf_cable;
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");
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_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");
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");
@ -2935,6 +2937,7 @@ public class ModBlocks {
GameRegistry.registerBlock(substation, ItemBlockBase.class, substation.getUnlocalizedName());
GameRegistry.registerBlock(cable_switch, cable_switch.getUnlocalizedName());
GameRegistry.registerBlock(cable_detector, cable_detector.getUnlocalizedName());
GameRegistry.registerBlock(cable_diode, cable_diode.getUnlocalizedName());
GameRegistry.registerBlock(machine_detector, machine_detector.getUnlocalizedName());
GameRegistry.registerBlock(rf_cable, rf_cable.getUnlocalizedName());
GameRegistry.registerBlock(oil_duct, oil_duct.getUnlocalizedName());

View File

@ -1,12 +1,17 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.TileEntityDiFurnace;
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.relauncher.Side;
@ -25,13 +30,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
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;
public long maxPower;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
@ -41,7 +47,7 @@ public class MachineBattery extends BlockContainer {
super(p_i45386_1_);
this.maxPower = maxPower;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
@ -71,84 +77,73 @@ public class MachineBattery extends BlockContainer {
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":battery_dineutronium_side");
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
if(side == 0 || side == 1)
return iconTop;
return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
return Item.getItemFromBlock(this);
}
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(this);
}
@Override
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, 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 block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
byte b0 = 3;
if(block1.func_149730_j() && !block2.func_149730_j())
{
if(block1.func_149730_j() && !block2.func_149730_j()) {
b0 = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j())
{
if(block2.func_149730_j() && !block1.func_149730_j()) {
b0 = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j())
{
if(block3.func_149730_j() && !block4.func_149730_j()) {
b0 = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j())
{
if(block4.func_149730_j() && !block3.func_149730_j()) {
b0 = 4;
}
world.setBlockMetadataWithNotify(x, y, z, b0, 2);
}
}
@Override
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;
if(i == 0)
{
if(i == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(i == 1)
{
if(i == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(i == 2)
{
if(i == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(i == 3)
{
if(i == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
if(itemStack.hasDisplayName())
{
((TileEntityDiFurnace)world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
if(itemStack.hasDisplayName()) {
((TileEntityDiFurnace) world.getTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
}
}
@ -156,17 +151,14 @@ public class MachineBattery extends BlockContainer {
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityMachineBattery();
}
@Override
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;
} else if(!player.isSneaking())
{
} else if(!player.isSneaking()) {
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);
}
return true;
@ -174,57 +166,64 @@ public class MachineBattery extends BlockContainer {
return false;
}
}
@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_)
{
if (!keepInventory)
{
TileEntityMachineBattery tileentityfurnace = (TileEntityMachineBattery)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
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) {
TileEntityMachineBattery tileentityfurnace = (TileEntityMachineBattery) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
if (tileentityfurnace != null)
{
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
{
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if(tileentityfurnace != null) {
for(int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
if (itemstack != null)
{
float f = 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;
if(itemstack != null) {
float f = 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;
while (itemstack.stackSize > 0)
{
int j1 = this.field_149933_a.nextInt(21) + 10;
while(itemstack.stackSize > 0) {
int j1 = this.field_149933_a.nextInt(21) + 10;
if (j1 > itemstack.stackSize)
{
j1 = itemstack.stackSize;
}
if(j1 > itemstack.stackSize) {
j1 = itemstack.stackSize;
}
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()));
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()));
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
if(itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
float f3 = 0.05F;
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
p_149749_1_.spawnEntityInWorld(entityitem);
}
}
}
float f3 = 0.05F;
entityitem.motionX = (float) this.field_149933_a.nextGaussian() * f3;
entityitem.motionY = (float) this.field_149933_a.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) this.field_149933_a.nextGaussian() * f3;
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);
}
}

View File

@ -132,6 +132,6 @@ public class MachineCatalyticCracker extends BlockDummyable implements ILookOver
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");
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x808000, text);
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}

View File

@ -1,17 +1,25 @@
package com.hbm.blocks.machine;
import java.util.ArrayList;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ILookOverlay;
import com.hbm.blocks.ModBlocks;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.machine.storage.TileEntityMachineBattery;
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 net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
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) {
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);
}
}

View File

@ -118,6 +118,6 @@ public class MachineFractionTower extends BlockDummyable implements ILookOverlay
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");
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x808000, text);
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
}
}

View 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;
}
}
}

View File

@ -1,6 +1,7 @@
package com.hbm.inventory.container;
import com.hbm.tileentity.machine.TileEntityStorageDrum;
import com.hbm.util.InventoryUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -47,10 +48,11 @@ public class ContainerStorageDrum extends Container {
var3 = var5.copy();
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;
}
} else if(!this.mergeItemStack(var5, 0, drum.getSizeInventory(), false)) {
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, drum.getSizeInventory(), false)) {
return null;
}

View File

@ -1,6 +1,7 @@
package com.hbm.inventory.container;
import com.hbm.tileentity.machine.TileEntityWasteDrum;
import com.hbm.util.InventoryUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -52,10 +53,10 @@ public class ContainerWasteDrum extends Container {
var3 = var5.copy();
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;
}
} else if(!this.mergeItemStack(var5, 0, 0, false)) {
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, var5, 0, 0, false)) {
return null;
}

View File

@ -654,6 +654,7 @@ public class ClientProxy extends ServerProxy {
RenderingRegistry.registerBlockHandler(new RenderBlockCT());
RenderingRegistry.registerBlockHandler(new RenderDetCord());
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_c4.getRenderType(), ResourceManager.charge_c4));

View File

@ -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(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_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(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() });

View File

@ -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) {
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));

View 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;
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
import com.hbm.blocks.generic.BlockEmitter.TileEntityEmitter;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.blocks.network.CableDiode.TileEntityDiode;
import com.hbm.tileentity.bomb.*;
import com.hbm.tileentity.conductor.*;
import com.hbm.tileentity.deco.*;
@ -289,6 +290,7 @@ public class TileMappings {
private static void putNetwork() {
put(TileEntityCableBaseNT.class, "tileentity_cable", "tileentity_wirecoated");
put(TileEntityCableSwitch.class, "tileentity_cable_switch");
put(TileEntityDiode.class, "tileentity_cable_diode");
put(TileEntityConnector.class, "tileentity_connector_redwire");
put(TileEntityPylon.class, "tileentity_pylon_redwire");

View File

@ -37,7 +37,7 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
IEnergyConductor conductor = (IEnergyConductor) te;
if(!conductor.canConnect(dir.getOpposite()))
break;
continue;
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
conductor.getPowerNet().joinLink(this);

View File

@ -459,26 +459,33 @@ public class InventoryUtil {
}
Slot slot;
ItemStack currentStack;
ItemStack current;
if(stack.isStackable()) {
while(stack.stackSize > 0 && (!reverse && index < end || reverse && index >= start)) {
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)) {
int l = currentStack.stackSize + stack.stackSize;
if(l <= stack.getMaxStackSize()) {
stack.stackSize = 0;
currentStack.stackSize = l;
slot.onSlotChanged();
success = true;
} else if(currentStack.stackSize < stack.getMaxStackSize()) {
stack.stackSize -= stack.getMaxStackSize() - currentStack.stackSize;
currentStack.stackSize = stack.getMaxStackSize();
slot.onSlotChanged();
success = true;
if(current != null) {
int max = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit());
int toRemove = Math.min(stack.stackSize, max);
if(slot.isItemValid(ItemStackUtil.carefulCopyWithSize(stack, toRemove)) && current.getItem() == stack.getItem() &&
(!stack.getHasSubtypes() || stack.getItemDamage() == current.getItemDamage()) && ItemStack.areItemStackTagsEqual(stack, current)) {
int currentSize = current.stackSize + stack.stackSize;
if(currentSize <= max) {
stack.stackSize = 0;
current.stackSize = currentSize;
slot.putStack(current);
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;
}
while(!reverse && index < end || reverse && index >= start) {
while((!reverse && index < end || reverse && index >= start) && stack.stackSize > 0) {
slot = slots.get(index);
currentStack = slot.getStack();
current = slot.getStack();
if(currentStack == null) {
slot.putStack(stack.copy());
slot.onSlotChanged();
stack.stackSize = 0;
success = true;
break;
if(current == null) {
int max = Math.min(stack.getMaxStackSize(), slot.getSlotStackLimit());
int toRemove = Math.min(stack.stackSize, max);
if(slot.isItemValid(ItemStackUtil.carefulCopyWithSize(stack, toRemove))) {
current = stack.splitStack(toRemove);
slot.putStack(current);
success = true;
}
}
if(reverse) {

View File

@ -3024,6 +3024,7 @@ tile.broadcaster_pc.name=Korrupter Sender
tile.burning_earth.name=Brennendes Gras
tile.c4.name=C4
tile.cable_detector.name=Redstone-Stromschalter
tile.cable_diode.name=Rote Kupferdiode
tile.cable_switch.name=Stromschalter
tile.charge_c4.name=Abrissladung
tile.charge_dynamite.name=Zeitbombe

View File

@ -3389,6 +3389,7 @@ tile.broadcaster_pc.name=Corrupted Broadcaster
tile.burning_earth.name=Burning Grass
tile.c4.name=C-4
tile.cable_detector.name=Redstone Power Switch
tile.cable_diode.name=Red Copper Diode
tile.cable_switch.name=Power Switch
tile.charge_c4.name=Demolition Charge
tile.charge_dynamite.name=Time Bomb

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B