Added fancy hud display instead of chat messages to most blocks

This commit is contained in:
Ellpeck 2015-12-21 22:18:33 +01:00
parent 1a13ef9b13
commit 92dc77839d
33 changed files with 383 additions and 185 deletions

View file

@ -25,7 +25,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -96,25 +95,20 @@ public class BlockAtomicReconstructor extends BlockContainerBase{
if(!world.isRemote){ if(!world.isRemote){
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(x, y, z); TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(x, y, z);
if(reconstructor != null){ if(reconstructor != null){
if(!player.isSneaking()){ ItemStack heldItem = player.getCurrentEquippedItem();
ItemStack heldItem = player.getCurrentEquippedItem(); if(heldItem != null){
if(heldItem != null){ if(heldItem.getItem() instanceof ItemLens && reconstructor.getStackInSlot(0) == null){
if(heldItem.getItem() instanceof ItemLens && reconstructor.getStackInSlot(0) == null){ ItemStack toPut = heldItem.copy();
ItemStack toPut = heldItem.copy(); toPut.stackSize = 1;
toPut.stackSize = 1; reconstructor.setInventorySlotContents(0, toPut);
reconstructor.setInventorySlotContents(0, toPut); player.inventory.decrStackSize(player.inventory.currentItem, 1);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
}
else{
if(reconstructor.getStackInSlot(0) != null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, reconstructor.getStackInSlot(0).copy());
reconstructor.setInventorySlotContents(0, null);
}
} }
} }
else{ else{
player.addChatComponentMessage(new ChatComponentText(reconstructor.storage.getEnergyStored()+"/"+reconstructor.storage.getMaxEnergyStored()+" RF")); if(reconstructor.getStackInSlot(0) != null){
player.inventory.setInventorySlotContents(player.inventory.currentItem, reconstructor.getStackInSlot(0).copy());
reconstructor.setInventorySlotContents(0, null);
}
} }
} }
} }

View file

@ -22,7 +22,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -52,17 +51,7 @@ public class BlockFireworkBox extends BlockContainerBase{
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, x, y, z, player)){ return this.tryToggleRedstone(world, x, y, z, player);
return true;
}
if(!world.isRemote){
TileEntityFireworkBox box = (TileEntityFireworkBox)world.getTileEntity(x, y, z);
if(box != null){
player.addChatComponentMessage(new ChatComponentText(box.storage.getEnergyStored()+"/"+box.storage.getMaxEnergyStored()+" RF"));
}
return true;
}
return true;
} }
@Override @Override

View file

@ -17,12 +17,10 @@ import ellpeck.actuallyadditions.tile.TileEntityFurnaceSolar;
import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.AssetUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -63,18 +61,6 @@ public class BlockFurnaceSolar extends BlockContainerBase{
return false; return false;
} }
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityFurnaceSolar generator = (TileEntityFurnaceSolar)world.getTileEntity(x, y, z);
if(generator != null){
player.addChatComponentMessage(new ChatComponentText(generator.storage.getEnergyStored()+"/"+generator.storage.getMaxEnergyStored()+" RF"));
}
return true;
}
return true;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){

View file

@ -17,11 +17,9 @@ import ellpeck.actuallyadditions.tile.TileEntityHeatCollector;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -51,18 +49,6 @@ public class BlockHeatCollector extends BlockContainerBase{
return side == 1 ? this.topIcon : (side == 0 ? this.bottomIcon : this.blockIcon); return side == 1 ? this.topIcon : (side == 0 ? this.bottomIcon : this.blockIcon);
} }
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityHeatCollector generator = (TileEntityHeatCollector)world.getTileEntity(x, y, z);
if(generator != null){
player.addChatComponentMessage(new ChatComponentText(generator.storage.getEnergyStored()+"/"+generator.storage.getMaxEnergyStored()+" RF"));
}
return true;
}
return true;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){

View file

@ -17,16 +17,19 @@ import ellpeck.actuallyadditions.tile.TileEntityLavaFactoryController;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockLavaFactoryController extends BlockContainerBase{ public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon topIcon; private IIcon topIcon;
@ -50,25 +53,6 @@ public class BlockLavaFactoryController extends BlockContainerBase{
return side == 1 ? this.topIcon : this.blockIcon; return side == 1 ? this.topIcon : this.blockIcon;
} }
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)world.getTileEntity(x, y, z);
if(factory != null){
int state = factory.isMultiblock();
if(state == TileEntityLavaFactoryController.NOT_MULTI){
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc")));
}
if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc")));
}
player.addChatComponentMessage(new ChatComponentText(factory.storage.getEnergyStored()+"/"+factory.storage.getMaxEnergyStored()+" RF"));
}
return true;
}
return true;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){
@ -80,4 +64,18 @@ public class BlockLavaFactoryController extends BlockContainerBase{
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.rare;
} }
@Override
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ);
if(factory != null){
int state = factory.isMultiblock();
if(state == TileEntityLavaFactoryController.NOT_MULTI){
minecraft.fontRenderer.drawSplitString(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE);
}
else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){
minecraft.fontRenderer.drawSplitString(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}
} }

