Turned multimeter into a multipart
This commit is contained in:
parent
53ce24127e
commit
b83b2f8336
17 changed files with 578 additions and 601 deletions
|
@ -4,7 +4,6 @@ itemGroup.resonantinduction=Resonant Induction
|
||||||
|
|
||||||
## Blocks
|
## Blocks
|
||||||
tile.resonantinduction\:tesla.name=Tesla Coil
|
tile.resonantinduction\:tesla.name=Tesla Coil
|
||||||
tile.resonantinduction\:multimeter.name=Multimeter
|
|
||||||
tile.resonantinduction\:contractor.name=Electromagnetic Contractor
|
tile.resonantinduction\:contractor.name=Electromagnetic Contractor
|
||||||
tile.resonantinduction\:battery.name=Modular Battery
|
tile.resonantinduction\:battery.name=Modular Battery
|
||||||
|
|
||||||
|
@ -14,6 +13,8 @@ item.resonantinduction\:capacitor.name=Capacitor Cell
|
||||||
item.resonantinduction\:infiniteCapacitor.name=Infinite Capacitor Cell
|
item.resonantinduction\:infiniteCapacitor.name=Infinite Capacitor Cell
|
||||||
item.resonantinduction\:linker.name=Electrostatic Linker
|
item.resonantinduction\:linker.name=Electrostatic Linker
|
||||||
|
|
||||||
|
item.resonantinduction\:multimeter.name=Multimeter
|
||||||
|
|
||||||
item.resonantinduction\:wire.copper.name=Copper Wire
|
item.resonantinduction\:wire.copper.name=Copper Wire
|
||||||
item.resonantinduction\:wire.tin.name=Tin Wire
|
item.resonantinduction\:wire.tin.name=Tin Wire
|
||||||
item.resonantinduction\:wire.iron.name=Iron Wire
|
item.resonantinduction\:wire.iron.name=Iron Wire
|
||||||
|
|
|
@ -4,13 +4,15 @@ import net.minecraft.client.gui.GuiScreen;
|
||||||
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.MinecraftForgeClient;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import resonantinduction.contractor.TileEntityEMContractor;
|
import resonantinduction.contractor.TileEntityEMContractor;
|
||||||
import resonantinduction.fx.FXElectricBolt;
|
import resonantinduction.fx.FXElectricBolt;
|
||||||
import resonantinduction.gui.GuiMultimeter;
|
import resonantinduction.gui.GuiMultimeter;
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
import resonantinduction.multimeter.PartMultimeter;
|
||||||
import resonantinduction.render.BlockRenderingHandler;
|
import resonantinduction.render.BlockRenderingHandler;
|
||||||
import resonantinduction.render.RenderEMContractor;
|
import resonantinduction.render.RenderEMContractor;
|
||||||
|
import resonantinduction.render.RenderItemMultimeter;
|
||||||
import resonantinduction.render.RenderMultimeter;
|
import resonantinduction.render.RenderMultimeter;
|
||||||
import resonantinduction.render.RenderTesla;
|
import resonantinduction.render.RenderTesla;
|
||||||
import resonantinduction.tesla.TileEntityTesla;
|
import resonantinduction.tesla.TileEntityTesla;
|
||||||
|
@ -34,9 +36,10 @@ public class ClientProxy extends CommonProxy
|
||||||
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
|
MinecraftForge.EVENT_BUS.register(SoundHandler.INSTANCE);
|
||||||
|
|
||||||
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
|
RenderingRegistry.registerBlockHandler(BlockRenderingHandler.INSTANCE);
|
||||||
|
MinecraftForgeClient.registerItemRenderer(ResonantInduction.itemMultimeter.itemID, new RenderItemMultimeter());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTesla.class, new RenderTesla());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMultimeter.class, new RenderMultimeter());
|
// ClientRegistry.bindTileEntitySpecialRenderer(PartMultimeter.class, new
|
||||||
|
// RenderMultimeter());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEMContractor.class, new RenderEMContractor());
|
||||||
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new
|
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBattery.class, new
|
||||||
// RenderBattery());
|
// RenderBattery());
|
||||||
|
@ -47,11 +50,11 @@ public class ClientProxy extends CommonProxy
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tileEntity instanceof TileEntityMultimeter)
|
|
||||||
{
|
|
||||||
return new GuiMultimeter(player.inventory, ((TileEntityMultimeter) tileEntity));
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
|
* if (tileEntity instanceof PartMultimeter)
|
||||||
|
* {
|
||||||
|
* return new GuiMultimeter(player.inventory, ((PartMultimeter) tileEntity));
|
||||||
|
* }
|
||||||
* else if (tileEntity instanceof TileEntityBattery)
|
* else if (tileEntity instanceof TileEntityBattery)
|
||||||
* {
|
* {
|
||||||
* return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
* return new GuiBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
||||||
|
|
|
@ -7,7 +7,7 @@ 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 resonantinduction.multimeter.ContainerMultimeter;
|
import resonantinduction.multimeter.ContainerMultimeter;
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
import resonantinduction.multimeter.PartMultimeter;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import codechicken.lib.colour.Colour;
|
import codechicken.lib.colour.Colour;
|
||||||
import codechicken.lib.colour.ColourRGBA;
|
import codechicken.lib.colour.ColourRGBA;
|
||||||
|
@ -29,11 +29,11 @@ public class CommonProxy implements IGuiHandler
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tileEntity instanceof TileEntityMultimeter)
|
/*if (tileEntity instanceof PartMultimeter)
|
||||||
{
|
{
|
||||||
return new ContainerMultimeter(player.inventory, ((TileEntityMultimeter) tileEntity));
|
return new ContainerMultimeter(player.inventory, ((PartMultimeter) tileEntity));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* else if (tileEntity instanceof TileEntityBattery)
|
* else if (tileEntity instanceof TileEntityBattery)
|
||||||
* {
|
* {
|
||||||
* return new ContainerBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
* return new ContainerBattery(player.inventory, ((TileEntityBattery) tileEntity));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package resonantinduction;
|
package resonantinduction;
|
||||||
|
|
||||||
|
import resonantinduction.multimeter.PartMultimeter;
|
||||||
import resonantinduction.wire.part.PartFlatWire;
|
import resonantinduction.wire.part.PartFlatWire;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||||
|
@ -12,7 +13,7 @@ public class MultipartRI implements IPartFactory
|
||||||
|
|
||||||
public MultipartRI()
|
public MultipartRI()
|
||||||
{
|
{
|
||||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire" });
|
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_flat_wire", "resonant_induction_multimeter" });
|
||||||
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
MultipartGenerator.registerTrait("universalelectricity.api.energy.IConductor", "resonantinduction.wire.part.TraitConductor");
|
||||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "resonantinduction.wire.part.TraitEnergySink");
|
||||||
}
|
}
|
||||||
|
@ -24,6 +25,10 @@ public class MultipartRI implements IPartFactory
|
||||||
{
|
{
|
||||||
return new PartFlatWire();
|
return new PartFlatWire();
|
||||||
}
|
}
|
||||||
|
else if (name.equals("resonant_induction_multimeter"))
|
||||||
|
{
|
||||||
|
return new PartMultimeter();
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,7 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
import net.minecraft.tileentity.TileEntityFurnace;
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
import net.minecraftforge.common.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||||
|
|
||||||
|
@ -28,10 +26,7 @@ import resonantinduction.entangler.ItemLinker;
|
||||||
import resonantinduction.entangler.ItemQuantumEntangler;
|
import resonantinduction.entangler.ItemQuantumEntangler;
|
||||||
import resonantinduction.furnace.BlockAdvancedFurnace;
|
import resonantinduction.furnace.BlockAdvancedFurnace;
|
||||||
import resonantinduction.furnace.TileEntityAdvancedFurnace;
|
import resonantinduction.furnace.TileEntityAdvancedFurnace;
|
||||||
import resonantinduction.multimeter.BlockMultimeter;
|
import resonantinduction.multimeter.ItemMultimeter;
|
||||||
import resonantinduction.multimeter.ItemBlockMultimeter;
|
|
||||||
import resonantinduction.multimeter.MultimeterEventHandler;
|
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
|
||||||
import resonantinduction.tesla.BlockTesla;
|
import resonantinduction.tesla.BlockTesla;
|
||||||
import resonantinduction.tesla.TileEntityTesla;
|
import resonantinduction.tesla.TileEntityTesla;
|
||||||
import resonantinduction.wire.EnumWireMaterial;
|
import resonantinduction.wire.EnumWireMaterial;
|
||||||
|
@ -40,7 +35,6 @@ import basiccomponents.api.BasicRegistry;
|
||||||
import calclavia.lib.UniversalRecipe;
|
import calclavia.lib.UniversalRecipe;
|
||||||
import calclavia.lib.network.PacketHandler;
|
import calclavia.lib.network.PacketHandler;
|
||||||
import calclavia.lib.network.PacketTile;
|
import calclavia.lib.network.PacketTile;
|
||||||
import calclavia.lib.prefab.CustomDamageSource;
|
|
||||||
import calclavia.lib.prefab.TranslationHelper;
|
import calclavia.lib.prefab.TranslationHelper;
|
||||||
import codechicken.lib.colour.ColourRGBA;
|
import codechicken.lib.colour.ColourRGBA;
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
@ -139,12 +133,14 @@ public class ResonantInduction
|
||||||
// Items
|
// Items
|
||||||
public static Item itemQuantumEntangler;
|
public static Item itemQuantumEntangler;
|
||||||
public static Item itemLinker;
|
public static Item itemLinker;
|
||||||
/** With Forge Multipart; Use EnumWireMaterial reference. **/
|
/**
|
||||||
|
* Forge Multipart
|
||||||
|
*/
|
||||||
private static Item itemPartWire;
|
private static Item itemPartWire;
|
||||||
|
public static Item itemMultimeter;
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
public static Block blockTesla;
|
public static Block blockTesla;
|
||||||
public static Block blockMultimeter;
|
|
||||||
public static Block blockEMContractor;
|
public static Block blockEMContractor;
|
||||||
public static Block blockBattery;
|
public static Block blockBattery;
|
||||||
public static Block blockAdvancedFurnace;
|
public static Block blockAdvancedFurnace;
|
||||||
|
@ -161,7 +157,6 @@ public class ResonantInduction
|
||||||
LOGGER.setParent(FMLLog.getLogger());
|
LOGGER.setParent(FMLLog.getLogger());
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, ResonantInduction.proxy);
|
NetworkRegistry.instance().registerGuiHandler(this, ResonantInduction.proxy);
|
||||||
Modstats.instance().getReporter().registerMod(this);
|
Modstats.instance().getReporter().registerMod(this);
|
||||||
MinecraftForge.EVENT_BUS.register(new MultimeterEventHandler());
|
|
||||||
CONFIGURATION.load();
|
CONFIGURATION.load();
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
|
@ -181,10 +176,10 @@ public class ResonantInduction
|
||||||
itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID());
|
itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID());
|
||||||
itemLinker = new ItemLinker(getNextItemID());
|
itemLinker = new ItemLinker(getNextItemID());
|
||||||
itemPartWire = new ItemWire(getNextItemID());
|
itemPartWire = new ItemWire(getNextItemID());
|
||||||
|
itemMultimeter = new ItemMultimeter(getNextItemID());
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
blockTesla = new BlockTesla(getNextBlockID());
|
blockTesla = new BlockTesla(getNextBlockID());
|
||||||
blockMultimeter = new BlockMultimeter(getNextBlockID());
|
|
||||||
blockEMContractor = new BlockEMContractor(getNextBlockID());
|
blockEMContractor = new BlockEMContractor(getNextBlockID());
|
||||||
// blockBattery = new BlockBattery(getNextBlockID());
|
// blockBattery = new BlockBattery(getNextBlockID());
|
||||||
|
|
||||||
|
@ -199,15 +194,14 @@ public class ResonantInduction
|
||||||
|
|
||||||
GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName());
|
GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName());
|
||||||
GameRegistry.registerItem(itemLinker, itemLinker.getUnlocalizedName());
|
GameRegistry.registerItem(itemLinker, itemLinker.getUnlocalizedName());
|
||||||
|
GameRegistry.registerItem(itemMultimeter, itemMultimeter.getUnlocalizedName());
|
||||||
|
|
||||||
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
|
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
|
||||||
GameRegistry.registerBlock(blockMultimeter, ItemBlockMultimeter.class, blockMultimeter.getUnlocalizedName());
|
|
||||||
GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName());
|
GameRegistry.registerBlock(blockEMContractor, ItemBlockContractor.class, blockEMContractor.getUnlocalizedName());
|
||||||
// GameRegistry.registerBlock(blockBattery, blockBattery.getUnlocalizedName());
|
// GameRegistry.registerBlock(blockBattery, blockBattery.getUnlocalizedName());
|
||||||
|
|
||||||
// Tiles
|
// Tiles
|
||||||
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
|
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
|
||||||
GameRegistry.registerTileEntity(TileEntityMultimeter.class, blockMultimeter.getUnlocalizedName());
|
|
||||||
GameRegistry.registerTileEntity(TileEntityEMContractor.class, blockEMContractor.getUnlocalizedName());
|
GameRegistry.registerTileEntity(TileEntityEMContractor.class, blockEMContractor.getUnlocalizedName());
|
||||||
// GameRegistry.registerTileEntity(TileEntityBattery.class,
|
// GameRegistry.registerTileEntity(TileEntityBattery.class,
|
||||||
// blockBattery.getUnlocalizedName());
|
// blockBattery.getUnlocalizedName());
|
||||||
|
@ -273,7 +267,7 @@ public class ResonantInduction
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockTesla, "WEW", " C ", " I ", 'W', defaultWire, 'E', Item.eyeOfEnder, 'C', UniversalRecipe.BATTERY.get(), 'I', UniversalRecipe.PRIMARY_PLATE.get()));
|
GameRegistry.addRecipe(new ShapedOreRecipe(blockTesla, "WEW", " C ", " I ", 'W', defaultWire, 'E', Item.eyeOfEnder, 'C', UniversalRecipe.BATTERY.get(), 'I', UniversalRecipe.PRIMARY_PLATE.get()));
|
||||||
|
|
||||||
/** Multimeter */
|
/** Multimeter */
|
||||||
GameRegistry.addRecipe(new ShapedOreRecipe(blockMultimeter, "WWW", "ICI", 'W', defaultWire, 'C', UniversalRecipe.BATTERY.get(), 'I', UniversalRecipe.PRIMARY_METAL.get()));
|
GameRegistry.addRecipe(new ShapedOreRecipe(itemMultimeter, "WWW", "ICI", 'W', defaultWire, 'C', UniversalRecipe.BATTERY.get(), 'I', UniversalRecipe.PRIMARY_METAL.get()));
|
||||||
|
|
||||||
/** Battery */
|
/** Battery */
|
||||||
// GameRegistry.addRecipe(new ShapedOreRecipe(blockBattery, "III", "IRI", "III", 'R',
|
// GameRegistry.addRecipe(new ShapedOreRecipe(blockBattery, "III", "IRI", "III", 'R',
|
||||||
|
|
|
@ -12,8 +12,9 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
import resonantinduction.multimeter.ContainerMultimeter;
|
import resonantinduction.multimeter.ContainerMultimeter;
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
import resonantinduction.multimeter.PartMultimeter;
|
||||||
import calclavia.lib.gui.GuiContainerBase;
|
import calclavia.lib.gui.GuiContainerBase;
|
||||||
|
import calclavia.lib.prefab.TranslationHelper;
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
@ -27,16 +28,16 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class GuiMultimeter extends GuiContainerBase
|
public class GuiMultimeter extends GuiContainerBase
|
||||||
{
|
{
|
||||||
TileEntityMultimeter tileEntity;
|
PartMultimeter multimeter;
|
||||||
|
|
||||||
private int containerWidth;
|
private int containerWidth;
|
||||||
private int containerHeight;
|
private int containerHeight;
|
||||||
private GuiTextField textFieldLimit;
|
private GuiTextField textFieldLimit;
|
||||||
|
|
||||||
public GuiMultimeter(InventoryPlayer inventoryPlayer, TileEntityMultimeter tileEntity)
|
public GuiMultimeter(InventoryPlayer inventoryPlayer, PartMultimeter tileEntity)
|
||||||
{
|
{
|
||||||
super(new ContainerMultimeter(inventoryPlayer, tileEntity));
|
super(new ContainerMultimeter(inventoryPlayer, tileEntity));
|
||||||
this.tileEntity = tileEntity;
|
this.multimeter = tileEntity;
|
||||||
this.ySize = 217;
|
this.ySize = 217;
|
||||||
this.baseTexture = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "gui_multimeter.png");
|
this.baseTexture = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.GUI_DIRECTORY + "gui_multimeter.png");
|
||||||
}
|
}
|
||||||
|
@ -48,7 +49,7 @@ public class GuiMultimeter extends GuiContainerBase
|
||||||
this.buttonList.add(new GuiButton(0, this.width / 2 + 20, this.height / 2 - 30, 50, 20, "Toggle"));
|
this.buttonList.add(new GuiButton(0, this.width / 2 + 20, this.height / 2 - 30, 50, 20, "Toggle"));
|
||||||
this.textFieldLimit = new GuiTextField(fontRenderer, 35, 82, 65, 12);
|
this.textFieldLimit = new GuiTextField(fontRenderer, 35, 82, 65, 12);
|
||||||
this.textFieldLimit.setMaxStringLength(8);
|
this.textFieldLimit.setMaxStringLength(8);
|
||||||
this.textFieldLimit.setText("" + this.tileEntity.getLimit());
|
this.textFieldLimit.setText("" + this.multimeter.getLimit());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,7 +60,7 @@ public class GuiMultimeter extends GuiContainerBase
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this.tileEntity, (byte) 3, Float.parseFloat(this.textFieldLimit.getText())));
|
this.multimeter.getWriteStream().writeByte(1).writeLong(Long.parseLong(this.textFieldLimit.getText()));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -76,12 +77,12 @@ public class GuiMultimeter extends GuiContainerBase
|
||||||
@Override
|
@Override
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||||
{
|
{
|
||||||
String s = this.tileEntity.getBlockType().getLocalizedName();
|
String s = TranslationHelper.getLocal("tile.resonantinduction:multimeter.name");
|
||||||
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752);
|
this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 15, 4210752);
|
||||||
this.fontRenderer.drawString("Average Energy: " + Math.round(this.tileEntity.getAverageDetectedEnergy()) + " J", 35, 25, 4210752);
|
this.fontRenderer.drawString("Average Energy: " + Math.round(this.multimeter.getAverageDetectedEnergy()) + " J", 35, 25, 4210752);
|
||||||
this.fontRenderer.drawString("Energy: " + Math.round(this.tileEntity.getDetectedEnergy()) + " J", 35, 35, 4210752);
|
this.fontRenderer.drawString("Energy: " + Math.round(this.multimeter.getDetectedEnergy()) + " J", 35, 35, 4210752);
|
||||||
this.fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752);
|
this.fontRenderer.drawString("Output Redstone If... ", 35, 54, 4210752);
|
||||||
this.fontRenderer.drawString(this.tileEntity.getMode().display, 35, 65, 4210752);
|
this.fontRenderer.drawString(this.multimeter.getMode().display, 35, 65, 4210752);
|
||||||
this.fontRenderer.drawString("KiloJoules", 35, 100, 4210752);
|
this.fontRenderer.drawString("KiloJoules", 35, 100, 4210752);
|
||||||
|
|
||||||
this.textFieldLimit.drawTextBox();
|
this.textFieldLimit.drawTextBox();
|
||||||
|
@ -91,14 +92,14 @@ public class GuiMultimeter extends GuiContainerBase
|
||||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
||||||
{
|
{
|
||||||
super.drawGuiContainerBackgroundLayer(f, x, y);
|
super.drawGuiContainerBackgroundLayer(f, x, y);
|
||||||
int length = Math.min((int) (this.tileEntity.getDetectedEnergy() / this.tileEntity.getPeak()) * 115, 115);
|
int length = Math.min((int) (this.multimeter.getDetectedEnergy() / this.multimeter.getPeak()) * 115, 115);
|
||||||
this.drawTexturedModalRect(this.containerWidth + 14, this.containerHeight + 126 - length, 176, 115 - length, 6, length);
|
this.drawTexturedModalRect(this.containerWidth + 14, this.containerHeight + 126 - length, 176, 115 - length, 6, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button)
|
protected void actionPerformed(GuiButton button)
|
||||||
{
|
{
|
||||||
PacketDispatcher.sendPacketToServer(ResonantInduction.PACKET_TILE.getPacket(this.tileEntity, (byte) 2));
|
this.multimeter.getWriteStream().writeByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,148 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.multimeter;
|
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.util.Vec3;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.ResonantInduction;
|
|
||||||
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.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BlockMultimeter extends BlockBase implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockMultimeter(int id)
|
|
||||||
{
|
|
||||||
super("multimeter", id);
|
|
||||||
this.setTextureName(ResonantInduction.PREFIX + "machine");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
|
|
||||||
{
|
|
||||||
int metadata = par1World.getBlockMetadata(par2, par3, par4) & 7;
|
|
||||||
float thickness = 0.15f;
|
|
||||||
|
|
||||||
if (metadata == 0)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0, 0, 0, 1, thickness, 1);
|
|
||||||
}
|
|
||||||
else if (metadata == 1)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0, 1 - thickness, 0, 1, 1, 1);
|
|
||||||
}
|
|
||||||
else if (metadata == 2)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0, 0, 0, 1, 1, thickness);
|
|
||||||
}
|
|
||||||
else if (metadata == 3)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0, 0, 1 - thickness, 1, 1, 1);
|
|
||||||
}
|
|
||||||
else if (metadata == 4)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0, 0, 0, thickness, 1, 1);
|
|
||||||
}
|
|
||||||
else if (metadata == 5)
|
|
||||||
{
|
|
||||||
this.setBlockBounds(1 - thickness, 0, 0, 1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY,
|
|
||||||
* hi@OverridetZ, block metadata
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata)
|
|
||||||
{
|
|
||||||
return ForgeDirection.getOrientation(side).getOpposite().ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float par7, float par8, float par9)
|
|
||||||
{
|
|
||||||
if (entityPlayer.isSneaking())
|
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.ROTATION_MATRIX[world.getBlockMetadata(x, y, z)][side], 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entityPlayer.openGui(ResonantInduction.INSTANCE, 0, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int isProvidingStrongPower(IBlockAccess blockAccess, int x, int y, int z, int par5)
|
|
||||||
{
|
|
||||||
return this.isProvidingWeakPower(blockAccess, x, y, z, par5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int isProvidingWeakPower(IBlockAccess blockAccess, int x, int y, int z, int par5)
|
|
||||||
{
|
|
||||||
TileEntity tile = blockAccess.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tile instanceof TileEntityMultimeter)
|
|
||||||
{
|
|
||||||
return ((TileEntityMultimeter) tile).redstoneOn ? 14 : 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvidePower()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
return BlockRenderingHandler.INSTANCE.getRenderId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileEntityMultimeter();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,9 +15,9 @@ import net.minecraft.inventory.Slot;
|
||||||
public class ContainerMultimeter extends Container
|
public class ContainerMultimeter extends Container
|
||||||
{
|
{
|
||||||
private final int yDisplacement = 51;
|
private final int yDisplacement = 51;
|
||||||
private TileEntityMultimeter tileEntity;
|
private PartMultimeter tileEntity;
|
||||||
|
|
||||||
public ContainerMultimeter(InventoryPlayer inventoryPlayer, TileEntityMultimeter tileEntity)
|
public ContainerMultimeter(InventoryPlayer inventoryPlayer, PartMultimeter tileEntity)
|
||||||
{
|
{
|
||||||
this.tileEntity = tileEntity;
|
this.tileEntity = tileEntity;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.multimeter;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ItemBlock for the Multimeter
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ItemBlockMultimeter extends ItemBlock
|
|
||||||
{
|
|
||||||
public ItemBlockMultimeter(int par1)
|
|
||||||
{
|
|
||||||
super(par1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
|
||||||
{
|
|
||||||
par3List.add("Shift-right click to place,");
|
|
||||||
par3List.add("Right click to scan data.");
|
|
||||||
|
|
||||||
float detection = this.getDetection(itemStack);
|
|
||||||
|
|
||||||
if (detection != -1)
|
|
||||||
{
|
|
||||||
par3List.add("Last Detection: " + detection + " KJ");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
par3List.add("No detection saved.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onItemUseFirst(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
|
|
||||||
{
|
|
||||||
if (!par2EntityPlayer.isSneaking())
|
|
||||||
{
|
|
||||||
// if (!world.isRemote)
|
|
||||||
{
|
|
||||||
par2EntityPlayer.addChatMessage("Energy: " + TileEntityMultimeter.getDetectedEnergy(ForgeDirection.getOrientation(par7), world.getBlockTileEntity(x, y, z)) + " J");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onItemUseFirst(par1ItemStack, par2EntityPlayer, world, x, y, z, par7, par8, par9, par10);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDetection(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("detection"))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemStack.stackTagCompound.getFloat("detection");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDetection(ItemStack itemStack, float detection)
|
|
||||||
{
|
|
||||||
if (itemStack.stackTagCompound == null)
|
|
||||||
{
|
|
||||||
itemStack.setTagCompound(new NBTTagCompound());
|
|
||||||
}
|
|
||||||
|
|
||||||
itemStack.stackTagCompound.setFloat("detection", detection);
|
|
||||||
}
|
|
||||||
}
|
|
111
src/resonantinduction/multimeter/ItemMultimeter.java
Normal file
111
src/resonantinduction/multimeter/ItemMultimeter.java
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
package resonantinduction.multimeter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.Icon;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.Configuration;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import resonantinduction.ResonantInduction;
|
||||||
|
import resonantinduction.TabRI;
|
||||||
|
import resonantinduction.Utility;
|
||||||
|
import resonantinduction.wire.EnumWireMaterial;
|
||||||
|
import resonantinduction.wire.part.PartFlatWire;
|
||||||
|
import resonantinduction.wire.render.RenderFlatWire;
|
||||||
|
import universalelectricity.api.energy.UnitDisplay;
|
||||||
|
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||||
|
import codechicken.lib.vec.BlockCoord;
|
||||||
|
import codechicken.lib.vec.Vector3;
|
||||||
|
import codechicken.multipart.JItemMultiPart;
|
||||||
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
|
import codechicken.multipart.TMultiPart;
|
||||||
|
import codechicken.multipart.TileMultipart;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
public class ItemMultimeter extends JItemMultiPart
|
||||||
|
{
|
||||||
|
private Icon[] icons = new Icon[EnumWireMaterial.values().length];
|
||||||
|
|
||||||
|
public ItemMultimeter(int id)
|
||||||
|
{
|
||||||
|
super(ResonantInduction.CONFIGURATION.get(Configuration.CATEGORY_ITEM, "multimeter", id).getInt(id));
|
||||||
|
this.setUnlocalizedName(ResonantInduction.PREFIX + "multimeter");
|
||||||
|
this.setCreativeTab(TabRI.INSTANCE);
|
||||||
|
this.setHasSubtypes(true);
|
||||||
|
this.setMaxDamage(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||||
|
{
|
||||||
|
BlockCoord onPos = pos.copy().offset(side ^ 1);
|
||||||
|
PartMultimeter part = (PartMultimeter) MultiPartRegistry.createPart("resonant_induction_multimeter", false);
|
||||||
|
|
||||||
|
if (part != null)
|
||||||
|
{
|
||||||
|
part.preparePlacement(side, itemStack.getItemDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||||
|
{
|
||||||
|
par3List.add("Shift-right click to place,");
|
||||||
|
par3List.add("Right click to scan data.");
|
||||||
|
|
||||||
|
float detection = this.getDetection(itemStack);
|
||||||
|
|
||||||
|
if (detection != -1)
|
||||||
|
{
|
||||||
|
par3List.add("Last Detection: " + detection + " KJ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
par3List.add("No detection saved.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
|
||||||
|
{
|
||||||
|
if (!par2EntityPlayer.isSneaking())
|
||||||
|
{
|
||||||
|
if (!world.isRemote)
|
||||||
|
{
|
||||||
|
par2EntityPlayer.addChatMessage("Energy: " + PartMultimeter.getDetectedEnergy(ForgeDirection.getOrientation(par7), world.getBlockTileEntity(x, y, z)) + " J");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onItemUse(par1ItemStack, par2EntityPlayer, world, x, y, z, par7, par8, par9, par10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDetection(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (itemStack.stackTagCompound == null || !itemStack.getTagCompound().hasKey("detection"))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemStack.stackTagCompound.getFloat("detection");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDetection(ItemStack itemStack, float detection)
|
||||||
|
{
|
||||||
|
if (itemStack.stackTagCompound == null)
|
||||||
|
{
|
||||||
|
itemStack.setTagCompound(new NBTTagCompound());
|
||||||
|
}
|
||||||
|
|
||||||
|
itemStack.stackTagCompound.setFloat("detection", detection);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,42 +0,0 @@
|
||||||
package resonantinduction.multimeter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.event.ForgeSubscribe;
|
|
||||||
import universalelectricity.api.energy.IEnergyNetwork;
|
|
||||||
import universalelectricity.api.net.NetworkEvent.EnergyUpdateEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class MultimeterEventHandler
|
|
||||||
{
|
|
||||||
private static final HashMap<IEnergyNetwork, Long> networkEnergyCache = new HashMap<IEnergyNetwork, Long>();
|
|
||||||
private static long lastCheckTime = 0;
|
|
||||||
|
|
||||||
public static HashMap<IEnergyNetwork, Long> getCache(World worldObj)
|
|
||||||
{
|
|
||||||
HashMap<IEnergyNetwork, Long> returnCache = new HashMap<IEnergyNetwork, Long>(networkEnergyCache);
|
|
||||||
|
|
||||||
if (Math.abs(worldObj.getWorldTime() - lastCheckTime) >= 40)
|
|
||||||
{
|
|
||||||
lastCheckTime = worldObj.getWorldTime();
|
|
||||||
networkEnergyCache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ForgeSubscribe
|
|
||||||
public void event(EnergyUpdateEvent evt)
|
|
||||||
{
|
|
||||||
IEnergyNetwork network = evt.network;
|
|
||||||
|
|
||||||
if (network.getLastBuffer() != 0)
|
|
||||||
{
|
|
||||||
networkEnergyCache.put(network, network.getLastBuffer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
372
src/resonantinduction/multimeter/PartMultimeter.java
Normal file
372
src/resonantinduction/multimeter/PartMultimeter.java
Normal file
|
@ -0,0 +1,372 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package resonantinduction.multimeter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockColored;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import resonantinduction.ResonantInduction;
|
||||||
|
import resonantinduction.base.PartAdvanced;
|
||||||
|
import resonantinduction.render.RenderMultimeter;
|
||||||
|
import resonantinduction.wire.render.RenderFlatWire;
|
||||||
|
import universalelectricity.api.Compatibility.CompatibilityType;
|
||||||
|
import universalelectricity.api.energy.IConductor;
|
||||||
|
import universalelectricity.api.energy.IEnergyContainer;
|
||||||
|
import universalelectricity.api.energy.IEnergyNetwork;
|
||||||
|
import universalelectricity.api.net.IConnectable;
|
||||||
|
import buildcraft.api.power.IPowerReceptor;
|
||||||
|
import codechicken.lib.data.MCDataInput;
|
||||||
|
import codechicken.lib.data.MCDataOutput;
|
||||||
|
import codechicken.lib.lighting.LazyLightMatrix;
|
||||||
|
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||||
|
import codechicken.lib.render.CCRenderState;
|
||||||
|
import codechicken.lib.render.TextureUtils;
|
||||||
|
import codechicken.lib.vec.Cuboid6;
|
||||||
|
import codechicken.lib.vec.Rotation;
|
||||||
|
import codechicken.lib.vec.Vector3;
|
||||||
|
import codechicken.multipart.JNormalOcclusion;
|
||||||
|
import codechicken.multipart.NormalOcclusionTest;
|
||||||
|
import codechicken.multipart.TFacePart;
|
||||||
|
import codechicken.multipart.TMultiPart;
|
||||||
|
import cofh.api.energy.IEnergyHandler;
|
||||||
|
import cofh.api.energy.TileEnergyHandler;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block that detects power.
|
||||||
|
*
|
||||||
|
* @author Calclavia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PartMultimeter extends PartAdvanced implements IConnectable, TFacePart, JNormalOcclusion
|
||||||
|
{
|
||||||
|
public static Cuboid6[] bounds = new Cuboid6[6];
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
// Subtract the box a little because we'd like things like posts to get first hit
|
||||||
|
Cuboid6 selection = new Cuboid6(0, 0, 0, 1, (2) / 16D, 1).expand(-0.005);
|
||||||
|
for (int s = 0; s < 6; s++)
|
||||||
|
{
|
||||||
|
bounds[s] = selection.copy().apply(Rotation.sideRotations[s].at(Vector3.center));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
||||||
|
|
||||||
|
public enum DetectMode
|
||||||
|
{
|
||||||
|
NONE("None"), LESS_THAN("Less Than"), LESS_THAN_EQUAL("Less Than or Equal"),
|
||||||
|
EQUAL("Equal"), GREATER_THAN("Greater Than or Equal"), GREATER_THAN_EQUAL("Greater Than");
|
||||||
|
|
||||||
|
public String display;
|
||||||
|
|
||||||
|
private DetectMode(String s)
|
||||||
|
{
|
||||||
|
display = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private DetectMode detectMode = DetectMode.NONE;
|
||||||
|
private long peakDetection;
|
||||||
|
private long energyLimit;
|
||||||
|
private long detectedEnergy;
|
||||||
|
private long detectedAverageEnergy;
|
||||||
|
public boolean redstoneOn;
|
||||||
|
private byte side;
|
||||||
|
|
||||||
|
public void preparePlacement(int side, int itemDamage)
|
||||||
|
{
|
||||||
|
this.side = (byte) (side ^ 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
super.update();
|
||||||
|
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
if (ticks % 20 == 0)
|
||||||
|
{
|
||||||
|
long prevDetectedEnergy = detectedEnergy;
|
||||||
|
updateDetection(doGetDetectedEnergy());
|
||||||
|
|
||||||
|
boolean outputRedstone = false;
|
||||||
|
|
||||||
|
switch (detectMode)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case EQUAL:
|
||||||
|
outputRedstone = detectedEnergy == energyLimit;
|
||||||
|
break;
|
||||||
|
case GREATER_THAN:
|
||||||
|
outputRedstone = detectedEnergy > energyLimit;
|
||||||
|
break;
|
||||||
|
case GREATER_THAN_EQUAL:
|
||||||
|
outputRedstone = detectedEnergy >= energyLimit;
|
||||||
|
break;
|
||||||
|
case LESS_THAN:
|
||||||
|
outputRedstone = detectedEnergy < energyLimit;
|
||||||
|
break;
|
||||||
|
case LESS_THAN_EQUAL:
|
||||||
|
outputRedstone = detectedEnergy <= energyLimit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outputRedstone != redstoneOn)
|
||||||
|
{
|
||||||
|
redstoneOn = outputRedstone;
|
||||||
|
this.tile().notifyTileChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prevDetectedEnergy != detectedEnergy)
|
||||||
|
{
|
||||||
|
this.getWriteStream().writeByte(3).writeByte((byte) detectMode.ordinal()).writeLong(detectedEnergy).writeLong(detectedAverageEnergy).writeLong(energyLimit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
for (EntityPlayer player : playersUsing)
|
||||||
|
{
|
||||||
|
this.getWriteStream().writeByte(3).writeByte((byte) detectMode.ordinal()).writeLong(detectedEnergy).writeLong(detectedAverageEnergy).writeLong(energyLimit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readDesc(MCDataInput packet)
|
||||||
|
{
|
||||||
|
this.side = packet.readByte();
|
||||||
|
detectMode = DetectMode.values()[packet.readByte()];
|
||||||
|
detectedEnergy = packet.readLong();
|
||||||
|
detectedAverageEnergy = packet.readLong();
|
||||||
|
energyLimit = packet.readLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeDesc(MCDataOutput packet)
|
||||||
|
{
|
||||||
|
packet.writeByte(this.side);
|
||||||
|
packet.writeByte((byte) detectMode.ordinal());
|
||||||
|
packet.writeLong(detectedEnergy);
|
||||||
|
packet.writeLong(detectedAverageEnergy);
|
||||||
|
packet.writeLong(energyLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(MCDataInput packet)
|
||||||
|
{
|
||||||
|
read(packet, packet.readUByte());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void read(MCDataInput packet, int packetID)
|
||||||
|
{
|
||||||
|
if (packetID == 0)
|
||||||
|
{
|
||||||
|
toggleMode();
|
||||||
|
}
|
||||||
|
else if (packetID == 1)
|
||||||
|
{
|
||||||
|
energyLimit = packet.readLong();
|
||||||
|
}
|
||||||
|
else if (packetID == 3)
|
||||||
|
{ System.out.println("READ");
|
||||||
|
|
||||||
|
this.detectMode = DetectMode.values()[packet.readByte()];
|
||||||
|
this.detectedEnergy = packet.readLong();
|
||||||
|
this.detectedAverageEnergy = packet.readLong();
|
||||||
|
this.energyLimit = packet.readLong();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long doGetDetectedEnergy()
|
||||||
|
{
|
||||||
|
ForgeDirection direction = getDirection();
|
||||||
|
TileEntity tileEntity = world().getBlockTileEntity(x() + direction.offsetX, y() + direction.offsetY, z() + direction.offsetZ);
|
||||||
|
return getDetectedEnergy(direction.getOpposite(), tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForgeDirection getDirection()
|
||||||
|
{
|
||||||
|
return ForgeDirection.getOrientation(this.side);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Check if side is correct.
|
||||||
|
public static long getDetectedEnergy(ForgeDirection side, TileEntity tileEntity)
|
||||||
|
{
|
||||||
|
if (tileEntity instanceof IEnergyContainer)
|
||||||
|
{
|
||||||
|
return ((IEnergyContainer) tileEntity).getEnergy(side);
|
||||||
|
}
|
||||||
|
else if (tileEntity instanceof IConductor)
|
||||||
|
{
|
||||||
|
IEnergyNetwork network = ((IConductor) tileEntity).getNetwork();
|
||||||
|
return network.getLastBuffer();
|
||||||
|
}
|
||||||
|
else if (tileEntity instanceof IEnergyHandler)
|
||||||
|
{
|
||||||
|
return (long) (((IEnergyHandler) tileEntity).getEnergyStored(side) * CompatibilityType.INDUSTRIALCRAFT.reciprocal_ratio);
|
||||||
|
}
|
||||||
|
else if (tileEntity instanceof TileEnergyHandler)
|
||||||
|
{
|
||||||
|
return (long) (((TileEnergyHandler) tileEntity).getEnergyStored(side.getOpposite()) * CompatibilityType.THERMAL_EXPANSION.reciprocal_ratio);
|
||||||
|
}
|
||||||
|
else if (tileEntity instanceof IPowerReceptor)
|
||||||
|
{
|
||||||
|
if (((IPowerReceptor) tileEntity).getPowerReceiver(side) != null)
|
||||||
|
{
|
||||||
|
return (long) (((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored() * CompatibilityType.BUILDCRAFT.reciprocal_ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateDetection(long detected)
|
||||||
|
{
|
||||||
|
detectedEnergy = detected;
|
||||||
|
detectedAverageEnergy = (detectedAverageEnergy + detectedEnergy) / 2;
|
||||||
|
peakDetection = Math.max(peakDetection, detectedEnergy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDetectedEnergy()
|
||||||
|
{
|
||||||
|
return detectedEnergy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getAverageDetectedEnergy()
|
||||||
|
{
|
||||||
|
return detectedAverageEnergy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleMode()
|
||||||
|
{
|
||||||
|
detectMode = DetectMode.values()[(detectMode.ordinal() + 1) % DetectMode.values().length];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.load(nbt);
|
||||||
|
side = nbt.getByte("side");
|
||||||
|
detectMode = DetectMode.values()[nbt.getByte("detectMode")];
|
||||||
|
energyLimit = nbt.getLong("energyLimit");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(NBTTagCompound nbt)
|
||||||
|
{
|
||||||
|
super.save(nbt);
|
||||||
|
nbt.setByte("side", (byte) this.side);
|
||||||
|
nbt.setByte("detectMode", (byte) detectMode.ordinal());
|
||||||
|
nbt.setLong("energyLimit", energyLimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetectMode getMode()
|
||||||
|
{
|
||||||
|
return detectMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getLimit()
|
||||||
|
{
|
||||||
|
return energyLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPeak()
|
||||||
|
{
|
||||||
|
return peakDetection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canConnect(ForgeDirection direction)
|
||||||
|
{
|
||||||
|
return direction == getDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return "resonant_induction_multimeter";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlotMask()
|
||||||
|
{
|
||||||
|
return 1 << this.side;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<IndexedCuboid6> getSubParts()
|
||||||
|
{
|
||||||
|
return Arrays.asList(new IndexedCuboid6(0, bounds[side]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Cuboid6> getOcclusionBoxes()
|
||||||
|
{
|
||||||
|
return Arrays.asList(bounds[this.side]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean occlusionTest(TMultiPart npart)
|
||||||
|
{
|
||||||
|
return NormalOcclusionTest.apply(this, npart);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int redstoneConductionMap()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean solid(int arg0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<ItemStack> getDrops()
|
||||||
|
{
|
||||||
|
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
|
drops.add(new ItemStack(ResonantInduction.itemMultimeter));
|
||||||
|
return drops;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void renderDynamic(Vector3 pos, float frame, int pass)
|
||||||
|
{
|
||||||
|
if (pass == 0)
|
||||||
|
{
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
TextureUtils.bindAtlas(0);
|
||||||
|
CCRenderState.useModelColours(true);
|
||||||
|
CCRenderState.startDrawing(7);
|
||||||
|
RenderMultimeter.render(this, pos.x, pos.y, pos.z);
|
||||||
|
CCRenderState.draw();
|
||||||
|
CCRenderState.setColour(-1);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,268 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.multimeter;
|
|
||||||
|
|
||||||
import ic2.api.tile.IEnergyStorage;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
import resonantinduction.ResonantInduction;
|
|
||||||
import universalelectricity.api.energy.IConductor;
|
|
||||||
import universalelectricity.api.energy.IEnergyContainer;
|
|
||||||
import universalelectricity.api.energy.IEnergyNetwork;
|
|
||||||
import buildcraft.api.power.IPowerReceptor;
|
|
||||||
import calclavia.lib.IRotatable;
|
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
|
||||||
import calclavia.lib.network.IPacketSender;
|
|
||||||
import calclavia.lib.tile.TileEntityAdvanced;
|
|
||||||
import cofh.api.energy.TileEnergyHandler;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
||||||
import cpw.mods.fml.common.network.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Block that detects power.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TileEntityMultimeter extends TileEntityAdvanced implements IRotatable, IPacketReceiver, IPacketSender
|
|
||||||
{
|
|
||||||
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
|
|
||||||
|
|
||||||
public enum DetectMode
|
|
||||||
{
|
|
||||||
NONE("None"), LESS_THAN("Less Than"), LESS_THAN_EQUAL("Less Than or Equal"),
|
|
||||||
EQUAL("Equal"), GREATER_THAN("Greater Than or Equal"), GREATER_THAN_EQUAL("Greater Than");
|
|
||||||
|
|
||||||
public String display;
|
|
||||||
|
|
||||||
private DetectMode(String s)
|
|
||||||
{
|
|
||||||
display = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DetectMode detectMode = DetectMode.NONE;
|
|
||||||
private float peakDetection;
|
|
||||||
private float energyLimit;
|
|
||||||
private float detectedEnergy;
|
|
||||||
private float detectedAverageEnergy;
|
|
||||||
public boolean redstoneOn;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateEntity()
|
|
||||||
{
|
|
||||||
super.updateEntity();
|
|
||||||
|
|
||||||
if (!worldObj.isRemote)
|
|
||||||
{
|
|
||||||
if (ticks % 20 == 0)
|
|
||||||
{
|
|
||||||
float prevDetectedEnergy = detectedEnergy;
|
|
||||||
updateDetection(doGetDetectedEnergy());
|
|
||||||
|
|
||||||
boolean outputRedstone = false;
|
|
||||||
|
|
||||||
switch (detectMode)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
case EQUAL:
|
|
||||||
outputRedstone = detectedEnergy == energyLimit;
|
|
||||||
break;
|
|
||||||
case GREATER_THAN:
|
|
||||||
outputRedstone = detectedEnergy > energyLimit;
|
|
||||||
break;
|
|
||||||
case GREATER_THAN_EQUAL:
|
|
||||||
outputRedstone = detectedEnergy >= energyLimit;
|
|
||||||
break;
|
|
||||||
case LESS_THAN:
|
|
||||||
outputRedstone = detectedEnergy < energyLimit;
|
|
||||||
break;
|
|
||||||
case LESS_THAN_EQUAL:
|
|
||||||
outputRedstone = detectedEnergy <= energyLimit;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outputRedstone != redstoneOn)
|
|
||||||
{
|
|
||||||
redstoneOn = outputRedstone;
|
|
||||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, ResonantInduction.blockMultimeter.blockID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevDetectedEnergy != detectedEnergy)
|
|
||||||
{
|
|
||||||
PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!worldObj.isRemote)
|
|
||||||
{
|
|
||||||
for (EntityPlayer player : playersUsing)
|
|
||||||
{
|
|
||||||
PacketDispatcher.sendPacketToPlayer(ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray()), (Player) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player)
|
|
||||||
{
|
|
||||||
switch (data.readByte())
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
detectMode = DetectMode.values()[data.readByte()];
|
|
||||||
detectedEnergy = data.readFloat();
|
|
||||||
energyLimit = data.readFloat();
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
toggleMode();
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
energyLimit = data.readFloat();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList getPacketData(int type)
|
|
||||||
{
|
|
||||||
ArrayList data = new ArrayList();
|
|
||||||
data.add((byte) 1);
|
|
||||||
data.add((byte) detectMode.ordinal());
|
|
||||||
data.add(detectedEnergy);
|
|
||||||
data.add(energyLimit);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet getDescriptionPacket()
|
|
||||||
{
|
|
||||||
return ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public float doGetDetectedEnergy()
|
|
||||||
{
|
|
||||||
ForgeDirection direction = getDirection();
|
|
||||||
TileEntity tileEntity = worldObj.getBlockTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
|
|
||||||
return getDetectedEnergy(direction.getOpposite(), tileEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Check if side is correct.
|
|
||||||
public static float getDetectedEnergy(ForgeDirection side, TileEntity tileEntity)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof IEnergyContainer)
|
|
||||||
{
|
|
||||||
return ((IEnergyContainer) tileEntity).getEnergy(side);
|
|
||||||
}
|
|
||||||
else if (tileEntity instanceof IConductor)
|
|
||||||
{
|
|
||||||
IEnergyNetwork network = ((IConductor) tileEntity).getNetwork();
|
|
||||||
|
|
||||||
if (MultimeterEventHandler.getCache(tileEntity.worldObj).containsKey(network) && MultimeterEventHandler.getCache(tileEntity.worldObj).get(network) instanceof Long)
|
|
||||||
{
|
|
||||||
return MultimeterEventHandler.getCache(tileEntity.worldObj).get(network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (tileEntity instanceof IEnergyStorage)
|
|
||||||
{
|
|
||||||
return ((IEnergyStorage) tileEntity).getStored();
|
|
||||||
}
|
|
||||||
else if (tileEntity instanceof TileEnergyHandler)
|
|
||||||
{
|
|
||||||
return ((TileEnergyHandler) tileEntity).getEnergyStored(side.getOpposite());
|
|
||||||
}
|
|
||||||
else if (tileEntity instanceof IPowerReceptor)
|
|
||||||
{
|
|
||||||
if (((IPowerReceptor) tileEntity).getPowerReceiver(side) != null)
|
|
||||||
{
|
|
||||||
return ((IPowerReceptor) tileEntity).getPowerReceiver(side).getEnergyStored();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateDetection(float detected)
|
|
||||||
{
|
|
||||||
detectedEnergy = detected;
|
|
||||||
detectedAverageEnergy = (detectedAverageEnergy + detectedEnergy) / 2;
|
|
||||||
peakDetection = Math.max(peakDetection, detectedEnergy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDetectedEnergy()
|
|
||||||
{
|
|
||||||
return detectedEnergy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getAverageDetectedEnergy()
|
|
||||||
{
|
|
||||||
return detectedAverageEnergy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleMode()
|
|
||||||
{
|
|
||||||
detectMode = DetectMode.values()[(detectMode.ordinal() + 1) % DetectMode.values().length];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.readFromNBT(nbt);
|
|
||||||
detectMode = DetectMode.values()[nbt.getInteger("detectMode")];
|
|
||||||
energyLimit = nbt.getFloat("energyLimit");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToNBT(NBTTagCompound nbt)
|
|
||||||
{
|
|
||||||
super.writeToNBT(nbt);
|
|
||||||
nbt.setInteger("detectMode", detectMode.ordinal());
|
|
||||||
nbt.setFloat("energyLimit", energyLimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DetectMode getMode()
|
|
||||||
{
|
|
||||||
return detectMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getLimit()
|
|
||||||
{
|
|
||||||
return energyLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getPeak()
|
|
||||||
{
|
|
||||||
return peakDetection;
|
|
||||||
}
|
|
||||||
|
|
||||||
//@Override
|
|
||||||
public boolean canConnect(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
return direction == getDirection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ForgeDirection getDirection()
|
|
||||||
{
|
|
||||||
return ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setDirection(ForgeDirection direction)
|
|
||||||
{
|
|
||||||
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,7 +10,6 @@ import net.minecraft.world.IBlockAccess;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.contractor.BlockEMContractor;
|
import resonantinduction.contractor.BlockEMContractor;
|
||||||
import resonantinduction.multimeter.BlockMultimeter;
|
|
||||||
import resonantinduction.tesla.BlockTesla;
|
import resonantinduction.tesla.BlockTesla;
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||||
|
@ -58,15 +57,6 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
|
||||||
RenderBattery.MODEL.render(0.0625f);
|
RenderBattery.MODEL.render(0.0625f);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}*/
|
}*/
|
||||||
else if (block instanceof BlockMultimeter)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
|
||||||
GL11.glTranslated(0, -1, -0.7);
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderMultimeter.TEXTURE);
|
|
||||||
RenderMultimeter.MODEL.render(0.0625f);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
40
src/resonantinduction/render/RenderItemMultimeter.java
Normal file
40
src/resonantinduction/render/RenderItemMultimeter.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
package resonantinduction.render;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import resonantinduction.multimeter.ItemMultimeter;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Calclavia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RenderItemMultimeter implements IItemRenderer
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||||
|
{
|
||||||
|
return item.getItem() instanceof ItemMultimeter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||||
|
{
|
||||||
|
return item.getItem() instanceof ItemMultimeter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
|
GL11.glTranslated(0, -1, -0.7);
|
||||||
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderMultimeter.TEXTURE);
|
||||||
|
RenderMultimeter.MODEL.render(0.0625f);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
package resonantinduction.render;
|
package resonantinduction.render;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
@ -10,9 +9,10 @@ import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import resonantinduction.ResonantInduction;
|
import resonantinduction.ResonantInduction;
|
||||||
import resonantinduction.model.ModelMultimeter;
|
import resonantinduction.model.ModelMultimeter;
|
||||||
import resonantinduction.multimeter.TileEntityMultimeter;
|
import resonantinduction.multimeter.PartMultimeter;
|
||||||
import universalelectricity.api.energy.UnitDisplay;
|
import universalelectricity.api.energy.UnitDisplay;
|
||||||
import universalelectricity.api.energy.UnitDisplay.Unit;
|
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||||
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -23,16 +23,15 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderMultimeter extends TileEntitySpecialRenderer
|
public class RenderMultimeter
|
||||||
{
|
{
|
||||||
public static final ModelMultimeter MODEL = new ModelMultimeter();
|
public static final ModelMultimeter MODEL = new ModelMultimeter();
|
||||||
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "multimeter.png");
|
public static final ResourceLocation TEXTURE = new ResourceLocation(ResonantInduction.DOMAIN, ResonantInduction.MODEL_TEXTURE_DIRECTORY + "multimeter.png");
|
||||||
|
|
||||||
@Override
|
@SuppressWarnings("incomplete-switch")
|
||||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float var8)
|
public static void render(PartMultimeter tileEntity, double x, double y, double z)
|
||||||
{
|
{
|
||||||
TileEntityMultimeter tileEntity = (TileEntityMultimeter) t;
|
ForgeDirection direction = tileEntity.getDirection();
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||||
|
@ -64,7 +63,7 @@ public class RenderMultimeter extends TileEntitySpecialRenderer
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bindTexture(TEXTURE);
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE);
|
||||||
MODEL.render(0.0625f);
|
MODEL.render(0.0625f);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
@ -121,7 +120,7 @@ public class RenderMultimeter extends TileEntitySpecialRenderer
|
||||||
GL11.glRotatef(-90, 1, 0, 0);
|
GL11.glRotatef(-90, 1, 0, 0);
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
FontRenderer fontRenderer = this.getFontRenderer();
|
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||||
|
|
||||||
String joules = UnitDisplay.getDisplayShort(tileEntity.getDetectedEnergy(), Unit.JOULES);
|
String joules = UnitDisplay.getDisplayShort(tileEntity.getDetectedEnergy(), Unit.JOULES);
|
||||||
|
|
||||||
|
|
|
@ -827,7 +827,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
|
||||||
@Override
|
@Override
|
||||||
public int redstoneConductionMap()
|
public int redstoneConductionMap()
|
||||||
{
|
{
|
||||||
return 0xF;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue