Remember how I said "I'm nearing the end of bugfixing"?

Well that was a lie apparently.
This commit is contained in:
Ellpeck 2016-01-07 21:41:28 +01:00
parent db1e183e45
commit 020745a813
70 changed files with 671 additions and 1726 deletions

View file

@ -59,31 +59,23 @@ public class Position extends BlockPos{
} }
public int getMetadata(IBlockAccess world){ public int getMetadata(IBlockAccess world){
//TODO Fix meta return this.getBlock(world).getMetaFromState(this.getBlockState(world));
return /*world != null ? world.getBlockMetadata(this.x, this.y, this.z) : */0;
} }
public void setMetadata(IBlockAccess world, int meta, int flag){ public void setMetadata(World world, int meta, int flag){
//TODO Fix meta if(world != null){
/*if(world != null){ world.setBlockState(this, this.getBlock(world).getStateFromMeta(meta), flag);
world.setBlockMetadataWithNotify(this.x, this.y, this.z, meta, flag); }
}*/ }
public boolean setBlock(World world, Block block, int meta, int flag){
return world.setBlockState(this, block.getStateFromMeta(meta), flag);
} }
public boolean isEqual(Position pos){ public boolean isEqual(Position pos){
return pos != null && this.getX() == pos.getX() && this.getY() == pos.getY() && this.getZ() == pos.getZ(); 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){
//TODO Fix meta
return world != null && this.setBlockState(world, block.getDefaultState(), meta, flag);
}
public boolean setBlockState(World world, IBlockState state, int meta, int flag){
//TODO Fix meta
return world.setBlockState(this, state, flag);
}
public Position copy(){ public Position copy(){
return new Position(this.getX(), this.getY(), this.getZ()); return new Position(this.getX(), this.getY(), this.getZ());
} }
@ -115,4 +107,8 @@ public class Position extends BlockPos{
public static Position fromBlockPos(BlockPos pos){ public static Position fromBlockPos(BlockPos pos){
return (Position)pos; return (Position)pos;
} }
public boolean setBlockState(World world, IBlockState state, int flag){
return world.setBlockState(this, state, flag);
}
} }

View file