View file

@ -18,11 +18,9 @@ import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -52,18 +50,6 @@ public class BlockLeafGenerator extends BlockContainerBase{
return side <= 1 ? (side == 0 ? this.bottomIcon : this.topIcon) : this.blockIcon; return side <= 1 ? (side == 0 ? this.bottomIcon : this.topIcon) : this.blockIcon;
} }
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){
TileEntityLeafGenerator generator = (TileEntityLeafGenerator)world.getTileEntity(x, y, z);
if(generator != null){
player.addChatComponentMessage(new ChatComponentText(generator.storage.getEnergyStored()+"/"+generator.storage.getMaxEnergyStored()+" RF"));
}
return true;
}
return true;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){

View file

@ -17,18 +17,22 @@ import ellpeck.actuallyadditions.blocks.base.BlockContainerBase;
import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.inventory.GuiHandler;
import ellpeck.actuallyadditions.tile.TileEntityMiner; import ellpeck.actuallyadditions.tile.TileEntityMiner;
import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockMiner extends BlockContainerBase{ public class BlockMiner extends BlockContainerBase implements IHudDisplay{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon frontIcon; private IIcon frontIcon;
@ -58,16 +62,8 @@ public class BlockMiner extends BlockContainerBase{
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile != null && tile instanceof TileEntityMiner){ if(tile instanceof TileEntityMiner){
if(player.isSneaking()){ player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.MINER.ordinal(), world, x, y, z);
player.addChatComponentMessage(new ChatComponentText(((TileEntityMiner)tile).storage.getEnergyStored()+"/"+((TileEntityMiner)tile).storage.getMaxEnergyStored()+" RF"));
String info = ((TileEntityMiner)tile).layerAt <= 0 ? "Done Mining!" : "Mining at Y = "+((TileEntityMiner)tile).layerAt+".";
player.addChatComponentMessage(new ChatComponentText(info));
}
else{
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.MINER.ordinal(), world, x, y, z);
}
} }
} }
return true; return true;
@ -96,4 +92,14 @@ public class BlockMiner extends BlockContainerBase{
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6); super.breakBlock(world, x, y, z, block, par6);
} }
@Override
@SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ);
if(tile instanceof TileEntityMiner){
String info = ((TileEntityMiner)tile).layerAt <= 0 ? "Done Mining!" : "Mining at Y = "+((TileEntityMiner)tile).layerAt+".";
minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-20, StringUtil.DECIMAL_COLOR_WHITE);
}
}
} }

View file

