Le Cleanup

This commit is contained in:
Ellpeck 2015-12-19 10:30:39 +01:00
parent c7fcdff17e
commit 6b0e24b185
79 changed files with 965 additions and 990 deletions

View file

@ -19,15 +19,7 @@ import java.util.ArrayList;
public class InitAchievements{ public class InitAchievements{
public enum Type{
CRAFTING,
SMELTING,
PICK_UP,
MISC
}
public static int pageNumber; public static int pageNumber;
public static AchievementPage theAchievementPage; public static AchievementPage theAchievementPage;
public static ArrayList<Achievement> achievementList = new ArrayList<Achievement>(); public static ArrayList<Achievement> achievementList = new ArrayList<Achievement>();
@ -43,4 +35,11 @@ public class InitAchievements{
AchievementPage.registerAchievementPage(theAchievementPage); AchievementPage.registerAchievementPage(theAchievementPage);
} }
public enum Type{
CRAFTING,
SMELTING,
PICK_UP,
MISC
}
} }

View file

@ -39,10 +39,6 @@ public enum TheAchievements{
this(name, x, y, displayStack, hasToHaveBefore, InitAchievements.Type.CRAFTING, false); this(name, x, y, displayStack, hasToHaveBefore, InitAchievements.Type.CRAFTING, false);
} }
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, InitAchievements.Type type){
this(name, x, y, displayStack, hasToHaveBefore, type, false);
}
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, InitAchievements.Type type, boolean special){ TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, InitAchievements.Type type, boolean special){
this.ach = new Achievement("achievement."+ModUtil.MOD_ID_LOWER+"."+name, ModUtil.MOD_ID_LOWER+"."+name, x, y, displayStack, hasToHaveBefore == null ? null : hasToHaveBefore.ach); this.ach = new Achievement("achievement."+ModUtil.MOD_ID_LOWER+"."+name, ModUtil.MOD_ID_LOWER+"."+name, x, y, displayStack, hasToHaveBefore == null ? null : hasToHaveBefore.ach);
if(hasToHaveBefore == null){ if(hasToHaveBefore == null){
@ -54,4 +50,8 @@ public enum TheAchievements{
this.ach.registerStat(); this.ach.registerStat();
this.type = type; this.type = type;
} }
TheAchievements(String name, int x, int y, ItemStack displayStack, TheAchievements hasToHaveBefore, InitAchievements.Type type){
this(name, x, y, displayStack, hasToHaveBefore, type, false);
}
} }

View file