@ -38,7 +38,7 @@ public interface IAtomicReconstructor{
/** /**
* Returns the world of the reconstructor * Returns the world of the reconstructor
*/ */
World getWorld(); World getWorldObject();
/** /**
* Extracts a specified amount of energy from the Reconstructor's RF storage * Extracts a specified amount of energy from the Reconstructor's RF storage

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.lens.ILensItem; import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -17,33 +18,27 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
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;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
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.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.BlockPos;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
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;
public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay{ public class BlockAtomicReconstructor extends BlockContainerBase implements IHudDisplay{
@SideOnly(Side.CLIENT)
private IIcon frontIcon;
@SideOnly(Side.CLIENT)
private IIcon topIcon;
public BlockAtomicReconstructor(String name){ public BlockAtomicReconstructor(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -54,40 +49,15 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player); int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
world.setBlockMetadataWithNotify(x, y, z, rotation, 2); Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
int meta = world.getBlockMetadata(x, y, z);
if(side != meta && (side == 0 || side == 1)){
return this.topIcon;
}
if(side == meta){
return this.frontIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
if(side == 0 || side == 1){
return this.topIcon;
}
if(side == 3){
return this.frontIcon;
}
return this.blockIcon;
} }
@Override @Override
@ -96,12 +66,12 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
if(this.tryToggleRedstone(world, x, y, z, player)){ if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
return true; return true;
} }
if(!world.isRemote){ if(!world.isRemote){
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(x, y, z); TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor)world.getTileEntity(pos);
if(reconstructor != null){ if(reconstructor != null){
ItemStack heldItem = player.getCurrentEquippedItem(); ItemStack heldItem = player.getCurrentEquippedItem();
if(heldItem != null){ if(heldItem != null){
@ -123,29 +93,21 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Top");
}
@Override @Override
public TileEntity createNewTileEntity(World world, int i){ public TileEntity createNewTileEntity(World world, int i){
return new TileEntityAtomicReconstructor(); return new TileEntityAtomicReconstructor();
} }
@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);
} }
@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 TileEntityAtomicReconstructor){ if(tile instanceof TileEntityAtomicReconstructor){
ItemStack slot = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0); ItemStack slot = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
String strg; String strg;
@ -157,7 +119,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F); AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
} }
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
} }

View file

@ -11,11 +11,6 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBushBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockBlackLotus extends BlockBushBase{ public class BlockBlackLotus extends BlockBushBase{
@ -23,15 +18,4 @@ public class BlockBlackLotus extends BlockBushBase{
super(name); super(name);
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
} }

View file

@ -10,33 +10,25 @@
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.TileEntityBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
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.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
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.world.IBlockAccess; 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 BlockBreaker extends BlockContainerBase{ public class BlockBreaker extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon frontIcon;
@SideOnly(Side.CLIENT)
private IIcon topIcon;
private boolean isPlacer; private boolean isPlacer;
public BlockBreaker(boolean isPlacer, String name){ public BlockBreaker(boolean isPlacer, String name){
@ -54,69 +46,36 @@ public class BlockBreaker extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
int meta = world.getBlockMetadata(x, y, z);
if(side != meta && (side == 0 || side == 1)){
return this.topIcon;
}
if(side == meta){
return this.frontIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
if(side == 0 || side == 1){
return this.topIcon;
}
if(side == 3){
return this.frontIcon;
}
return 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(this.tryToggleRedstone(world, x, y, z, player)){
return true; return true;
} }
if(!world.isRemote){ if(!world.isRemote){
TileEntityBreaker breaker = (TileEntityBreaker)world.getTileEntity(x, y, z); TileEntityBreaker breaker = (TileEntityBreaker)world.getTileEntity(pos);
if(breaker != null){ if(breaker != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BREAKER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.BREAKER.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.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
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.uncommon; return EnumRarity.UNCOMMON;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player); int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
world.setBlockMetadataWithNotify(x, y, z, rotation, 2); Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
} }
@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,20 +10,21 @@
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.proxy.ClientProxy; import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
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.util.EnumParticleTypes;
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;
@ -32,11 +33,6 @@ import java.util.Random;
public class BlockCoalGenerator extends BlockContainerBase{ public class BlockCoalGenerator extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockCoalGenerator(String name){ public BlockCoalGenerator(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -53,50 +49,36 @@ public class BlockCoalGenerator extends BlockContainerBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){ public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
return side <= 1 ? (side == 0 ? this.bottomIcon : this.topIcon) : this.blockIcon; int meta = Position.fromBlockPos(pos).getMetadata(world);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
int meta = world.getBlockMetadata(x, y, z);
if(meta == 1){ if(meta == 1){
for(int i = 0; i < 5; i++){ for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? "heart" : "smoke", (double)x+0.5F, (double)y+1.0F, (double)z+0.5F, 0.0D, 0.0D, 0.0D); world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
} }
} }
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
TileEntityCoalGenerator press = (TileEntityCoalGenerator)world.getTileEntity(x, y, z); TileEntityCoalGenerator press = (TileEntityCoalGenerator)world.getTileEntity(pos);
if(press != null){ if(press != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COAL_GENERATOR.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COAL_GENERATOR.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");
this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Bottom");
}
@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,25 +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.TileEntityCoffeeMachine; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
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.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.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.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockCoffeeMachine extends BlockContainerBase{ public class BlockCoffeeMachine extends BlockContainerBase{
@ -43,20 +41,9 @@ public class BlockCoffeeMachine extends BlockContainerBase{
this.setBlockBounds(f, 0F, f, 1F-f, 1F-2*f, 1F-f); this.setBlockBounds(f, 0F, f, 1F-f, 1F-2*f, 1F-f);
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.coffeeMachineRenderId; return AssetUtil.TESR_RENDER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
} }
@Override @Override
@ -65,56 +52,51 @@ public class BlockCoffeeMachine extends BlockContainerBase{
} }
@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 f6, float f7, float f8, float f9){
if(!world.isRemote){ if(!world.isRemote){
TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(x, y, z); TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(pos);
if(machine != null){ if(machine != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.COFFEE_MACHINE.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 = Blocks.coal_block.getIcon(0, 0);
}
@Override @Override
public TileEntity createNewTileEntity(World world, int meta){ public TileEntity createNewTileEntity(World world, int meta){
return new TileEntityCoffeeMachine(); return new TileEntityCoffeeMachine();
} }
@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);
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, 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 thePos = Position.fromBlockPos(pos);
if(rotation == 0){ if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 2, 2); thePos.setMetadata(world, 0, 2);
} }
if(rotation == 1){ if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 1, 2); thePos.setMetadata(world, 3, 2);
} }
if(rotation == 2){ if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 0, 2); thePos.setMetadata(world, 1, 2);
} }
if(rotation == 3){ if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 3, 2); thePos.setMetadata(world, 2, 2);
} }
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
} }
} }

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.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer; import de.ellpeck.actuallyadditions.mod.items.ItemFertilizer;
@ -18,22 +19,17 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
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.Block;
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.Entity; import net.minecraft.entity.Entity;
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.AxisAlignedBB; import net.minecraft.util.*;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
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;
@ -52,35 +48,24 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
this.setBlockBoundsForItemRender(); this.setBlockBoundsForItemRender();
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.compostRenderId; return AssetUtil.TESR_RENDER_ID;
} }
@Override @Override
@SideOnly(Side.CLIENT) public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity){
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB mask, List list, Entity collidingEntity){
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
super.addCollisionBoxesToList(world, x, y, z, mask, list, collidingEntity); super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
float f = 0.125F; float f = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, x, y, z, mask, list, collidingEntity); super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
super.addCollisionBoxesToList(world, x, y, z, mask, list, collidingEntity); super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBounds(1.0F-f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.setBlockBounds(1.0F-f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, x, y, z, mask, list, collidingEntity); super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 1.0F-f, 1.0F, 1.0F, 1.0F); this.setBlockBounds(0.0F, 0.0F, 1.0F-f, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(world, x, y, z, mask, list, collidingEntity); super.addCollisionBoxesToList(world, pos, state, mask, list, collidingEntity);
this.setBlockBoundsForItemRender(); this.setBlockBoundsForItemRender();
} }
@ -90,10 +75,10 @@ public class BlockCompost 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 f6, float f7, float f8, float f9){
if(!world.isRemote){ if(!world.isRemote){
ItemStack stackPlayer = player.getCurrentEquippedItem(); ItemStack stackPlayer = player.getCurrentEquippedItem();
TileEntityCompost tile = (TileEntityCompost)world.getTileEntity(x, y, z); TileEntityCompost tile = (TileEntityCompost)world.getTileEntity(pos);
//Add items to be composted //Add items to be composted
if(stackPlayer != null && stackPlayer.getItem() instanceof ItemMisc && stackPlayer.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal() && (tile.slots[0] == null || (!(tile.slots[0].getItem() instanceof ItemFertilizer) && tile.slots[0].stackSize < TileEntityCompost.AMOUNT))){ if(stackPlayer != null && stackPlayer.getItem() instanceof ItemMisc && stackPlayer.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal() && (tile.slots[0] == null || (!(tile.slots[0].getItem() instanceof ItemFertilizer) && tile.slots[0].stackSize < TileEntityCompost.AMOUNT))){
if(tile.slots[0] == null){ if(tile.slots[0] == null){
@ -129,32 +114,26 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
this.setBlockBounds(f, 0.0F, f, 1.0F-f, 1.0F, 1.0F-f); this.setBlockBounds(f, 0.0F, f, 1.0F-f, 1.0F, 1.0F-f);
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.planks.getIcon(0, 0);
}
@Override @Override
public TileEntity createNewTileEntity(World world, int meta){ public TileEntity createNewTileEntity(World world, int meta){
return new TileEntityCompost(); return new TileEntityCompost();
} }
@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);
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.UNCOMMON;
} }
@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 TileEntityCompost){ if(tile instanceof TileEntityCompost){
ItemStack slot = ((TileEntityCompost)tile).getStackInSlot(0); ItemStack slot = ((TileEntityCompost)tile).getStackInSlot(0);
String strg; String strg;
@ -166,7 +145,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F); AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
} }
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg, resolution.getScaledWidth()/2+35, resolution.getScaledHeight()/2-25, StringUtil.DECIMAL_COLOR_WHITE);
} }
} }
} }

View file

@ -13,16 +13,15 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -41,26 +40,21 @@ public class BlockCrystal extends BlockBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public int damageDropped(IBlockState state){
public IIcon getIcon(int side, int metadata){ return this.getMetaFromState(state);
return this.blockIcon;
}
@Override
public int damageDropped(int meta){
return meta;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getRenderColor(int meta){ public int getRenderColor(IBlockState state){
return meta >= allCrystals.length ? super.getRenderColor(meta) : allCrystals[meta].color; int meta = this.getMetaFromState(state);
return meta >= allCrystals.length ? super.getRenderColor(state) : allCrystals[meta].color;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z){ public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass){
return this.getRenderColor(world.getBlockMetadata(x, y, z)); return this.getRenderColor(world.getBlockState(pos));
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@ -71,12 +65,6 @@ public class BlockCrystal extends BlockBase{
} }
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
@Override @Override
public Class<? extends ItemBlockBase> getItemBlock(){ public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class; return TheItemBlock.class;
@ -84,7 +72,7 @@ public class BlockCrystal extends BlockBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allCrystals.length ? EnumRarity.common : allCrystals[stack.getItemDamage()].rarity; return stack.getItemDamage() >= allCrystals.length ? EnumRarity.COMMON : allCrystals[stack.getItemDamage()].rarity;
} }
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{

View file

@ -10,33 +10,25 @@
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.TileEntityDirectionalBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
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.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
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.world.IBlockAccess; 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 BlockDirectionalBreaker extends BlockContainerBase{ public class BlockDirectionalBreaker extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon frontIcon;
@SideOnly(Side.CLIENT)
private IIcon topIcon;
public BlockDirectionalBreaker(String name){ public BlockDirectionalBreaker(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -51,69 +43,36 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
int meta = world.getBlockMetadata(x, y, z);
if(side != meta && (side == 0 || side == 1)){
return this.topIcon;
}
if(side == meta){
return this.frontIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
if(side == 0 || side == 1){
return this.topIcon;
}
if(side == 3){
return this.frontIcon;
}
return 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(this.tryToggleRedstone(world, x, y, z, player)){
return true; return true;
} }
if(!world.isRemote){ if(!world.isRemote){
TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker)world.getTileEntity(x, y, z); TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker)world.getTileEntity(pos);
if(breaker != null){ if(breaker != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.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.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
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.epic; return EnumRarity.EPIC;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player); int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
world.setBlockMetadataWithNotify(x, y, z, rotation, 2); Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
} }
@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,33 +10,25 @@
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.TileEntityDropper; import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
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.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
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.world.IBlockAccess; 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 BlockDropper extends BlockContainerBase{ public class BlockDropper extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon frontIcon;
@SideOnly(Side.CLIENT)
private IIcon topIcon;
public BlockDropper(String name){ public BlockDropper(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -51,69 +43,36 @@ public class BlockDropper extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ if(this.tryToggleRedstone(world, Position.fromBlockPos(pos), player)){
int meta = world.getBlockMetadata(x, y, z);
if(side != meta && (side == 0 || side == 1)){
return this.topIcon;
}
if(side == meta){
return this.frontIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
if(side == 0 || side == 1){
return this.topIcon;
}
if(side == 3){
return this.frontIcon;
}
return 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(this.tryToggleRedstone(world, x, y, z, player)){
return true; return true;
} }
if(!world.isRemote){ if(!world.isRemote){
TileEntityDropper dropper = (TileEntityDropper)world.getTileEntity(x, y, z); TileEntityDropper dropper = (TileEntityDropper)world.getTileEntity(pos);
if(dropper != null){ if(dropper != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.DROPPER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.DROPPER.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.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
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 onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player); int rotation = BlockPistonBase.getFacingFromEntity(world, pos, player).ordinal();
world.setBlockMetadataWithNotify(x, y, z, rotation, 2); Position.fromBlockPos(pos).setMetadata(world, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
} }
@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,30 +10,24 @@
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.TileEntityEnergizer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
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 BlockEnergizer extends BlockContainerBase{ public class BlockEnergizer extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon sideIcon;
private boolean isEnergizer; private boolean isEnergizer;
public BlockEnergizer(boolean isEnergizer, String name){ public BlockEnergizer(boolean isEnergizer, String name){
@ -51,24 +45,18 @@ public class BlockEnergizer extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(int side, int meta){
return side == 1 ? this.topIcon : (side == 0 ? this.blockIcon : this.sideIcon);
}
@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){
if(this.isEnergizer){ if(this.isEnergizer){
TileEntityEnergizer energizer = (TileEntityEnergizer)world.getTileEntity(x, y, z); TileEntityEnergizer energizer = (TileEntityEnergizer)world.getTileEntity(pos);
if(energizer != null){ if(energizer != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.ENERGIZER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.ENERGIZER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
} }
else{ else{
TileEntityEnervator energizer = (TileEntityEnervator)world.getTileEntity(x, y, z); TileEntityEnervator energizer = (TileEntityEnervator)world.getTileEntity(pos);
if(energizer != null){ if(energizer != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.ENERVATOR.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.ENERVATOR.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
} }
return true; return true;
@ -76,22 +64,14 @@ public class BlockEnergizer extends BlockContainerBase{
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");
this.sideIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Side");
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@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,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.TileEntityFeeder; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder;
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 BlockFeeder extends BlockContainerBase{ public class BlockFeeder extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
public BlockFeeder(String name){ public BlockFeeder(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -46,38 +41,25 @@ public class BlockFeeder extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(int side, int metadata){
return (side == 0 || side == 1) ? this.topIcon : this.blockIcon;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
TileEntityFeeder feeder = (TileEntityFeeder)world.getTileEntity(x, y, z); TileEntityFeeder feeder = (TileEntityFeeder)world.getTileEntity(pos);
if(feeder != null){ if(feeder != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FEEDER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FEEDER.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.uncommon; return EnumRarity.UNCOMMON;
} }
@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

@ -47,7 +47,7 @@ public class BlockFishingNet extends BlockContainerBase{
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.fishingNetRenderId; return AssetUtil.TESR_RENDER_ID;
} }
@Override @Override

View file

@ -10,21 +10,22 @@
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.proxy.ClientProxy; import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceDouble;
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.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
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.util.EnumParticleTypes;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -35,13 +36,6 @@ import java.util.Random;
public class BlockFurnaceDouble extends BlockContainerBase{ public class BlockFurnaceDouble extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon onIcon;
@SideOnly(Side.CLIENT)
private IIcon frontIcon;
public BlockFurnaceDouble(String name){ public BlockFurnaceDouble(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -58,73 +52,45 @@ public class BlockFurnaceDouble extends BlockContainerBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
int meta = world.getBlockMetadata(x, y, z); int meta = Position.fromBlockPos(pos).getMetadata(world);
if(side == 1){
return this.topIcon;
}
if(side == meta+2 && meta <= 3){
return this.frontIcon;
}
else if(side == meta-2 && meta > 3){
return this.onIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
if(side == 1){
return this.topIcon;
}
if(side == 3){
return this.frontIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
int meta = world.getBlockMetadata(x, y, z);
if(meta > 3){ if(meta > 3){
float f = (float)x+0.5F; float f = (float)pos.getX()+0.5F;
float f1 = (float)y+0.0F+rand.nextFloat()*6.0F/16.0F; float f1 = (float)pos.getY()+0.0F+rand.nextFloat()*6.0F/16.0F;
float f2 = (float)z+0.5F; float f2 = (float)pos.getZ()+0.5F;
float f3 = 0.52F; float f3 = 0.52F;
float f4 = rand.nextFloat()*0.6F-0.3F; float f4 = rand.nextFloat()*0.6F-0.3F;
if(meta == 6){ if(meta == 6){
world.spawnParticle("smoke", (double)(f-f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(f-f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f-f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.FLAME, (double)(f-f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D);
} }
if(meta == 7){ if(meta == 7){
world.spawnParticle("smoke", (double)(f+f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(f+f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f+f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.FLAME, (double)(f+f3), (double)f1, (double)(f2+f4), 0.0D, 0.0D, 0.0D);
} }
if(meta == 4){ if(meta == 4){
world.spawnParticle("smoke", (double)(f+f4), (double)f1, (double)(f2-f3), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(f+f4), (double)f1, (double)(f2-f3), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f+f4), (double)f1, (double)(f2-f3), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.FLAME, (double)(f+f4), (double)f1, (double)(f2-f3), 0.0D, 0.0D, 0.0D);
} }
if(meta == 5){ if(meta == 5){
world.spawnParticle("smoke", (double)(f+f4), (double)f1, (double)(f2+f3), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(f+f4), (double)f1, (double)(f2+f3), 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", (double)(f+f4), (double)f1, (double)(f2+f3), 0.0D, 0.0D, 0.0D); world.spawnParticle(EnumParticleTypes.FLAME, (double)(f+f4), (double)f1, (double)(f2+f3), 0.0D, 0.0D, 0.0D);
} }
for(int i = 0; i < 5; i++){ for(int i = 0; i < 5; i++){
world.spawnParticle(ClientProxy.bulletForMyValentine ? "heart" : "smoke", (double)x+0.5F, (double)y+1.0F, (double)z+0.5F, 0.0D, 0.0D, 0.0D); world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
} }
} }
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble)world.getTileEntity(x, y, z); TileEntityFurnaceDouble furnace = (TileEntityFurnaceDouble)world.getTileEntity(pos);
if(furnace != null){ if(furnace != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FURNACE_DOUBLE.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.FURNACE_DOUBLE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
return true; return true;
} }
@ -132,47 +98,39 @@ public class BlockFurnaceDouble extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public int getLightValue(IBlockAccess world, BlockPos pos){
public void registerBlockIcons(IIconRegister iconReg){ return Position.fromBlockPos(pos).getMetadata(world) > 3 ? 12 : 0;
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Top");
this.onIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"On");
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z){
return world.getBlockMetadata(x, y, z) > 3 ? 12 : 0;
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.UNCOMMON;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, 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 thePos = Position.fromBlockPos(pos);
if(rotation == 0){ if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 0, 2); thePos.setMetadata(world, 0, 2);
} }
if(rotation == 1){ if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 3, 2); thePos.setMetadata(world, 3, 2);
} }
if(rotation == 2){ if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 1, 2); thePos.setMetadata(world, 1, 2);
} }
if(rotation == 3){ if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 2, 2); thePos.setMetadata(world, 2, 2);
} }
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
} }
@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

@ -14,15 +14,10 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.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 BlockFurnaceSolar extends BlockContainerBase{ public class BlockFurnaceSolar extends BlockContainerBase{
@ -40,20 +35,9 @@ public class BlockFurnaceSolar extends BlockContainerBase{
return new TileEntityFurnaceSolar(); return new TileEntityFurnaceSolar();
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.furnaceSolarRenderId; return AssetUtil.TESR_RENDER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
} }
@Override @Override
@ -61,14 +45,8 @@ public class BlockFurnaceSolar extends BlockContainerBase{
return false; return false;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.daylight_detector.getIcon(0, 0);
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.UNCOMMON;
} }
} }

View file

@ -11,14 +11,9 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
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.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockGeneric extends BlockBase{ public class BlockGeneric extends BlockBase{
@ -30,20 +25,8 @@ public class BlockGeneric extends BlockBase{
this.setStepSound(soundTypeStone); this.setStepSound(soundTypeStone);
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.common; return EnumRarity.COMMON;
} }
} }

View file

@ -12,15 +12,11 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGreenhouseGlass; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGreenhouseGlass;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
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.Facing; import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
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;
@ -35,22 +31,10 @@ public class BlockGreenhouseGlass extends BlockContainerBase{
this.setStepSound(soundTypeStone); this.setStepSound(soundTypeStone);
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int meta){ public EnumWorldBlockLayer getBlockLayer(){
return world.getBlockMetadata(x, y, z) != world.getBlockMetadata(x-Facing.offsetsXForSide[meta], y-Facing.offsetsYForSide[meta], z-Facing.offsetsZForSide[meta]) || (world.getBlock(x, y, z) != this && super.shouldSideBeRendered(world, x, y, z, meta)); return EnumWorldBlockLayer.CUTOUT;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
} }
@Override @Override
@ -58,21 +42,9 @@ public class BlockGreenhouseGlass extends BlockContainerBase{
return false; return false;
} }
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass(){
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@Override @Override

View file

@ -10,20 +10,21 @@
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.proxy.ClientProxy; import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder;
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.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -34,12 +35,6 @@ import java.util.Random;
public class BlockGrinder extends BlockContainerBase{ public class BlockGrinder extends BlockContainerBase{
private final boolean isDouble; private final boolean isDouble;
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon onIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockGrinder(boolean isDouble, String name){ public BlockGrinder(boolean isDouble, String name){
super(Material.rock, name); super(Material.rock, name);
@ -58,40 +53,26 @@ public class BlockGrinder extends BlockContainerBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){ public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
if(side == 1 && meta != 1){ Position thePos = Position.fromBlockPos(pos);
return this.topIcon; int meta = thePos.getMetadata(world);
}
if(side == 1){
return this.onIcon;
}
if(side == 0){
return this.bottomIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
int meta = world.getBlockMetadata(x, y, z);
if(meta == 1){ if(meta == 1){
for(int i = 0; i < 5; i++){ for(int i = 0; i < 5; i++){
double xRand = rand.nextDouble()/0.75D-0.5D; double xRand = rand.nextDouble()/0.75D-0.5D;
double zRand = rand.nextDouble()/0.75D-0.5D; double zRand = rand.nextDouble()/0.75D-0.5D;
world.spawnParticle("crit", (double)x+0.4F, (double)y+0.8F, (double)z+0.4F, xRand, 0.5D, zRand); world.spawnParticle(EnumParticleTypes.CRIT, (double)pos.getX()+0.4F, (double)pos.getY()+0.8F, (double)pos.getZ()+0.4F, xRand, 0.5D, zRand);
} }
world.spawnParticle(ClientProxy.bulletForMyValentine ? "heart" : "smoke", (double)x+0.5F, (double)y+1.0F, (double)z+0.5F, 0.0D, 0.0D, 0.0D); world.spawnParticle(ClientProxy.bulletForMyValentine ? EnumParticleTypes.HEART : EnumParticleTypes.SMOKE_NORMAL, (double)pos.getX()+0.5F, (double)pos.getY()+1.0F, (double)pos.getZ()+0.5F, 0.0D, 0.0D, 0.0D);
} }
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
TileEntityGrinder grinder = (TileEntityGrinder)world.getTileEntity(x, y, z); TileEntityGrinder grinder = (TileEntityGrinder)world.getTileEntity(pos);
if(grinder != null){ if(grinder != null){
player.openGui(ActuallyAdditions.instance, this.isDouble ? GuiHandler.GuiTypes.GRINDER_DOUBLE.ordinal() : GuiHandler.GuiTypes.GRINDER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, this.isDouble ? GuiHandler.GuiTypes.GRINDER_DOUBLE.ordinal() : GuiHandler.GuiTypes.GRINDER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
return true; return true;
} }
@ -99,27 +80,18 @@ public class BlockGrinder extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public int getLightValue(IBlockAccess world, BlockPos pos){
public void registerBlockIcons(IIconRegister iconReg){ return Position.fromBlockPos(pos).getMetadata(world) == 1 ? 12 : 0;
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockGrinderTop");
this.onIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockGrinderOn");
this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":blockGrinderBottom");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z){
return world.getBlockMetadata(x, y, z) == 1 ? 12 : 0;
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@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

@ -12,24 +12,14 @@ package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector; import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
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.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockHeatCollector extends BlockContainerBase{ public class BlockHeatCollector extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockHeatCollector(String name){ public BlockHeatCollector(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -43,22 +33,8 @@ public class BlockHeatCollector extends BlockContainerBase{
return new TileEntityHeatCollector(); return new TileEntityHeatCollector();
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return side == 1 ? this.topIcon : (side == 0 ? this.bottomIcon : this.blockIcon);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Side");
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Top");
this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Bottom");
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.UNCOMMON;
} }
} }

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.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.blocks.base.ItemBlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
@ -21,15 +22,14 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.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 BlockInputter extends BlockContainerBase{ public class BlockInputter extends BlockContainerBase{
@ -53,17 +53,11 @@ public class BlockInputter extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(int side, int meta){
return 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){
TileEntityInputter inputter = (TileEntityInputter)world.getTileEntity(x, y, z); TileEntityInputter inputter = (TileEntityInputter)world.getTileEntity(pos);
if(inputter != null){ if(inputter != null){
player.openGui(ActuallyAdditions.instance, this.isAdvanced ? GuiHandler.GuiTypes.INPUTTER_ADVANCED.ordinal() : GuiHandler.GuiTypes.INPUTTER.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, this.isAdvanced ? GuiHandler.GuiTypes.INPUTTER_ADVANCED.ordinal() : GuiHandler.GuiTypes.INPUTTER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
return true; return true;
} }
@ -71,21 +65,15 @@ public class BlockInputter extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public void breakBlock(World world, BlockPos pos, IBlockState state){
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
if(!world.isRemote){ if(!world.isRemote){
TileEntity aTile = world.getTileEntity(x, y, z); TileEntity aTile = world.getTileEntity(pos);
if(aTile instanceof TileEntityInventoryBase){ if(aTile instanceof TileEntityInventoryBase){
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile; TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
this.dropSlotFromInventory(0, tile, world, x, y, z); this.dropSlotFromInventory(0, tile, world, Position.fromBlockPos(pos));
} }
} }
super.breakBlock(world, x, y, z, block, par6); super.breakBlock(world, pos, state);
} }
@Override @Override
@ -95,7 +83,7 @@ public class BlockInputter extends BlockContainerBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{

View file

@ -47,7 +47,7 @@ public class BlockLaserRelay extends BlockContainerBase{
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.laserRelayRenderId; return AssetUtil.TESR_RENDER_ID;
} }
@Override @Override

View file

@ -18,13 +18,11 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
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.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler; import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition; 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;
@ -32,9 +30,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{ public class BlockLavaFactoryController extends BlockContainerBase implements IHudDisplay{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
public BlockLavaFactoryController(String name){ public BlockLavaFactoryController(String name){
super(Material.rock, name); super(Material.rock, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -48,35 +43,22 @@ public class BlockLavaFactoryController extends BlockContainerBase implements IH
return new TileEntityLavaFactoryController(); return new TileEntityLavaFactoryController();
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
return side == 1 ? this.topIcon : this.blockIcon;
}
@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
@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){
TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ); TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)minecraft.theWorld.getTileEntity(posHit.getBlockPos());
if(factory != null){ if(factory != null){
int state = factory.isMultiblock(); int state = factory.isMultiblock();
if(state == TileEntityLavaFactoryController.NOT_MULTI){ if(state == TileEntityLavaFactoryController.NOT_MULTI){
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true); StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
} }
else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){ else if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){
StringUtil.drawSplitString(minecraft.fontRenderer, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true); StringUtil.drawSplitString(minecraft.fontRendererObj, StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, 200, StringUtil.DECIMAL_COLOR_WHITE, true);
} }
} }
} }

View file

@ -10,27 +10,19 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator;
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.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.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockLeafGenerator extends BlockContainerBase{ public class BlockLeafGenerator extends BlockContainerBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
public BlockLeafGenerator(String name){ public BlockLeafGenerator(String name){
super(Material.iron, name); super(Material.iron, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
@ -44,28 +36,14 @@ public class BlockLeafGenerator extends BlockContainerBase{
return new TileEntityLeafGenerator(); return new TileEntityLeafGenerator();
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
return side <= 1 ? (side == 0 ? this.bottomIcon : this.topIcon) : this.blockIcon;
}
@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");
this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Bottom");
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@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

@ -14,15 +14,10 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBooster; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBooster;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.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 BlockPhantomBooster extends BlockContainerBase{ public class BlockPhantomBooster extends BlockContainerBase{
@ -37,20 +32,9 @@ public class BlockPhantomBooster extends BlockContainerBase{
this.setBlockBounds(3*f, 0F, 3*f, 1-3*f, 1F, 1-3*f); this.setBlockBounds(3*f, 0F, 3*f, 1-3*f, 1F, 1-3*f);
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.phantomBoosterRenderId; return AssetUtil.TESR_RENDER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
} }
@Override @Override
@ -58,15 +42,9 @@ public class BlockPhantomBooster extends BlockContainerBase{
return false; return false;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.lapis_block.getIcon(0, 0);
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@Override @Override

View file

@ -10,22 +10,20 @@
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.TileEntityRangedCollector; import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector;
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 BlockRangedCollector extends BlockContainerBase{ public class BlockRangedCollector extends BlockContainerBase{
@ -43,45 +41,33 @@ public class BlockRangedCollector extends BlockContainerBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
public IIcon getIcon(int side, int meta){
return 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){
TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(x, y, z); TileEntityRangedCollector breaker = (TileEntityRangedCollector)world.getTileEntity(pos);
if(breaker != null){ if(breaker != null){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.RANGED_COLLECTOR.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.RANGED_COLLECTOR.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());
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
@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){
if(!world.isRemote){ if(!world.isRemote){
TileEntity aTile = world.getTileEntity(x, y, z); TileEntity aTile = world.getTileEntity(pos);
if(aTile instanceof TileEntityRangedCollector){ if(aTile instanceof TileEntityRangedCollector){
TileEntityRangedCollector tile = (TileEntityRangedCollector)aTile; TileEntityRangedCollector tile = (TileEntityRangedCollector)aTile;
for(int i = 0; i < TileEntityRangedCollector.WHITELIST_START; i++){ for(int i = 0; i < TileEntityRangedCollector.WHITELIST_START; i++){
this.dropSlotFromInventory(i, tile, world, x, y, z); this.dropSlotFromInventory(i, tile, world, Position.fromBlockPos(pos));
} }
} }
} }
super.breakBlock(world, x, y, z, block, par6); super.breakBlock(world, pos, state);
} }
} }

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.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements; import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
@ -17,19 +18,15 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
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.Entity; import net.minecraft.entity.Entity;
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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.*;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -48,20 +45,9 @@ public class BlockSmileyCloud extends BlockContainerBase{
this.setTickRandomly(true); this.setTickRandomly(true);
} }
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override @Override
public int getRenderType(){ public int getRenderType(){
return AssetUtil.smileyCloudRenderId; return AssetUtil.TESR_RENDER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
return this.blockIcon;
} }
@Override @Override
@ -71,23 +57,23 @@ public class BlockSmileyCloud extends BlockContainerBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){ public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
if(Util.RANDOM.nextInt(30) == 0){ if(Util.RANDOM.nextInt(30) == 0){
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
double d = Util.RANDOM.nextGaussian()*0.02D; double d = Util.RANDOM.nextGaussian()*0.02D;
double d1 = Util.RANDOM.nextGaussian()*0.02D; double d1 = Util.RANDOM.nextGaussian()*0.02D;
double d2 = Util.RANDOM.nextGaussian()*0.02D; double d2 = Util.RANDOM.nextGaussian()*0.02D;
world.spawnParticle("heart", x+Util.RANDOM.nextFloat(), y+0.65+Util.RANDOM.nextFloat(), z+Util.RANDOM.nextFloat(), d, d1, d2); world.spawnParticle(EnumParticleTypes.HEART, pos.getX()+Util.RANDOM.nextFloat(), pos.getY()+0.65+Util.RANDOM.nextFloat(), pos.getZ()+Util.RANDOM.nextFloat(), d, d1, d2);
} }
} }
} }
@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 f6, float f7, float f8, float f9){
if(!world.isRemote){ if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntitySmileyCloud){ if(tile instanceof TileEntitySmileyCloud){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CLOUD.ordinal(), world, x, y, z); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.CLOUD.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
player.triggerAchievement(TheAchievements.NAME_SMILEY_CLOUD.ach); player.triggerAchievement(TheAchievements.NAME_SMILEY_CLOUD.ach);
} }
@ -96,14 +82,14 @@ public class BlockSmileyCloud extends BlockContainerBase{
} }
@Override @Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axis, List list, Entity entity){ public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axis, List list, Entity entity){
this.setBlockBoundsBasedOnState(world, x, y, z); this.setBlockBoundsBasedOnState(world, pos);
super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); super.addCollisionBoxesToList(world, pos, state, axis, list, entity);
} }
@Override @Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
int meta = world.getBlockMetadata(x, y, z); int meta = Position.fromBlockPos(pos).getMetadata(world);
float f = 0.0625F; float f = 0.0625F;
if(meta == 0){ if(meta == 0){
@ -120,45 +106,40 @@ public class BlockSmileyCloud extends BlockContainerBase{
} }
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.wool.getIcon(0, 0);
}
@Override @Override
public TileEntity createNewTileEntity(World world, int meta){ public TileEntity createNewTileEntity(World world, int meta){
return new TileEntitySmileyCloud(); return new TileEntitySmileyCloud();
} }
@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);
} }
@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, BlockPos pos, IBlockState state, 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 thePos = Position.fromBlockPos(pos);
if(rotation == 0){ if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 2, 2); thePos.setMetadata(world, 0, 2);
} }
if(rotation == 1){ if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 1, 2); thePos.setMetadata(world, 3, 2);
} }
if(rotation == 2){ if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 0, 2); thePos.setMetadata(world, 1, 2);
} }
if(rotation == 3){ if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 3, 2); thePos.setMetadata(world, 2, 2);
} }
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, pos, state, player, stack);
} }
} }

View file

@ -11,13 +11,13 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot; import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements; import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
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.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -25,10 +25,7 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.*;
import net.minecraft.util.MathHelper;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.IBlockAccess;
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;
@ -37,13 +34,6 @@ import java.util.Random;
public class BlockTreasureChest extends BlockBase{ public class BlockTreasureChest extends BlockBase{
@SideOnly(Side.CLIENT)
private IIcon topIcon;
@SideOnly(Side.CLIENT)
private IIcon bottomIcon;
@SideOnly(Side.CLIENT)
private IIcon frontIcon;
public BlockTreasureChest(String name){ public BlockTreasureChest(String name){
super(Material.wood, name); super(Material.wood, name);
this.setHarvestLevel("axe", 0); this.setHarvestLevel("axe", 0);
@ -55,58 +45,27 @@ public class BlockTreasureChest extends BlockBase{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand){
int meta = world.getBlockMetadata(x, y, z);
if(side == 1){
return this.topIcon;
}
if(side == meta+2){
return this.frontIcon;
}
if(side == 0){
return this.bottomIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
if(side == 1){
return this.topIcon;
}
if(side == 0){
return this.bottomIcon;
}
if(side == 3){
return this.frontIcon;
}
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
for(int i = 0; i < 2; i++){ for(int i = 0; i < 2; i++){
for(float f = 0; f <= 3; f += 0.5){ for(float f = 0; f <= 3; f += 0.5){
float particleX = rand.nextFloat(); float particleX = rand.nextFloat();
float particleZ = rand.nextFloat(); float particleZ = rand.nextFloat();
world.spawnParticle("bubble", (double)x+particleX, (double)y+f+1, (double)z+particleZ, 0.0D, 0.2D, 0.0D); world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, (double)pos.getX()+particleX, (double)pos.getY()+f+1, (double)pos.getZ()+particleZ, 0.0D, 0.2D, 0.0D);
} }
} }
} }
@Override @Override
public Item getItemDropped(int par1, Random rand, int par3){ public Item getItemDropped(IBlockState state, Random rand, int par3){
return null; return null;
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
world.playSoundAtEntity(player, "random.chestopen", 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F); world.playSoundAtEntity(player, "random.chestopen", 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
this.dropItems(world, x, y, z); this.dropItems(world, Position.fromBlockPos(pos));
world.setBlockToAir(x, y, z); world.setBlockToAir(pos);
player.triggerAchievement(TheAchievements.OPEN_TREASURE_CHEST.ach); player.triggerAchievement(TheAchievements.OPEN_TREASURE_CHEST.ach);
} }
@ -119,42 +78,34 @@ public class BlockTreasureChest extends BlockBase{
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, 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 thePos = Position.fromBlockPos(pos);
if(rotation == 0){ if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 0, 2); thePos.setMetadata(world, 0, 2);
} }
if(rotation == 1){ if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 3, 2); thePos.setMetadata(world, 3, 2);
} }
if(rotation == 2){ if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 1, 2); thePos.setMetadata(world, 1, 2);
} }
if(rotation == 3){ if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 2, 2); thePos.setMetadata(world, 2, 2);
} }
} }
@Override private void dropItems(World world, Position pos){
@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");
this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Bottom");
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
}
private void dropItems(World world, int x, int y, int z){
for(int i = 0; i < MathHelper.getRandomIntegerInRange(Util.RANDOM, 3, 6); i++){ for(int i = 0; i < MathHelper.getRandomIntegerInRange(Util.RANDOM, 3, 6); i++){
TreasureChestLoot theReturn = (TreasureChestLoot)WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.treasureChestLoot); TreasureChestLoot theReturn = WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.treasureChestLoot);
ItemStack itemStack = theReturn.returnItem.copy(); ItemStack itemStack = theReturn.returnItem.copy();
itemStack.stackSize = MathHelper.getRandomIntegerInRange(Util.RANDOM, theReturn.minAmount, theReturn.maxAmount); itemStack.stackSize = MathHelper.getRandomIntegerInRange(Util.RANDOM, theReturn.minAmount, theReturn.maxAmount);
float dX = Util.RANDOM.nextFloat()*0.8F+0.1F; float dX = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dY = Util.RANDOM.nextFloat()*0.8F+0.1F; float dY = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dZ = Util.RANDOM.nextFloat()*0.8F+0.1F; float dZ = Util.RANDOM.nextFloat()*0.8F+0.1F;
EntityItem entityItem = new EntityItem(world, x+dX, y+dY, z+dZ, itemStack.copy()); EntityItem entityItem = new EntityItem(world, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, itemStack.copy());
if(itemStack.hasTagCompound()){ if(itemStack.hasTagCompound()){
entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy()); entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
} }
@ -169,6 +120,6 @@ public class BlockTreasureChest extends BlockBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
} }

View file

@ -10,41 +10,33 @@
package de.ellpeck.actuallyadditions.mod.blocks.base; package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
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.util.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockFluidFlowing extends BlockFluidClassic{ public class BlockFluidFlowing extends BlockFluidClassic{
@SideOnly(Side.CLIENT)
public IIcon stillIcon;
@SideOnly(Side.CLIENT)
public IIcon flowingIcon;
private String name; private String name;
public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName){ public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName){
super(fluid, material); super(fluid, material);
this.name = unlocalizedName; this.name = unlocalizedName;
this.setRenderPass(1);
displacements.put(this, false); displacements.put(this, false);
this.register(); this.register();
} }
private void register(){ private void register(){
this.setBlockName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName()); this.setUnlocalizedName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName()); GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
if(this.shouldAddCreative()){ if(this.shouldAddCreative()){
this.setCreativeTab(CreativeTab.instance); this.setCreativeTab(CreativeTab.instance);
@ -67,30 +59,16 @@ public class BlockFluidFlowing extends BlockFluidClassic{
} }
@Override @Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z){ public boolean canDisplace(IBlockAccess world, BlockPos pos){
return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.canDisplace(world, x, y, z); return !Position.fromBlockPos(pos).getMaterial(world).isLiquid() && super.canDisplace(world, pos);
} }
@Override @Override
public boolean displaceIfPossible(World world, int x, int y, int z){ public boolean displaceIfPossible(World world, BlockPos pos){
return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.displaceIfPossible(world, x, y, z); return !Position.fromBlockPos(pos).getMaterial(world).isLiquid() && super.displaceIfPossible(world, pos);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){
return side <= 1 ? this.stillIcon : this.flowingIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.stillIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Still");
this.flowingIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Flowing");
this.definedFluid.setIcons(this.stillIcon, this.flowingIcon);
} }
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.EPIC;
} }
} }

View file

@ -13,17 +13,15 @@ package de.ellpeck.actuallyadditions.mod.blocks.base;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.BlockCrops; import net.minecraft.block.BlockCrops;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random; import java.util.Random;
@ -32,8 +30,6 @@ public class BlockPlant extends BlockCrops{
public Item seedItem; public Item seedItem;
public Item returnItem; public Item returnItem;
public int returnMeta; public int returnMeta;
@SideOnly(Side.CLIENT)
private IIcon[] textures;
private int stages; private int stages;
private String name; private String name;
private int minDropAmount; private int minDropAmount;
@ -49,7 +45,7 @@ public class BlockPlant extends BlockCrops{
} }
private void register(){ private void register(){
this.setBlockName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName()); this.setUnlocalizedName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName()); GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
if(this.shouldAddCreative()){ if(this.shouldAddCreative()){
this.setCreativeTab(CreativeTab.instance); this.setCreativeTab(CreativeTab.instance);
@ -72,64 +68,41 @@ public class BlockPlant extends BlockCrops{
} }
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
} }
@Override @Override
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z){ public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos){
return EnumPlantType.Crop; return EnumPlantType.Crop;
} }
@Override @Override
@SideOnly(Side.CLIENT) public Item getSeed(){
public IIcon getIcon(int side, int meta){
if(meta < 7){
if(meta == 6){
meta = 5;
}
return this.textures[meta >> 1];
}
else{
return this.textures[this.textures.length-1];
}
}
@Override
public Item func_149866_i(){
return this.seedItem; return this.seedItem;
} }
@Override @Override
public Item func_149865_P(){ public Item getCrop(){
return this.returnItem; return this.returnItem;
} }
@Override @Override
public Item getItemDropped(int meta, Random rand, int par3){ public Item getItemDropped(IBlockState state, Random rand, int par3){
return meta >= 7 ? this.func_149865_P() : this.func_149866_i(); return this.getMetaFromState(state) >= 7 ? this.getCrop() : this.getSeed();
} }
@Override @Override
@SideOnly(Side.CLIENT) public int damageDropped(IBlockState state){
public void registerBlockIcons(IIconRegister iconReg){ return this.getMetaFromState(state) >= 7 ? this.returnMeta : 0;
this.textures = new IIcon[this.stages];
for(int i = 0; i < this.textures.length; i++){
textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Stage"+(i+1));
}
} }
@Override @Override
public int damageDropped(int meta){ public int getDamageValue(World world, BlockPos pos){
return meta >= 7 ? this.returnMeta : 0;
}
@Override
public int getDamageValue(World world, int x, int y, int z){
return 0; return 0;
} }
@Override @Override
public int quantityDropped(int meta, int fortune, Random random){ public int quantityDropped(IBlockState state, int fortune, Random random){
return meta >= 7 ? random.nextInt(addDropAmount)+minDropAmount : super.quantityDropped(meta, fortune, random); return this.getMetaFromState(state) >= 7 ? random.nextInt(addDropAmount)+minDropAmount : super.quantityDropped(state, fortune, random);
} }
} }

View file

@ -10,14 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks.render; package de.ellpeck.actuallyadditions.mod.blocks.render;
import net.minecraft.block.Block; //TODO Fix the rendering handler
import net.minecraft.client.Minecraft; public class RenderInventory{
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.client.registry.ISimpleBlockRenderingHandler;
import org.lwjgl.opengl.GL11;
public class RenderInventory implements ISimpleBlockRenderingHandler{
private RenderTileEntity tileRender; private RenderTileEntity tileRender;
private int renderID; private int renderID;
@ -27,7 +21,7 @@ public class RenderInventory implements ISimpleBlockRenderingHandler{
this.renderID = renderID; this.renderID = renderID;
} }
@Override /*@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer){ public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer){
GL11.glPushMatrix(); GL11.glPushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(this.tileRender.resLoc); Minecraft.getMinecraft().renderEngine.bindTexture(this.tileRender.resLoc);
@ -50,5 +44,5 @@ public class RenderInventory implements ISimpleBlockRenderingHandler{
@Override @Override
public int getRenderId(){ public int getRenderId(){
return this.renderID; return this.renderID;
} }*/
} }

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.blocks.render; package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
@ -21,7 +22,7 @@ import org.lwjgl.opengl.GL11;
public class RenderReconstructorLens extends TileEntitySpecialRenderer{ public class RenderReconstructorLens extends TileEntitySpecialRenderer{
@Override @Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5){ public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5, int par6){
if(!(tile instanceof TileEntityAtomicReconstructor)){ if(!(tile instanceof TileEntityAtomicReconstructor)){
return; return;
} }
@ -32,7 +33,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer{
GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F); GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); int meta = Position.fromTileEntity(tile).getMetadata(getWorld());
if(meta == 0){ if(meta == 0){
GL11.glTranslatef(0F, -0.5F, 0F); GL11.glTranslatef(0F, -0.5F, 0F);
GL11.glTranslatef(-0.25F, 0F, -0.25F); GL11.glTranslatef(-0.25F, 0F, -0.25F);

View file

@ -18,13 +18,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.village.MerchantRecipe; import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList; import net.minecraft.village.MerchantRecipeList;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHandler{ //TODO Fix the villager
public class JamVillagerTradeHandler{
private ArrayList<Trade> trades = new ArrayList<Trade>(); private ArrayList<Trade> trades = new ArrayList<Trade>();
@ -41,7 +41,7 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa
} }
public void addWants(String oredictName, int minSize, int maxSize){ public void addWants(String oredictName, int minSize, int maxSize){
ArrayList<ItemStack> stacks = (ArrayList<ItemStack>)OreDictionary.getOres(oredictName, false); ArrayList<ItemStack> stacks = (ArrayList<ItemStack>)OreDictionary.getOres(oredictName);
trades.add(new Trade(stacks, minSize, maxSize)); trades.add(new Trade(stacks, minSize, maxSize));
} }
@ -49,7 +49,8 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa
trades.add(new Trade(stack, minSize, maxSize)); trades.add(new Trade(stack, minSize, maxSize));
} }
@Override //TODO Fix the Villager
//@Override
@SuppressWarnings("all") @SuppressWarnings("all")
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random rand){ public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random rand){
for(int trade = 0; trade < trades.size(); trade++){ for(int trade = 0; trade < trades.size(); trade++){

View file

@ -21,7 +21,6 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -61,8 +60,8 @@ public class ContainerEnergizer extends Container{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getBackgroundIconIndex(){ public String getSlotTexture(){
return ItemArmor.func_94602_b(finalI); return ItemArmor.EMPTY_SLOT_NAMES[finalI];
} }
}); });
} }

View file

@ -21,7 +21,6 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -61,8 +60,8 @@ public class ContainerEnervator extends Container{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getBackgroundIconIndex(){ public String getSlotTexture(){
return ItemArmor.func_94602_b(finalI); return ItemArmor.EMPTY_SLOT_NAMES[finalI];
} }
}); });
} }

View file

@ -11,13 +11,8 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
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.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemBattery extends ItemEnergy{ public class ItemBattery extends ItemEnergy{
@ -28,18 +23,6 @@ public class ItemBattery extends ItemEnergy{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
}
@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

@ -10,22 +10,20 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
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.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockChest; import net.minecraft.block.BlockChest;
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.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest; import net.minecraft.tileentity.TileEntityChest;
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 ItemChestToCrateUpgrade extends ItemBase{ public class ItemChestToCrateUpgrade extends ItemBase{
@ -34,10 +32,11 @@ public class ItemChestToCrateUpgrade extends ItemBase{
} }
@Override @Override
public boolean onItemUse(ItemStack heldStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ public boolean onItemUse(ItemStack heldStack, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, float par8, float par9, float par10){
if(player.isSneaking()){ if(player.isSneaking()){
TileEntity tileHit = world.getTileEntity(x, y, z); TileEntity tileHit = world.getTileEntity(pos);
if(world.getBlock(x, y, z) instanceof BlockChest && tileHit instanceof TileEntityChest){ Block block = Position.fromBlockPos(pos).getBlock(world);
if(block instanceof BlockChest && tileHit instanceof TileEntityChest){
if(!world.isRemote){ if(!world.isRemote){
TileEntityChest chest = (TileEntityChest)tileHit; TileEntityChest chest = (TileEntityChest)tileHit;
@ -52,11 +51,11 @@ public class ItemChestToCrateUpgrade extends ItemBase{
} }
//Set New Block //Set New Block
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(world.getBlock(x, y, z))+(world.getBlockMetadata(x, y, z) << 12)); world.playAuxSFX(2001, pos, Block.getIdFromBlock(block)+(Position.fromBlockPos(pos).getMetadata(world) << 12));
world.setBlock(x, y, z, InitBlocks.blockGiantChest, 0, 2); Position.fromBlockPos(pos).setBlock(world, InitBlocks.blockGiantChest, 0, 2);
//Copy Items into new Chest //Copy Items into new Chest
TileEntity newTileHit = world.getTileEntity(x, y, z); TileEntity newTileHit = world.getTileEntity(pos);
if(newTileHit instanceof TileEntityGiantChest){ if(newTileHit instanceof TileEntityGiantChest){
TileEntityGiantChest newChest = (TileEntityGiantChest)newTileHit; TileEntityGiantChest newChest = (TileEntityGiantChest)newTileHit;
for(int i = 0; i < stacks.length; i++){ for(int i = 0; i < stacks.length; i++){
@ -76,24 +75,11 @@ public class ItemChestToCrateUpgrade extends ItemBase{
} }
} }
return super.onItemUse(heldStack, player, world, x, y, z, par7, par8, par9, par10); return super.onItemUse(heldStack, player, world, pos, facing, par8, par9, par10);
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
} }
@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

@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
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;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.EnumAction; import net.minecraft.item.EnumAction;
@ -28,12 +27,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.IIcon;
import net.minecraft.util.StringUtils; import net.minecraft.util.StringUtils;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -77,9 +73,9 @@ public class ItemCoffee extends ItemFoodBase{
} }
@Override @Override
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){ public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player){
ItemStack theStack = stack.copy(); ItemStack theStack = stack.copy();
super.onEaten(stack, world, player); super.onItemUseFinish(stack, world, player);
applyPotionEffectsFromStack(stack, player); applyPotionEffectsFromStack(stack, player);
theStack.setItemDamage(theStack.getItemDamage()+1); theStack.setItemDamage(theStack.getItemDamage()+1);
if(theStack.getMaxDamage()-theStack.getItemDamage() < 0){ if(theStack.getMaxDamage()-theStack.getItemDamage() < 0){
@ -101,13 +97,7 @@ public class ItemCoffee extends ItemFoodBase{
@Override @Override
public EnumAction getItemUseAction(ItemStack stack){ public EnumAction getItemUseAction(ItemStack stack){
return EnumAction.drink; return EnumAction.DRINK;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1){
return this.itemIcon;
} }
@Override @Override
@ -136,13 +126,7 @@ public class ItemCoffee extends ItemFoodBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
} }
public static class MilkIngredient extends CoffeeIngredient{ public static class MilkIngredient extends CoffeeIngredient{

View file

@ -11,13 +11,8 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
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.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemCoffeeBean extends ItemFoodBase{ public class ItemCoffeeBean extends ItemFoodBase{
@ -28,18 +23,6 @@ public class ItemCoffeeBean extends ItemFoodBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
}
@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

@ -12,8 +12,8 @@ package de.ellpeck.actuallyadditions.mod.items;
import cofh.api.energy.IEnergyContainerItem; import cofh.api.energy.IEnergyContainerItem;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.config.ConfigValues; import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
@ -22,7 +22,7 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -37,8 +37,9 @@ import net.minecraft.item.Item;
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.BlockPos;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.ForgeHooks;
@ -54,8 +55,6 @@ public class ItemDrill extends ItemEnergy{
private static final int ENERGY_USE = 100; private static final int ENERGY_USE = 100;
private static final int HARVEST_LEVEL = 4; private static final int HARVEST_LEVEL = 4;
@SideOnly(Side.CLIENT)
private IIcon[] allDemDamnIconsMaan;
public ItemDrill(String name){ public ItemDrill(String name){
super(500000, 5000, name); super(500000, 5000, name);
@ -72,15 +71,9 @@ public class ItemDrill extends ItemEnergy{
this.setHarvestLevel("pickaxe", HARVEST_LEVEL); this.setHarvestLevel("pickaxe", HARVEST_LEVEL);
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int par1){
return par1 >= this.allDemDamnIconsMaan.length ? null : this.allDemDamnIconsMaan[par1];
}
@Override @Override
//Places Blocks if the Placing Upgrade is installed //Places Blocks if the Placing Upgrade is installed
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int hitSide, float hitX, float hitY, float hitZ){ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){
ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER); ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER);
if(upgrade != null){ if(upgrade != null){
int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade); int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade);
@ -92,7 +85,7 @@ public class ItemDrill extends ItemEnergy{
//tryPlaceItemIntoWorld could throw an Exception //tryPlaceItemIntoWorld could throw an Exception
try{ try{
//Places the Block into the World //Places the Block into the World
if(equip.tryPlaceItemIntoWorld(player, world, x, y, z, hitSide, hitX, hitY, hitZ)){ if(equip.onItemUse(player, world, pos, side, hitX, hitY, hitZ)){
if(!player.capabilities.isCreativeMode){ if(!player.capabilities.isCreativeMode){
player.inventory.setInventorySlotContents(slot, equip.stackSize <= 0 ? null : equip.copy()); player.inventory.setInventorySlotContents(slot, equip.stackSize <= 0 ? null : equip.copy());
} }
@ -104,7 +97,7 @@ public class ItemDrill extends ItemEnergy{
//Notify the Player and log the Exception //Notify the Player and log the Exception
catch(Exception e){ catch(Exception e){
player.addChatComponentMessage(new ChatComponentText("Ouch! That really hurt! You must have done something wrong, don't do that again please!")); player.addChatComponentMessage(new ChatComponentText("Ouch! That really hurt! You must have done something wrong, don't do that again please!"));
ModUtil.LOGGER.error("Player "+player.getCommandSenderName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!"); ModUtil.LOGGER.error("Player "+player.getName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.getDimensionId()+" threw an Exception! Don't let that happen again!");
} }
} }
else{ else{
@ -216,32 +209,23 @@ public class ItemDrill extends ItemEnergy{
@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.allDemDamnIconsMaan = new IIcon[16];
for(int i = 0; i < this.allDemDamnIconsMaan.length; i++){
this.allDemDamnIconsMaan[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+TheColoredLampColors.values()[i].name);
}
} }
@Override @Override
public Multimap getAttributeModifiers(ItemStack stack){ public Multimap getAttributeModifiers(ItemStack stack){
Multimap map = super.getAttributeModifiers(stack); Multimap map = super.getAttributeModifiers(stack);
map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE ? 8.0F : 0.1F, 0)); map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE ? 8.0F : 0.1F, 0));
return map; return map;
} }
@Override @Override
public float getDigSpeed(ItemStack stack, Block block, int meta){ public float getDigSpeed(ItemStack stack, IBlockState state){
return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) ? (this.hasExtraWhitelist(block) || block.getHarvestTool(meta) == null || block.getHarvestTool(meta).isEmpty() || this.getToolClasses(stack).contains(block.getHarvestTool(meta)) ? this.getEfficiencyFromUpgrade(stack) : 1.0F) : 0.1F; return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) ? (this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.getEfficiencyFromUpgrade(stack) : 1.0F) : 0.1F;
} }
@Override @Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player){ public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player){
boolean toReturn = false; boolean toReturn = false;
int use = this.getEnergyUsePerBlock(stack); int use = this.getEnergyUsePerBlock(stack);
if(this.getEnergyStored(stack) >= use){ if(this.getEnergyStored(stack) >= use){
@ -258,14 +242,14 @@ public class ItemDrill extends ItemEnergy{
//Breaks the Blocks //Breaks the Blocks
if(!player.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ if(!player.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){
if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){ if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){
toReturn = this.breakBlocks(stack, 2, player.worldObj, x, y, z, player); toReturn = this.breakBlocks(stack, 2, player.worldObj, pos, player);
} }
else{ else{
toReturn = this.breakBlocks(stack, 1, player.worldObj, x, y, z, player); toReturn = this.breakBlocks(stack, 1, player.worldObj, pos, player);
} }
} }
else{ else{
toReturn = this.breakBlocks(stack, 0, player.worldObj, x, y, z, player); toReturn = this.breakBlocks(stack, 0, player.worldObj, pos, player);
} }
//Removes Enchantments added above //Removes Enchantments added above
@ -353,7 +337,7 @@ public class ItemDrill extends ItemEnergy{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tabs, List list){ public void getSubItems(Item item, CreativeTabs tabs, List list){
for(int i = 0; i < this.allDemDamnIconsMaan.length; i++){ for(int i = 0; i < 16; i++){
this.addDrillStack(list, i); this.addDrillStack(list, i);
} }
} }
@ -427,12 +411,9 @@ public class ItemDrill extends ItemEnergy{
* @param stack The Drill * @param stack The Drill
* @param radius The Radius to break Blocks in (0 means only 1 Block will be broken!) * @param radius The Radius to break Blocks in (0 means only 1 Block will be broken!)
* @param world The World * @param world The World
* @param x The X Coord of the main Block to break
* @param y The Y Coord of the main Block to break
* @param z The Z Coord of the main Block to break
* @param player The Player who breaks the Blocks * @param player The Player who breaks the Blocks
*/ */
public boolean breakBlocks(ItemStack stack, int radius, World world, int x, int y, int z, EntityPlayer player){ public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, EntityPlayer player){
int xRange = radius; int xRange = radius;
int yRange = radius; int yRange = radius;
int zRange = 0; int zRange = 0;
@ -444,7 +425,7 @@ public class ItemDrill extends ItemEnergy{
} }
//Corrects Blocks to hit depending on Side of original Block hit //Corrects Blocks to hit depending on Side of original Block hit
int side = pos.sideHit; int side = pos.sideHit.ordinal();
if(side == 0 || side == 1){ if(side == 0 || side == 1){
zRange = radius; zRange = radius;
yRange = 0; yRange = 0;
@ -455,12 +436,12 @@ public class ItemDrill extends ItemEnergy{
} }
//Not defined later because main Block is getting broken below //Not defined later because main Block is getting broken below
float mainHardness = world.getBlock(x, y, z).getBlockHardness(world, x, y, z); float mainHardness = Position.fromBlockPos(aPos).getBlock(world).getBlockHardness(world, aPos);
//Break Middle Block first //Break Middle Block first
int use = this.getEnergyUsePerBlock(stack); int use = this.getEnergyUsePerBlock(stack);
if(this.getEnergyStored(stack) >= use){ if(this.getEnergyStored(stack) >= use){
if(!this.tryHarvestBlock(world, x, y, z, false, stack, player, use)){ if(!this.tryHarvestBlock(world, Position.fromBlockPos(aPos), false, stack, player, use)){
return false; return false;
} }
} }
@ -470,14 +451,15 @@ public class ItemDrill extends ItemEnergy{
//Break Blocks around //Break Blocks around
if(radius > 0 && mainHardness >= 0.2F){ if(radius > 0 && mainHardness >= 0.2F){
for(int xPos = x-xRange; xPos <= x+xRange; xPos++){ for(int xPos = aPos.getX()-xRange; xPos <= aPos.getX()+xRange; xPos++){
for(int yPos = y-yRange; yPos <= y+yRange; yPos++){ for(int yPos = aPos.getY()-yRange; yPos <= aPos.getY()+yRange; yPos++){
for(int zPos = z-zRange; zPos <= z+zRange; zPos++){ for(int zPos = aPos.getZ()-zRange; zPos <= aPos.getZ()+zRange; zPos++){
if(!(x == xPos && y == yPos && z == zPos)){ if(!(aPos.getX() == xPos && aPos.getY() == yPos && aPos.getZ() == zPos)){
if(this.getEnergyStored(stack) >= use){ if(this.getEnergyStored(stack) >= use){
//Only break Blocks around that are (about) as hard or softer //Only break Blocks around that are (about) as hard or softer
if(world.getBlock(xPos, yPos, zPos).getBlockHardness(world, xPos, yPos, zPos) <= mainHardness+5.0F){ Position thePos = new Position(xPos, yPos, zPos);
this.tryHarvestBlock(world, xPos, yPos, zPos, true, stack, player, use); if(thePos.getBlock(world).getBlockHardness(world, thePos) <= mainHardness+5.0F){
this.tryHarvestBlock(world, thePos, true, stack, player, use);
} }
} }
else{ else{
@ -497,29 +479,26 @@ public class ItemDrill extends ItemEnergy{
* Has to be called on both Server and Client * Has to be called on both Server and Client
* *
* @param world The World * @param world The World
* @param xPos The X Position of the Block to break
* @param yPos The Y Position of the Block to break
* @param zPos The Z Position of the Block to break
* @param isExtra If the Block is the Block that was looked at when breaking or an additional Block * @param isExtra If the Block is the Block that was looked at when breaking or an additional Block
* @param stack The Drill * @param stack The Drill
* @param player The Player breaking the Blocks * @param player The Player breaking the Blocks
* @param use The Energy that should be extracted per Block * @param use The Energy that should be extracted per Block
*/ */
private boolean tryHarvestBlock(World world, int xPos, int yPos, int zPos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){ private boolean tryHarvestBlock(World world, Position pos, boolean isExtra, ItemStack stack, EntityPlayer player, int use){
Block block = world.getBlock(xPos, yPos, zPos); Block block = pos.getBlock(world);
float hardness = block.getBlockHardness(world, xPos, yPos, zPos); float hardness = block.getBlockHardness(world, pos);
int meta = world.getBlockMetadata(xPos, yPos, zPos); int meta = pos.getMetadata(world);
boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, meta) || this.canHarvestBlock(block, stack)) && (!isExtra || this.getDigSpeed(stack, block, meta) > 1.0F); boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(block, stack)) && (!isExtra || this.getDigSpeed(stack, pos.getBlockState(world)) > 1.0F);
if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(meta)))){ if(hardness >= 0.0F && (!isExtra || (canHarvest && !block.hasTileEntity(pos.getBlockState(world))))){
this.extractEnergy(stack, use, false); this.extractEnergy(stack, use, false);
//Break the Block //Break the Block
return WorldUtil.playerHarvestBlock(world, xPos, yPos, zPos, player); return WorldUtil.playerHarvestBlock(world, pos, player);
} }
return false; return false;
} }
private boolean hasExtraWhitelist(Block block){ private boolean hasExtraWhitelist(Block block){
String name = Block.blockRegistry.getNameForObject(block); String name = block.getRegistryName();
if(name != null){ if(name != null){
for(String list : ConfigValues.drillExtraminingWhitelist){ for(String list : ConfigValues.drillExtraminingWhitelist){
if(list.equals(name)){ if(list.equals(name)){

View file

@ -11,15 +11,10 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
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.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
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 ItemDrillUpgrade extends ItemBase{ public class ItemDrillUpgrade extends ItemBase{
@ -58,18 +53,6 @@ public class ItemDrillUpgrade extends ItemBase{
stack.setTagCompound(compound); stack.setTagCompound(compound);
} }
@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;
}
public enum UpgradeType{ public enum UpgradeType{
SPEED, SPEED,
SPEED_II, SPEED_II,

View file

@ -11,16 +11,13 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
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.ItemDye; import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
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 ItemFertilizer extends ItemBase{ public class ItemFertilizer extends ItemBase{
@ -29,30 +26,18 @@ public class ItemFertilizer extends ItemBase{
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float par8, float par9, float par10){
if(ItemDye.applyBonemeal(stack, world, x, y, z, player)){ if(ItemDye.applyBonemeal(stack, world, pos, player)){
if(!world.isRemote){ if(!world.isRemote){
world.playAuxSFX(2005, x, y, z, 0); world.playAuxSFX(2005, pos, 0);
} }
return true; return true;
} }
return super.onItemUse(stack, player, world, x, y, z, par7, par8, par9, par10); return super.onItemUse(stack, player, world, pos, side, par8, par9, par10);
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.RARE;
}
@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

@ -12,10 +12,8 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -23,7 +21,6 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
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;
@ -33,10 +30,6 @@ import java.util.List;
public class ItemFoods extends ItemFoodBase{ public class ItemFoods extends ItemFoodBase{
public static final TheFoods[] allFoods = TheFoods.values(); public static final TheFoods[] allFoods = TheFoods.values();
@SideOnly(Side.CLIENT)
public IIcon[] textures;
@SideOnly(Side.CLIENT)
private IIcon iconEllspeck;
private static final String ELLSPECK = "ellspeck"; private static final String ELLSPECK = "ellspeck";
@ -48,14 +41,14 @@ public class ItemFoods extends ItemFoodBase{
} }
@Override @Override
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){ public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player){
ItemStack stackToReturn = super.onEaten(stack, world, player); ItemStack stackToReturn = super.onItemUseFinish(stack, world, player);
ItemStack returnItem = stack.getItemDamage() >= allFoods.length ? null : allFoods[stack.getItemDamage()].returnItem; ItemStack returnItem = stack.getItemDamage() >= allFoods.length ? null : allFoods[stack.getItemDamage()].returnItem;
if(returnItem != null){ if(returnItem != null){
if(!player.inventory.addItemStackToInventory(returnItem.copy())){ if(!player.inventory.addItemStackToInventory(returnItem.copy())){
if(!world.isRemote){ if(!world.isRemote){
EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy()); EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy());
entityItem.delayBeforeCanPickup = 0; entityItem.setPickupDelay(0);
player.worldObj.spawnEntityInWorld(entityItem); player.worldObj.spawnEntityInWorld(entityItem);
} }
} }
@ -70,36 +63,19 @@ public class ItemFoods extends ItemFoodBase{
@Override @Override
public EnumAction getItemUseAction(ItemStack stack){ public EnumAction getItemUseAction(ItemStack stack){
return stack.getItemDamage() >= allFoods.length ? EnumAction.eat : (allFoods[stack.getItemDamage()].getsDrunken ? EnumAction.drink : EnumAction.eat); return stack.getItemDamage() >= allFoods.length ? EnumAction.EAT : (allFoods[stack.getItemDamage()].getsDrunken ? EnumAction.DRINK : EnumAction.EAT);
} }
@Override @Override
public int func_150905_g(ItemStack stack){ public int getHealAmount(ItemStack stack){
return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].healAmount; return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].healAmount;
} }
@Override @Override
public float func_150906_h(ItemStack stack){ public float getSaturationModifier(ItemStack stack){
return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].saturation; return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].saturation;
} }
@Override
public IIcon getIcon(ItemStack stack, int pass){
return getIconIndex(stack);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack){
int damage = stack.getItemDamage();
if(damage == TheFoods.BACON.ordinal() && StringUtil.equalsToLowerCase(stack.getDisplayName(), ELLSPECK)){
return this.iconEllspeck;
}
else{
return damage >= textures.length ? null : textures[damage];
}
}
@Override @Override
public int getMetadata(int damage){ public int getMetadata(int damage){
return damage; return damage;
@ -112,7 +88,7 @@ public class ItemFoods extends ItemFoodBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allFoods.length ? EnumRarity.common : allFoods[stack.getItemDamage()].rarity; return stack.getItemDamage() >= allFoods.length ? EnumRarity.COMMON : allFoods[stack.getItemDamage()].rarity;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@ -123,22 +99,12 @@ public class ItemFoods extends ItemFoodBase{
} }
} }
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.textures = new IIcon[allFoods.length];
for(int i = 0; i < textures.length; i++){
textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+allFoods[i].name);
}
this.iconEllspeck = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":itemEllspeck");
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){
if(stack.getItemDamage() == TheFoods.BACON.ordinal() && StringUtil.equalsToLowerCase(stack.getDisplayName(), ELLSPECK)){ if(stack.getItemDamage() == TheFoods.BACON.ordinal() && StringUtil.equalsToLowerCase(stack.getDisplayName(), ELLSPECK)){
String strg = "Yes, this is an ugly texture of bacon with its legs behind its head. This is an homage to Ellpeck, the mod author, being able to put his legs behind his head. Wasn't my idea, so don't judge me."; String strg = "Yes, this is an ugly texture of bacon with its legs behind its head. This is an homage to Ellpeck, the mod author, being able to put his legs behind his head. Wasn't my idea, so don't judge me.";
list.addAll(Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(strg, 200)); list.addAll(Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(strg, 200));
} }
} }
} }

View file

@ -13,18 +13,13 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn; import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
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.util.WeightedRandom; import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemHairyBall extends ItemBase{ public class ItemHairyBall extends ItemBase{
@ -38,7 +33,7 @@ public class ItemHairyBall extends ItemBase{
ItemStack returnItem = this.getRandomReturnItem(); ItemStack returnItem = this.getRandomReturnItem();
if(!player.inventory.addItemStackToInventory(returnItem)){ if(!player.inventory.addItemStackToInventory(returnItem)){
EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem); EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem);
entityItem.delayBeforeCanPickup = 0; entityItem.setPickupDelay(0);
player.worldObj.spawnEntityInWorld(entityItem); player.worldObj.spawnEntityInWorld(entityItem);
} }
stack.stackSize--; stack.stackSize--;
@ -53,18 +48,6 @@ public class ItemHairyBall 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

@ -12,9 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -23,7 +21,6 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
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.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -33,8 +30,6 @@ import java.util.List;
public class ItemJams extends ItemFoodBase{ public class ItemJams extends ItemFoodBase{
public static final TheJams[] allJams = TheJams.values(); public static final TheJams[] allJams = TheJams.values();
@SideOnly(Side.CLIENT)
public IIcon overlayIcon;
public ItemJams(String name){ public ItemJams(String name){
super(0, 0.0F, false, name); super(0, 0.0F, false, name);
@ -61,18 +56,7 @@ public class ItemJams extends ItemFoodBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allJams.length ? EnumRarity.common : allJams[stack.getItemDamage()].rarity; return stack.getItemDamage() >= allJams.length ? EnumRarity.COMMON : allJams[stack.getItemDamage()].rarity;
}
@Override
public boolean requiresMultipleRenderPasses(){
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int damage, int pass){
return pass > 0 ? this.overlayIcon : super.getIconFromDamageForRenderPass(damage, pass);
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@ -84,15 +68,8 @@ public class ItemJams extends ItemFoodBase{
} }
@Override @Override
@SideOnly(Side.CLIENT) public ItemStack onItemUseFinish(ItemStack stack, World world, EntityPlayer player){
public void registerIcons(IIconRegister iconReg){ ItemStack stackToReturn = super.onItemUseFinish(stack, world, player);
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
this.overlayIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Overlay");
}
@Override
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){
ItemStack stackToReturn = super.onEaten(stack, world, player);
if(!world.isRemote && stack.getItemDamage() < allJams.length){ if(!world.isRemote && stack.getItemDamage() < allJams.length){
PotionEffect firstEffectToGet = new PotionEffect(allJams[stack.getItemDamage()].firstEffectToGet, 200); PotionEffect firstEffectToGet = new PotionEffect(allJams[stack.getItemDamage()].firstEffectToGet, 200);
@ -104,7 +81,7 @@ public class ItemJams extends ItemFoodBase{
ItemStack returnItem = new ItemStack(Items.glass_bottle); ItemStack returnItem = new ItemStack(Items.glass_bottle);
if(!player.inventory.addItemStackToInventory(returnItem.copy())){ if(!player.inventory.addItemStackToInventory(returnItem.copy())){
EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy()); EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy());
entityItem.delayBeforeCanPickup = 0; entityItem.setPickupDelay(0);
player.worldObj.spawnEntityInWorld(entityItem); player.worldObj.spawnEntityInWorld(entityItem);
} }
} }
@ -112,12 +89,12 @@ public class ItemJams extends ItemFoodBase{
} }
@Override @Override
public int func_150905_g(ItemStack stack){ public int getHealAmount(ItemStack stack){
return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].healAmount; return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].healAmount;
} }
@Override @Override
public float func_150906_h(ItemStack stack){ public float getSaturationModifier(ItemStack stack){
return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].saturation; return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].saturation;
} }
} }

View file

@ -12,15 +12,10 @@ package de.ellpeck.actuallyadditions.mod.items;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
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.SharedMonsterAttributes; import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.AttributeModifier;
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.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemKnife extends ItemBase{ public class ItemKnife extends ItemBase{
@ -31,11 +26,6 @@ public class ItemKnife extends ItemBase{
this.setContainerItem(this); this.setContainerItem(this);
} }
@Override
public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack){
return false;
}
@Override @Override
public boolean getShareTag(){ public boolean getShareTag(){
return true; return true;
@ -43,20 +33,14 @@ public class ItemKnife 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());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Multimap getAttributeModifiers(ItemStack stack){ public Multimap getAttributeModifiers(ItemStack stack){
Multimap map = super.getAttributeModifiers(stack); Multimap map = super.getAttributeModifiers(stack);
map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Knife Modifier", 3, 0)); map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(itemModifierUUID, "Knife Modifier", 3, 0));
return map; return map;
} }
@ -67,10 +51,4 @@ public class ItemKnife extends ItemBase{
theStack.stackSize = 1; theStack.stackSize = 1;
return theStack; return theStack;
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int pass){
return this.itemIcon;
}
} }

View file

@ -16,15 +16,15 @@ import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
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;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
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.BlockPos;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon; 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.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -39,17 +39,17 @@ public class ItemLaserWrench extends ItemBase{
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing par7, float par8, float par9, float par10){
if(!world.isRemote){ if(!world.isRemote){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityLaserRelay){ if(tile instanceof TileEntityLaserRelay){
if(ItemPhantomConnector.getStoredPosition(stack) == null){ if(ItemPhantomConnector.getStoredPosition(stack) == null){
ItemPhantomConnector.storeConnection(stack, x, y, z, world); ItemPhantomConnector.storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.stored.desc"))); player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".laser.stored.desc")));
} }
else{ else{
Position savedPos = ItemPhantomConnector.getStoredPosition(stack); Position savedPos = ItemPhantomConnector.getStoredPosition(stack);
Position otherPos = new Position(x, y, z); Position otherPos = Position.fromBlockPos(pos);
if(ItemPhantomConnector.getStoredWorld(stack) == world && savedPos.getTileEntity(world) instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){ if(ItemPhantomConnector.getStoredWorld(stack) == world && savedPos.getTileEntity(world) instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, otherPos)){
ItemPhantomConnector.clearStorage(stack); ItemPhantomConnector.clearStorage(stack);
@ -96,18 +96,6 @@ public class ItemLaserWrench 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

@ -13,20 +13,15 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.Position; import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
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.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockBush; import net.minecraft.block.BlockBush;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction; import net.minecraft.item.EnumAction;
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.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -49,7 +44,7 @@ public class ItemLeafBlower extends ItemBase{
@Override @Override
public EnumAction getItemUseAction(ItemStack stack){ public EnumAction getItemUseAction(ItemStack stack){
return EnumAction.bow; return EnumAction.BOW;
} }
@Override @Override
@ -60,13 +55,7 @@ public class ItemLeafBlower extends ItemBase{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return this.isAdvanced ? EnumRarity.epic : EnumRarity.rare; return this.isAdvanced ? EnumRarity.EPIC : EnumRarity.RARE;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
} }
@Override @Override
@ -100,9 +89,10 @@ public class ItemLeafBlower extends ItemBase{
for(int reachZ = -rangeSides; reachZ < rangeSides+1; reachZ++){ for(int reachZ = -rangeSides; reachZ < rangeSides+1; reachZ++){
for(int reachY = (this.isAdvanced ? -rangeSides : -rangeUp); reachY < (this.isAdvanced ? rangeSides : rangeUp)+1; reachY++){ for(int reachY = (this.isAdvanced ? -rangeSides : -rangeUp); reachY < (this.isAdvanced ? rangeSides : rangeUp)+1; reachY++){
//The current Block to break //The current Block to break
Block block = world.getBlock(x+reachX, y+reachY, z+reachZ); Position pos = new Position(x+reachX, y+reachY, z+reachZ);
if(block != null && (block instanceof BlockBush || (this.isAdvanced && block.isLeaves(world, x+reachX, y+reachY, z+reachZ)))){ Block block = pos.getBlock(world);
breakPositions.add(new Position(x+reachX, y+reachY, z+reachZ)); if(block != null && (block instanceof BlockBush || (this.isAdvanced && block.isLeaves(world, pos)))){
breakPositions.add(pos);
} }
} }
} }
@ -112,17 +102,17 @@ public class ItemLeafBlower extends ItemBase{
Collections.shuffle(breakPositions); Collections.shuffle(breakPositions);
Position theCoord = breakPositions.get(0); Position theCoord = breakPositions.get(0);
Block theBlock = world.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ()); Block theBlock = theCoord.getBlock(world);
ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
int meta = world.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ()); int meta = theCoord.getMetadata(world);
//Gets all of the Drops the Block should have //Gets all of the Drops the Block should have
drops.addAll(theBlock.getDrops(world, theCoord.getX(), theCoord.getY(), theCoord.getZ(), meta, 0)); drops.addAll(theBlock.getDrops(world, theCoord, theCoord.getBlockState(world), 0));
//Deletes the Block //Deletes the Block
world.setBlockToAir(theCoord.getX(), theCoord.getY(), theCoord.getZ()); world.setBlockToAir(theCoord);
//Plays the Breaking Sound //Plays the Breaking Sound
world.playAuxSFX(2001, theCoord.getX(), theCoord.getY(), theCoord.getZ(), Block.getIdFromBlock(theBlock)+(meta << 12)); world.playAuxSFX(2001, theCoord, Block.getIdFromBlock(theBlock)+(meta << 12));
for(ItemStack theDrop : drops){ for(ItemStack theDrop : drops){
//Drops the Items into the World //Drops the Items into the World
@ -130,10 +120,4 @@ public class ItemLeafBlower extends ItemBase{
} }
} }
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int pass){
return this.itemIcon;
}
} }

View file

@ -11,19 +11,14 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
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.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3; 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.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,13 +35,13 @@ public class ItemMagnetRing extends ItemEnergy{
if(!entity.isSneaking()){ if(!entity.isSneaking()){
//Get all the Items in the area //Get all the Items in the area
int range = 5; int range = 5;
ArrayList<EntityItem> items = (ArrayList<EntityItem>)world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX-range, entity.posY-range, entity.posZ-range, entity.posX+range, entity.posY+range, entity.posZ+range)); ArrayList<EntityItem> items = (ArrayList<EntityItem>)world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.fromBounds(entity.posX-range, entity.posY-range, entity.posZ-range, entity.posX+range, entity.posY+range, entity.posZ+range));
if(!items.isEmpty()){ if(!items.isEmpty()){
for(EntityItem item : items){ for(EntityItem item : items){
if(this.getEnergyStored(stack) >= energyUse){ if(this.getEnergyStored(stack) >= energyUse){
//If the Item is near enough to get picked up //If the Item is near enough to get picked up
//(So it doesn't bounce around until it notices itself..) //(So it doesn't bounce around until it notices itself..)
if(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ).distanceTo(Vec3.createVectorHelper(item.posX, item.posY, item.posZ)) <= 1.5){ if(new Vec3(entity.posX, entity.posY, entity.posZ).distanceTo(new Vec3(item.posX, item.posY, item.posZ)) <= 1.5){
item.onCollideWithPlayer((EntityPlayer)entity); item.onCollideWithPlayer((EntityPlayer)entity);
} }
else{ else{
@ -71,18 +66,6 @@ public class ItemMagnetRing extends ItemEnergy{
@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

@ -16,16 +16,16 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
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;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
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.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -41,10 +41,10 @@ public class ItemPhantomConnector extends ItemBase{
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing par7, float par8, float par9, float par10){
if(!world.isRemote){ if(!world.isRemote){
//Passing Data to Phantoms //Passing Data to Phantoms
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(pos);
if(tile != null){ if(tile != null){
//Passing to Phantom //Passing to Phantom
if(tile instanceof IPhantomTile){ if(tile instanceof IPhantomTile){
@ -61,7 +61,7 @@ public class ItemPhantomConnector extends ItemBase{
} }
} }
//Storing Connections //Storing Connections
storeConnection(stack, x, y, z, world); storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.stored.desc"))); player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.stored.desc")));
} }
return true; return true;
@ -114,7 +114,7 @@ public class ItemPhantomConnector extends ItemBase{
tag.setInteger("XCoordOfTileStored", x); tag.setInteger("XCoordOfTileStored", x);
tag.setInteger("YCoordOfTileStored", y); tag.setInteger("YCoordOfTileStored", y);
tag.setInteger("ZCoordOfTileStored", z); tag.setInteger("ZCoordOfTileStored", z);
tag.setInteger("WorldOfTileStored", world.provider.dimensionId); tag.setInteger("WorldOfTileStored", world.provider.getDimensionId());
stack.setTagCompound(tag); stack.setTagCompound(tag);
} }
@ -147,18 +147,6 @@ public class ItemPhantomConnector 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

@ -11,15 +11,10 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
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 ItemResonantRice extends ItemBase{ public class ItemResonantRice extends ItemBase{
@ -38,18 +33,6 @@ public class ItemResonantRice 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

@ -11,14 +11,9 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
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.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
@ -94,18 +89,6 @@ public class ItemWingsOfTheBats 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

@ -16,18 +16,18 @@ import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockDirt;
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.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool; import net.minecraft.item.ItemTool;
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.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -39,8 +39,6 @@ import java.util.Set;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class ItemAllToolAA extends ItemTool{ public class ItemAllToolAA extends ItemTool{
@SideOnly(Side.CLIENT)
private IIcon overlayIcon;
private int color; private int color;
private String name; private String name;
@ -87,35 +85,48 @@ public class ItemAllToolAA extends ItemTool{
} }
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){
if(!player.canPlayerEdit(x, y, z, side, stack)){ if(!playerIn.canPlayerEdit(pos.offset(side), side, stack)){
return false; return false;
} }
else{ else{
UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); int hook = ForgeEventFactory.onHoeUse(stack, playerIn, worldIn, pos);
if(MinecraftForge.EVENT_BUS.post(event)){ if(hook != 0){
return false; return hook > 0;
} }
if(event.getResult() == Event.Result.ALLOW){
stack.damageItem(1, player); IBlockState state = worldIn.getBlockState(pos);
return true; Block block = state.getBlock();
}
Block block = world.getBlock(x, y, z); if(side != EnumFacing.DOWN && worldIn.isAirBlock(pos.up())){
if(side != 0 && world.getBlock(x, y+1, z).isAir(world, x, y+1, z) && (block == Blocks.grass || block == Blocks.dirt)){ if(block == Blocks.grass){
Block block1 = Blocks.farmland; return this.useHoe(stack, playerIn, worldIn, pos, Blocks.farmland.getDefaultState());
world.playSoundEffect((double)((float)x+0.5F), (double)((float)y+0.5F), (double)((float)z+0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume()+1.0F)/2.0F, block1.stepSound.getPitch()*0.8F);
if(world.isRemote){
return true;
} }
else{
world.setBlock(x, y, z, block1); if(block == Blocks.dirt){
stack.damageItem(1, player); switch(state.getValue(BlockDirt.VARIANT)){
return true; case DIRT:
return this.useHoe(stack, playerIn, worldIn, pos, Blocks.farmland.getDefaultState());
case COARSE_DIRT:
return this.useHoe(stack, playerIn, worldIn, pos, Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
}
} }
} }
else{
return false; return false;
} }
}
private boolean useHoe(ItemStack stack, EntityPlayer player, World worldIn, BlockPos target, IBlockState newState){
worldIn.playSoundEffect((double)((float)target.getX()+0.5F), (double)((float)target.getY()+0.5F), (double)((float)target.getZ()+0.5F), newState.getBlock().stepSound.getStepSound(), (newState.getBlock().stepSound.getVolume()+1.0F)/2.0F, newState.getBlock().stepSound.getFrequency()*0.8F);
if(worldIn.isRemote){
return true;
}
else{
worldIn.setBlockState(target, newState);
stack.damageItem(1, player);
return true;
} }
} }
@ -130,31 +141,13 @@ public class ItemAllToolAA extends ItemTool{
return this.rarity; return this.rarity;
} }
@Override
public boolean requiresMultipleRenderPasses(){
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int damage, int pass){
return pass > 0 ? this.overlayIcon : super.getIconFromDamageForRenderPass(damage, pass);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":itemPaxel");
this.overlayIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":itemPaxelOverlay");
}
@Override @Override
public boolean canHarvestBlock(Block block, ItemStack stack){ public boolean canHarvestBlock(Block block, ItemStack stack){
return this.hasExtraWhitelist(block) || block.getMaterial().isToolNotRequired() || (block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() >= 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2))); return this.hasExtraWhitelist(block) || block.getMaterial().isToolNotRequired() || (block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() >= 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2)));
} }
private boolean hasExtraWhitelist(Block block){ private boolean hasExtraWhitelist(Block block){
String name = Block.blockRegistry.getNameForObject(block); String name = block.getRegistryName();
if(name != null){ if(name != null){
for(String list : ConfigValues.paxelExtraMiningWhitelist){ for(String list : ConfigValues.paxelExtraMiningWhitelist){
if(list.equals(name)){ if(list.equals(name)){
@ -191,7 +184,7 @@ public class ItemAllToolAA extends ItemTool{
} }
@Override @Override
public float getDigSpeed(ItemStack stack, Block block, int meta){ public float getDigSpeed(ItemStack stack, IBlockState state){
return this.hasExtraWhitelist(block) || block.getHarvestTool(meta) == null || block.getHarvestTool(meta).isEmpty() || this.getToolClasses(stack).contains(block.getHarvestTool(meta)) ? this.efficiencyOnProperMaterial : 1.0F; return this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) ? this.efficiencyOnProperMaterial : 1.0F;
} }
} }

View file

@ -13,15 +13,11 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemArmorAA extends ItemArmor{ public class ItemArmorAA extends ItemArmor{
@ -42,7 +38,7 @@ public class ItemArmorAA extends ItemArmor{
} }
public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem, String textureBase){ public ItemArmorAA(String name, ArmorMaterial material, int type, ItemStack repairItem, String textureBase){
this(name, material, type, repairItem, textureBase, EnumRarity.rare); this(name, material, type, repairItem, textureBase, EnumRarity.RARE);
} }
private void register(){ private void register(){
@ -69,12 +65,6 @@ public class ItemArmorAA extends ItemArmor{
return this.rarity; return this.rarity;
} }
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int pass){
return this.itemIcon;
}
@Override @Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){
return this.textures[slot == 2 ? 1 : 0]; return this.textures[slot == 2 ? 1 : 0];
@ -84,10 +74,4 @@ public class ItemArmorAA extends ItemArmor{
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
return ItemUtil.areItemsEqual(this.repairItem, stack, false); return ItemUtil.areItemsEqual(this.repairItem, stack, false);
} }
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconReg){
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
}
} }

View file

@ -13,15 +13,11 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemBucketAA extends ItemBucket{ public class ItemBucketAA extends ItemBucket{
@ -56,18 +52,6 @@ public class ItemBucketAA extends ItemBucket{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.UNCOMMON;
}
@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

@ -13,15 +13,11 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemHoeAA extends ItemHoe{ public class ItemHoeAA extends ItemHoe{
@ -67,16 +63,4 @@ public class ItemHoeAA extends ItemHoe{
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
return ItemUtil.areItemsEqual(this.repairItem, stack, false); return ItemUtil.areItemsEqual(this.repairItem, stack, false);
} }
@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

@ -13,15 +13,11 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.creative.CreativeTab; import de.ellpeck.actuallyadditions.mod.creative.CreativeTab;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemShovelAA extends ItemSpade{ public class ItemShovelAA extends ItemSpade{
@ -67,16 +63,4 @@ public class ItemShovelAA extends ItemSpade{
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return this.rarity; return this.rarity;
} }
@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

@ -13,13 +13,8 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.lens.Lens;
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.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemLens extends ItemBase implements ILensItem{ public class ItemLens extends ItemBase implements ILensItem{
@ -34,19 +29,7 @@ public class ItemLens extends ItemBase implements ILensItem{
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.UNCOMMON;
}
@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;
} }
@Override @Override

View file

@ -24,8 +24,8 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -68,7 +68,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
private void doWork(){ private void doWork(){
if(this.storage.getEnergyStored() >= ENERGY_USE){ if(this.storage.getEnergyStored() >= ENERGY_USE){
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); Position thisPos = Position.fromTileEntity(this);
EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(thisPos.getMetadata(worldObj));
//Extract energy for shooting the laser itself too! //Extract energy for shooting the laser itself too!
this.storage.extractEnergy(ENERGY_USE, false); this.storage.extractEnergy(ENERGY_USE, false);
@ -76,7 +77,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
Lens currentLens = this.getCurrentLens(); Lens currentLens = this.getCurrentLens();
int distance = currentLens.getDistance(); int distance = currentLens.getDistance();
for(int i = 0; i < distance; i++){ for(int i = 0; i < distance; i++){
Position hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, i); Position hitBlock = WorldUtil.getCoordsFromSide(sideToManipulate, thisPos, i);
if(currentLens.invoke(hitBlock, this)){ if(currentLens.invoke(hitBlock, this)){
this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens); this.shootLaser(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
@ -99,8 +100,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
} }
private void shootLaser(int endX, int endY, int endZ, Lens currentLens){ private void shootLaser(int endX, int endY, int endZ, Lens currentLens){
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, ModUtil.MOD_ID_LOWER+":reconstructor", 0.35F, 1.0F); this.worldObj.playSoundEffect(this.getX(), this.getY(), this.getZ(), ModUtil.MOD_ID_LOWER+":reconstructor", 0.35F, 1.0F);
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(xCoord, yCoord, zCoord, endX, endY, endZ, currentLens.getColor(), 8, 2F), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64)); PacketHandler.theNetwork.sendToAllAround(new PacketParticle(this.getX(), this.getY(), this.getZ(), endX, endY, endZ, currentLens.getColor(), 8, 2F), new NetworkRegistry.TargetPoint(worldObj.provider.getDimensionId(), this.getX(), this.getY(), this.getZ(), 64));
} }
@Override @Override
@ -135,27 +136,27 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
} }
@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;
} }
@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);
} }
@ -165,28 +166,28 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
} }
@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 getX(){ public int getX(){
return this.xCoord; return this.getPos().getX();
} }
@Override @Override
public int getY(){ public int getY(){
return this.yCoord; return this.getPos().getY();
} }
@Override @Override
public int getZ(){ public int getZ(){
return this.zCoord; return this.getPos().getZ();
} }
@Override @Override
public World getWorld(){ public World getWorldObject(){
return this.getWorldObj(); return this.getWorld();
} }
@Override @Override

View file

@ -16,7 +16,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 java.util.ArrayList; import java.util.ArrayList;
@ -67,26 +67,26 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
} }
private void doWork(){ private void doWork(){
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); EnumFacing sideToManipulate = WorldUtil.getDirectionByPistonRotation(Position.fromTileEntity(this).getMetadata(worldObj));
Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord, 0); Position coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, Position.fromTileEntity(this), 0);
if(coordsBlock != null){ if(coordsBlock != null){
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()); Block blockToBreak = coordsBlock.getBlock(worldObj);
if(!this.isPlacer && blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){ if(!this.isPlacer && blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock) > -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, true)){
worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12)); worldObj.playAuxSFX(2001, coordsBlock, Block.getIdFromBlock(blockToBreak)+(meta << 12));
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this));
WorldUtil.addToInventory(this, drops, true); WorldUtil.addToInventory(this, drops, true, true);
this.markDirty(); this.markDirty();
} }
} }
else if(this.isPlacer && worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()).isReplaceable(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ())){ else if(this.isPlacer && coordsBlock.getBlock(worldObj).isReplaceable(worldObj, coordsBlock)){
int theSlot = WorldUtil.findFirstFilledSlot(this.slots); int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, this.slots[theSlot])); this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, Position.fromTileEntity(this), this.slots[theSlot]));
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){ if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
this.slots[theSlot] = null; this.slots[theSlot] = null;
} }
@ -95,7 +95,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
} }
@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,7 +105,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return true; return true;
} }

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.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;
public class TileEntityDropper extends TileEntityInventoryBase implements IRedstoneToggle{ public class TileEntityDropper extends TileEntityInventoryBase implements IRedstoneToggle{
@ -59,7 +60,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
if(this.removeFromInventory(false) != null){ if(this.removeFromInventory(false) != null){
ItemStack stack = this.removeFromInventory(true); ItemStack stack = this.removeFromInventory(true);
stack.stackSize = 1; stack.stackSize = 1;
WorldUtil.dropItemAtSide(ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)), worldObj, xCoord, yCoord, zCoord, stack); WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(Position.fromTileEntity(this).getMetadata(worldObj)), worldObj, Position.fromTileEntity(this), stack);
} }
} }
@ -80,7 +81,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
} }
@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);
} }
@ -90,7 +91,7 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return true; return true;
} }

View file

@ -15,7 +15,7 @@ import cofh.api.energy.IEnergyContainerItem;
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;
@ -66,7 +66,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
} }
@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);
} }
@ -76,7 +76,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
} }
@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;
} }
@ -86,22 +86,22 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
} }
@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

@ -13,10 +13,11 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyContainerItem; import cofh.api.energy.IEnergyContainerItem;
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.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;
@ -48,13 +49,8 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
} }
} }
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(lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ if(lastEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
@ -76,22 +72,22 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
} }
@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;
} }
@ -101,7 +97,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
} }
@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);
} }
@ -111,7 +107,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
} }
@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;
} }

View file

@ -10,12 +10,13 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
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.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.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;
@ -58,12 +59,12 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
WorldUtil.fillBucket(oilTank, slots, 2, 3); WorldUtil.fillBucket(oilTank, slots, 2, 3);
if(this.oilTank.getFluidAmount() > 0){ if(this.oilTank.getFluidAmount() > 0){
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.oilTank); WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.DOWN, this.oilTank);
if(!this.isRedstonePowered){ if(!this.isRedstonePowered){
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, this.oilTank); WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.NORTH, this.oilTank);
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, this.oilTank); WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.EAST, this.oilTank);
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, this.oilTank); WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.SOUTH, this.oilTank);
WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, this.oilTank); WorldUtil.pushFluid(worldObj, Position.fromTileEntity(this), EnumFacing.WEST, this.oilTank);
} }
} }
@ -109,7 +110,7 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
} }
@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);
} }
@ -119,20 +120,20 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return (slot == 1 && stack.getItem() == Items.bucket) || (slot == 3 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME))); return (slot == 1 && stack.getItem() == Items.bucket) || (slot == 3 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)));
} }
@Override @Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ public int fill(EnumFacing from, FluidStack resource, boolean doFill){
if(from != ForgeDirection.DOWN && resource.getFluid() == InitBlocks.fluidCanolaOil){ if(from != EnumFacing.DOWN && resource.getFluid() == InitBlocks.fluidCanolaOil){
return this.canolaTank.fill(resource, doFill); return this.canolaTank.fill(resource, doFill);
} }
return 0; return 0;
} }
@Override @Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
if(resource.getFluid() == InitBlocks.fluidOil){ if(resource.getFluid() == InitBlocks.fluidOil){
return this.oilTank.drain(resource.amount, doDrain); return this.oilTank.drain(resource.amount, doDrain);
} }
@ -140,22 +141,22 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
} }
@Override @Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
return this.oilTank.drain(maxDrain, doDrain); return this.oilTank.drain(maxDrain, doDrain);
} }
@Override @Override
public boolean canFill(ForgeDirection from, Fluid fluid){ public boolean canFill(EnumFacing from, Fluid fluid){
return from != ForgeDirection.DOWN && fluid == InitBlocks.fluidCanolaOil; return from != EnumFacing.DOWN && fluid == InitBlocks.fluidCanolaOil;
} }
@Override @Override
public boolean canDrain(ForgeDirection from, Fluid fluid){ public boolean canDrain(EnumFacing from, Fluid fluid){
return from != ForgeDirection.UP && fluid == InitBlocks.fluidOil; return from != EnumFacing.UP && fluid == InitBlocks.fluidOil;
} }
@Override @Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){ public FluidTankInfo[] getTankInfo(EnumFacing from){
return new FluidTankInfo[]{this.canolaTank.getInfo(), this.oilTank.getInfo()}; return new FluidTankInfo[]{this.canolaTank.getInfo(), this.oilTank.getInfo()};
} }

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.Position;
import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -18,8 +19,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.FishingHooks; import net.minecraftforge.common.FishingHooks;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,19 +33,20 @@ public class TileEntityFishingNet extends TileEntityBase{
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote){ if(!worldObj.isRemote){
if(!this.isRedstonePowered){ if(!this.isRedstonePowered){
if(worldObj.getBlock(xCoord, yCoord-1, zCoord).getMaterial() == Material.water){ Position pos = Position.fromTileEntity(this);
if(pos.getOffsetPosition(0, -1, 0).getMaterial(worldObj) == Material.water){
if(this.timeUntilNextDrop > 0){ if(this.timeUntilNextDrop > 0){
this.timeUntilNextDrop--; this.timeUntilNextDrop--;
if(timeUntilNextDrop <= 0){ if(timeUntilNextDrop <= 0){
ItemStack fishable = FishingHooks.getRandomFishable(Util.RANDOM, Util.RANDOM.nextFloat()); ItemStack fishable = FishingHooks.getRandomFishable(Util.RANDOM, Util.RANDOM.nextFloat());
TileEntity tile = worldObj.getTileEntity(xCoord, yCoord+1, zCoord); TileEntity tile = pos.getOffsetPosition(0, 1, 0).getTileEntity(worldObj);
if(tile != null && tile instanceof IInventory){ if(tile != null && tile instanceof IInventory){
ArrayList<ItemStack> list = new ArrayList<ItemStack>(); ArrayList<ItemStack> list = new ArrayList<ItemStack>();
list.add(fishable); list.add(fishable);
WorldUtil.addToInventory((IInventory)tile, list, ForgeDirection.DOWN, true); WorldUtil.addToInventory((IInventory)tile, list, EnumFacing.DOWN, true, false);
} }
else{ else{
EntityItem item = new EntityItem(worldObj, xCoord+0.5, yCoord+0.5, zCoord+0.5, fishable); EntityItem item = new EntityItem(worldObj, pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, fishable);
item.lifespan = 2000; item.lifespan = 2000;
worldObj.spawnEntityInWorld(item); worldObj.spawnEntityInWorld(item);
} }

View file

@ -19,7 +19,7 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.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;
@ -37,12 +37,12 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote){ if(!worldObj.isRemote){
ArrayList<Integer> blocksAround = new ArrayList<Integer>(); ArrayList<Integer> blocksAround = new ArrayList<Integer>();
if(ENERGY_PRODUCE <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ if(ENERGY_PRODUCE <= this.storage.getMaxEnergyStored()-this.storage.getEnergyStored()){
for(int i = 1; i <= 5; i++){ for(int i = 1; i <= 5; i++){
Position coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), xCoord, yCoord, zCoord, 0); Position coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), Position.fromTileEntity(this), 0);
if(coords != null){ if(coords != null){
Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ()); Block block = coords.getBlock(worldObj);
if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){ if(block != null && block.getMaterial() == Material.lava && coords.getMetadata(worldObj) == 0){
blocksAround.add(i); blocksAround.add(i);
} }
} }
@ -54,13 +54,13 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
if(Util.RANDOM.nextInt(10000) == 0){ if(Util.RANDOM.nextInt(10000) == 0){
int randomSide = blocksAround.get(Util.RANDOM.nextInt(blocksAround.size())); int randomSide = blocksAround.get(Util.RANDOM.nextInt(blocksAround.size()));
WorldUtil.breakBlockAtSide(WorldUtil.getDirectionBySidesInOrder(randomSide), worldObj, xCoord, yCoord, zCoord); WorldUtil.breakBlockAtSide(WorldUtil.getDirectionBySidesInOrder(randomSide), worldObj, Position.fromTileEntity(this));
} }
} }
} }
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ if(this.storage.getEnergyStored() > 0){
WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, this.storage); WorldUtil.pushEnergy(worldObj, Position.fromTileEntity(this), EnumFacing.UP, this.storage);
} }
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
@ -82,23 +82,23 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
} }
@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 from == ForgeDirection.UP; return from == EnumFacing.UP;
} }
@Override @Override

