mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Added fancy hud display instead of chat messages to most blocks
This commit is contained in:
parent
1a13ef9b13
commit
92dc77839d
33 changed files with 383 additions and 185 deletions
|
@ -25,7 +25,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -96,25 +95,20 @@ public class BlockAtomicReconstructor extends BlockContainerBase{
|
|||
if(!world.isRemote){
|
||||
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(x, y, z);
|
||||
if(reconstructor != null){
|
||||
if(!player.isSneaking()){
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if(heldItem != null){
|
||||
if(heldItem.getItem() instanceof ItemLens && reconstructor.getStackInSlot(0) == null){
|
||||
ItemStack toPut = heldItem.copy();
|
||||
toPut.stackSize = 1;
|
||||
reconstructor.setInventorySlotContents(0, toPut);
|
||||
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);
|
||||
}
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if(heldItem != null){
|
||||
if(heldItem.getItem() instanceof ItemLens && reconstructor.getStackInSlot(0) == null){
|
||||
ItemStack toPut = heldItem.copy();
|
||||
toPut.stackSize = 1;
|
||||
reconstructor.setInventorySlotContents(0, toPut);
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -52,17 +51,7 @@ public class BlockFireworkBox extends BlockContainerBase{
|
|||
|
||||
@Override
|
||||
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 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;
|
||||
return this.tryToggleRedstone(world, x, y, z, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,12 +17,10 @@ import ellpeck.actuallyadditions.tile.TileEntityFurnaceSolar;
|
|||
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -63,18 +61,6 @@ public class BlockFurnaceSolar extends BlockContainerBase{
|
|||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
|
|
|
@ -17,11 +17,9 @@ import ellpeck.actuallyadditions.tile.TileEntityHeatCollector;
|
|||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
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);
|
||||
}
|
||||
|
||||
@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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
|
|
|
@ -17,16 +17,19 @@ import ellpeck.actuallyadditions.tile.TileEntityLavaFactoryController;
|
|||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockLavaFactoryController extends BlockContainerBase{
|
||||
public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon topIcon;
|
||||
|
@ -50,25 +53,6 @@ public class BlockLavaFactoryController extends BlockContainerBase{
|
|||
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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
|
@ -80,4 +64,18 @@ public class BlockLavaFactoryController extends BlockContainerBase{
|
|||
public EnumRarity getRarity(ItemStack stack){
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,9 @@ import ellpeck.actuallyadditions.util.ModUtil;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
|
|
|
@ -17,18 +17,22 @@ import ellpeck.actuallyadditions.blocks.base.BlockContainerBase;
|
|||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityMiner;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMiner extends BlockContainerBase{
|
||||
public class BlockMiner extends BlockContainerBase implements IHudDisplay{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
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){
|
||||
if(!world.isRemote){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileEntityMiner){
|
||||
if(player.isSneaking()){
|
||||
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);
|
||||
}
|
||||
if(tile instanceof TileEntityMiner){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.MINER.ordinal(), world, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -96,4 +92,14 @@ public class BlockMiner extends BlockContainerBase{
|
|||
this.dropInventory(world, x, y, z);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,18 +20,22 @@ import ellpeck.actuallyadditions.util.ModUtil;
|
|||
import ellpeck.actuallyadditions.util.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockPhantom extends BlockContainerBase{
|
||||
public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
||||
|
||||
public Type type;
|
||||
public int range;
|
||||
|
@ -92,32 +96,8 @@ public class BlockPhantom extends BlockContainerBase{
|
|||
}
|
||||
if(!world.isRemote){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null){
|
||||
if(tile instanceof IPhantomTile){
|
||||
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);
|
||||
}
|
||||
}
|
||||
if(tile instanceof IPhantomTile && ((IPhantomTile)tile).getGuiID() != -1){
|
||||
player.openGui(ActuallyAdditions.instance, ((IPhantomTile)tile).getGuiID(), world, x, y, z);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -136,6 +116,33 @@ public class BlockPhantom extends BlockContainerBase{
|
|||
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{
|
||||
FACE,
|
||||
PLACER,
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -28,7 +28,6 @@ import net.minecraft.item.EnumRarity;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
|
@ -118,7 +117,7 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
tile.markDirty();
|
||||
}
|
||||
if(tile instanceof IRedstoneToggle){
|
||||
if(((IRedstoneToggle)tile).isRightMode() && powered){
|
||||
if(((IRedstoneToggle)tile).isPulseMode() && powered){
|
||||
((IRedstoneToggle)tile).activateOnPulse();
|
||||
}
|
||||
}
|
||||
|
@ -227,12 +226,10 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof IRedstoneToggle){
|
||||
if(!world.isRemote){
|
||||
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
|
||||
|
||||
if(((IRedstoneToggle)tile).toggle()){
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Pulse Mode"));
|
||||
}
|
||||
else{
|
||||
player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Deactivation Mode"));
|
||||
if(tile instanceof TileEntityBase){
|
||||
((TileEntityBase)tile).sendUpdate();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
78
src/main/java/ellpeck/actuallyadditions/event/HudEvent.java
Normal file
78
src/main/java/ellpeck/actuallyadditions/event/HudEvent.java
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -35,6 +35,7 @@ public class InitEvents{
|
|||
|
||||
public static void initClient(){
|
||||
Util.registerEvent(new TooltipEvent());
|
||||
Util.registerEvent(new HudEvent());
|
||||
|
||||
if(Loader.isModLoaded("NotEnoughItems")){
|
||||
Util.registerEvent(new NEIScreenEvents());
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -12,9 +12,9 @@ package ellpeck.actuallyadditions.tile;
|
|||
|
||||
public interface IRedstoneToggle{
|
||||
|
||||
boolean toggle();
|
||||
void toggle(boolean to);
|
||||
|
||||
boolean isRightMode();
|
||||
boolean isPulseMode();
|
||||
|
||||
void activateOnPulse();
|
||||
}
|
||||
|
|
|
@ -25,12 +25,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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 EnergyStorage storage = new EnergyStorage(300000);
|
||||
private int currentTime;
|
||||
private boolean activateOnceWithSignal;
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityAtomicReconstructor(){
|
||||
super(1, "reconstructor");
|
||||
|
@ -52,6 +53,10 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy(){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,11 +111,15 @@ public abstract class TileEntityBase extends TileEntity{
|
|||
}
|
||||
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
|
||||
if(this instanceof IRedstoneToggle){
|
||||
compound.setBoolean("IsPulseMode", ((IRedstoneToggle)this).isPulseMode());
|
||||
}
|
||||
}
|
||||
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
|
||||
if(this instanceof IRedstoneToggle){
|
||||
((IRedstoneToggle)this).toggle(compound.getBoolean("IsPulseMode"));
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedstonePowered(boolean powered){
|
||||
|
|
|
@ -25,6 +25,7 @@ public class TileEntityBookletStand extends TileEntityBase{
|
|||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.writeSyncableNBT(compound, isForSync);
|
||||
compound.setTag("SavedEntry", this.assignedEntry.writeToNBT());
|
||||
|
||||
if(this.assignedPlayer != null){
|
||||
|
@ -34,6 +35,7 @@ public class TileEntityBookletStand extends TileEntityBase{
|
|||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.readSyncableNBT(compound, isForSync);
|
||||
this.assignedEntry = EntrySet.readFromNBT(compound.getCompoundTag("SavedEntry"));
|
||||
|
||||
String player = compound.getString("Player");
|
||||
|
|
|
@ -110,12 +110,12 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,12 +151,12 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,12 +95,12 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,24 +22,31 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import net.minecraft.util.MathHelper;
|
||||
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 EnergyStorage storage = new EnergyStorage(20000);
|
||||
private int timeUntilNextFirework;
|
||||
private boolean activateOnceWithSignal;
|
||||
private int oldEnergy;
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
if(!this.worldObj.isRemote && !this.isRedstonePowered && !this.activateOnceWithSignal){
|
||||
if(this.timeUntilNextFirework > 0){
|
||||
this.timeUntilNextFirework--;
|
||||
if(this.timeUntilNextFirework <= 0){
|
||||
this.doWork();
|
||||
if(!this.worldObj.isRemote){
|
||||
if(!this.isRedstonePowered && !this.activateOnceWithSignal){
|
||||
if(this.timeUntilNextFirework > 0){
|
||||
this.timeUntilNextFirework--;
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
|
@ -125,12 +144,12 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
@ -138,4 +157,19 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
|
|||
public void activateOnPulse(){
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,11 +61,13 @@ public class TileEntityFishingNet extends TileEntityBase{
|
|||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.writeSyncableNBT(compound, sync);
|
||||
compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.readSyncableNBT(compound, sync);
|
||||
this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,11 @@ import ellpeck.actuallyadditions.util.WorldUtil;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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 EnergyStorage storage = new EnergyStorage(30000);
|
||||
private int oldEnergy;
|
||||
|
||||
@Override
|
||||
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.WEST, storage);
|
||||
}
|
||||
|
||||
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||
this.oldEnergy = this.storage.getEnergyStored();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -86,6 +93,11 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro
|
|||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy(){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
|
|
|
@ -66,11 +66,13 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
|
|||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.writeSyncableNBT(compound, isForSync);
|
||||
this.timeUntilNextFert = compound.getInteger("Time");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.readSyncableNBT(compound, isForSync);
|
||||
compound.setInteger("Time", this.timeUntilNextFert);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,12 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
|
||||
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 BLOCKS_NEEDED = 4;
|
||||
public EnergyStorage storage = new EnergyStorage(30000);
|
||||
private int oldEnergy;
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
|
@ -58,16 +59,22 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){
|
||||
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, this.storage);
|
||||
}
|
||||
|
||||
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||
this.oldEnergy = this.storage.getEnergyStored();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.writeSyncableNBT(compound, isForSync);
|
||||
this.storage.writeToNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.readSyncableNBT(compound, isForSync);
|
||||
this.storage.readFromNBT(compound);
|
||||
}
|
||||
|
||||
|
@ -96,6 +103,11 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy(){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
|
|
|
@ -52,6 +52,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.writeSyncableNBT(compound, isForSync);
|
||||
if(!isForSync || this.shouldSyncSlots()){
|
||||
if(this.slots.length > 0){
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
@ -74,6 +75,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||
super.readSyncableNBT(compound, isForSync);
|
||||
if(!isForSync || this.shouldSyncSlots()){
|
||||
if(this.slots.length > 0){
|
||||
NBTTagList tagList = compound.getTagList("Items", 10);
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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 HAS_LAVA = 1;
|
||||
|
@ -51,12 +51,14 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.writeSyncableNBT(compound, sync);
|
||||
this.storage.writeToNBT(compound);
|
||||
compound.setInteger("WorkTime", this.currentWorkTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.readSyncableNBT(compound, sync);
|
||||
this.storage.readFromNBT(compound);
|
||||
this.currentWorkTime = compound.getInteger("WorkTime");
|
||||
}
|
||||
|
@ -98,6 +100,11 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I
|
|||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy(){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
|
|
|
@ -24,12 +24,13 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import java.util.ArrayList;
|
||||
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 ENERGY_PRODUCED = 300;
|
||||
public EnergyStorage storage = new EnergyStorage(35000);
|
||||
private int nextUseCounter;
|
||||
private int oldEnergy;
|
||||
|
||||
@Override
|
||||
@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.WEST, storage);
|
||||
}
|
||||
|
||||
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
|
||||
this.oldEnergy = this.storage.getEnergyStored();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -122,6 +129,11 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
|
|||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy(){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
|
|
|
@ -28,12 +28,14 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||
|
||||
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 EnergyStorage storage = new EnergyStorage(1000000);
|
||||
public int layerAt = -1;
|
||||
public boolean onlyMineOres;
|
||||
private int oldLayerAt;
|
||||
private int oldEnergy;
|
||||
|
||||
public TileEntityMiner(){
|
||||
super(9, "miner");
|
||||
|
@ -43,10 +45,11 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR
|
|||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
if(!this.worldObj.isRemote){
|
||||
if(this.layerAt == -1){
|
||||
this.layerAt = this.yCoord-1;
|
||||
}
|
||||
|
||||
if(!this.isRedstonePowered && this.ticksElapsed%5 == 0){
|
||||
if(this.layerAt == -1){
|
||||
this.layerAt = this.yCoord-1;
|
||||
}
|
||||
|
||||
if(this.layerAt > 0){
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy(){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(int energy){
|
||||
this.storage.setEnergyStored(energy);
|
||||
|
|
|
@ -33,6 +33,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
public int range;
|
||||
public boolean isBreaker;
|
||||
private boolean activateOnceWithSignal;
|
||||
private int oldRange;
|
||||
|
||||
public TileEntityPhantomPlacer(int slots, String 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{
|
||||
if(this.boundPosition != null){
|
||||
|
@ -77,11 +84,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
@Override
|
||||
public boolean hasBoundPosition(){
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
return this.boundPosition.getWorld() == this.worldObj;
|
||||
return this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -160,6 +167,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.writeSyncableNBT(compound, sync);
|
||||
compound.setInteger("Range", this.range);
|
||||
if(this.boundPosition != null){
|
||||
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||
|
@ -175,6 +183,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
int y = compound.getInteger("YCoordOfTileStored");
|
||||
int z = compound.getInteger("ZCoordOfTileStored");
|
||||
int world = compound.getInteger("WorldOfTileStored");
|
||||
this.range = compound.getInteger("Range");
|
||||
if(!(x == 0 && y == 0 && z == 0)){
|
||||
this.boundPosition = new WorldPos(world, x, y, z);
|
||||
this.markDirty();
|
||||
|
@ -197,12 +206,12 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean toggle(){
|
||||
return this.activateOnceWithSignal = !this.activateOnceWithSignal;
|
||||
public void toggle(boolean to){
|
||||
this.activateOnceWithSignal = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRightMode(){
|
||||
public boolean isPulseMode(){
|
||||
return this.activateOnceWithSignal;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.writeSyncableNBT(compound, sync);
|
||||
compound.setInteger("Range", this.range);
|
||||
if(this.boundPosition != null){
|
||||
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
|
||||
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
|
||||
|
@ -88,6 +89,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
int y = compound.getInteger("YCoordOfTileStored");
|
||||
int z = compound.getInteger("ZCoordOfTileStored");
|
||||
int world = compound.getInteger("WorldOfTileStored");
|
||||
this.range = compound.getInteger("Range");
|
||||
if(!(x == 0 && y == 0 && z == 0)){
|
||||
this.boundPosition = new WorldPos(world, x, y, z);
|
||||
this.markDirty();
|
||||
|
@ -111,11 +113,11 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
@Override
|
||||
public boolean hasBoundPosition(){
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
return this.boundPosition.getWorld() == this.worldObj;
|
||||
return this.worldObj.provider.dimensionId == this.boundPosition.getWorld().provider.dimensionId;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
|
|||
|
||||
@Override
|
||||
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.writeSyncableNBT(compound, sync);
|
||||
if(this.name != null){
|
||||
compound.setString("Name", this.name);
|
||||
}
|
||||
|
@ -47,6 +48,7 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
|
|||
|
||||
@Override
|
||||
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
|
||||
super.readSyncableNBT(compound, sync);
|
||||
this.name = compound.getString("Name");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue