PROGRESS!!

Yes, this will be progress updates.
A lot.
This commit is contained in:
Ellpeck 2016-01-07 19:04:29 +01:00
parent d39fb82992
commit 02e66e23df
16 changed files with 228 additions and 266 deletions

View file

@ -23,20 +23,14 @@ import net.minecraft.world.World;
/** /**
* This utility class describes a position in the world * This utility class describes a position in the world
*/ */
public class Position{ public class Position extends BlockPos{
private int x;
private int y;
private int z;
public Position(int x, int y, int z){ public Position(int x, int y, int z){
this.x = x; super(x, y, z);
this.y = y;
this.z = z;
} }
public TileEntity getTileEntity(World world){ public TileEntity getTileEntity(World world){
return world != null ? world.getTileEntity(this.toBlockPos()) : null; return world != null ? world.getTileEntity(this) : null;
} }
public Material getMaterial(World world){ public Material getMaterial(World world){
@ -76,19 +70,7 @@ public class Position{
} }
public boolean isEqual(Position pos){ public boolean isEqual(Position pos){
return pos != null && this.x == pos.getX() && this.y == pos.getY() && this.z == pos.getZ(); return pos != null && this.getX() == pos.getX() && this.getY() == pos.getY() && this.getZ() == pos.getZ();
}
public int getX(){
return this.x;
}
public int getY(){
return this.y;
}
public int getZ(){
return this.z;
} }
public boolean setBlock(World world, Block block, int meta, int flag){ public boolean setBlock(World world, Block block, int meta, int flag){
@ -98,35 +80,35 @@ public class Position{
public boolean setBlockState(World world, IBlockState state, int meta, int flag){ public boolean setBlockState(World world, IBlockState state, int meta, int flag){
//TODO Fix meta //TODO Fix meta
return world.setBlockState(this.toBlockPos(), state, flag); return world.setBlockState(this, state, flag);
} }
public Position copy(){ public Position copy(){
return new Position(this.x, this.y, this.z); return new Position(this.getX(), this.getY(), this.getZ());
} }
public String toString(){ public String toString(){
return "["+this.x+", "+this.y+", "+this.z+"]"; return "["+this.getX()+", "+this.getY()+", "+this.getZ()+"]";
} }
public Vec3 toVec(){ public Vec3 toVec(){
return new Vec3(this.x, this.y, this.z); return new Vec3(this.getX(), this.getY(), this.getZ());
}
public BlockPos toBlockPos(){
return new BlockPos(this.x, this.y, this.z);
} }
public IBlockState getBlockState(World world){ public IBlockState getBlockState(World world){
return world != null ? world.getBlockState(this.toBlockPos()) : null; return world != null ? world.getBlockState(this) : null;
} }
public Position getOffsetPosition(EnumFacing side){ public Position getOffsetPosition(EnumFacing side){
return new Position(this.x+side.getFrontOffsetX(), this.y+side.getFrontOffsetY(), this.z+side.getFrontOffsetZ()); return new Position(this.getX()+side.getFrontOffsetX(), this.getY()+side.getFrontOffsetY(), this.getZ()+side.getFrontOffsetZ());
} }
public static Position fromTileEntity(TileEntity tile){ public static Position fromTileEntity(TileEntity tile){
BlockPos pos = tile.getPos(); BlockPos pos = tile.getPos();
return new Position(pos.getX(), pos.getY(), pos.getZ()); return new Position(pos.getX(), pos.getY(), pos.getZ());
} }
public static Position fromBlockPos(BlockPos pos){
return (Position)pos;
}
} }

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.api.block.IHudDisplay; import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
import de.ellpeck.actuallyadditions.api.internal.EntrySet; import de.ellpeck.actuallyadditions.api.internal.EntrySet;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
@ -20,20 +21,16 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBookletStand;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.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.profiler.Profiler; import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.*;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -51,20 +48,9 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
this.setBlockBounds(f, 0F, f, 1F-f, 1F-4*f, 1F-f); this.setBlockBounds(f, 0F, f, 1F-f, 1F-4*f, 1F-f);
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.bookletStandRenderId; return AssetUtil.TESR_RENDER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
} }
@Override @Override
@ -73,44 +59,39 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK_STAND.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK_STAND.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.planks.getIcon(0, 0);
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
Position pos = new Position(x, y, z);
if(rotation == 0){ if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 2, 2); pos.setMetadata(world, 2, 2);
} }
if(rotation == 1){ if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 1, 2); pos.setMetadata(world, 1, 2);
} }
if(rotation == 2){ if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 0, 2); pos.setMetadata(world, 0, 2);
} }
if(rotation == 3){ if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 3, 2); pos.setMetadata(world, 3, 2);
} }
TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(x, y, z); TileEntityBookletStand tile = (TileEntityBookletStand)world.getTileEntity(pos);
if(tile != null){ if(tile != null){
//Assign a UUID //Assign a UUID
if(tile.assignedPlayer == null){ if(tile.assignedPlayer == null){
tile.assignedPlayer = player.getCommandSenderName(); tile.assignedPlayer = player.getName();
tile.markDirty(); tile.markDirty();
tile.sendUpdate(); tile.sendUpdate();
} }
@ -127,7 +108,7 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){ 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); TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityBookletStand){ if(tile instanceof TileEntityBookletStand){
EntrySet set = ((TileEntityBookletStand)tile).assignedEntry; EntrySet set = ((TileEntityBookletStand)tile).assignedEntry;
@ -147,8 +128,8 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
AssetUtil.renderStackToGui(set.chapter.getDisplayItemStack() != null ? set.chapter.getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F); AssetUtil.renderStackToGui(set.chapter.getDisplayItemStack() != null ? set.chapter.getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F);
} }
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
} }

View file

@ -10,28 +10,23 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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.block.state.IBlockState;
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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockCanolaPress extends BlockContainerBase{ public class BlockCanolaPress extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
public BlockCanolaPress(String name){ public BlockCanolaPress(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -46,38 +41,25 @@ public class BlockCanolaPress extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float par7, float par8, float par9){
public IIcon getIcon(int side, int meta){
return side == 1 || side == 0 ? 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){ if(!world.isRemote){
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(x, y, z); TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos);
if(press != null){ if(press != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CANOLA_PRESS.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
return true; return true;
} }
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Top");
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
} }
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){ public void breakBlock(World world, BlockPos pos, IBlockState state){
this.dropInventory(world, x, y, z); this.dropInventory(world, Position.fromBlockPos(pos));
super.breakBlock(world, x, y, z, block, par6); super.breakBlock(world, pos, state);
} }
} }

View file

@ -10,11 +10,11 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.api.block.IHudDisplay; import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile; import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -28,10 +28,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler; import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos; import net.minecraft.util.*;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -60,7 +57,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
@Override @Override
public void breakBlock(World world, BlockPos pos, IBlockState state){ public void breakBlock(World world, BlockPos pos, IBlockState state){
if(this.type == Type.PLACER || this.type == Type.BREAKER){ if(this.type == Type.PLACER || this.type == Type.BREAKER){
this.dropInventory(world, pos); this.dropInventory(world, Position.fromBlockPos(pos));
} }
super.breakBlock(world, pos, state); super.breakBlock(world, pos, state);
} }
@ -82,61 +79,47 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
public IIcon getIcon(int side, int metadata){ if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
return (this.type == Type.FACE && ClientProxy.pumpkinBlurPumpkinBlur && side > 1) ? this.iconSeasonal : this.blockIcon;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ){
if(this.tryToggleRedstone(world, x, y, z, player)){
return true; return true;
} }
if(!world.isRemote){ if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof IPhantomTile && ((IPhantomTile)tile).getGuiID() != -1){ if(tile instanceof IPhantomTile && ((IPhantomTile)tile).getGuiID() != -1){
player.openGui(ActuallyAdditions.instance, ((IPhantomTile)tile).getGuiID(), world, x, y, z); player.openGui(ActuallyAdditions.instance, ((IPhantomTile)tile).getGuiID(), world, pos.getX(), pos.getY(), pos.getZ());
} }
} }
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
this.iconSeasonal = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockPhantomfacePumpkin");
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){ 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); TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(tile != null){ if(tile != null){
if(tile instanceof IPhantomTile){ if(tile instanceof IPhantomTile){
IPhantomTile phantom = (IPhantomTile)tile; 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-40, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.GOLD+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc")+": "+phantom.getRange(), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-40, StringUtil.DECIMAL_COLOR_WHITE);
if(phantom.hasBoundPosition()){ 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())); int distance = (int)new Vec3(posHit.getBlockPos()).distanceTo(new Vec3(phantom.getBoundPosition()));
Item item = phantom.getBoundPosition().getItemBlock(minecraft.theWorld); Item item = phantom.getBoundPosition().getItemBlock(minecraft.theWorld);
String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(minecraft.theWorld), 1, phantom.getBoundPosition().getMetadata(minecraft.theWorld))); String name = item == null ? "Absolutely Nothing" : item.getItemStackDisplayName(new ItemStack(phantom.getBoundPosition().getBlock(minecraft.theWorld), 1, phantom.getBoundPosition().getMetadata(minecraft.theWorld)));
StringUtil.drawSplitString(minecraft.fontRenderer, 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-30, 200, StringUtil.DECIMAL_COLOR_WHITE, true); StringUtil.drawSplitString(minecraft.fontRendererObj, 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-30, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
if(phantom.isBoundThingInRange()){ if(phantom.isBoundThingInRange()){
StringUtil.drawSplitString(minecraft.fontRenderer, 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, true); StringUtil.drawSplitString(minecraft.fontRendererObj, 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, true);
} }
else{ else{
StringUtil.drawSplitString(minecraft.fontRenderer, 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, true); StringUtil.drawSplitString(minecraft.fontRendererObj, 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, true);
} }
} }
else{ else{
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.RED+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+25, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
} }

View file

@ -109,11 +109,11 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
@Override @Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state){ public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
this.updateRedstoneState(world, x, y, z); this.updateRedstoneState(world, pos);
} }
public void updateRedstoneState(World world, int x, int y, int z){ public void updateRedstoneState(World world, Position pos){
if(!world.isRemote){ if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityBase){ if(tile instanceof TileEntityBase){
@ -235,14 +235,14 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
@Override @Override
public void onBlockAdded(World world, int x, int y, int z){ public void onBlockAdded(World world, BlockPos pos, IBlockState state){
this.updateRedstoneState(world, x, y, z); this.updateRedstoneState(world, pos);
} }
public boolean tryToggleRedstone(World world, int x, int y, int z, EntityPlayer player){ public boolean tryToggleRedstone(World world, Position pos, EntityPlayer player){
ItemStack stack = player.getCurrentEquippedItem(); ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){ if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = pos.getTileEntity(world);
if(tile instanceof IRedstoneToggle){ if(tile instanceof IRedstoneToggle){
if(!world.isRemote){ if(!world.isRemote){
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode()); ((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());

View file

@ -13,15 +13,10 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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.util.IIcon;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemCrafterOnAStick extends ItemBase{ public class ItemCrafterOnAStick extends ItemBase{
@ -40,18 +35,6 @@ public class ItemCrafterOnAStick extends ItemBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int pass){
return this.itemIcon;
} }
} }

View file

@ -19,7 +19,6 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;

View file

@ -12,11 +12,12 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyProvider;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -67,25 +68,21 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
} }
} }
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ if(this.storage.getEnergyStored() > 0){
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, storage); WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
} }
if(flag != this.currentBurnTime > 0){ if(flag != this.currentBurnTime > 0){
this.markDirty(); this.markDirty();
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); Position thisPos = Position.fromTileEntity(this);
int meta = thisPos.getMetadata(worldObj);
if(meta == 1){ if(meta == 1){
if(!(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored())){ if(!(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored())){
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); thisPos.setMetadata(worldObj, 0, 2);
} }
} }
else{ else{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); thisPos.setMetadata(worldObj, 1, 2);
} }
} }
@ -114,7 +111,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@ -124,27 +121,27 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return false; return false;
} }
@Override @Override
public int extractEnergy(ForgeDirection from, int maxReceive, boolean simulate){ public int extractEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.storage.extractEnergy(maxReceive, simulate); return this.storage.extractEnergy(maxReceive, simulate);
} }
@Override @Override
public int getEnergyStored(ForgeDirection from){ public int getEnergyStored(EnumFacing from){
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override @Override
public int getMaxEnergyStored(ForgeDirection from){ public int getMaxEnergyStored(EnumFacing from){
return this.storage.getMaxEnergyStored(); return this.storage.getMaxEnergyStored();
} }
@Override @Override
public boolean canConnectEnergy(ForgeDirection from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }

View file

@ -18,7 +18,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockAir; import net.minecraft.block.BlockAir;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -63,20 +63,21 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
} }
private void doWork(){ private void doWork(){
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); Position pos = Position.fromTileEntity(this);
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(pos.getMetadata(worldObj));
for(int i = 0; i < RANGE; i++){ for(int i = 0; i < RANGE; i++){
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, i); Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, pos, i);
if(coordsBlock != null){ if(coordsBlock != null){
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()); Block blockToBreak = coordsBlock.getBlock(worldObj);
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){ if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, pos) > -1.0F){
ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
int meta = worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()); int meta = coordsBlock.getMetadata(worldObj);
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), meta, 0)); drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock, coordsBlock.getBlockState(worldObj), 0));
if(WorldUtil.addToInventory(this, drops, false)){ if(WorldUtil.addToInventory(this, drops, false)){
worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12)); worldObj.playAuxSFX(2001, this.getPos(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i); WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this), i);
WorldUtil.addToInventory(this, drops, true); WorldUtil.addToInventory(this, drops, true);
this.storage.extractEnergy(ENERGY_USE, false); this.storage.extractEnergy(ENERGY_USE, false);
this.markDirty(); this.markDirty();
@ -106,7 +107,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@ -116,27 +117,27 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return true; return true;
} }
@Override @Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.storage.receiveEnergy(maxReceive, simulate); return this.storage.receiveEnergy(maxReceive, simulate);
} }
@Override @Override
public int getEnergyStored(ForgeDirection from){ public int getEnergyStored(EnumFacing from){
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override @Override
public int getMaxEnergyStored(ForgeDirection from){ public int getMaxEnergyStored(EnumFacing from){
return this.storage.getMaxEnergyStored(); return this.storage.getMaxEnergyStored();
} }
@Override @Override
public boolean canConnectEnergy(ForgeDirection from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }

View file

@ -16,6 +16,8 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{ public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
@ -31,20 +33,6 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
this.slots = new ItemStack[itemAmount]; this.slots = new ItemStack[itemAmount];
} }
@Override
public int[] getAccessibleSlotsFromSide(int side){
if(this.slots.length > 0){
int[] theInt = new int[slots.length];
for(int i = 0; i < theInt.length; i++){
theInt[i] = i;
}
return theInt;
}
else{
return new int[0];
}
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -98,12 +86,42 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
@Override @Override
public boolean isUseableByPlayer(EntityPlayer player){ public boolean isUseableByPlayer(EntityPlayer player){
return player.getDistanceSq(xCoord+0.5D, yCoord+0.5D, zCoord+0.5D) <= 64; return player.getDistanceSq(this.getPos().getX()+0.5D, this.pos.getY()+0.5D, this.pos.getZ()+0.5D) <= 64;
} }
@Override @Override
public ItemStack getStackInSlotOnClosing(int i){ public void openInventory(EntityPlayer player){
return getStackInSlot(i);
}
@Override
public void closeInventory(EntityPlayer player){
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return false;
}
@Override
public int getField(int id){
return 0;
}
@Override
public void setField(int id, int value){
}
@Override
public int getFieldCount(){
return 0;
}
@Override
public void clear(){
this.initializeSlots(this.slots.length);
} }
@Override @Override
@ -147,26 +165,37 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
return null; return null;
} }
@Override
public ItemStack removeStackFromSlot(int index){
return this.slots[index] = null;
}
@Override @Override
public String getInventoryName(){ public int[] getSlotsForFace(EnumFacing side){
if(this.slots.length > 0){
int[] theInt = new int[slots.length];
for(int i = 0; i < theInt.length; i++){
theInt[i] = i;
}
return theInt;
}
else{
return new int[0];
}
}
@Override
public String getName(){
return this.name; return this.name;
} }
@Override @Override
public boolean hasCustomInventoryName(){ public boolean hasCustomName(){
return false; return false;
} }
@Override @Override
public void openInventory(){ public IChatComponent getDisplayName(){
return null;
} }
@Override
public void closeInventory(){
}
} }

View file

@ -14,7 +14,7 @@ import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyReceiver;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -95,7 +95,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@ -105,27 +105,27 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == SLOT_OUTPUT; return slot == SLOT_OUTPUT;
} }
@Override @Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.storage.receiveEnergy(maxReceive, simulate); return this.storage.receiveEnergy(maxReceive, simulate);
} }
@Override @Override
public int getEnergyStored(ForgeDirection from){ public int getEnergyStored(EnumFacing from){
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override @Override
public int getMaxEnergyStored(ForgeDirection from){ public int getMaxEnergyStored(EnumFacing from){
return this.storage.getMaxEnergyStored(); return this.storage.getMaxEnergyStored();
} }
@Override @Override
public boolean canConnectEnergy(ForgeDirection from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }

View file

@ -12,11 +12,12 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyProvider;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.*;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -64,7 +65,7 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
int fuelUsed = 50; int fuelUsed = 50;
if(ENERGY_PRODUCED*BURN_TIME <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ if(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
if(this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed){ if(this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed){
this.currentBurnTime = BURN_TIME; this.currentBurnTime = BURN_TIME;
this.tank.drain(fuelUsed, true); this.tank.drain(fuelUsed, true);
@ -73,25 +74,21 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
WorldUtil.emptyBucket(tank, slots, 0, 1, InitBlocks.fluidOil); WorldUtil.emptyBucket(tank, slots, 0, 1, InitBlocks.fluidOil);
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ if(this.storage.getEnergyStored() > 0){
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, storage); WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage);
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage);
} }
if(flag != this.currentBurnTime > 0){ if(flag != this.currentBurnTime > 0){
this.markDirty(); this.markDirty();
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); Position thisPos = Position.fromTileEntity(this);
int meta = thisPos.getMetadata(worldObj);
if(meta == 1){ if(meta == 1){
if(!(ENERGY_PRODUCED*BURN_TIME <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN) && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){ if(!(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored() && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); thisPos.setMetadata(worldObj, 0, 2);
} }
} }
else{ else{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); thisPos.setMetadata(worldObj, 1, 2);
} }
} }
@ -120,7 +117,7 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@ -130,32 +127,32 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == 1; return slot == 1;
} }
@Override @Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate){
return this.storage.extractEnergy(maxExtract, simulate); return this.storage.extractEnergy(maxExtract, simulate);
} }
@Override @Override
public int getEnergyStored(ForgeDirection from){ public int getEnergyStored(EnumFacing from){
return this.storage.getEnergyStored(); return this.storage.getEnergyStored();
} }
@Override @Override
public int getMaxEnergyStored(ForgeDirection from){ public int getMaxEnergyStored(EnumFacing from){
return this.storage.getMaxEnergyStored(); return this.storage.getMaxEnergyStored();
} }
@Override @Override
public boolean canConnectEnergy(ForgeDirection from){ public boolean canConnectEnergy(EnumFacing from){
return true; return true;
} }
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ public int fill(EnumFacing from, FluidStack resource, boolean doFill){
if(resource.getFluid() == InitBlocks.fluidOil){ if(resource.getFluid() == InitBlocks.fluidOil){
return this.tank.fill(resource, doFill); return this.tank.fill(resource, doFill);
} }
@ -163,27 +160,27 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
return null; return null;
} }
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
return null; return null;
} }
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid){ public boolean canFill(EnumFacing from, Fluid fluid){
return from != ForgeDirection.DOWN && fluid == InitBlocks.fluidOil; return from != EnumFacing.DOWN && fluid == InitBlocks.fluidOil;
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid){ public boolean canDrain(EnumFacing from, Fluid fluid){
return false; return false;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){ public FluidTankInfo[] getTankInfo(EnumFacing from){
return new FluidTankInfo[]{this.tank.getInfo()}; return new FluidTankInfo[]{this.tank.getInfo()};
} }

View file

@ -100,7 +100,7 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
@Override @Override
public boolean isBoundThingInRange(){ public boolean isBoundThingInRange(){
return super.isBoundThingInRange() && (worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyReceiver || worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IEnergyProvider); return super.isBoundThingInRange() && (worldObj.getTileEntity(boundPosition.toBlockPos()) instanceof IEnergyReceiver || worldObj.getTileEntity(boundPosition.toBlockPos()) instanceof IEnergyProvider);
} }
private void pushEnergy(EnumFacing side){ private void pushEnergy(EnumFacing side){

View file

@ -10,10 +10,11 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom; import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraft.util.EnumFacing;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
@ -32,19 +33,19 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
if(!worldObj.isRemote){ if(!worldObj.isRemote){
if(this.isRedstonePowered && this.isBoundThingInRange() && this.getHandler() != null){ if(this.isRedstonePowered && this.isBoundThingInRange() && this.getHandler() != null){
this.pushFluid(ForgeDirection.UP); this.pushFluid(EnumFacing.UP);
this.pushFluid(ForgeDirection.DOWN); this.pushFluid(EnumFacing.DOWN);
this.pushFluid(ForgeDirection.NORTH); this.pushFluid(EnumFacing.NORTH);
this.pushFluid(ForgeDirection.EAST); this.pushFluid(EnumFacing.EAST);
this.pushFluid(ForgeDirection.SOUTH); this.pushFluid(EnumFacing.SOUTH);
this.pushFluid(ForgeDirection.WEST); this.pushFluid(EnumFacing.WEST);
} }
} }
} }
public IFluidHandler getHandler(){ public IFluidHandler getHandler(){
if(this.boundPosition != null){ if(this.boundPosition != null){
TileEntity tile = worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()); TileEntity tile = boundPosition.getTileEntity(worldObj);
if(tile instanceof IFluidHandler){ if(tile instanceof IFluidHandler){
return (IFluidHandler)tile; return (IFluidHandler)tile;
} }
@ -52,8 +53,8 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
return null; return null;
} }
private void pushFluid(ForgeDirection side){ private void pushFluid(EnumFacing side){
TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, xCoord, yCoord, zCoord); TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, Position.fromTileEntity(this));
if(tile != null && tile instanceof IFluidHandler && this.getTankInfo(side) != null && this.getTankInfo(side).length > 0 && ((IFluidHandler)tile).getTankInfo(side.getOpposite()) != null && ((IFluidHandler)tile).getTankInfo(side.getOpposite()).length > 0){ if(tile != null && tile instanceof IFluidHandler && this.getTankInfo(side) != null && this.getTankInfo(side).length > 0 && ((IFluidHandler)tile).getTankInfo(side.getOpposite()) != null && ((IFluidHandler)tile).getTankInfo(side.getOpposite()).length > 0){
for(FluidTankInfo myInfo : this.getTankInfo(side)){ for(FluidTankInfo myInfo : this.getTankInfo(side)){
for(FluidTankInfo hisInfo : ((IFluidHandler)tile).getTankInfo(side.getOpposite())){ for(FluidTankInfo hisInfo : ((IFluidHandler)tile).getTankInfo(side.getOpposite())){
@ -73,11 +74,11 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
@Override @Override
public boolean isBoundThingInRange(){ public boolean isBoundThingInRange(){
return super.isBoundThingInRange() && worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IFluidHandler; return super.isBoundThingInRange() && boundPosition.getTileEntity(worldObj) instanceof IFluidHandler;
} }
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ public int fill(EnumFacing from, FluidStack resource, boolean doFill){
if(this.isBoundThingInRange()){ if(this.isBoundThingInRange()){
return this.getHandler().fill(from, resource, doFill); return this.getHandler().fill(from, resource, doFill);
} }
@ -85,7 +86,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
} }
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
if(this.isBoundThingInRange()){ if(this.isBoundThingInRange()){
return this.getHandler().drain(from, resource, doDrain); return this.getHandler().drain(from, resource, doDrain);
} }
@ -93,7 +94,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
} }
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
if(this.isBoundThingInRange()){ if(this.isBoundThingInRange()){
return this.getHandler().drain(from, maxDrain, doDrain); return this.getHandler().drain(from, maxDrain, doDrain);
} }
@ -101,17 +102,17 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
} }
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid){ public boolean canFill(EnumFacing from, Fluid fluid){
return this.isBoundThingInRange() && this.getHandler().canFill(from, fluid); return this.isBoundThingInRange() && this.getHandler().canFill(from, fluid);
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid){ public boolean canDrain(EnumFacing from, Fluid fluid){
return this.isBoundThingInRange() && this.getHandler().canDrain(from, fluid); return this.isBoundThingInRange() && this.getHandler().canDrain(from, fluid);
} }
@Override @Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){ public FluidTankInfo[] getTankInfo(EnumFacing from){
if(this.isBoundThingInRange()){ if(this.isBoundThingInRange()){
return this.getHandler().getTankInfo(from); return this.getHandler().getTankInfo(from);
} }

View file

@ -31,6 +31,7 @@ import org.lwjgl.opengl.GL12;
public class AssetUtil{ public class AssetUtil{
public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("guiInventory"); public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("guiInventory");
public static final int TESR_RENDER_ID = 2;
public static int compostRenderId; public static int compostRenderId;
public static int fishingNetRenderId; public static int fishingNetRenderId;

View file

@ -56,6 +56,15 @@ public class WorldUtil{
public static Position getCoordsFromSide(EnumFacing side, Position pos, int offset){ public static Position getCoordsFromSide(EnumFacing side, Position pos, int offset){
return new Position(pos.getX()+side.getFrontOffsetX()*(offset+1), pos.getY()+side.getFrontOffsetY()*(offset+1), pos.getZ()+side.getFrontOffsetZ()*(offset+1)); return new Position(pos.getX()+side.getFrontOffsetX()*(offset+1), pos.getY()+side.getFrontOffsetY()*(offset+1), pos.getZ()+side.getFrontOffsetZ()*(offset+1));
} }
public static void pushEnergyToAllSides(World world, Position pos, EnergyStorage storage){
WorldUtil.pushEnergy(world, pos, EnumFacing.UP, storage);
WorldUtil.pushEnergy(world, pos, EnumFacing.DOWN, storage);
WorldUtil.pushEnergy(world, pos, EnumFacing.NORTH, storage);
WorldUtil.pushEnergy(world, pos, EnumFacing.EAST, storage);
WorldUtil.pushEnergy(world, pos, EnumFacing.SOUTH, storage);
WorldUtil.pushEnergy(world, pos, EnumFacing.WEST, storage);
}
public static void pushEnergy(World world, Position pos, EnumFacing side, EnergyStorage storage){ public static void pushEnergy(World world, Position pos, EnumFacing side, EnergyStorage storage){
TileEntity tile = getTileEntityFromSide(side, world, pos); TileEntity tile = getTileEntityFromSide(side, world, pos);
@ -224,6 +233,23 @@ public class WorldUtil{
} }
} }
public static EnumFacing getDirectionByPistonRotation(int meta){
switch(meta){
case 0:
return EnumFacing.UP;
case 1:
return EnumFacing.DOWN;
case 2:
return EnumFacing.NORTH;
case 3:
return EnumFacing.EAST;
case 4:
return EnumFacing.SOUTH;
default:
return EnumFacing.WEST;
}
}
public static ArrayList<Material> getMaterialsAround(World world, Position pos){ public static ArrayList<Material> getMaterialsAround(World world, Position pos){
ArrayList<Material> blocks = new ArrayList<Material>(); ArrayList<Material> blocks = new ArrayList<Material>();
blocks.add(pos.getOffsetPosition(EnumFacing.NORTH).getMaterial(world)); blocks.add(pos.getOffsetPosition(EnumFacing.NORTH).getMaterial(world));