@ -20,18 +20,22 @@ import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil; import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockPhantom extends BlockContainerBase{ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
public Type type; public Type type;
public int range; public int range;
@ -92,32 +96,8 @@ public class BlockPhantom extends BlockContainerBase{
} }
if(!world.isRemote){ if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile != null){ if(tile instanceof IPhantomTile && ((IPhantomTile)tile).getGuiID() != -1){
if(tile instanceof IPhantomTile){ player.openGui(ActuallyAdditions.instance, ((IPhantomTile)tile).getGuiID(), world, x, y, z);
IPhantomTile phantom = (IPhantomTile)tile;
if(player.isSneaking() || phantom.getGuiID() == -1){
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc")+": "+phantom.getRange()));
if(phantom.hasBoundPosition()){
int distance = (int)Vec3.createVectorHelper(x, y, z).distanceTo(Vec3.createVectorHelper(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()));
Item item = phantom.getBoundPosition().getItemBlock();
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(), 1, phantom.getBoundPosition().getMetadata()));
player.addChatComponentMessage(new ChatComponentText(StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance)));
if(phantom.isBoundThingInRange()){
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc")));
}
else{
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc")));
}
}
else{
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc")));
}
}
else{
player.openGui(ActuallyAdditions.instance, phantom.getGuiID(), world, x, y, z);
}
}
} }
} }
return true; return true;
@ -136,6 +116,33 @@ public class BlockPhantom extends BlockContainerBase{
return EnumRarity.epic; return EnumRarity.epic;
} }
@Override
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ);
if(tile != null){
if(tile instanceof IPhantomTile){
IPhantomTile phantom = (IPhantomTile)tile;
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.GOLD+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-10, StringUtil.DECIMAL_COLOR_WHITE);
if(phantom.hasBoundPosition()){
int distance = (int)Vec3.createVectorHelper(posHit.blockX, posHit.blockY, posHit.blockZ).distanceTo(Vec3.createVectorHelper(phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ()));
Item item = phantom.getBoundPosition().getItemBlock();
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(), 1, phantom.getBoundPosition().getMetadata()));
minecraft.fontRenderer.drawSplitString(StringUtil.localizeFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.blockInfo.desc", name, phantom.getBoundPosition().getX(), phantom.getBoundPosition().getY(), phantom.getBoundPosition().getZ(), distance), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE);
if(phantom.isBoundThingInRange()){
minecraft.fontRenderer.drawSplitString(EnumChatFormatting.DARK_GREEN+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE);
}
else{
minecraft.fontRenderer.drawSplitString(EnumChatFormatting.DARK_RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, 200, StringUtil.DECIMAL_COLOR_WHITE);
}
}
else{
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}
}
public enum Type{ public enum Type{
FACE, FACE,
PLACER, PLACER,

View file

@ -0,0 +1,27 @@
/*
* This file ("IHudDisplay.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.util.MovingObjectPosition;
public interface IHudDisplay{
@SideOnly(Side.CLIENT)
void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution);
}

View file

@ -28,7 +28,6 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@ -118,7 +117,7 @@ public abstract class BlockContainerBase extends BlockContainer{
tile.markDirty(); tile.markDirty();
} }
if(tile instanceof IRedstoneToggle){ if(tile instanceof IRedstoneToggle){
if(((IRedstoneToggle)tile).isRightMode() && powered){ if(((IRedstoneToggle)tile).isPulseMode() && powered){
((IRedstoneToggle)tile).activateOnPulse(); ((IRedstoneToggle)tile).activateOnPulse();
} }
} }
@ -227,12 +226,10 @@ public abstract class BlockContainerBase extends BlockContainer{
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IRedstoneToggle){ if(tile instanceof IRedstoneToggle){
if(!world.isRemote){ if(!world.isRemote){
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
if(((IRedstoneToggle)tile).toggle()){ if(tile instanceof TileEntityBase){
player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Pulse Mode")); ((TileEntityBase)tile).sendUpdate();
}
else{
player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Deactivation Mode"));
} }
} }
return true; return true;

View file

@ -0,0 +1,78 @@
/*
* This file ("HudEvent.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ellpeck.actuallyadditions.blocks.IHudDisplay;
import ellpeck.actuallyadditions.tile.IEnergyDisplay;
import ellpeck.actuallyadditions.tile.IRedstoneToggle;
import ellpeck.actuallyadditions.util.ModUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneTorch;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
public class HudEvent{
@SubscribeEvent
public void onGameOverlay(RenderGameOverlayEvent.Post event){
if(event.type == RenderGameOverlayEvent.ElementType.ALL){
Minecraft minecraft = Minecraft.getMinecraft();
Profiler profiler = minecraft.mcProfiler;
EntityPlayer player = minecraft.thePlayer;
MovingObjectPosition posHit = minecraft.objectMouseOver;
FontRenderer font = minecraft.fontRenderer;
profiler.startSection(ModUtil.MOD_ID+"Hud");
if(posHit != null){
Block blockHit = minecraft.theWorld.getBlock(posHit.blockX, posHit.blockY, posHit.blockZ);
TileEntity tileHit = minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ);
if(blockHit instanceof IHudDisplay){
profiler.startSection("BlockHudDisplay");
((IHudDisplay)blockHit).displayHud(minecraft, player, player.getCurrentEquippedItem(), posHit, profiler, event.resolution);
profiler.endSection();
}
if(tileHit instanceof IRedstoneToggle){
if(player.getCurrentEquippedItem() != null && Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()) instanceof BlockRedstoneTorch){
profiler.startSection("RedstoneToggleHudDisplay");
String strg = "Redstone Mode: "+EnumChatFormatting.DARK_RED+(((IRedstoneToggle)tileHit).isPulseMode() ? "Pulse" : "Deactivation")+EnumChatFormatting.RESET;
String expl = "Right-Click to toggle!";
font.drawStringWithShadow(strg, event.resolution.getScaledWidth()/2+5, event.resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
font.drawStringWithShadow(expl, event.resolution.getScaledWidth()/2+5, event.resolution.getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE);
profiler.endSection();
}
}
if(tileHit instanceof IEnergyDisplay){
profiler.startSection("EnergyDisplay");
String strg = ((IEnergyDisplay)tileHit).getEnergy()+"/"+((IEnergyDisplay)tileHit).getMaxEnergy()+" RF";
font.drawStringWithShadow(EnumChatFormatting.GOLD+strg, event.resolution.getScaledWidth()/2+5, event.resolution.getScaledHeight()/2-10, StringUtil.DECIMAL_COLOR_WHITE);
profiler.endSection();
}
}
profiler.endSection();
}
}
}

View file

@ -35,6 +35,7 @@ public class InitEvents{
public static void initClient(){ public static void initClient(){
Util.registerEvent(new TooltipEvent()); Util.registerEvent(new TooltipEvent());
Util.registerEvent(new HudEvent());
if(Loader.isModLoaded("NotEnoughItems")){ if(Loader.isModLoaded("NotEnoughItems")){
Util.registerEvent(new NEIScreenEvents()); Util.registerEvent(new NEIScreenEvents());

View file

@ -0,0 +1,18 @@
/*
* This file ("IEnergyDisplay.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015 Ellpeck
*/
package ellpeck.actuallyadditions.tile;
public interface IEnergyDisplay{
int getEnergy();
int getMaxEnergy();
}

View file

@ -12,9 +12,9 @@ package ellpeck.actuallyadditions.tile;
public interface IRedstoneToggle{ public interface IRedstoneToggle{
boolean toggle(); void toggle(boolean to);
boolean isRightMode(); boolean isPulseMode();
void activateOnPulse(); void activateOnPulse();
} }

View file

@ -25,12 +25,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IRedstoneToggle{ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IRedstoneToggle, IEnergyDisplay{
public static final int ENERGY_USE = 1000; public static final int ENERGY_USE = 1000;
public EnergyStorage storage = new EnergyStorage(300000); public EnergyStorage storage = new EnergyStorage(300000);
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal; private boolean activateOnceWithSignal;
private int oldEnergy;
public TileEntityAtomicReconstructor(){ public TileEntityAtomicReconstructor(){
super(1, "reconstructor"); super(1, "reconstructor");
@ -52,6 +53,10 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
this.currentTime = 100; this.currentTime = 100;
} }
} }
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored();
}
} }
} }
@ -164,18 +169,23 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public void setEnergy(int energy){ public void setEnergy(int energy){
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }

View file

@ -111,11 +111,15 @@ public abstract class TileEntityBase extends TileEntity{
} }
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
if(this instanceof IRedstoneToggle){
compound.setBoolean("IsPulseMode", ((IRedstoneToggle)this).isPulseMode());
}
} }
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
if(this instanceof IRedstoneToggle){
((IRedstoneToggle)this).toggle(compound.getBoolean("IsPulseMode"));
}
} }
public void setRedstonePowered(boolean powered){ public void setRedstonePowered(boolean powered){

View file

@ -25,6 +25,7 @@ public class TileEntityBookletStand extends TileEntityBase{
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync);
compound.setTag("SavedEntry", this.assignedEntry.writeToNBT()); compound.setTag("SavedEntry", this.assignedEntry.writeToNBT());
if(this.assignedPlayer != null){ if(this.assignedPlayer != null){
@ -34,6 +35,7 @@ public class TileEntityBookletStand extends TileEntityBase{
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.readSyncableNBT(compound, isForSync);
this.assignedEntry = EntrySet.readFromNBT(compound.getCompoundTag("SavedEntry")); this.assignedEntry = EntrySet.readFromNBT(compound.getCompoundTag("SavedEntry"));
String player = compound.getString("Player"); String player = compound.getString("Player");

View file

@ -110,12 +110,12 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }

View file

@ -151,12 +151,12 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }

View file

@ -95,12 +95,12 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }

View file

@ -22,24 +22,31 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IRedstoneToggle{ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IRedstoneToggle, IEnergyDisplay, IEnergySaver{
public static final int USE_PER_SHOT = 300; public static final int USE_PER_SHOT = 300;
public EnergyStorage storage = new EnergyStorage(20000); public EnergyStorage storage = new EnergyStorage(20000);
private int timeUntilNextFirework; private int timeUntilNextFirework;
private boolean activateOnceWithSignal; private boolean activateOnceWithSignal;
private int oldEnergy;
@Override @Override
public void updateEntity(){ public void updateEntity(){
if(!this.worldObj.isRemote && !this.isRedstonePowered && !this.activateOnceWithSignal){ if(!this.worldObj.isRemote){
if(this.timeUntilNextFirework > 0){ if(!this.isRedstonePowered && !this.activateOnceWithSignal){
this.timeUntilNextFirework--; if(this.timeUntilNextFirework > 0){
if(this.timeUntilNextFirework <= 0){ this.timeUntilNextFirework--;
this.doWork(); if(this.timeUntilNextFirework <= 0){
this.doWork();
}
}
else{
this.timeUntilNextFirework = 100;
} }
} }
else{
this.timeUntilNextFirework = 100; if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored();
} }
} }
} }
@ -104,6 +111,18 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
return compound; return compound;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
}
@Override @Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
return this.storage.receiveEnergy(maxReceive, simulate); return this.storage.receiveEnergy(maxReceive, simulate);
@ -125,12 +144,12 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }
@ -138,4 +157,19 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
public void activateOnPulse(){ public void activateOnPulse(){
this.doWork(); this.doWork();
} }
@Override
public int getEnergy(){
return this.storage.getEnergyStored();
}
@Override
public void setEnergy(int energy){
this.storage.setEnergyStored(energy);
}
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
} }

View file

@ -61,11 +61,13 @@ public class TileEntityFishingNet extends TileEntityBase{
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop); compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop);
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop");
} }
} }

View file

@ -39,12 +39,12 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }

View file

@ -16,10 +16,11 @@ import ellpeck.actuallyadditions.util.WorldUtil;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider, IEnergySaver{ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider, IEnergySaver, IEnergyDisplay{
public static final int PRODUCE = 10; public static final int PRODUCE = 10;
public EnergyStorage storage = new EnergyStorage(30000); public EnergyStorage storage = new EnergyStorage(30000);
private int oldEnergy;
@Override @Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){
@ -59,16 +60,22 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage); WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
} }
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored();
}
} }
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
} }
@ -86,6 +93,11 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public void setEnergy(int energy){ public void setEnergy(int energy){
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);

View file

@ -66,11 +66,13 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync);
this.timeUntilNextFert = compound.getInteger("Time"); this.timeUntilNextFert = compound.getInteger("Time");
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.readSyncableNBT(compound, isForSync);
compound.setInteger("Time", this.timeUntilNextFert); compound.setInteger("Time", this.timeUntilNextFert);
} }
} }

View file

@ -22,11 +22,12 @@ import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList; import java.util.ArrayList;
public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider, IEnergySaver{ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider, IEnergySaver, IEnergyDisplay{
public static final int ENERGY_PRODUCE = 40; public static final int ENERGY_PRODUCE = 40;
public static final int BLOCKS_NEEDED = 4; public static final int BLOCKS_NEEDED = 4;
public EnergyStorage storage = new EnergyStorage(30000); public EnergyStorage storage = new EnergyStorage(30000);
private int oldEnergy;
@Override @Override
public void updateEntity(){ public void updateEntity(){
@ -58,16 +59,22 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, this.storage); WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, this.storage);
} }
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored();
}
} }
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync);
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.readSyncableNBT(compound, isForSync);
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
} }
@ -96,6 +103,11 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public void setEnergy(int energy){ public void setEnergy(int energy){
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);

View file

@ -52,6 +52,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync);
if(!isForSync || this.shouldSyncSlots()){ if(!isForSync || this.shouldSyncSlots()){
if(this.slots.length > 0){ if(this.slots.length > 0){
NBTTagList tagList = new NBTTagList(); NBTTagList tagList = new NBTTagList();
@ -74,6 +75,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.readSyncableNBT(compound, isForSync);
if(!isForSync || this.shouldSyncSlots()){ if(!isForSync || this.shouldSyncSlots()){
if(this.slots.length > 0){ if(this.slots.length > 0){
NBTTagList tagList = compound.getTagList("Items", 10); NBTTagList tagList = compound.getTagList("Items", 10);

View file

@ -19,7 +19,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyReceiver, IEnergySaver{ public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyReceiver, IEnergySaver, IEnergyDisplay{
public static final int NOT_MULTI = 0; public static final int NOT_MULTI = 0;
public static final int HAS_LAVA = 1; public static final int HAS_LAVA = 1;
@ -51,12 +51,14 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
compound.setInteger("WorkTime", this.currentWorkTime); compound.setInteger("WorkTime", this.currentWorkTime);
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
this.currentWorkTime = compound.getInteger("WorkTime"); this.currentWorkTime = compound.getInteger("WorkTime");
} }
@ -98,6 +100,11 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public void setEnergy(int energy){ public void setEnergy(int energy){
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);

View file

@ -24,12 +24,13 @@ import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyProvider, IEnergySaver{ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyProvider, IEnergySaver, IEnergyDisplay{
public static final int RANGE = 7; public static final int RANGE = 7;
public static final int ENERGY_PRODUCED = 300; public static final int ENERGY_PRODUCED = 300;
public EnergyStorage storage = new EnergyStorage(35000); public EnergyStorage storage = new EnergyStorage(35000);
private int nextUseCounter; private int nextUseCounter;
private int oldEnergy;
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -84,16 +85,22 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage); WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
} }
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored();
}
} }
} }
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound); this.storage.writeToNBT(compound);
} }
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
} }
@ -122,6 +129,11 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public void setEnergy(int energy){ public void setEnergy(int energy){
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);

View file

@ -28,12 +28,14 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList; import java.util.ArrayList;
public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergySaver{ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergySaver, IEnergyDisplay{
public static final int ENERGY_USE_PER_BLOCK = 500; public static final int ENERGY_USE_PER_BLOCK = 500;
public EnergyStorage storage = new EnergyStorage(1000000); public EnergyStorage storage = new EnergyStorage(1000000);
public int layerAt = -1; public int layerAt = -1;
public boolean onlyMineOres; public boolean onlyMineOres;
private int oldLayerAt;
private int oldEnergy;
public TileEntityMiner(){ public TileEntityMiner(){
super(9, "miner"); super(9, "miner");
@ -43,10 +45,11 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
if(!this.worldObj.isRemote){ if(!this.worldObj.isRemote){
if(this.layerAt == -1){
this.layerAt = this.yCoord-1;
}
if(!this.isRedstonePowered && this.ticksElapsed%5 == 0){ if(!this.isRedstonePowered && this.ticksElapsed%5 == 0){
if(this.layerAt == -1){
this.layerAt = this.yCoord-1;
}
if(this.layerAt > 0){ if(this.layerAt > 0){
if(this.mine(TileEntityPhantomface.upgradeRange(2, worldObj, xCoord, yCoord, zCoord))){ if(this.mine(TileEntityPhantomface.upgradeRange(2, worldObj, xCoord, yCoord, zCoord))){
@ -54,6 +57,11 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
} }
} }
} }
if((this.oldEnergy != this.storage.getEnergyStored() || this.oldLayerAt != this.layerAt) && this.sendUpdateWithInterval()){
this.oldEnergy = this.storage.getEnergyStored();
this.oldLayerAt = this.layerAt;
}
} }
} }
@ -182,6 +190,11 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override
public int getMaxEnergy(){
return this.storage.getMaxEnergyStored();
}
@Override @Override
public void setEnergy(int energy){ public void setEnergy(int energy){
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);

View file

@ -33,6 +33,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
public int range; public int range;
public boolean isBreaker; public boolean isBreaker;
private boolean activateOnceWithSignal; private boolean activateOnceWithSignal;
private int oldRange;
public TileEntityPhantomPlacer(int slots, String name){ public TileEntityPhantomPlacer(int slots, String name){
super(slots, name); super(slots, name);
@ -66,6 +67,12 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
} }
} }
if(this.oldRange != this.range){
this.oldRange = this.range;
this.sendUpdate();
}
} }
else{ else{
if(this.boundPosition != null){ if(this.boundPosition != null){
@ -77,11 +84,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
@Override @Override
public boolean hasBoundPosition(){ public boolean hasBoundPosition(){
if(this.boundPosition != null && this.boundPosition.getWorld() != null){ if(this.boundPosition != null && this.boundPosition.getWorld() != null){
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){ if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId)){
this.boundPosition = null; this.boundPosition = null;
return false; return false;
} }
return this.boundPosition.getWorld() == this.worldObj; return this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId;
} }
return false; return false;
} }
@ -160,6 +167,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
compound.setInteger("Range", this.range);
if(this.boundPosition != null){ if(this.boundPosition != null){
compound.setInteger("XCoordOfTileStored", boundPosition.getX()); compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY()); compound.setInteger("YCoordOfTileStored", boundPosition.getY());
@ -175,6 +183,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
int y = compound.getInteger("YCoordOfTileStored"); int y = compound.getInteger("YCoordOfTileStored");
int z = compound.getInteger("ZCoordOfTileStored"); int z = compound.getInteger("ZCoordOfTileStored");
int world = compound.getInteger("WorldOfTileStored"); int world = compound.getInteger("WorldOfTileStored");
this.range = compound.getInteger("Range");
if(!(x == 0 && y == 0 && z == 0)){ if(!(x == 0 && y == 0 && z == 0)){
this.boundPosition = new WorldPos(world, x, y, z); this.boundPosition = new WorldPos(world, x, y, z);
this.markDirty(); this.markDirty();
@ -197,12 +206,12 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean toggle(){ public void toggle(boolean to){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; this.activateOnceWithSignal = to;
} }
@Override @Override
public boolean isRightMode(){ public boolean isPulseMode(){
return this.activateOnceWithSignal; return this.activateOnceWithSignal;
} }

View file

@ -73,6 +73,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync); super.writeSyncableNBT(compound, sync);
compound.setInteger("Range", this.range);
if(this.boundPosition != null){ if(this.boundPosition != null){
compound.setInteger("XCoordOfTileStored", boundPosition.getX()); compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY()); compound.setInteger("YCoordOfTileStored", boundPosition.getY());
@ -88,6 +89,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
int y = compound.getInteger("YCoordOfTileStored"); int y = compound.getInteger("YCoordOfTileStored");
int z = compound.getInteger("ZCoordOfTileStored"); int z = compound.getInteger("ZCoordOfTileStored");
int world = compound.getInteger("WorldOfTileStored"); int world = compound.getInteger("WorldOfTileStored");
this.range = compound.getInteger("Range");
if(!(x == 0 && y == 0 && z == 0)){ if(!(x == 0 && y == 0 && z == 0)){
this.boundPosition = new WorldPos(world, x, y, z); this.boundPosition = new WorldPos(world, x, y, z);
this.markDirty(); this.markDirty();
@ -111,11 +113,11 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
@Override @Override
public boolean hasBoundPosition(){ public boolean hasBoundPosition(){
if(this.boundPosition != null && this.boundPosition.getWorld() != null){ if(this.boundPosition != null && this.boundPosition.getWorld() != null){
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){ if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId)){
this.boundPosition = null; this.boundPosition = null;
return false; return false;
} }
return this.boundPosition.getWorld() == this.worldObj; return this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId;
} }
return false; return false;
} }

View file

@ -40,6 +40,7 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
@Override @Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
if(this.name != null){ if(this.name != null){
compound.setString("Name", this.name); compound.setString("Name", this.name);
} }
@ -47,6 +48,7 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
@Override @Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.name = compound.getString("Name"); this.name = compound.getString("Name");
} }