View file

@ -19,7 +19,7 @@ import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
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.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
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,9 +51,10 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
for(int reachX = -RANGE; reachX < RANGE+1; reachX++){ for(int reachX = -RANGE; reachX < RANGE+1; reachX++){
for(int reachZ = -RANGE; reachZ < RANGE+1; reachZ++){ for(int reachZ = -RANGE; reachZ < RANGE+1; reachZ++){
for(int reachY = -RANGE; reachY < RANGE+1; reachY++){ for(int reachY = -RANGE; reachY < RANGE+1; reachY++){
Block block = this.worldObj.getBlock(this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ); Position pos = new Position(this.pos.getX()+reachX, this.pos.getY()+reachY, this.pos.getZ()+reachZ);
if(block != null && block.isLeaves(this.worldObj, this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)){ Block block = pos.getBlock(worldObj);
breakPositions.add(new Position(this.xCoord+reachX, this.yCoord+reachY, this.zCoord+reachZ)); if(block != null && block.isLeaves(this.worldObj, pos)){
breakPositions.add(pos);
} }
} }
} }
@ -63,15 +64,15 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
Collections.shuffle(breakPositions); Collections.shuffle(breakPositions);
Position theCoord = breakPositions.get(0); Position theCoord = breakPositions.get(0);
Block theBlock = this.worldObj.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ()); Block theBlock = theCoord.getBlock(worldObj);
int meta = this.worldObj.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ()); int meta = theCoord.getMetadata(worldObj);
this.worldObj.playAuxSFX(2001, theCoord.getX(), theCoord.getY(), theCoord.getZ(), Block.getIdFromBlock(theBlock)+(meta << 12)); this.worldObj.playAuxSFX(2001, theCoord, Block.getIdFromBlock(theBlock)+(meta << 12));
this.worldObj.setBlockToAir(theCoord.getX(), theCoord.getY(), theCoord.getZ()); this.worldObj.setBlockToAir(this.getPos());
this.storage.receiveEnergy(ENERGY_PRODUCED, false); this.storage.receiveEnergy(ENERGY_PRODUCED, false);
PacketHandler.theNetwork.sendToAllAround(new PacketParticle(xCoord, yCoord, zCoord, theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64)); PacketHandler.theNetwork.sendToAllAround(new PacketParticle(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), theCoord.getX(), theCoord.getY(), theCoord.getZ(), new float[]{62F/255F, 163F/255F, 74F/255F}, 5, 1.0F), new NetworkRegistry.TargetPoint(worldObj.provider.getDimensionId(), this.pos.getX(), this.pos.getY(), this.pos.getZ(), 64));
} }
} }
} }
@ -80,13 +81,8 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
} }
} }
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(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){ if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
@ -108,22 +104,22 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr
} }
@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

@ -19,8 +19,9 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -49,7 +50,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote){ if(!worldObj.isRemote){
this.range = TileEntityPhantomface.upgradeRange(RANGE, worldObj, xCoord, yCoord, zCoord); this.range = TileEntityPhantomface.upgradeRange(RANGE, worldObj, Position.fromTileEntity(this));
if(!this.hasBoundPosition()){ if(!this.hasBoundPosition()){
this.boundPosition = null; this.boundPosition = null;
@ -85,11 +86,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
@Override @Override
public boolean hasBoundPosition(){ public boolean hasBoundPosition(){
if(this.boundPosition != null){ if(this.boundPosition != null){
if(this.worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj.provider.dimensionId == this.worldObj.provider.dimensionId)){ if(this.worldObj.getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.getPos().getX() == this.boundPosition.getX() && this.getPos().getY() == this.boundPosition.getY() && this.getPos().getZ() == this.boundPosition.getZ() && this.worldObj.provider.getDimensionId() == this.worldObj.provider.getDimensionId())){
this.boundPosition = null; this.boundPosition = null;
return false; return false;
} }
return this.worldObj.provider.dimensionId == this.worldObj.provider.dimensionId; return this.worldObj.provider.getDimensionId() == this.worldObj.provider.getDimensionId();
} }
return false; return false;
} }
@ -103,9 +104,9 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
drops.addAll(blockToBreak.getDrops(worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0)); drops.addAll(blockToBreak.getDrops(worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0));
if(WorldUtil.addToInventory(this, drops, false)){ if(WorldUtil.addToInventory(this, drops, false)){
worldObj.playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12)); worldObj.playAuxSFX(2001, this.boundPosition, Block.getIdFromBlock(blockToBreak)+(meta << 12));
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, worldObj, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()); worldObj.setBlockToAir(this.boundPosition);
WorldUtil.addToInventory(this, drops, true); WorldUtil.addToInventory(this, drops, true, true);
this.markDirty(); this.markDirty();
} }
} }
@ -132,17 +133,17 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
double d5 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)j1); double d5 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)j1);
double d0 = (double)this.boundPosition.getX()+0.5D+0.25D*(double)i1; double d0 = (double)this.boundPosition.getX()+0.5D+0.25D*(double)i1;
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1); double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
worldObj.spawnParticle("portal", d0, d1, d2, d3, d4, d5); worldObj.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
} }
if(this.ticksElapsed%80 == 0){ if(this.ticksElapsed%80 == 0){
PacketParticle.renderParticlesFromAToB(xCoord, yCoord, zCoord, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), 2, 0.35F, TileEntityPhantomface.COLORS, 3); PacketParticle.renderParticlesFromAToB(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), 2, 0.35F, TileEntityPhantomface.COLORS, 3);
} }
} }
@Override @Override
public boolean isBoundThingInRange(){ public boolean isBoundThingInRange(){
return this.hasBoundPosition() && this.boundPosition.toVec().distanceTo(Vec3.createVectorHelper(xCoord, yCoord, zCoord)) <= this.range; return this.hasBoundPosition() && this.boundPosition.toVec().distanceTo(new Vec3(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ())) <= this.range;
} }
@Override @Override
@ -190,7 +191,7 @@ public class TileEntityPhantomPlacer 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);
} }
@ -200,7 +201,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return this.isBreaker; return this.isBreaker;
} }

View file

@ -14,14 +14,12 @@ import de.ellpeck.actuallyadditions.mod.booklet.GuiBooklet;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -33,14 +31,14 @@ 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 final int TESR_RENDER_ID = 2;
public static int compostRenderId; /*public static int compostRenderId;
public static int fishingNetRenderId; public static int fishingNetRenderId;
public static int furnaceSolarRenderId; public static int furnaceSolarRenderId;
public static int coffeeMachineRenderId; public static int coffeeMachineRenderId;
public static int phantomBoosterRenderId; public static int phantomBoosterRenderId;
public static int smileyCloudRenderId; public static int smileyCloudRenderId;
public static int laserRelayRenderId; public static int laserRelayRenderId;
public static int bookletStandRenderId; public static int bookletStandRenderId;*/
public static ResourceLocation getGuiLocation(String file){ public static ResourceLocation getGuiLocation(String file){
return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png"); return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/"+file+".png");
@ -57,19 +55,21 @@ public class AssetUtil{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack, int renderPass){ public static void renderItemInWorld(ItemStack stack, int renderPass){
IIcon icon = stack.getItem().getIcon(stack, renderPass); //TODO Fix rendering items in world
/*IIcon icon = stack.getItem().getIcon(stack, renderPass);
float f = icon.getMinU(); float f = icon.getMinU();
float f1 = icon.getMaxU(); float f1 = icon.getMaxU();
float f2 = icon.getMinV(); float f2 = icon.getMinV();
float f3 = icon.getMaxV(); float f3 = icon.getMaxV();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F/16F); ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F/16F);*/
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderBlockInWorld(Block block, int meta){ public static void renderBlockInWorld(Block block, int meta){
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); //TODO Fix rendering blocks in world
RenderBlocks.getInstance().renderBlockAsItem(block, meta, 1F); /*Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
RenderBlocks.getInstance().renderBlockAsItem(block, meta, 1F);*/
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -84,11 +84,11 @@ public class AssetUtil{
GL11.glScalef(scale, scale, scale); GL11.glScalef(scale, scale, scale);
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
boolean flagBefore = mc.fontRenderer.getUnicodeFlag(); boolean flagBefore = mc.fontRendererObj.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(false); mc.fontRendererObj.setUnicodeFlag(false);
RenderItem.getInstance().renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), stack, 0, 0); Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0);
RenderItem.getInstance().renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), stack, 0, 0); Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(mc.fontRendererObj, stack, 0, 0, null);
mc.fontRenderer.setUnicodeFlag(flagBefore); mc.fontRendererObj.setUnicodeFlag(flagBefore);
//GL+MC+NEI suck //GL+MC+NEI suck
if(mc.currentScreen instanceof GuiBooklet || mc.currentScreen == null){ if(mc.currentScreen instanceof GuiBooklet || mc.currentScreen == null){
@ -98,32 +98,31 @@ public class AssetUtil{
} }
//Copied from Gui.class and changed //Copied from Gui.class and changed
public static void drawHorizontalGradientRect(int startX, int startY, int endX, int endY, int firstColor, int secondColor){ public static void drawHorizontalGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel){
float f = (float)(firstColor >> 24 & 255)/255.0F; float f = (float)(startColor >> 24 & 255)/255.0F;
float f1 = (float)(firstColor >> 16 & 255)/255.0F; float f1 = (float)(startColor >> 16 & 255)/255.0F;
float f2 = (float)(firstColor >> 8 & 255)/255.0F; float f2 = (float)(startColor >> 8 & 255)/255.0F;
float f3 = (float)(firstColor & 255)/255.0F; float f3 = (float)(startColor & 255)/255.0F;
float f4 = (float)(secondColor >> 24 & 255)/255.0F; float f4 = (float)(endColor >> 24 & 255)/255.0F;
float f5 = (float)(secondColor >> 16 & 255)/255.0F; float f5 = (float)(endColor >> 16 & 255)/255.0F;
float f6 = (float)(secondColor >> 8 & 255)/255.0F; float f6 = (float)(endColor >> 8 & 255)/255.0F;
float f7 = (float)(secondColor & 255)/255.0F; float f7 = (float)(endColor & 255)/255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D); GlStateManager.disableTexture2D();
GL11.glEnable(GL11.GL_BLEND); GlStateManager.enableBlend();
GL11.glDisable(GL11.GL_ALPHA_TEST); GlStateManager.disableAlpha();
OpenGlHelper.glBlendFunc(770, 771, 1, 0); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH); GlStateManager.shadeModel(7425);
Tessellator tessellator = Tessellator.instance; Tessellator tessellator = Tessellator.getInstance();
tessellator.startDrawingQuads(); WorldRenderer worldrenderer = tessellator.getWorldRenderer();
tessellator.setColorRGBA_F(f1, f2, f3, f); worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
tessellator.addVertex((double)startX, (double)startY, 0); worldrenderer.pos((double)right, (double)top, (double)zLevel).color(f1, f2, f3, f).endVertex();
tessellator.addVertex((double)startX, (double)endY, 0); worldrenderer.pos((double)left, (double)top, (double)zLevel).color(f1, f2, f3, f).endVertex();
tessellator.setColorRGBA_F(f5, f6, f7, f4); worldrenderer.pos((double)left, (double)bottom, (double)zLevel).color(f5, f6, f7, f4).endVertex();
tessellator.addVertex((double)endX, (double)endY, 0); worldrenderer.pos((double)right, (double)bottom, (double)zLevel).color(f5, f6, f7, f4).endVertex();
tessellator.addVertex((double)endX, (double)startY, 0);
tessellator.draw(); tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT); GlStateManager.shadeModel(7424);
GL11.glDisable(GL11.GL_BLEND); GlStateManager.disableBlend();
GL11.glEnable(GL11.GL_ALPHA_TEST); GlStateManager.enableAlpha();
GL11.glEnable(GL11.GL_TEXTURE_2D); GlStateManager.enableTexture2D();
} }
} }

