Gave the Battery a model
This commit is contained in:
parent
b727502276
commit
a34d9d86a9
5 changed files with 60 additions and 44 deletions
|
@ -6,11 +6,13 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import resonantinduction.base.Vector3;
|
import resonantinduction.base.Vector3;
|
||||||
|
import resonantinduction.battery.TileEntityBattery;
|
||||||
import resonantinduction.contractor.TileEntityEMContractor;
|
import resonantinduction.contractor.TileEntityEMContractor;
|
||||||
import resonantinduction.fx.FXElectricBolt;
|
import resonantinduction.fx.FXElectricBolt;
|
||||||
import resonantinduction.multimeter.GuiMultimeter;
|
import resonantinduction.multimeter.GuiMultimeter;
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
import resonantinduction.multimeter.TileEntityMultimeter;
|
||||||
import resonantinduction.render.BlockRenderingHandler;
|
import resonantinduction.render.BlockRenderingHandler;
|
||||||
|
import resonantinduction.render.RenderBattery;
|
||||||
import resonantinduction.render.RenderEMContractor;
|
import resonantinduction.render.RenderEMContractor;
|
||||||
import resonantinduction.render.RenderMultimeter;
|
import resonantinduction.render.RenderMultimeter;
|
||||||
import resonantinduction.render.RenderTesla;
|
import resonantinduction.render.RenderTesla;
|
||||||
|
@ -38,6 +40,7 @@ public class ClientProxy extends CommonProxy
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultimeter.class, new RenderMultimeter());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultimeter.class, new RenderMultimeter());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor());
|
||||||
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new RenderBattery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SetUtil
|
public class SetUtil
|
||||||
{
|
{
|
||||||
public static <V> Set<V> inverse(Set<V> set)
|
public static <V> Set<V> inverse(Set<V> set)
|
||||||
|
@ -19,4 +21,31 @@ public class SetUtil
|
||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <V> Set<V> cap(Set<V> set, int cap)
|
||||||
|
{
|
||||||
|
Set<V> toReturn = new HashSet<V>();
|
||||||
|
|
||||||
|
if(set.size() <= cap)
|
||||||
|
{
|
||||||
|
toReturn = set;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
for(V obj : set)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
|
||||||
|
toReturn.add(obj);
|
||||||
|
|
||||||
|
if(count == cap)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import resonantinduction.base.SetUtil;
|
||||||
import resonantinduction.base.Vector3;
|
import resonantinduction.base.Vector3;
|
||||||
import resonantinduction.battery.BatteryManager.BatteryCache;
|
import resonantinduction.battery.BatteryManager.BatteryCache;
|
||||||
|
|
||||||
|
@ -249,27 +250,7 @@ public class BatteryUpdateProtocol
|
||||||
idFound = BatteryManager.getUniqueInventoryID();
|
idFound = BatteryManager.getUniqueInventoryID();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<ItemStack> newInventory = new HashSet<ItemStack>();
|
Set<ItemStack> newInventory = SetUtil.cap(cache.inventory, structureFound.getMaxCells());
|
||||||
|
|
||||||
if(cache.inventory.size() <= structureFound.getMaxCells())
|
|
||||||
{
|
|
||||||
newInventory = cache.inventory;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for(ItemStack itemStack : cache.inventory)
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
|
|
||||||
newInventory.add(itemStack);
|
|
||||||
|
|
||||||
if(count == structureFound.getMaxCells())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
structureFound.inventory = newInventory;
|
structureFound.inventory = newInventory;
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,16 @@ package resonantinduction.battery;
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.ResonantInduction;
|
|
||||||
import resonantinduction.base.BlockBase;
|
import resonantinduction.base.BlockBase;
|
||||||
|
import resonantinduction.render.BlockRenderingHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A block that detects power.
|
* A block that detects power.
|
||||||
|
@ -24,31 +24,11 @@ import resonantinduction.base.BlockBase;
|
||||||
*/
|
*/
|
||||||
public class BlockBattery extends BlockBase implements ITileEntityProvider
|
public class BlockBattery extends BlockBase implements ITileEntityProvider
|
||||||
{
|
{
|
||||||
private Icon machineIcon;
|
|
||||||
|
|
||||||
public BlockBattery(int id)
|
public BlockBattery(int id)
|
||||||
{
|
{
|
||||||
super("battery", id, Material.iron);
|
super("battery", id, Material.iron);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Icon getIcon(int side, int metadata)
|
|
||||||
{
|
|
||||||
if (side == metadata)
|
|
||||||
{
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.machineIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
super.registerIcons(iconRegister);
|
|
||||||
this.machineIcon = iconRegister.registerIcon(ResonantInduction.PREFIX + "machine");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9)
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +75,19 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return BlockRenderingHandler.INSTANCE.getRenderId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world)
|
public TileEntity createNewTileEntity(World world)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import resonantinduction.battery.BlockBattery;
|
||||||
import resonantinduction.contractor.BlockEMContractor;
|
import resonantinduction.contractor.BlockEMContractor;
|
||||||
import resonantinduction.model.ModelEMContractor;
|
import resonantinduction.model.ModelEMContractor;
|
||||||
import resonantinduction.tesla.BlockTesla;
|
import resonantinduction.tesla.BlockTesla;
|
||||||
|
@ -50,6 +51,15 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
||||||
MODEL_CONTRACTOR.render(0.0625f, false);
|
MODEL_CONTRACTOR.render(0.0625f, false);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
else if (block instanceof BlockBattery)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslated(0.5, 1.5, 0.5);
|
||||||
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
|
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(RenderBattery.TEXTURE);
|
||||||
|
RenderBattery.MODEL.render(0.0625f);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue