mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
PROGRESS!!
Yes, this will be progress updates. A lot.
This commit is contained in:
parent
d39fb82992
commit
02e66e23df
16 changed files with 228 additions and 266 deletions
|
@ -23,20 +23,14 @@ import net.minecraft.world.World;
|
|||
/**
|
||||
* This utility class describes a position in the world
|
||||
*/
|
||||
public class Position{
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
public class Position extends BlockPos{
|
||||
|
||||
public Position(int x, int y, int z){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
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){
|
||||
|
@ -76,19 +70,7 @@ public class Position{
|
|||
}
|
||||
|
||||
public boolean isEqual(Position pos){
|
||||
return pos != null && this.x == pos.getX() && this.y == pos.getY() && this.z == pos.getZ();
|
||||
}
|
||||
|
||||
public int getX(){
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY(){
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ(){
|
||||
return this.z;
|
||||
return pos != null && this.getX() == pos.getX() && this.getY() == pos.getY() && this.getZ() == pos.getZ();
|
||||
}
|
||||
|
||||
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){
|
||||
//TODO Fix meta
|
||||
return world.setBlockState(this.toBlockPos(), state, flag);
|
||||
return world.setBlockState(this, state, flag);
|
||||
}
|
||||
|
||||
public Position copy(){
|
||||
return new Position(this.x, this.y, this.z);
|
||||
return new Position(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "["+this.x+", "+this.y+", "+this.z+"]";
|
||||
return "["+this.getX()+", "+this.getY()+", "+this.getZ()+"]";
|
||||
}
|
||||
|
||||
public Vec3 toVec(){
|
||||
return new Vec3(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public BlockPos toBlockPos(){
|
||||
return new BlockPos(this.x, this.y, this.z);
|
||||
return new Vec3(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
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){
|
||||
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){
|
||||
BlockPos pos = tile.getPos();
|
||||
return new Position(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
public static Position fromBlockPos(BlockPos pos){
|
||||
return (Position)pos;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.Position;
|
||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||
import de.ellpeck.actuallyadditions.api.internal.EntrySet;
|
||||
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.StringUtil;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return AssetUtil.bookletStandRenderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata){
|
||||
return this.blockIcon;
|
||||
return AssetUtil.TESR_RENDER_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,44 +59,39 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BOOK_STAND.ordinal(), world, x, y, z);
|
||||
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, pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = Blocks.planks.getIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.rare;
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
Position pos = new Position(x, y, z);
|
||||
|
||||
if(rotation == 0){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
pos.setMetadata(world, 2, 2);
|
||||
}
|
||||
if(rotation == 1){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
pos.setMetadata(world, 1, 2);
|
||||
}
|
||||
if(rotation == 2){
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||
pos.setMetadata(world, 0, 2);
|
||||
}
|
||||
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){
|
||||
//Assign a UUID
|
||||
if(tile.assignedPlayer == null){
|
||||
tile.assignedPlayer = player.getCommandSenderName();
|
||||
tile.assignedPlayer = player.getName();
|
||||
tile.markDirty();
|
||||
tile.sendUpdate();
|
||||
}
|
||||
|
@ -127,7 +108,7 @@ public class BlockBookletStand extends BlockContainerBase implements IHudDisplay
|
|||
@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);
|
||||
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
||||
if(tile instanceof TileEntityBookletStand){
|
||||
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);
|
||||
}
|
||||
minecraft.fontRenderer.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+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,28 +10,23 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.Position;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
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.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
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.IIcon;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCanolaPress extends BlockContainerBase{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon topIcon;
|
||||
|
||||
public BlockCanolaPress(String name){
|
||||
super(Material.rock, name);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
|
@ -46,38 +41,25 @@ public class BlockCanolaPress extends BlockContainerBase{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
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){
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float par7, float par8, float par9){
|
||||
if(!world.isRemote){
|
||||
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(x, y, z);
|
||||
TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(pos);
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.rare;
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
||||
this.dropInventory(world, x, y, z);
|
||||
super.breakBlock(world, x, y, z, block, par6);
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.Position;
|
||||
import de.ellpeck.actuallyadditions.api.block.IHudDisplay;
|
||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
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.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
|
@ -28,10 +28,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -60,7 +57,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
|||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state){
|
||||
if(this.type == Type.PLACER || this.type == Type.BREAKER){
|
||||
this.dropInventory(world, pos);
|
||||
this.dropInventory(world, Position.fromBlockPos(pos));
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
@ -82,61 +79,47 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata){
|
||||
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)){
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){
|
||||
if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
|
||||
return true;
|
||||
}
|
||||
if(!world.isRemote){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.epic;
|
||||
return EnumRarity.EPIC;
|
||||
}
|
||||
|
||||
@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);
|
||||
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
||||
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-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()){
|
||||
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);
|
||||
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()){
|
||||
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{
|
||||
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{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,11 +109,11 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state){
|
||||
this.updateRedstoneState(world, x, y, z);
|
||||
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock){
|
||||
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){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile instanceof TileEntityBase){
|
||||
|
@ -235,14 +235,14 @@ public abstract class BlockContainerBase extends BlockContainer{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z){
|
||||
this.updateRedstoneState(world, x, y, z);
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state){
|
||||
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();
|
||||
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(!world.isRemote){
|
||||
((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode());
|
||||
|
|
|
@ -13,15 +13,10 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
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.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemCrafterOnAStick extends ItemBase{
|
||||
|
||||
|
@ -40,18 +35,6 @@ public class ItemCrafterOnAStick extends ItemBase{
|
|||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
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;
|
||||
return EnumRarity.EPIC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
|||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
|
|
@ -12,11 +12,12 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import de.ellpeck.actuallyadditions.api.Position;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
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.SideOnly;
|
||||
|
||||
|
@ -67,25 +68,21 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
}
|
||||
}
|
||||
|
||||
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){
|
||||
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, 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(this.storage.getEnergyStored() > 0){
|
||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
||||
}
|
||||
|
||||
if(flag != this.currentBurnTime > 0){
|
||||
this.markDirty();
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
Position thisPos = Position.fromTileEntity(this);
|
||||
int meta = thisPos.getMetadata(worldObj);
|
||||
if(meta == 1){
|
||||
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{
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2);
|
||||
thisPos.setMetadata(worldObj, 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +111,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
|
@ -124,27 +121,27 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return false;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from){
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from){
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from){
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.SideOnly;
|
||||
|
||||
|
@ -63,20 +63,21 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
}
|
||||
|
||||
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++){
|
||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, i);
|
||||
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, pos, i);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||
Block blockToBreak = coordsBlock.getBlock(worldObj);
|
||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, pos) > -1.0F){
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
int meta = worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), meta, 0));
|
||||
int meta = coordsBlock.getMetadata(worldObj);
|
||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock, coordsBlock.getBlockState(worldObj), 0));
|
||||
|
||||
if(WorldUtil.addToInventory(this, drops, false)){
|
||||
worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
worldObj.playAuxSFX(2001, this.getPos(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this), i);
|
||||
WorldUtil.addToInventory(this, drops, true);
|
||||
this.storage.extractEnergy(ENERGY_USE, false);
|
||||
this.markDirty();
|
||||
|
@ -106,7 +107,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
|
@ -116,27 +117,27 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return true;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from){
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from){
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from){
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ import net.minecraft.inventory.ISidedInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
|
||||
|
||||
|
@ -31,20 +33,6 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
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
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
|
@ -98,12 +86,42 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
|
||||
@Override
|
||||
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
|
||||
public ItemStack getStackInSlotOnClosing(int i){
|
||||
return getStackInSlot(i);
|
||||
public void openInventory(EntityPlayer player){
|
||||
|
||||
}
|
||||
|
||||
@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
|
||||
|
@ -147,26 +165,37 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index){
|
||||
return this.slots[index] = null;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName(){
|
||||
public boolean hasCustomName(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(){
|
||||
|
||||
public IChatComponent getDisplayName(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import cofh.api.energy.EnergyStorage;
|
|||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.SideOnly;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
|
@ -105,27 +105,27 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return slot == SLOT_OUTPUT;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from){
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from){
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from){
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import de.ellpeck.actuallyadditions.api.Position;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
@ -64,7 +65,7 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
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){
|
||||
this.currentBurnTime = BURN_TIME;
|
||||
this.tank.drain(fuelUsed, true);
|
||||
|
@ -73,25 +74,21 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
|
|||
|
||||
WorldUtil.emptyBucket(tank, slots, 0, 1, InitBlocks.fluidOil);
|
||||
|
||||
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){
|
||||
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, 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(this.storage.getEnergyStored() > 0){
|
||||
WorldUtil.pushEnergyToAllSides(worldObj, Position.fromTileEntity(this), this.storage);
|
||||
}
|
||||
|
||||
if(flag != this.currentBurnTime > 0){
|
||||
this.markDirty();
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
Position thisPos = Position.fromTileEntity(this);
|
||||
int meta = thisPos.getMetadata(worldObj);
|
||||
if(meta == 1){
|
||||
if(!(ENERGY_PRODUCED*BURN_TIME <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN) && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
|
||||
if(!(ENERGY_PRODUCED*BURN_TIME <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored() && this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= fuelUsed)){
|
||||
thisPos.setMetadata(worldObj, 0, 2);
|
||||
}
|
||||
}
|
||||
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
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
public boolean canInsertItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
|
@ -130,32 +127,32 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from){
|
||||
public int getEnergyStored(EnumFacing from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from){
|
||||
public int getMaxEnergyStored(EnumFacing from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from){
|
||||
public boolean canConnectEnergy(EnumFacing from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill){
|
||||
if(resource.getFluid() == InitBlocks.fluidOil){
|
||||
return this.tank.fill(resource, doFill);
|
||||
}
|
||||
|
@ -163,27 +160,27 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid){
|
||||
return from != ForgeDirection.DOWN && fluid == InitBlocks.fluidOil;
|
||||
public boolean canFill(EnumFacing from, Fluid fluid){
|
||||
return from != EnumFacing.DOWN && fluid == InitBlocks.fluidOil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid){
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from){
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
||||
return new FluidTankInfo[]{this.tank.getInfo()};
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
|
||||
@Override
|
||||
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){
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.Position;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||
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.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
@ -32,19 +33,19 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
|
||||
if(!worldObj.isRemote){
|
||||
if(this.isRedstonePowered && this.isBoundThingInRange() && this.getHandler() != null){
|
||||
this.pushFluid(ForgeDirection.UP);
|
||||
this.pushFluid(ForgeDirection.DOWN);
|
||||
this.pushFluid(ForgeDirection.NORTH);
|
||||
this.pushFluid(ForgeDirection.EAST);
|
||||
this.pushFluid(ForgeDirection.SOUTH);
|
||||
this.pushFluid(ForgeDirection.WEST);
|
||||
this.pushFluid(EnumFacing.UP);
|
||||
this.pushFluid(EnumFacing.DOWN);
|
||||
this.pushFluid(EnumFacing.NORTH);
|
||||
this.pushFluid(EnumFacing.EAST);
|
||||
this.pushFluid(EnumFacing.SOUTH);
|
||||
this.pushFluid(EnumFacing.WEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IFluidHandler getHandler(){
|
||||
if(this.boundPosition != null){
|
||||
TileEntity tile = worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
|
||||
TileEntity tile = boundPosition.getTileEntity(worldObj);
|
||||
if(tile instanceof IFluidHandler){
|
||||
return (IFluidHandler)tile;
|
||||
}
|
||||
|
@ -52,8 +53,8 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
return null;
|
||||
}
|
||||
|
||||
private void pushFluid(ForgeDirection side){
|
||||
TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, xCoord, yCoord, zCoord);
|
||||
private void pushFluid(EnumFacing side){
|
||||
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){
|
||||
for(FluidTankInfo myInfo : this.getTankInfo(side)){
|
||||
for(FluidTankInfo hisInfo : ((IFluidHandler)tile).getTankInfo(side.getOpposite())){
|
||||
|
@ -73,11 +74,11 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
|
||||
@Override
|
||||
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
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
|
||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill){
|
||||
if(this.isBoundThingInRange()){
|
||||
return this.getHandler().fill(from, resource, doFill);
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
|
||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
|
||||
if(this.isBoundThingInRange()){
|
||||
return this.getHandler().drain(from, resource, doDrain);
|
||||
}
|
||||
|
@ -93,7 +94,7 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
|
||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
|
||||
if(this.isBoundThingInRange()){
|
||||
return this.getHandler().drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
@ -101,17 +102,17 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid){
|
||||
public boolean canFill(EnumFacing from, Fluid fluid){
|
||||
return this.isBoundThingInRange() && this.getHandler().canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid){
|
||||
public boolean canDrain(EnumFacing from, Fluid fluid){
|
||||
return this.isBoundThingInRange() && this.getHandler().canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from){
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
||||
if(this.isBoundThingInRange()){
|
||||
return this.getHandler().getTankInfo(from);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.lwjgl.opengl.GL12;
|
|||
public class AssetUtil{
|
||||
|
||||
public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("guiInventory");
|
||||
public static final int TESR_RENDER_ID = 2;
|
||||
|
||||
public static int compostRenderId;
|
||||
public static int fishingNetRenderId;
|
||||
|
|
|
@ -56,6 +56,15 @@ public class WorldUtil{
|
|||
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));
|
||||
}
|
||||
|
||||
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){
|
||||
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){
|
||||
ArrayList<Material> blocks = new ArrayList<Material>();
|
||||
blocks.add(pos.getOffsetPosition(EnumFacing.NORTH).getMaterial(world));
|
||||
|
|
Loading…
Reference in a new issue