@ -50,6 +50,14 @@ public class BlockAtomicReconstructor extends BlockContainerBase{
return EnumRarity.epic; return EnumRarity.epic;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
@ -113,14 +121,6 @@ public class BlockAtomicReconstructor extends BlockContainerBase{
return true; return true;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){

View file

@ -69,6 +69,17 @@ public class BlockBookletStand extends BlockContainerBase{
return true; return true;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.planks.getIcon(0, 0);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
@ -99,17 +110,6 @@ public class BlockBookletStand extends BlockContainerBase{
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, x, y, z, player, stack);
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.planks.getIcon(0, 0);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@Override @Override
public TileEntity createNewTileEntity(World world, int i){ public TileEntity createNewTileEntity(World world, int i){
return new TileEntityBookletStand(); return new TileEntityBookletStand();

View file

@ -93,14 +93,6 @@ public class BlockBreaker extends BlockContainerBase{
return true; return true;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){
@ -114,6 +106,14 @@ public class BlockBreaker extends BlockContainerBase{
return EnumRarity.uncommon; return EnumRarity.uncommon;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){ public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);

View file

@ -76,26 +76,6 @@ public class BlockCoffeeMachine extends BlockContainerBase{
return true; return true;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
}
if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
}
if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){
@ -117,4 +97,24 @@ public class BlockCoffeeMachine extends BlockContainerBase{
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic; return EnumRarity.epic;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
if(rotation == 0){
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(rotation == 1){
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
}
if(rotation == 2){
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
}
if(rotation == 3){
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
} }

View file

@ -48,11 +48,6 @@ public class BlockColoredLamp extends BlockBase{
this.isOn = isOn; this.isOn = isOn;
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta){ public IIcon getIcon(int side, int meta){
@ -140,6 +135,11 @@ public class BlockColoredLamp extends BlockBase{
return TheItemBlock.class; return TheItemBlock.class;
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{
public TheItemBlock(Block block){ public TheItemBlock(Block block){

View file

@ -78,13 +78,13 @@ public class BlockCrystal extends BlockBase{
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public Class<? extends ItemBlockBase> getItemBlock(){
return stack.getItemDamage() >= allCrystals.length ? EnumRarity.common : allCrystals[stack.getItemDamage()].rarity; return TheItemBlock.class;
} }
@Override @Override
public Class<? extends ItemBlockBase> getItemBlock(){ public EnumRarity getRarity(ItemStack stack){
return TheItemBlock.class; 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

@ -90,14 +90,6 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
return true; return true;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){
@ -111,6 +103,14 @@ public class BlockDirectionalBreaker extends BlockContainerBase{
return EnumRarity.epic; return EnumRarity.epic;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){ public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);

View file

@ -90,14 +90,6 @@ public class BlockDropper extends BlockContainerBase{
return true; return true;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){
@ -111,6 +103,14 @@ public class BlockDropper extends BlockContainerBase{
return EnumRarity.rare; return EnumRarity.rare;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){ public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);

View file

@ -93,14 +93,6 @@ public class BlockFluidCollector extends BlockContainerBase{
return true; return true;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){
@ -114,6 +106,14 @@ public class BlockFluidCollector extends BlockContainerBase{
return EnumRarity.rare; return EnumRarity.rare;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
super.onBlockPlacedBy(world, x, y, z, player, stack);
}
@Override @Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){ public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);

View file

@ -131,6 +131,25 @@ public class BlockFurnaceDouble 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.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
public EnumRarity getRarity(ItemStack stack){
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, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
@ -151,25 +170,6 @@ public class BlockFurnaceDouble extends BlockContainerBase{
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, x, y, z, player, stack);
} }
@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.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
public EnumRarity getRarity(ItemStack stack){
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, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);

View file

@ -85,35 +85,6 @@ public class BlockGiantChest extends BlockContainerBase{
return EnumRarity.epic; return EnumRarity.epic;
} }
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityGiantChest){
if(!ItemUtil.contains(((TileEntityGiantChest)tile).slots, new ItemStack(InitItems.itemCrateKeeper), false)){
this.dropInventory(world, x, y, z);
}
}
super.breakBlock(world, x, y, z, block, par6);
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack){
if(stack.getTagCompound() != null){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityGiantChest){
NBTTagList list = stack.getTagCompound().getTagList("Items", 10);
ItemStack[] slots = ((TileEntityGiantChest)tile).slots;
for(int i = 0; i < list.tagCount(); i++){
slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
}
}
}
super.onBlockPlacedBy(world, x, y, z, entity, stack);
}
@Override @Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){ public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){
ArrayList<ItemStack> drops = super.getDrops(world, x, y, z, metadata, fortune); ArrayList<ItemStack> drops = super.getDrops(world, x, y, z, metadata, fortune);
@ -147,4 +118,33 @@ public class BlockGiantChest extends BlockContainerBase{
return drops; return drops;
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack){
if(stack.getTagCompound() != null){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityGiantChest){
NBTTagList list = stack.getTagCompound().getTagList("Items", 10);
ItemStack[] slots = ((TileEntityGiantChest)tile).slots;
for(int i = 0; i < list.tagCount(); i++){
slots[i] = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
}
}
}
super.onBlockPlacedBy(world, x, y, z, entity, stack);
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof TileEntityGiantChest){
if(!ItemUtil.contains(((TileEntityGiantChest)tile).slots, new ItemStack(InitItems.itemCrateKeeper), false)){
this.dropInventory(world, x, y, z);
}
}
super.breakBlock(world, x, y, z, block, par6);
}
} }

View file

@ -76,11 +76,6 @@ public class BlockInputter extends BlockContainerBase{
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()); this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
} }
@Override
public EnumRarity getRarity(ItemStack stack){
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, int x, int y, int z, Block block, int par6){
if(!world.isRemote){ if(!world.isRemote){
@ -98,6 +93,11 @@ public class BlockInputter extends BlockContainerBase{
return TheItemBlock.class; return TheItemBlock.class;
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic;
}
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{
private long lastSysTime; private long lastSysTime;

View file

@ -83,11 +83,6 @@ public class BlockLampPowerer extends BlockBase{
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front"); this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
private void updateLamp(World world, int x, int y, int z){ private void updateLamp(World world, int x, int y, int z){
if(!world.isRemote){ if(!world.isRemote){
WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), world, x, y, z, 0); WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), world, x, y, z, 0);
@ -105,4 +100,9 @@ public class BlockLampPowerer extends BlockBase{
} }
} }
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
} }

View file

@ -35,31 +35,6 @@ public class BlockLaserRelay extends BlockContainerBase{
this.setStepSound(soundTypeStone); this.setStepSound(soundTypeStone);
} }
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
int meta = world.getBlockMetadata(x, y, z);
float pixel = 1F/16F;
if(meta == 0){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F, 1F-3*pixel);
}
else if(meta == 1){
this.setBlockBounds(3*pixel, 0F, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 2){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F);
}
else if(meta == 3){
this.setBlockBounds(3*pixel, 3*pixel, 0F, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 4){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 5){
this.setBlockBounds(0F, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
}
@Override @Override
public boolean renderAsNormalBlock(){ public boolean renderAsNormalBlock(){
return false; return false;
@ -86,6 +61,31 @@ public class BlockLaserRelay extends BlockContainerBase{
return side; return side;
} }
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
int meta = world.getBlockMetadata(x, y, z);
float pixel = 1F/16F;
if(meta == 0){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F, 1F-3*pixel);
}
else if(meta == 1){
this.setBlockBounds(3*pixel, 0F, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 2){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F);
}
else if(meta == 3){
this.setBlockBounds(3*pixel, 3*pixel, 0F, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 4){
this.setBlockBounds(3*pixel, 3*pixel, 3*pixel, 1F, 1F-3*pixel, 1F-3*pixel);
}
else if(meta == 5){
this.setBlockBounds(0F, 3*pixel, 3*pixel, 1F-3*pixel, 1F-3*pixel, 1F-3*pixel);
}
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){ public void registerBlockIcons(IIconRegister iconReg){

View file

@ -54,30 +54,6 @@ public class BlockMiner extends BlockContainerBase{
return false; return false;
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@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
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityMiner();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!world.isRemote){ if(!world.isRemote){
@ -96,4 +72,28 @@ public class BlockMiner 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.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Top");
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@Override
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityMiner();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
} }

View file

@ -90,13 +90,13 @@ public class BlockMisc extends BlockBase{
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public Class<? extends ItemBlockBase> getItemBlock(){
return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.common : allMiscBlocks[stack.getItemDamage()].rarity; return TheItemBlock.class;
} }
@Override @Override
public Class<? extends ItemBlockBase> getItemBlock(){ public EnumRarity getRarity(ItemStack stack){
return TheItemBlock.class; return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.common : allMiscBlocks[stack.getItemDamage()].rarity;
} }
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{

View file

@ -32,6 +32,10 @@ public class BlockSlabs extends BlockBase{
private Block fullBlock; private Block fullBlock;
private int meta; private int meta;
public BlockSlabs(String name, Block fullBlock){
this(name, fullBlock, 0);
}
public BlockSlabs(String name, Block fullBlock, int meta){ public BlockSlabs(String name, Block fullBlock, int meta){
super(fullBlock.getMaterial(), name); super(fullBlock.getMaterial(), name);
this.setHardness(1.5F); this.setHardness(1.5F);
@ -40,10 +44,6 @@ public class BlockSlabs extends BlockBase{
this.meta = meta; this.meta = meta;
} }
public BlockSlabs(String name, Block fullBlock){
this(name, fullBlock, 0);
}
@Override @Override
public boolean renderAsNormalBlock(){ public boolean renderAsNormalBlock(){
return false; return false;
@ -97,13 +97,13 @@ public class BlockSlabs extends BlockBase{
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public Class<? extends ItemBlockBase> getItemBlock(){
return EnumRarity.common; return TheItemBlock.class;
} }
@Override @Override
public Class<? extends ItemBlockBase> getItemBlock(){ public EnumRarity getRarity(ItemStack stack){
return TheItemBlock.class; return EnumRarity.common;
} }
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{

View file

@ -66,6 +66,19 @@ public class BlockSmileyCloud extends BlockContainerBase{
return false; return false;
} }
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
if(Util.RANDOM.nextInt(30) == 0){
for(int i = 0; i < 2; i++){
double d = Util.RANDOM.nextGaussian()*0.02D;
double d1 = 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);
}
}
}
@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, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){
if(!world.isRemote){ if(!world.isRemote){
@ -98,6 +111,28 @@ public class BlockSmileyCloud extends BlockContainerBase{
} }
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.wool.getIcon(0, 0);
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
return new TileEntitySmileyCloud();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
@ -117,39 +152,4 @@ public class BlockSmileyCloud extends BlockContainerBase{
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, x, y, z, player, stack);
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconReg){
this.blockIcon = Blocks.wool.getIcon(0, 0);
}
@Override
public TileEntity createNewTileEntity(World world, int meta){
return new TileEntitySmileyCloud();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z);
super.breakBlock(world, x, y, z, block, par6);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
if(Util.RANDOM.nextInt(30) == 0){
for(int i = 0; i < 2; i++){
double d = Util.RANDOM.nextGaussian()*0.02D;
double d1 = 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);
}
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare;
}
} }

View file

@ -144,11 +144,6 @@ public class BlockTreasureChest extends BlockBase{
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front"); this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic;
}
private void dropItems(World world, int x, int y, int z){ 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++){
TreasureChestHandler.Return theReturn = (TreasureChestHandler.Return)WeightedRandom.getRandomItem(Util.RANDOM, TreasureChestHandler.returns); TreasureChestHandler.Return theReturn = (TreasureChestHandler.Return)WeightedRandom.getRandomItem(Util.RANDOM, TreasureChestHandler.returns);
@ -170,4 +165,9 @@ public class BlockTreasureChest extends BlockBase{
itemStack.stackSize = 0; itemStack.stackSize = 0;
} }
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.epic;
}
} }

View file

@ -50,6 +50,16 @@ public class BlockWildPlant extends BlockBushBase{
return false; return false;
} }
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
}
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allWildPlants.length ? EnumRarity.common : allWildPlants[stack.getItemDamage()].rarity;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){ public IIcon getIcon(int side, int metadata){
@ -87,16 +97,6 @@ public class BlockWildPlant extends BlockBushBase{
return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, x, y, z, 7, fortune); return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, x, y, z, 7, fortune);
} }
@Override
public EnumRarity getRarity(ItemStack stack){
return stack.getItemDamage() >= allWildPlants.length ? EnumRarity.common : allWildPlants[stack.getItemDamage()].rarity;
}
@Override
public Class<? extends ItemBlockBase> getItemBlock(){
return TheItemBlock.class;
}
public static class TheItemBlock extends ItemBlockBase{ public static class TheItemBlock extends ItemBlockBase{
public TheItemBlock(Block block){ public TheItemBlock(Block block){

View file

@ -91,6 +91,19 @@ public class BlockXPSolidifier 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.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
}
@Override
public EnumRarity getRarity(ItemStack stack){
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, int x, int y, int z, EntityLivingBase player, ItemStack stack){
int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3;
@ -111,19 +124,6 @@ public class BlockXPSolidifier extends BlockContainerBase{
super.onBlockPlacedBy(world, x, y, z, player, stack); super.onBlockPlacedBy(world, x, y, z, player, stack);
} }
@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.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
}
@Override
public EnumRarity getRarity(ItemStack stack){
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, int x, int y, int z, Block block, int par6){
this.dropInventory(world, x, y, z); this.dropInventory(world, x, y, z);

View file

@ -37,10 +37,6 @@ public class BlockBase extends Block{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -49,6 +45,10 @@ public class BlockBase extends Block{
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.common; return EnumRarity.common;
} }

View file

@ -36,10 +36,6 @@ public class BlockBushBase extends BlockBush{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -48,6 +44,10 @@ public class BlockBushBase extends BlockBush{
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.common; return EnumRarity.common;
} }

View file

@ -53,10 +53,6 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -65,6 +61,10 @@ public abstract class BlockContainerBase extends BlockContainer{
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.common; return EnumRarity.common;
} }
@ -102,30 +102,11 @@ public abstract class BlockContainerBase extends BlockContainer{
tile.setInventorySlotContents(i, null); tile.setInventorySlotContents(i, null);
} }
@Override
public boolean hasComparatorInputOverride(){
return true;
}
@Override
public int getComparatorInputOverride(World world, int x, int y, int z, int meta){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IInventory){
return Container.calcRedstoneFromInventory((IInventory)tile);
}
return 0;
}
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block){ public void onNeighborBlockChange(World world, int x, int y, int z, Block block){
this.updateRedstoneState(world, x, y, z); this.updateRedstoneState(world, x, y, z);
} }
@Override
public void onBlockAdded(World world, int x, int y, int z){
this.updateRedstoneState(world, x, y, z);
}
public void updateRedstoneState(World world, int x, int y, int z){ public void updateRedstoneState(World world, int x, int y, int z){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z); boolean powered = world.isBlockIndirectlyGettingPowered(x, y, z);
@ -140,6 +121,34 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
} }
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack){
if(stack.getTagCompound() != null){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IEnergySaver){
((IEnergySaver)tile).setEnergy(stack.getTagCompound().getInteger("Energy"));
}
if(tile instanceof IFluidSaver){
int amount = stack.getTagCompound().getInteger("FluidAmount");
if(amount > 0){
FluidStack[] fluids = new FluidStack[amount];
for(int i = 0; i < amount; i++){
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Fluid"+i);
if(compound != null){
fluids[i] = FluidStack.loadFluidStackFromNBT(compound);
}
}
((IFluidSaver)tile).setFluids(fluids);
}
}
}
}
@Override @Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player){ public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player){
if(!player.capabilities.isCreativeMode){ if(!player.capabilities.isCreativeMode){
@ -147,24 +156,18 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
} }
public boolean tryToggleRedstone(World world, int x, int y, int z, EntityPlayer player){ @Override
ItemStack stack = player.getCurrentEquippedItem(); public boolean hasComparatorInputOverride(){
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){ return true;
TileEntity tile = world.getTileEntity(x, y, z); }
if(tile instanceof IRedstoneToggle){
if(!world.isRemote){
if(((IRedstoneToggle)tile).toggle()){ @Override
player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Pulse Mode")); public int getComparatorInputOverride(World world, int x, int y, int z, int meta){
} TileEntity tile = world.getTileEntity(x, y, z);
else{ if(tile instanceof IInventory){
player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Deactivation Mode")); return Container.calcRedstoneFromInventory((IInventory)tile);
}
}
return true;
}
} }
return false; return 0;
} }
@Override @Override
@ -211,31 +214,28 @@ public abstract class BlockContainerBase extends BlockContainer{
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack){ public void onBlockAdded(World world, int x, int y, int z){
if(stack.getTagCompound() != null){ this.updateRedstoneState(world, x, y, z);
}
public boolean tryToggleRedstone(World world, int x, int y, int z, EntityPlayer player){
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
TileEntity tile = world.getTileEntity(x, y, z); TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IRedstoneToggle){
if(!world.isRemote){
if(tile instanceof IEnergySaver){ if(((IRedstoneToggle)tile).toggle()){
((IEnergySaver)tile).setEnergy(stack.getTagCompound().getInteger("Energy")); player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Pulse Mode"));
} }
else{
if(tile instanceof IFluidSaver){ player.addChatComponentMessage(new ChatComponentText("Changed to Redstone Deactivation Mode"));
int amount = stack.getTagCompound().getInteger("FluidAmount");
if(amount > 0){
FluidStack[] fluids = new FluidStack[amount];
for(int i = 0; i < amount; i++){
NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Fluid"+i);
if(compound != null){
fluids[i] = FluidStack.loadFluidStackFromNBT(compound);
}
} }
((IFluidSaver)tile).setFluids(fluids);
} }
return true;
} }
} }
return false;
} }
} }

View file

@ -51,10 +51,6 @@ public class BlockFluidFlowing extends BlockFluidClassic{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -63,6 +59,10 @@ public class BlockFluidFlowing extends BlockFluidClassic{
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z){ public boolean canDisplace(IBlockAccess world, int x, int y, int z){
return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.canDisplace(world, x, y, z); return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.canDisplace(world, x, y, z);

View file

@ -27,7 +27,7 @@ import net.minecraftforge.common.EnumPlantType;
import java.util.Random; import java.util.Random;
public class BlockPlant extends BlockCrops { public class BlockPlant extends BlockCrops{
public Item seedItem; public Item seedItem;
public Item returnItem; public Item returnItem;
@ -56,10 +56,6 @@ public class BlockPlant extends BlockCrops {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -68,6 +64,10 @@ public class BlockPlant extends BlockCrops {
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.rare;
} }

View file

@ -23,6 +23,10 @@ public class BlockStair extends BlockStairs{
private String name; private String name;
public BlockStair(Block block, String name){
this(block, name, 0);
}
public BlockStair(Block block, String name, int meta){ public BlockStair(Block block, String name, int meta){
super(block, meta); super(block, meta);
this.name = name; this.name = name;
@ -31,10 +35,6 @@ public class BlockStair extends BlockStairs{
this.register(); this.register();
} }
public BlockStair(Block block, String name){
this(block, name, 0);
}
private void register(){ private void register(){
this.setBlockName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName()); this.setBlockName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName()); GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
@ -43,10 +43,6 @@ public class BlockStair extends BlockStairs{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -55,6 +51,10 @@ public class BlockStair extends BlockStairs{
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.common; return EnumRarity.common;
} }

View file

@ -25,12 +25,16 @@ import net.minecraft.util.IIcon;
import java.util.List; import java.util.List;
public class BlockWallAA extends BlockWall { public class BlockWallAA extends BlockWall{
private String name; private String name;
private Block baseBlock; private Block baseBlock;
private int meta; private int meta;
public BlockWallAA(String name, Block base){
this(name, base, 0);
}
public BlockWallAA(String name, Block base, int meta){ public BlockWallAA(String name, Block base, int meta){
super(base); super(base);
this.baseBlock = base; this.baseBlock = base;
@ -40,10 +44,6 @@ public class BlockWallAA extends BlockWall {
this.register(); this.register();
} }
public BlockWallAA(String name, Block base){
this(name, base, 0);
}
private void register(){ private void register(){
this.setBlockName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName()); this.setBlockName(ModUtil.MOD_ID_LOWER+"."+this.getBaseName());
GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName()); GameRegistry.registerBlock(this, this.getItemBlock(), this.getBaseName());
@ -52,10 +52,6 @@ public class BlockWallAA extends BlockWall {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
@ -64,6 +60,10 @@ public class BlockWallAA extends BlockWall {
return ItemBlockBase.class; return ItemBlockBase.class;
} }
public boolean shouldAddCreative(){
return true;
}
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.common; return EnumRarity.common;
} }

View file

@ -22,16 +22,12 @@ public class EntrySet{
public BookletEntry entry; public BookletEntry entry;
public int pageInIndex; public int pageInIndex;
public EntrySet(BookletPage page, BookletChapter chapter, BookletEntry entry, int pageInIndex){
this.setEntry(page, chapter, entry, pageInIndex);
}
public EntrySet(BookletEntry entry){ public EntrySet(BookletEntry entry){
this(null, null, entry, 1); this(null, null, entry, 1);
} }
public void removeEntry(){ public EntrySet(BookletPage page, BookletChapter chapter, BookletEntry entry, int pageInIndex){
this.setEntry(null, null, null, 1); this.setEntry(page, chapter, entry, pageInIndex);
} }
public void setEntry(BookletPage page, BookletChapter chapter, BookletEntry entry, int pageInIndex){ public void setEntry(BookletPage page, BookletChapter chapter, BookletEntry entry, int pageInIndex){
@ -41,15 +37,6 @@ public class EntrySet{
this.pageInIndex = pageInIndex; this.pageInIndex = pageInIndex;
} }
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Entry", entry == null ? -1 : InitBooklet.entries.indexOf(entry));
compound.setInteger("Chapter", entry == null || chapter == null ? -1 : entry.chapters.indexOf(chapter));
compound.setInteger("Page", page == null ? -1 : page.getID());
compound.setInteger("PageInIndex", pageInIndex);
return compound;
}
public static EntrySet readFromNBT(NBTTagCompound compound){ public static EntrySet readFromNBT(NBTTagCompound compound){
if(compound.hasKey("Entry")){ if(compound.hasKey("Entry")){
int entry = compound.getInteger("Entry"); int entry = compound.getInteger("Entry");
@ -65,4 +52,17 @@ public class EntrySet{
} }
return new EntrySet(null); return new EntrySet(null);
} }
public void removeEntry(){
this.setEntry(null, null, null, 1);
}
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Entry", entry == null ? -1 : InitBooklet.entries.indexOf(entry));
compound.setInteger("Chapter", entry == null || chapter == null ? -1 : entry.chapters.indexOf(chapter));
compound.setInteger("Page", page == null ? -1 : page.getID());
compound.setInteger("PageInIndex", pageInIndex);
return compound;
}
} }

View file

@ -50,16 +50,13 @@ public class GuiBooklet extends GuiScreen{
public static final int CHAPTER_BUTTONS_AMOUNT = 13; public static final int CHAPTER_BUTTONS_AMOUNT = 13;
public static final int INDEX_BUTTONS_OFFSET = 3; public static final int INDEX_BUTTONS_OFFSET = 3;
private static final int[] AND_HIS_NAME_IS = new int[]{Keyboard.KEY_C, Keyboard.KEY_E, Keyboard.KEY_N, Keyboard.KEY_A};
public int xSize; public int xSize;
public int ySize; public int ySize;
public int guiLeft; public int guiLeft;
public int guiTop; public int guiTop;
public EntrySet currentEntrySet = new EntrySet(null); public EntrySet currentEntrySet = new EntrySet(null);
public int indexPageAmount; public int indexPageAmount;
public GuiButton buttonForward; public GuiButton buttonForward;
public GuiButton buttonBackward; public GuiButton buttonBackward;
public GuiButton buttonPreviousScreen; public GuiButton buttonPreviousScreen;
@ -69,17 +66,13 @@ public class GuiBooklet extends GuiScreen{
public GuiButton buttonAchievements; public GuiButton buttonAchievements;
public GuiButton buttonConfig; public GuiButton buttonConfig;
public GuiButton[] chapterButtons = new GuiButton[CHAPTER_BUTTONS_AMOUNT]; public GuiButton[] chapterButtons = new GuiButton[CHAPTER_BUTTONS_AMOUNT];
public GuiButton[] bookmarkButtons = new GuiButton[8]; public GuiButton[] bookmarkButtons = new GuiButton[8];
public GuiTextField searchField; public GuiTextField searchField;
public GuiScreen parentScreen; public GuiScreen parentScreen;
private int ticksElapsed; private int ticksElapsed;
private boolean mousePressed; private boolean mousePressed;
private boolean tryOpenMainPage; private boolean tryOpenMainPage;
private boolean saveOnClose; private boolean saveOnClose;
private static final int[] AND_HIS_NAME_IS = new int[]{Keyboard.KEY_C, Keyboard.KEY_E, Keyboard.KEY_N, Keyboard.KEY_A};
private int hisNameIsAt; private int hisNameIsAt;
public GuiBooklet(GuiScreen parentScreen, boolean tryOpenMainPage, boolean saveOnClose){ public GuiBooklet(GuiScreen parentScreen, boolean tryOpenMainPage, boolean saveOnClose){
@ -153,21 +146,6 @@ public class GuiBooklet extends GuiScreen{
} }
} }
@Override
//For scrolling through pages
public void handleMouseInput(){
int wheel = Mouse.getEventDWheel();
if(wheel != 0){
if(wheel > 0){
BookletUtils.handleNextPage(this);
}
else if(wheel < 0){
BookletUtils.handlePreviousPage(this);
}
}
super.handleMouseInput();
}
@Override @Override
public void keyTyped(char theChar, int key){ public void keyTyped(char theChar, int key){
if(key == Keyboard.KEY_ESCAPE || (!this.searchField.isFocused() && key == Minecraft.getMinecraft().gameSettings.keyBindInventory.getKeyCode())){ if(key == Keyboard.KEY_ESCAPE || (!this.searchField.isFocused() && key == Minecraft.getMinecraft().gameSettings.keyBindInventory.getKeyCode())){
@ -339,6 +317,21 @@ public class GuiBooklet extends GuiScreen{
} }
} }
@Override
//For scrolling through pages
public void handleMouseInput(){
int wheel = Mouse.getEventDWheel();
if(wheel != 0){
if(wheel > 0){
BookletUtils.handleNextPage(this);
}
else if(wheel < 0){
BookletUtils.handlePreviousPage(this);
}
}
super.handleMouseInput();
}
@Override @Override
public void updateScreen(){ public void updateScreen(){
super.updateScreen(); super.updateScreen();

View file

@ -26,6 +26,10 @@ public class TexturedButton extends GuiButton{
public List textList = new ArrayList(); public List textList = new ArrayList();
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
this(id, x, y, texturePosX, texturePosY, width, height, new ArrayList());
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){ public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height, List hoverTextList){
super(id, x, y, width, height, ""); super(id, x, y, width, height, "");
@ -34,10 +38,6 @@ public class TexturedButton extends GuiButton{
this.textList.addAll(hoverTextList); this.textList.addAll(hoverTextList);
} }
public TexturedButton(int id, int x, int y, int texturePosX, int texturePosY, int width, int height){
this(id, x, y, texturePosX, texturePosY, width, height, new ArrayList());
}
public void setTexturePos(int x, int y){ public void setTexturePos(int x, int y){
this.texturePosX = x; this.texturePosX = x;
this.texturePosY = y; this.texturePosY = y;

View file

@ -39,6 +39,18 @@ public class GuiMiner extends GuiContainer{
this.ySize = 93+86; this.ySize = 93+86;
} }
@SuppressWarnings("unchecked")
@Override
public void initGui(){
super.initGui();
GuiButton buttonMode = new GuiButton(0, guiLeft+xSize/2-51, guiTop+75, 50, 20, "Mode");
this.buttonList.add(buttonMode);
GuiButton buttonReset = new GuiButton(1, guiLeft+xSize/2+1, guiTop+75, 50, 20, "Reset");
this.buttonList.add(buttonReset);
}
@Override @Override
public void drawScreen(int x, int y, float f){ public void drawScreen(int x, int y, float f){
super.drawScreen(x, y, f); super.drawScreen(x, y, f);
@ -63,18 +75,6 @@ public class GuiMiner extends GuiContainer{
this.fontRendererObj.drawString(mining, this.guiLeft+this.xSize/2-fontRendererObj.getStringWidth(mining)/2, guiTop+8, StringUtil.DECIMAL_COLOR_GRAY_TEXT); this.fontRendererObj.drawString(mining, this.guiLeft+this.xSize/2-fontRendererObj.getStringWidth(mining)/2, guiTop+8, StringUtil.DECIMAL_COLOR_GRAY_TEXT);
} }
@SuppressWarnings("unchecked")
@Override
public void initGui(){
super.initGui();
GuiButton buttonMode = new GuiButton(0, guiLeft+xSize/2-51, guiTop+75, 50, 20, "Mode");
this.buttonList.add(buttonMode);
GuiButton buttonReset = new GuiButton(1, guiLeft+xSize/2+1, guiTop+75, 50, 20, "Reset");
this.buttonList.add(buttonReset);
}
@Override @Override
public void actionPerformed(GuiButton button){ public void actionPerformed(GuiButton button){
PacketHandler.theNetwork.sendToServer(new PacketGuiButton(miner.xCoord, miner.yCoord, miner.zCoord, miner.getWorldObj(), button.id, Minecraft.getMinecraft().thePlayer)); PacketHandler.theNetwork.sendToServer(new PacketGuiButton(miner.xCoord, miner.yCoord, miner.zCoord, miner.getWorldObj(), button.id, Minecraft.getMinecraft().thePlayer));

View file

@ -52,14 +52,14 @@ public class ItemSeed extends ItemSeeds{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.rare;

View file

@ -36,7 +36,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class ItemAllToolAA extends ItemTool { public class ItemAllToolAA extends ItemTool{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon overlayIcon; private IIcon overlayIcon;
@ -68,14 +68,14 @@ public class ItemAllToolAA extends ItemTool {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@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 player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){
if(!player.canPlayerEdit(x, y, z, side, stack)){ if(!player.canPlayerEdit(x, y, z, side, stack)){

View file

@ -50,14 +50,14 @@ public class ItemArmorAA extends ItemArmor{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.rare; return EnumRarity.rare;

View file

@ -22,7 +22,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
public class ItemAxeAA extends ItemAxe { public class ItemAxeAA extends ItemAxe{
private String name; private String name;
private EnumRarity rarity; private EnumRarity rarity;
@ -48,14 +48,14 @@ public class ItemAxeAA extends ItemAxe {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
int[] idsStack = OreDictionary.getOreIDs(stack); int[] idsStack = OreDictionary.getOreIDs(stack);

View file

@ -34,11 +34,11 @@ public class ItemBase extends Item{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
} }

View file

@ -23,7 +23,7 @@ import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
public class ItemBucketAA extends ItemBucket { public class ItemBucketAA extends ItemBucket{
private String name; private String name;
@ -43,14 +43,14 @@ public class ItemBucketAA extends ItemBucket {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.uncommon; return EnumRarity.uncommon;

View file

@ -25,7 +25,7 @@ import net.minecraft.world.World;
import java.util.List; import java.util.List;
public abstract class ItemEnergy extends ItemEnergyContainer { public abstract class ItemEnergy extends ItemEnergyContainer{
private String name; private String name;
@ -46,14 +46,14 @@ public abstract class ItemEnergy extends ItemEnergyContainer {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public boolean getShareTag(){ public boolean getShareTag(){
return true; return true;

View file

@ -35,11 +35,11 @@ public class ItemFoodBase extends ItemFood{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
} }

View file

@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
public class ItemHoeAA extends ItemHoe { public class ItemHoeAA extends ItemHoe{
private String name; private String name;
private EnumRarity rarity; private EnumRarity rarity;
@ -49,14 +49,14 @@ public class ItemHoeAA extends ItemHoe {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return this.rarity; return this.rarity;

View file

@ -48,14 +48,14 @@ public class ItemPickaxeAA extends ItemPickaxe{
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
int[] idsStack = OreDictionary.getOreIDs(stack); int[] idsStack = OreDictionary.getOreIDs(stack);

View file

@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
public class ItemShovelAA extends ItemSpade { public class ItemShovelAA extends ItemSpade{
private String name; private String name;
private EnumRarity rarity; private EnumRarity rarity;
@ -49,14 +49,14 @@ public class ItemShovelAA extends ItemSpade {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
@Override @Override
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
int[] idsStack = OreDictionary.getOreIDs(stack); int[] idsStack = OreDictionary.getOreIDs(stack);

View file

@ -23,7 +23,7 @@ import net.minecraft.item.ItemSword;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
public class ItemSwordAA extends ItemSword { public class ItemSwordAA extends ItemSword{
private String name; private String name;
private EnumRarity rarity; private EnumRarity rarity;
@ -49,14 +49,14 @@ public class ItemSwordAA extends ItemSword {
} }
} }
public boolean shouldAddCreative(){
return true;
}
protected String getBaseName(){ protected String getBaseName(){
return this.name; return this.name;
} }
public boolean shouldAddCreative(){
return true;
}
protected Class<? extends ItemBlockBase> getItemBlock(){ protected Class<? extends ItemBlockBase> getItemBlock(){
return ItemBlockBase.class; return ItemBlockBase.class;
} }

View file

@ -24,6 +24,17 @@ import java.util.ArrayList;
public class LensColor extends Lens{ public class LensColor extends Lens{
public static final int ENERGY_USE = 200;
public static final Object[] CONVERTABLE_BLOCKS = new Object[]{
Items.dye,
Blocks.wool,
Blocks.stained_glass,
Blocks.stained_glass_pane,
Blocks.stained_hardened_clay,
Blocks.carpet,
InitBlocks.blockColoredLamp,
InitBlocks.blockColoredLampOn
};
//Thanks to xdjackiexd for this, as I couldn't be bothered //Thanks to xdjackiexd for this, as I couldn't be bothered
private static final float[][] possibleColorLensColors = { private static final float[][] possibleColorLensColors = {
{158F, 43F, 39F}, //Red {158F, 43F, 39F}, //Red
@ -40,19 +51,6 @@ public class LensColor extends Lens{
{86F, 51F, 28F}, //Brown {86F, 51F, 28F}, //Brown
}; };
public static final int ENERGY_USE = 200;
public static final Object[] CONVERTABLE_BLOCKS = new Object[]{
Items.dye,
Blocks.wool,
Blocks.stained_glass,
Blocks.stained_glass_pane,
Blocks.stained_hardened_clay,
Blocks.carpet,
InitBlocks.blockColoredLamp,
InitBlocks.blockColoredLampOn
};
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile){ public boolean invoke(WorldPos hitBlock, TileEntityAtomicReconstructor tile){

View file

@ -122,10 +122,9 @@ public class LensNoneRecipeHandler{
public static class Recipe{ public static class Recipe{
public int energyUse;
private String input; private String input;
private String output; private String output;
public int energyUse;
private ItemStack inputStack; private ItemStack inputStack;
private ItemStack outputStack; private ItemStack outputStack;

View file

@ -50,6 +50,25 @@ public class PacketParticle implements IMessage{
this.particleSize = particleSize; this.particleSize = particleSize;
} }
@SideOnly(Side.CLIENT)
public static void renderParticlesFromAToB(int startX, int startY, int startZ, int endX, int endY, int endZ, int particleAmount, float particleSize, float[] color, float ageMultiplier){
World world = Minecraft.getMinecraft().theWorld;
if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64 || Minecraft.getMinecraft().thePlayer.getDistance(endX, endY, endZ) <= 64){
int difX = startX-endX;
int difY = startY-endY;
int difZ = startZ-endZ;
double distance = Vec3.createVectorHelper(startX, startY, startZ).distanceTo(Vec3.createVectorHelper(endX, endY, endZ));
for(int times = 0; times < particleAmount/2; times++){
for(double i = 0; i <= 1; i += 1/(distance*particleAmount)){
EntityColoredParticleFX fx = new EntityColoredParticleFX(world, (difX*i)+endX+0.5, (difY*i)+endY+0.5, (difZ*i)+endZ+0.5, particleSize, color[0], color[1], color[2], ageMultiplier);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
}
}
}
@Override @Override
public void fromBytes(ByteBuf buf){ public void fromBytes(ByteBuf buf){
this.startX = buf.readInt(); this.startX = buf.readInt();
@ -92,23 +111,4 @@ public class PacketParticle implements IMessage{
return null; return null;
} }
} }
@SideOnly(Side.CLIENT)
public static void renderParticlesFromAToB(int startX, int startY, int startZ, int endX, int endY, int endZ, int particleAmount, float particleSize, float[] color, float ageMultiplier){
World world = Minecraft.getMinecraft().theWorld;
if(Minecraft.getMinecraft().thePlayer.getDistance(startX, startY, startZ) <= 64 || Minecraft.getMinecraft().thePlayer.getDistance(endX, endY, endZ) <= 64){
int difX = startX-endX;
int difY = startY-endY;
int difZ = startZ-endZ;
double distance = Vec3.createVectorHelper(startX, startY, startZ).distanceTo(Vec3.createVectorHelper(endX, endY, endZ));
for(int times = 0; times < particleAmount/2; times++){
for(double i = 0; i <= 1; i += 1/(distance*particleAmount)){
EntityColoredParticleFX fx = new EntityColoredParticleFX(world, (difX*i)+endX+0.5, (difY*i)+endY+0.5, (difZ*i)+endZ+0.5, particleSize, color[0], color[1], color[2], ageMultiplier);
Minecraft.getMinecraft().effectRenderer.addEffect(fx);
}
}
}
}
} }

View file

@ -26,12 +26,6 @@ public class CrusherRecipeRegistry{
public static ArrayList<CrusherRecipe> recipes = new ArrayList<CrusherRecipe>(); public static ArrayList<CrusherRecipe> recipes = new ArrayList<CrusherRecipe>();
public static ArrayList<SearchCase> searchCases = new ArrayList<SearchCase>(); public static ArrayList<SearchCase> searchCases = new ArrayList<SearchCase>();
public static void addRecipe(String input, String outputOne, int outputOneAmount, String outputTwo, int outputTwoAmount, int outputTwoChance){
if(!OreDictionary.getOres(input, false).isEmpty() && !OreDictionary.getOres(outputOne, false).isEmpty() && (outputTwo == null || outputTwo.isEmpty() || !OreDictionary.getOres(outputTwo, false).isEmpty())){
recipes.add(new CrusherRecipe(input, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance));
}
}
public static void registerFinally(){ public static void registerFinally(){
ArrayList<String> oresNoResult = new ArrayList<String>(); ArrayList<String> oresNoResult = new ArrayList<String>();
int recipeStartedAt = recipes.size(); int recipeStartedAt = recipes.size();
@ -86,22 +80,28 @@ public class CrusherRecipeRegistry{
return false; return false;
} }
public static void addRecipe(ItemStack input, ItemStack outputOne){ public static void addRecipe(String input, String outputOne, int outputOneAmount){
addRecipe(input, outputOne, null, 0); addRecipe(input, outputOne, outputOneAmount, "", 0, 0);
} }
public static void addRecipe(ItemStack input, String outputOne, int outputOneAmount){ public static void addRecipe(String input, String outputOne, int outputOneAmount, String outputTwo, int outputTwoAmount, int outputTwoChance){
if(!OreDictionary.getOres(outputOne, false).isEmpty()){ if(!OreDictionary.getOres(input, false).isEmpty() && !OreDictionary.getOres(outputOne, false).isEmpty() && (outputTwo == null || outputTwo.isEmpty() || !OreDictionary.getOres(outputTwo, false).isEmpty())){
recipes.add(new CrusherRecipe(input, outputOne, outputOneAmount)); recipes.add(new CrusherRecipe(input, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance));
} }
} }
public static void addRecipe(ItemStack input, ItemStack outputOne){
addRecipe(input, outputOne, null, 0);
}
public static void addRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){ public static void addRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
recipes.add(new CrusherRecipe(input, outputOne, outputTwo, outputTwoChance)); recipes.add(new CrusherRecipe(input, outputOne, outputTwo, outputTwoChance));
} }
public static void addRecipe(String input, String outputOne, int outputOneAmount){ public static void addRecipe(ItemStack input, String outputOne, int outputOneAmount){
addRecipe(input, outputOne, outputOneAmount, "", 0, 0); if(!OreDictionary.getOres(outputOne, false).isEmpty()){
recipes.add(new CrusherRecipe(input, outputOne, outputOneAmount));
}
} }
public static List<ItemStack> getOutputOnes(ItemStack input){ public static List<ItemStack> getOutputOnes(ItemStack input){
@ -130,15 +130,12 @@ public class CrusherRecipeRegistry{
public static class CrusherRecipe{ public static class CrusherRecipe{
public int outputTwoChance;
private String input; private String input;
private String outputOne; private String outputOne;
private int outputOneAmount; private int outputOneAmount;
private String outputTwo; private String outputTwo;
private int outputTwoAmount; private int outputTwoAmount;
public int outputTwoChance;
private ItemStack inputStack; private ItemStack inputStack;
private ItemStack outputOneStack; private ItemStack outputOneStack;
private ItemStack outputTwoStack; private ItemStack outputTwoStack;

View file

@ -30,6 +30,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
public static final int ENERGY_USE = 1000; public static final int ENERGY_USE = 1000;
public EnergyStorage storage = new EnergyStorage(3000000); public EnergyStorage storage = new EnergyStorage(3000000);
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal;
public TileEntityAtomicReconstructor(){ public TileEntityAtomicReconstructor(){
super(1, "reconstructor"); super(1, "reconstructor");
@ -111,11 +112,6 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
this.storage.readFromNBT(compound); this.storage.readFromNBT(compound);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return stack != null && stack.getItem() instanceof ItemLens;
}
@Override @Override
public void setInventorySlotContents(int i, ItemStack stack){ public void setInventorySlotContents(int i, ItemStack stack){
super.setInventorySlotContents(i, stack); super.setInventorySlotContents(i, stack);
@ -153,6 +149,11 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return stack != null && stack.getItem() instanceof ItemLens;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return true; return true;
@ -168,8 +169,6 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);
} }
private boolean activateOnceWithSignal;
@Override @Override
public boolean toggle(){ public boolean toggle(){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; return this.activateOnceWithSignal = !this.activateOnceWithSignal;

View file

@ -93,10 +93,6 @@ public abstract class TileEntityBase extends TileEntity{
this.ticksElapsed++; this.ticksElapsed++;
} }
public void setRedstonePowered(boolean powered){
this.isRedstonePowered = powered;
}
@Override @Override
public Packet getDescriptionPacket(){ public Packet getDescriptionPacket(){
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
@ -122,6 +118,10 @@ public abstract class TileEntityBase extends TileEntity{
} }
public void setRedstonePowered(boolean powered){
this.isRedstonePowered = powered;
}
protected boolean sendUpdateWithInterval(){ protected boolean sendUpdateWithInterval(){
if(this.ticksElapsed%ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){ if(this.ticksElapsed%ConfigIntValues.TILE_ENTITY_UPDATE_INTERVAL.getValue() == 0){
this.sendUpdate(); this.sendUpdate();

View file

@ -24,6 +24,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
public boolean isPlacer; public boolean isPlacer;
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal;
public TileEntityBreaker(int slots, String name){ public TileEntityBreaker(int slots, String name){
super(slots, name); super(slots, name);
@ -34,18 +35,6 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
this.isPlacer = false; this.isPlacer = false;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("CurrentTime", this.currentTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTime = compound.getInteger("CurrentTime");
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -65,6 +54,18 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("CurrentTime", this.currentTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTime = compound.getInteger("CurrentTime");
}
private void doWork(){ private void doWork(){
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
@ -94,13 +95,13 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return this.isPlacer; return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return this.isPlacer;
} }
@Override @Override
@ -108,21 +109,19 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
return true; return true;
} }
private boolean activateOnceWithSignal;
@Override @Override
public boolean toggle(){ public boolean toggle(){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; return this.activateOnceWithSignal = !this.activateOnceWithSignal;
} }
@Override @Override
public void activateOnPulse(){ public boolean isRightMode(){
this.doWork(); return this.activateOnceWithSignal;
} }
@Override @Override
public boolean isRightMode(){ public void activateOnPulse(){
return this.activateOnceWithSignal; this.doWork();
} }
public static class TileEntityPlacer extends TileEntityBreaker{ public static class TileEntityPlacer extends TileEntityBreaker{

View file

@ -55,22 +55,6 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("ProcessTime", this.currentProcessTime);
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentProcessTime = compound.getInteger("ProcessTime");
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -117,18 +101,34 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("ProcessTime", this.currentProcessTime);
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentProcessTime = compound.getInteger("ProcessTime");
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
public boolean isCanola(int slot){ public boolean isCanola(int slot){
return this.slots[slot] != null && this.slots[slot].getItem() == InitItems.itemMisc && this.slots[slot].getItemDamage() == TheMiscItems.CANOLA.ordinal(); return this.slots[slot] != null && this.slots[slot].getItem() == InitItems.itemMisc && this.slots[slot].getItemDamage() == TheMiscItems.CANOLA.ordinal();
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal()) || (i == 1 && stack.getItem() == Items.bucket); return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal()) || (i == 1 && stack.getItem() == Items.bucket);
} }
@Override @Override

View file

@ -44,22 +44,6 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
return this.currentBurnTime*i/this.maxBurnTime; return this.currentBurnTime*i/this.maxBurnTime;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("BurnTime", this.currentBurnTime);
compound.setInteger("MaxBurnTime", this.maxBurnTime);
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentBurnTime = compound.getInteger("BurnTime");
this.maxBurnTime = compound.getInteger("MaxBurnTime");
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -114,8 +98,19 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return TileEntityFurnace.getItemBurnTime(stack) > 0; compound.setInteger("BurnTime", this.currentBurnTime);
compound.setInteger("MaxBurnTime", this.maxBurnTime);
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentBurnTime = compound.getInteger("BurnTime");
this.maxBurnTime = compound.getInteger("MaxBurnTime");
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
} }
@Override @Override
@ -123,6 +118,11 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return TileEntityFurnace.getItemBurnTime(stack) > 0;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return false; return false;

View file

@ -71,24 +71,6 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
return this.brewTime*i/TIME_USED; return this.brewTime*i/TIME_USED;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
compound.setInteger("Cache", this.coffeeCacheAmount);
compound.setInteger("Time", this.brewTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
this.coffeeCacheAmount = compound.getInteger("Cache");
this.brewTime = compound.getInteger("Time");
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -108,6 +90,24 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
compound.setInteger("Cache", this.coffeeCacheAmount);
compound.setInteger("Time", this.brewTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
this.coffeeCacheAmount = compound.getInteger("Cache");
this.brewTime = compound.getInteger("Time");
}
public void storeCoffee(){ public void storeCoffee(){
if(this.slots[SLOT_COFFEE_BEANS] != null && this.slots[SLOT_COFFEE_BEANS].getItem() == InitItems.itemCoffeeBean){ if(this.slots[SLOT_COFFEE_BEANS] != null && this.slots[SLOT_COFFEE_BEANS].getItem() == InitItems.itemCoffeeBean){
int toAdd = 2; int toAdd = 2;
@ -127,7 +127,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
if(!worldObj.isRemote){ if(!worldObj.isRemote){
if(this.slots[SLOT_INPUT] != null && this.slots[SLOT_INPUT].getItem() == InitItems.itemMisc && this.slots[SLOT_INPUT].getItemDamage() == TheMiscItems.CUP.ordinal() && this.slots[SLOT_OUTPUT] == null && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= WATER_USE){ if(this.slots[SLOT_INPUT] != null && this.slots[SLOT_INPUT].getItem() == InitItems.itemMisc && this.slots[SLOT_INPUT].getItemDamage() == TheMiscItems.CUP.ordinal() && this.slots[SLOT_OUTPUT] == null && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= WATER_USE){
if(this.storage.getEnergyStored() >= ENERGY_USED){ if(this.storage.getEnergyStored() >= ENERGY_USED){
if(this.brewTime % 30 == 0){ if(this.brewTime%30 == 0){
this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, ModUtil.MOD_ID_LOWER+":coffeeMachine", 0.35F, 1.0F); this.worldObj.playSoundEffect(xCoord, yCoord, zCoord, ModUtil.MOD_ID_LOWER+":coffeeMachine", 0.35F, 1.0F);
} }
@ -166,13 +166,13 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal()) || (i == SLOT_WATER_INPUT && FluidContainerRegistry.containsFluid(stack, new FluidStack(FluidRegistry.WATER, 1))); return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal()) || (i == SLOT_WATER_INPUT && FluidContainerRegistry.containsFluid(stack, new FluidStack(FluidRegistry.WATER, 1)));
} }
@Override @Override

View file

@ -26,18 +26,6 @@ public class TileEntityCompost extends TileEntityInventoryBase{
super(1, "compost"); super(1, "compost");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
compound.setInteger("ConversionTime", this.conversionTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.conversionTime = compound.getInteger("ConversionTime");
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -70,13 +58,20 @@ public class TileEntityCompost extends TileEntityInventoryBase{
} }
@Override @Override
public int getInventoryStackLimit(){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return AMOUNT; super.readSyncableNBT(compound, sync);
compound.setInteger("ConversionTime", this.conversionTime);
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
return stack.getItem() instanceof ItemMisc && stack.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal(); super.readSyncableNBT(compound, sync);
this.conversionTime = compound.getInteger("ConversionTime");
}
@Override
public int getInventoryStackLimit(){
return AMOUNT;
} }
@Override @Override
@ -84,6 +79,11 @@ public class TileEntityCompost extends TileEntityInventoryBase{
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return stack.getItem() instanceof ItemMisc && stack.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal();
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return stack.getItem() instanceof ItemFertilizer; return stack.getItem() instanceof ItemFertilizer;

View file

@ -31,6 +31,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
public EnergyStorage storage = new EnergyStorage(10000); public EnergyStorage storage = new EnergyStorage(10000);
private int lastEnergy; private int lastEnergy;
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal;
public TileEntityDirectionalBreaker(){ public TileEntityDirectionalBreaker(){
super(9, "directionalBreaker"); super(9, "directionalBreaker");
@ -99,11 +100,6 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
this.currentTime = compound.getInteger("CurrentTime"); this.currentTime = compound.getInteger("CurrentTime");
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return false;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){ public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
@ -114,6 +110,11 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return false;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return true; return true;
@ -149,8 +150,6 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);
} }
private boolean activateOnceWithSignal;
@Override @Override
public boolean toggle(){ public boolean toggle(){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; return this.activateOnceWithSignal = !this.activateOnceWithSignal;

View file

@ -18,23 +18,12 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityDropper extends TileEntityInventoryBase implements IRedstoneToggle{ public class TileEntityDropper extends TileEntityInventoryBase implements IRedstoneToggle{
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal;
public TileEntityDropper(){ public TileEntityDropper(){
super(9, "dropper"); super(9, "dropper");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("CurrentTime", this.currentTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTime = compound.getInteger("CurrentTime");
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -54,6 +43,18 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("CurrentTime", this.currentTime);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTime = compound.getInteger("CurrentTime");
}
private void doWork(){ private void doWork(){
if(this.removeFromInventory(false) != null){ if(this.removeFromInventory(false) != null){
ItemStack stack = this.removeFromInventory(true); ItemStack stack = this.removeFromInventory(true);
@ -79,13 +80,13 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return true; return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return true;
} }
@Override @Override
@ -93,8 +94,6 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst
return true; return true;
} }
private boolean activateOnceWithSignal;
@Override @Override
public boolean toggle(){ public boolean toggle(){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; return this.activateOnceWithSignal = !this.activateOnceWithSignal;

View file

@ -28,18 +28,6 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
super(2, "energizer"); super(2, "energizer");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -66,8 +54,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return i == 0 && stack.getItem() instanceof IEnergyContainerItem; this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
} }
@Override @Override
@ -75,6 +70,11 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return i == 0 && stack.getItem() instanceof IEnergyContainerItem;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == 1; return slot == 1;

View file

@ -29,18 +29,6 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
super(2, "enervator"); super(2, "enervator");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -76,8 +64,15 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return i == 0 && stack.getItem() instanceof IEnergyContainerItem; this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
} }
@Override @Override
@ -110,6 +105,11 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return i == 0 && stack.getItem() instanceof IEnergyContainerItem;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == 1; return slot == 1;

View file

@ -38,24 +38,6 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
return this.currentTimer*i/TIME; return this.currentTimer*i/TIME;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("Timer", this.currentTimer);
if(sync){
compound.setInteger("Animals", this.currentAnimalAmount);
}
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTimer = compound.getInteger("Timer");
if(sync){
this.currentAnimalAmount = compound.getInteger("Animals");
}
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -107,6 +89,24 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("Timer", this.currentTimer);
if(sync){
compound.setInteger("Animals", this.currentAnimalAmount);
}
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.currentTimer = compound.getInteger("Timer");
if(sync){
this.currentAnimalAmount = compound.getInteger("Animals");
}
}
public void feedAnimal(EntityAnimal animal){ public void feedAnimal(EntityAnimal animal){
animal.func_146082_f(null); animal.func_146082_f(null);
for(int i = 0; i < 7; i++){ for(int i = 0; i < 7; i++){
@ -118,13 +118,13 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return true; return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return true;
} }
@Override @Override

View file

@ -93,11 +93,6 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
super.readSyncableNBT(compound, sync); super.readSyncableNBT(compound, sync);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == 0 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))) || (i == 2 && stack.getItem() == Items.bucket);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getProcessScaled(int i){ public int getProcessScaled(int i){
return this.currentProcessTime*i/PROCESS_TIME; return this.currentProcessTime*i/PROCESS_TIME;
@ -118,6 +113,11 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == 0 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))) || (i == 2 && stack.getItem() == Items.bucket);
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int 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)));

View file

@ -24,11 +24,10 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IRedstoneToggle{ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IRedstoneToggle{
public EnergyStorage storage = new EnergyStorage(20000);
private int timeUntilNextFirework;
public static final int USE_PER_SHOT = 300; public static final int USE_PER_SHOT = 300;
public EnergyStorage storage = new EnergyStorage(20000);
private int timeUntilNextFirework;
private boolean activateOnceWithSignal;
@Override @Override
public void updateEntity(){ public void updateEntity(){
@ -125,8 +124,6 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
return true; return true;
} }
private boolean activateOnceWithSignal;
@Override @Override
public boolean toggle(){ public boolean toggle(){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; return this.activateOnceWithSignal = !this.activateOnceWithSignal;

View file

@ -27,12 +27,16 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
public boolean isPlacer; public boolean isPlacer;
private int lastTankAmount; private int lastTankAmount;
private int currentTime; private int currentTime;
private boolean activateOnceWithSignal;
public TileEntityFluidCollector(int slots, String name){ public TileEntityFluidCollector(int slots, String name){
super(slots, name); super(slots, name);
} }
private boolean activateOnceWithSignal; public TileEntityFluidCollector(){
super(2, "fluidCollector");
this.isPlacer = false;
}
@Override @Override
public boolean toggle(){ public boolean toggle(){
@ -49,50 +53,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
this.doWork(); this.doWork();
} }
public TileEntityFluidCollector(){
super(2, "fluidCollector");
this.isPlacer = false;
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
if(this.isPlacer){
return this.tank.fill(resource, doFill);
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
if(!this.isPlacer){
return this.tank.drain(resource.amount, doDrain);
}
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
if(!this.isPlacer){
return this.tank.drain(maxDrain, doDrain);
}
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid){
return this.isPlacer;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid){
return !this.isPlacer;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.tank.getInfo()};
}
private void doWork(){ private void doWork(){
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
@ -133,6 +93,45 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
} }
} }
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill){
if(this.isPlacer){
return this.tank.fill(resource, doFill);
}
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){
if(!this.isPlacer){
return this.tank.drain(resource.amount, doDrain);
}
return null;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){
if(!this.isPlacer){
return this.tank.drain(maxDrain, doDrain);
}
return null;
}
@Override
public boolean canFill(ForgeDirection from, Fluid fluid){
return this.isPlacer;
}
@Override
public boolean canDrain(ForgeDirection from, Fluid fluid){
return !this.isPlacer;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from){
return new FluidTankInfo[]{this.tank.getInfo()};
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -187,6 +186,16 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
this.tank.readFromNBT(compound); this.tank.readFromNBT(compound);
} }
@SideOnly(Side.CLIENT)
public int getTankScaled(int i){
return this.tank.getFluidAmount()*i/this.tank.getCapacity();
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side){
return this.isItemValidForSlot(slot, stack);
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
if(i == 0){ if(i == 0){
@ -200,16 +209,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
return false; return false;
} }
@SideOnly(Side.CLIENT)
public int getTankScaled(int i){
return this.tank.getFluidAmount()*i/this.tank.getCapacity();
}
@Override
public boolean canInsertItem(int slot, ItemStack stack, int side){
return this.isItemValidForSlot(slot, stack);
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == 1; return slot == 1;

View file

@ -38,22 +38,6 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
super(4, "furnaceDouble"); super(4, "furnaceDouble");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("FirstSmeltTime", this.firstSmeltTime);
compound.setInteger("SecondSmeltTime", this.secondSmeltTime);
this.storage.writeToNBT(compound);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.firstSmeltTime = compound.getInteger("FirstSmeltTime");
this.secondSmeltTime = compound.getInteger("SecondSmeltTime");
this.storage.readFromNBT(compound);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -115,6 +99,22 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("FirstSmeltTime", this.firstSmeltTime);
compound.setInteger("SecondSmeltTime", this.secondSmeltTime);
this.storage.writeToNBT(compound);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.firstSmeltTime = compound.getInteger("FirstSmeltTime");
this.secondSmeltTime = compound.getInteger("SecondSmeltTime");
this.storage.readFromNBT(compound);
}
public boolean canSmeltOn(int theInput, int theOutput){ public boolean canSmeltOn(int theInput, int theOutput){
if(this.slots[theInput] != null){ if(this.slots[theInput] != null){
ItemStack output = FurnaceRecipes.smelting().getSmeltingResult(this.slots[theInput]); ItemStack output = FurnaceRecipes.smelting().getSmeltingResult(this.slots[theInput]);
@ -144,11 +144,6 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
} }
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && FurnaceRecipes.smelting().getSmeltingResult(stack) != null;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){ public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
@ -169,6 +164,11 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && FurnaceRecipes.smelting().getSmeltingResult(stack) != null;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2; return slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2;

View file

@ -69,22 +69,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
return true; return true;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("FirstCrushTime", this.firstCrushTime);
compound.setInteger("SecondCrushTime", this.secondCrushTime);
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.firstCrushTime = compound.getInteger("FirstCrushTime");
this.secondCrushTime = compound.getInteger("SecondCrushTime");
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -163,6 +147,22 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("FirstCrushTime", this.firstCrushTime);
compound.setInteger("SecondCrushTime", this.secondCrushTime);
this.storage.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.firstCrushTime = compound.getInteger("FirstCrushTime");
this.secondCrushTime = compound.getInteger("SecondCrushTime");
this.storage.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput){ public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput){
if(this.slots[theInput] != null){ if(this.slots[theInput] != null){
List<ItemStack> outputOnes = CrusherRecipeRegistry.getOutputOnes(this.slots[theInput]); List<ItemStack> outputOnes = CrusherRecipeRegistry.getOutputOnes(this.slots[theInput]);
@ -236,11 +236,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
} }
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && CrusherRecipeRegistry.getRecipeFromInput(stack) != null;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){ public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored(); return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
@ -261,6 +256,11 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && CrusherRecipeRegistry.getRecipeFromInput(stack) != null;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2; return slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2;

View file

@ -368,32 +368,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
this.markDirty(); this.markDirty();
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setInteger("SideToPut", this.sideToPut);
compound.setInteger("SlotToPut", this.slotToPutStart);
compound.setInteger("SlotToPutEnd", this.slotToPutEnd);
compound.setInteger("SideToPull", this.sideToPull);
compound.setInteger("SlotToPull", this.slotToPullStart);
compound.setInteger("SlotToPullEnd", this.slotToPullEnd);
compound.setBoolean("PullWhitelist", this.isPullWhitelist);
compound.setBoolean("PutWhitelist", this.isPutWhitelist);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.sideToPut = compound.getInteger("SideToPut");
this.slotToPutStart = compound.getInteger("SlotToPut");
this.slotToPutEnd = compound.getInteger("SlotToPutEnd");
this.sideToPull = compound.getInteger("SideToPull");
this.slotToPullStart = compound.getInteger("SlotToPull");
this.slotToPullEnd = compound.getInteger("SlotToPullEnd");
this.isPullWhitelist = compound.getBoolean("PullWhitelist");
this.isPutWhitelist = compound.getBoolean("PutWhitelist");
super.readSyncableNBT(compound, sync);
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -427,8 +401,29 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return i == 0; super.writeSyncableNBT(compound, sync);
compound.setInteger("SideToPut", this.sideToPut);
compound.setInteger("SlotToPut", this.slotToPutStart);
compound.setInteger("SlotToPutEnd", this.slotToPutEnd);
compound.setInteger("SideToPull", this.sideToPull);
compound.setInteger("SlotToPull", this.slotToPullStart);
compound.setInteger("SlotToPullEnd", this.slotToPullEnd);
compound.setBoolean("PullWhitelist", this.isPullWhitelist);
compound.setBoolean("PutWhitelist", this.isPutWhitelist);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.sideToPut = compound.getInteger("SideToPut");
this.slotToPutStart = compound.getInteger("SlotToPut");
this.slotToPutEnd = compound.getInteger("SlotToPutEnd");
this.sideToPull = compound.getInteger("SideToPull");
this.slotToPullStart = compound.getInteger("SlotToPull");
this.slotToPullEnd = compound.getInteger("SlotToPullEnd");
this.isPullWhitelist = compound.getBoolean("PullWhitelist");
this.isPutWhitelist = compound.getBoolean("PutWhitelist");
super.readSyncableNBT(compound, sync);
} }
@Override @Override
@ -436,6 +431,11 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return i == 0;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == 0; return slot == 0;

View file

@ -31,20 +31,6 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
super(2, "repairer"); super(2, "repairer");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("NextRepairTick", this.nextRepairTick);
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.nextRepairTick = compound.getInteger("NextRepairTick");
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -77,13 +63,22 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
} }
} }
public static boolean canBeRepaired(ItemStack stack){ @Override
return stack != null && stack.getItem().isRepairable(); public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("NextRepairTick", this.nextRepairTick);
super.writeSyncableNBT(compound, sync);
this.storage.writeToNBT(compound);
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void readSyncableNBT(NBTTagCompound compound, boolean sync){
return i == SLOT_INPUT; this.nextRepairTick = compound.getInteger("NextRepairTick");
super.readSyncableNBT(compound, sync);
this.storage.readFromNBT(compound);
}
public static boolean canBeRepaired(ItemStack stack){
return stack != null && stack.getItem().isRepairable();
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -104,6 +99,11 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return i == SLOT_INPUT;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == SLOT_OUTPUT; return slot == SLOT_OUTPUT;

View file

@ -30,9 +30,8 @@ import java.util.ArrayList;
public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergySaver{ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergySaver{
public EnergyStorage storage = new EnergyStorage(1000000);
public static final int ENERGY_USE_PER_BLOCK = 500; public static final int ENERGY_USE_PER_BLOCK = 500;
public EnergyStorage storage = new EnergyStorage(1000000);
public int layerAt = -1; public int layerAt = -1;
public boolean onlyMineOres; public boolean onlyMineOres;

View file

@ -51,22 +51,6 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
return this.currentBurnTime*i/BURN_TIME; return this.currentBurnTime*i/BURN_TIME;
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
compound.setInteger("BurnTime", this.currentBurnTime);
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentBurnTime = compound.getInteger("BurnTime");
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void updateEntity(){ public void updateEntity(){
@ -120,8 +104,19 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)) && i == 0; compound.setInteger("BurnTime", this.currentBurnTime);
this.storage.writeToNBT(compound);
this.tank.writeToNBT(compound);
super.writeSyncableNBT(compound, sync);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
this.currentBurnTime = compound.getInteger("BurnTime");
this.storage.readFromNBT(compound);
this.tank.readFromNBT(compound);
super.readSyncableNBT(compound, sync);
} }
@Override @Override
@ -129,6 +124,11 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)) && i == 0;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return slot == 1; return slot == 1;

View file

@ -45,11 +45,6 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
return this.isBoundThingInRange() ? this.getInventory().getInventoryStackLimit() : 0; return this.isBoundThingInRange() ? this.getInventory().getInventoryStackLimit() : 0;
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isBoundThingInRange() && this.getInventory().isItemValidForSlot(i, stack);
}
@Override @Override
public ItemStack getStackInSlotOnClosing(int i){ public ItemStack getStackInSlotOnClosing(int i){
return this.isBoundThingInRange() ? this.getInventory().getStackInSlotOnClosing(i) : null; return this.isBoundThingInRange() ? this.getInventory().getStackInSlotOnClosing(i) : null;
@ -112,4 +107,9 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
return this.isBoundThingInRange() && (this.getSided() == null || this.getSided().canExtractItem(slot, stack, side)); return this.isBoundThingInRange() && (this.getSided() == null || this.getSided().canExtractItem(slot, stack, side));
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isBoundThingInRange() && this.getInventory().isItemValidForSlot(i, stack);
}
} }

View file

@ -32,6 +32,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
public int currentTime; public int currentTime;
public int range; public int range;
public boolean isBreaker; public boolean isBreaker;
private boolean activateOnceWithSignal;
public TileEntityPhantomPlacer(int slots, String name){ public TileEntityPhantomPlacer(int slots, String name){
super(slots, name); super(slots, name);
@ -42,33 +43,6 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
this.isBreaker = false; this.isBreaker = false;
} }
private void doWork(){
if(this.isBreaker){
Block blockToBreak = boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
if(blockToBreak != null && blockToBreak.getBlockHardness(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) > -1.0F){
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
int meta = boundPosition.getWorld().getBlockMetadata(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
drops.addAll(blockToBreak.getDrops(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0));
if(WorldUtil.addToInventory(this, drops, false)){
boundPosition.getWorld().playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
WorldUtil.addToInventory(this, drops, true);
this.markDirty();
}
}
}
else{
if(boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()).isReplaceable(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ())){
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), this.slots[theSlot]));
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
this.slots[theSlot] = null;
}
}
}
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -100,6 +74,45 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
} }
@Override
public boolean hasBoundPosition(){
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){
this.boundPosition = null;
return false;
}
return this.boundPosition.getWorld() == this.worldObj;
}
return false;
}
private void doWork(){
if(this.isBreaker){
Block blockToBreak = boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
if(blockToBreak != null && blockToBreak.getBlockHardness(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) > -1.0F){
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
int meta = boundPosition.getWorld().getBlockMetadata(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
drops.addAll(blockToBreak.getDrops(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), meta, 0));
if(WorldUtil.addToInventory(this, drops, false)){
boundPosition.getWorld().playAuxSFX(2001, boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ());
WorldUtil.addToInventory(this, drops, true);
this.markDirty();
}
}
}
else{
if(boundPosition.getWorld().getBlock(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()).isReplaceable(boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ())){
int theSlot = WorldUtil.findFirstFilledSlot(this.slots);
this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundPosition.getWorld(), boundPosition.getX(), boundPosition.getY(), boundPosition.getZ(), this.slots[theSlot]));
if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0){
this.slots[theSlot] = null;
}
}
}
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderParticles(){ public void renderParticles(){
if(Util.RANDOM.nextInt(2) == 0){ if(Util.RANDOM.nextInt(2) == 0){
@ -119,18 +132,6 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
} }
@Override
public boolean hasBoundPosition(){
if(this.boundPosition != null && this.boundPosition.getWorld() != null){
if(this.boundPosition.getWorld().getTileEntity(boundPosition.getX(), boundPosition.getY(), boundPosition.getZ()) instanceof IPhantomTile || (this.xCoord == this.boundPosition.getX() && this.yCoord == this.boundPosition.getY() && this.zCoord == this.boundPosition.getZ() && this.worldObj == this.boundPosition.getWorld())){
this.boundPosition = null;
return false;
}
return this.boundPosition.getWorld() == this.worldObj;
}
return false;
}
@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(Vec3.createVectorHelper(xCoord, yCoord, zCoord)) <= this.range;
@ -181,13 +182,13 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return !this.isBreaker; return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return !this.isBreaker;
} }
@Override @Override
@ -195,8 +196,6 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
return this.isBreaker; return this.isBreaker;
} }
private boolean activateOnceWithSignal;
@Override @Override
public boolean toggle(){ public boolean toggle(){
return this.activateOnceWithSignal = !this.activateOnceWithSignal; return this.activateOnceWithSignal = !this.activateOnceWithSignal;

View file

@ -26,6 +26,7 @@ import net.minecraft.world.World;
public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{ public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{
public static final int RANGE = 16; public static final int RANGE = 16;
public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F};
public WorldPos boundPosition; public WorldPos boundPosition;
public BlockPhantom.Type type; public BlockPhantom.Type type;
public int range; public int range;
@ -33,36 +34,10 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
private WorldPos boundPosBefore; private WorldPos boundPosBefore;
private Block boundBlockBefore; private Block boundBlockBefore;
public static final float[] COLORS = new float[]{93F/255F, 43F/255F, 181F/255F};
public TileEntityPhantomface(String name){ public TileEntityPhantomface(String name){
super(0, name); super(0, name);
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
if(this.boundPosition != null){
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
}
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
int x = compound.getInteger("XCoordOfTileStored");
int y = compound.getInteger("YCoordOfTileStored");
int z = compound.getInteger("ZCoordOfTileStored");
int world = compound.getInteger("WorldOfTileStored");
if(!(x == 0 && y == 0 && z == 0)){
this.boundPosition = new WorldPos(world, x, y, z);
this.markDirty();
}
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -95,6 +70,30 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
if(this.boundPosition != null){
compound.setInteger("XCoordOfTileStored", boundPosition.getX());
compound.setInteger("YCoordOfTileStored", boundPosition.getY());
compound.setInteger("ZCoordOfTileStored", boundPosition.getZ());
compound.setInteger("WorldOfTileStored", boundPosition.getWorld().provider.dimensionId);
}
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
int x = compound.getInteger("XCoordOfTileStored");
int y = compound.getInteger("YCoordOfTileStored");
int z = compound.getInteger("ZCoordOfTileStored");
int world = compound.getInteger("WorldOfTileStored");
if(!(x == 0 && y == 0 && z == 0)){
this.boundPosition = new WorldPos(world, x, y, z);
this.markDirty();
}
}
public static int upgradeRange(int defaultRange, World world, int x, int y, int z){ public static int upgradeRange(int defaultRange, World world, int x, int y, int z){
int newRange = defaultRange; int newRange = defaultRange;
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){

View file

@ -85,13 +85,13 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean canInsertItem(int slot, ItemStack stack, int side){
return false; return this.isItemValidForSlot(slot, stack);
} }
@Override @Override
public boolean canInsertItem(int slot, ItemStack stack, int side){ public boolean isItemValidForSlot(int i, ItemStack stack){
return this.isItemValidForSlot(slot, stack); return false;
} }
@Override @Override

View file

@ -29,18 +29,6 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
super(1, "xpSolidifier"); super(1, "xpSolidifier");
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
super.writeSyncableNBT(compound, sync);
compound.setShort("Amount", this.amount);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.amount = compound.getShort("Amount");
}
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
@ -66,8 +54,15 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
} }
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
return false; super.writeSyncableNBT(compound, sync);
compound.setShort("Amount", this.amount);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
super.readSyncableNBT(compound, sync);
this.amount = compound.getShort("Amount");
} }
@Override @Override
@ -75,6 +70,11 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
return this.isItemValidForSlot(slot, stack); return this.isItemValidForSlot(slot, stack);
} }
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return false;
}
@Override @Override
public boolean canExtractItem(int slot, ItemStack stack, int side){ public boolean canExtractItem(int slot, ItemStack stack, int side){
return true; return true;

View file

@ -249,14 +249,6 @@ public class WorldUtil{
return addToInventory(inventory, start, end, stacks, ForgeDirection.UNKNOWN, actuallyDo); return addToInventory(inventory, start, end, stacks, ForgeDirection.UNKNOWN, actuallyDo);
} }
public static boolean addToInventory(IInventory inventory, ArrayList<ItemStack> stacks, boolean actuallyDo){
return addToInventory(inventory, stacks, ForgeDirection.UNKNOWN, actuallyDo);
}
public static boolean addToInventory(IInventory inventory, ArrayList<ItemStack> stacks, ForgeDirection side, boolean actuallyDo){
return addToInventory(inventory, 0, inventory.getSizeInventory(), stacks, side, actuallyDo);
}
/** /**
* Add an ArrayList of ItemStacks to an Array of slots * Add an ArrayList of ItemStacks to an Array of slots
* *
@ -309,6 +301,14 @@ public class WorldUtil{
return working >= stacks.size(); return working >= stacks.size();
} }
public static boolean addToInventory(IInventory inventory, ArrayList<ItemStack> stacks, boolean actuallyDo){
return addToInventory(inventory, stacks, ForgeDirection.UNKNOWN, actuallyDo);
}
public static boolean addToInventory(IInventory inventory, ArrayList<ItemStack> stacks, ForgeDirection side, boolean actuallyDo){
return addToInventory(inventory, 0, inventory.getSizeInventory(), stacks, side, actuallyDo);
}
public static int findFirstFilledSlot(ItemStack[] slots){ public static int findFirstFilledSlot(ItemStack[] slots){
for(int i = 0; i < slots.length; i++){ for(int i = 0; i < slots.length; i++){
if(slots[i] != null){ if(slots[i] != null){