View file

@ -49,7 +49,7 @@ public class WorldUtil{
public static void breakBlockAtSide(EnumFacing side, World world, Position pos, int offset){ public static void breakBlockAtSide(EnumFacing side, World world, Position pos, int offset){
Position c = getCoordsFromSide(side, pos, offset); Position c = getCoordsFromSide(side, pos, offset);
if(c != null){ if(c != null){
world.setBlockToAir(pos.toBlockPos()); world.setBlockToAir(pos);
} }
} }
@ -79,7 +79,7 @@ public class WorldUtil{
public static TileEntity getTileEntityFromSide(EnumFacing side, World world, Position pos){ public static TileEntity getTileEntityFromSide(EnumFacing side, World world, Position pos){
Position c = getCoordsFromSide(side, pos, 0); Position c = getCoordsFromSide(side, pos, 0);
if(c != null){ if(c != null){
return world.getTileEntity(pos.toBlockPos()); return world.getTileEntity(pos);
} }
return null; return null;
} }
@ -118,7 +118,7 @@ public class WorldUtil{
//Fluids //Fluids
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack); FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
if(fluid != null && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, offsetPos.toBlockPos())){ if(fluid != null && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, offsetPos)){
Block block = offsetPos.getBlock(world); Block block = offsetPos.getBlock(world);
if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){ if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){
if(offsetPos.setBlock(world, fluid.getFluid().getBlock(), 0, 2)){ if(offsetPos.setBlock(world, fluid.getFluid().getBlock(), 0, 2)){
@ -135,8 +135,8 @@ public class WorldUtil{
//Plants //Plants
else if(stack.getItem() instanceof IPlantable){ else if(stack.getItem() instanceof IPlantable){
if(((IPlantable)stack.getItem()).getPlant(world, offsetPos.toBlockPos()).getBlock().canPlaceBlockAt(world, offsetPos.toBlockPos())){ if(((IPlantable)stack.getItem()).getPlant(world, offsetPos).getBlock().canPlaceBlockAt(world, offsetPos)){
if(offsetPos.setBlockState(world, ((IPlantable)stack.getItem()).getPlant(world, offsetPos.toBlockPos()), 0, 2)){ if(offsetPos.setBlockState(world, ((IPlantable)stack.getItem()).getPlant(world, offsetPos), 2)){
stack.stackSize--; stack.stackSize--;
} }
} }
@ -144,7 +144,7 @@ public class WorldUtil{
else{ else{
try{ try{
//Blocks //Blocks
stack.onItemUse(FakePlayerUtil.getFakePlayer(world), world, pos.toBlockPos(), side, 0, 0, 0); stack.onItemUse(FakePlayerUtil.getFakePlayer(world), world, pos, side, 0, 0, 0);
return stack; return stack;
} }
catch(Exception e){ catch(Exception e){
@ -413,7 +413,7 @@ public class WorldUtil{
else{ else{
//Check the Server if a Block that changed on the Client really changed, if not, revert the change //Check the Server if a Block that changed on the Client really changed, if not, revert the change
//TODO Check if this is the right action //TODO Check if this is the right action
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, pos.toBlockPos(), Minecraft.getMinecraft().objectMouseOver.sideHit)); Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, pos, Minecraft.getMinecraft().objectMouseOver.sideHit));
} }
return removed; return removed;
} }