Compiles corporea dispenser mana and string block subpkgs

This commit is contained in:
Vincent Lee committed 2017-01-05 01:11:09 -06:00
1 parent 44a8fe17eb
commit a8558ea9a1
18 files changed
+70 -57

No files matched your search

@@ -93,8 +93,9 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing s, float xs, float ys, float zs) {
if(stack != null) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing s, float xs, float ys, float zs) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty()) {
TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos);
cube.setRequestTarget(stack);
return true;
@@ -60,7 +60,7 @@ public class BlockCorporeaFunnel extends BlockCorporeaBase implements ILexiconab
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
boolean power = world.isBlockIndirectlyGettingPowered(pos) > 0 || world.isBlockIndirectlyGettingPowered(pos.up()) > 0;
boolean powered = state.getValue(BotaniaStateProps.POWERED);
@@ -65,7 +65,7 @@ public class BlockCorporeaRetainer extends BlockMod implements ILexiconable, ICr
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
boolean power = world.isBlockIndirectlyGettingPowered(pos) > 0 || world.isBlockIndirectlyGettingPowered(pos.up()) > 0;
boolean powered = state.getValue(BotaniaStateProps.POWERED);
@@ -26,6 +26,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BehaviourCocoaBeans extends BehaviorDefaultDispenseItem {
IBehaviorDispenseItem vanillaBehaviour;
@@ -33,6 +35,7 @@ public class BehaviourCocoaBeans extends BehaviorDefaultDispenseItem {
vanillaBehaviour = vanilla;
}
@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
if(par2ItemStack.getItemDamage() == EnumDyeColor.BROWN.getDyeDamage()) {
@@ -45,7 +48,7 @@ public class BehaviourCocoaBeans extends BehaviorDefaultDispenseItem {
IBlockState logState = world.getBlockState(logPos);
if(logState.getBlock() == Blocks.LOG && logState.getValue(BlockOldLog.VARIANT) == BlockPlanks.EnumType.JUNGLE && world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
world.setBlockState(pos, block.getDefaultState().withProperty(BlockHorizontal.FACING, facing));
par2ItemStack.stackSize--;
par2ItemStack.shrink(1);
return par2ItemStack;
}
}
@@ -34,7 +34,7 @@ public class BehaviourFelPumpkin extends BehaviorDefaultDispenseItem {
world.setBlockState(blockpos, blockpumpkin.getDefaultState(), 3);
}
--stack.stackSize;
stack.shrink(1);
}
else
{
@@ -19,6 +19,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class BehaviourSeeds extends BehaviorDefaultDispenseItem {
Block block;
@@ -27,6 +29,7 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem {
this.block = block;
}
@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING);
@@ -35,7 +38,7 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem {
if(world.isAirBlock(pos) && block.canPlaceBlockAt(world, pos)) {
world.setBlockState(pos, block.getDefaultState());
par2ItemStack.stackSize--;
par2ItemStack.shrink(1);
return par2ItemStack;
}
@@ -90,7 +90,7 @@ public class BlockBellows extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing s, float xs, float ys, float zs) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing s, float xs, float ys, float zs) {
if(EntityDoppleganger.isTruePlayer(player))
((TileBellows) world.getTileEntity(pos)).interact();
return true;
@@ -86,14 +86,15 @@ public class BlockBrewery extends BlockMod implements ILexiconable, IWandHUD {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float par7, float par8, float par9) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
TileBrewery brew = (TileBrewery) world.getTileEntity(pos);
if(player.isSneaking()) {
if(brew.recipe == null && !state.getValue(BotaniaStateProps.POWERED))
InventoryHelper.withdrawFromInventory(brew, player);
} else {
if(stack != null)
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty())
return brew.addItem(player, stack, hand);
}
return false;
@@ -111,20 +111,21 @@ public class BlockEnchanter extends BlockMod implements IWandable, ILexiconable,
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float par7, float par8, float par9) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
TileEnchanter enchanter = (TileEnchanter) world.getTileEntity(pos);
if(stack != null && stack.getItem() == ModItems.twigWand)
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty() && stack.getItem() == ModItems.twigWand)
return false;
boolean stackEnchantable = stack != null
boolean stackEnchantable = !stack.isEmpty()
&& stack.getItem() != Items.BOOK
&& stack.isItemEnchantable()
&& stack.stackSize == 1;
&& stack.getCount() == 1;
if(enchanter.itemToEnchant == null) {
if(stackEnchantable) {
enchanter.itemToEnchant = stack.copy();
player.setHeldItem(hand, null);
player.setHeldItem(hand, ItemStack.EMPTY);
enchanter.sync();
}
} else if(enchanter.stage == TileEnchanter.State.IDLE) {
@@ -147,13 +148,13 @@ public class BlockEnchanter extends BlockMod implements IWandable, ILexiconable,
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntity(entityitem)) {
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.getCount() > 0; world.spawnEntity(entityitem)) {
int k1 = random.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
k1 = itemstack.stackSize;
if (k1 > itemstack.getCount())
k1 = itemstack.getAnimationsToGo();
itemstack.stackSize -= k1;
itemstack.shrink(k1);
entityitem = new EntityItem(world, pos.getX() + f, pos.getY() + f1, pos.getZ() + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3 * 0.5;
@@ -147,13 +147,13 @@ public class BlockForestDrum extends BlockMod implements IManaTrigger, ILexicona
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(entity.posX, entity.posY, entity.posZ, entity.posX + entity.width, entity.posY + entity.height, entity.posZ + entity.width));
for(EntityItem item : items) {
ItemStack itemstack = item.getEntityItem();
if(itemstack != null && itemstack.getItem() == Items.BUCKET && !world.isRemote) {
while(itemstack.stackSize > 0) {
if(!itemstack.isEmpty() && itemstack.getItem() == Items.BUCKET && !world.isRemote) {
while(itemstack.getCount() > 0) {
EntityItem ent = entity.entityDropItem(new ItemStack(Items.MILK_BUCKET), 1.0F);
ent.motionY += world.rand.nextFloat() * 0.05F;
ent.motionX += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F;
ent.motionZ += (world.rand.nextFloat() - world.rand.nextFloat()) * 0.1F;
itemstack.stackSize--;
itemstack.shrink(1);
}
item.setDead();
}
@@ -79,9 +79,9 @@ public class BlockManaDetector extends BlockMod implements ILexiconable, IManaCo
}
@Override
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB par5AxisAlignedBB, @Nonnull List<AxisAlignedBB> stacks, Entity par7Entity) {
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB par5AxisAlignedBB, @Nonnull List<AxisAlignedBB> stacks, Entity par7Entity, boolean useActualState) {
if(par7Entity != null && !(par7Entity instanceof IManaBurst))
super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity);
super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity, useActualState);
}
@Override
@@ -183,7 +183,7 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
@Override
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, @Nonnull List<AxisAlignedBB> boxes, Entity entity) {
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, @Nonnull List<AxisAlignedBB> boxes, Entity entity, boolean useActualState) {
addCollisionBoxToList(pos, entityBox, boxes, BOTTOM_AABB);
addCollisionBoxToList(pos, entityBox, boxes, NORTH_AABB);
addCollisionBoxToList(pos, entityBox, boxes, SOUTH_AABB);
@@ -98,7 +98,7 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos) {
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) {
return NULL_AABB;
}
@@ -113,27 +113,28 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float par7, float par8, float par9) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
TileEntity tile = world.getTileEntity(pos);
if(!(tile instanceof TilePrism))
return false;
TilePrism prism = (TilePrism) tile;
ItemStack lens = prism.getItemHandler().getStackInSlot(0);
boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens;
ItemStack heldItem = player.getHeldItem(hand);
boolean isHeldItemLens = !heldItem.isEmpty() && heldItem.getItem() instanceof ILens;
if(lens == null && isHeldItemLens) {
if(lens.isEmpty() && isHeldItemLens) {
if(!player.capabilities.isCreativeMode)
player.setHeldItem(hand, null);
player.setHeldItem(hand, ItemStack.EMPTY);
prism.getItemHandler().setStackInSlot(0, heldItem.copy());
prism.markDirty();
world.setBlockState(pos, state.withProperty(BotaniaStateProps.HAS_LENS, true), 1 | 2);
} else if(lens != null) {
} else if(!lens.isEmpty()) {
ItemStack add = lens.copy();
if(!player.inventory.addItemStackToInventory(add))
player.dropItem(add, false);
prism.getItemHandler().setStackInSlot(0, null);
prism.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
prism.markDirty();
world.setBlockState(pos, state.withProperty(BotaniaStateProps.HAS_LENS, false), 1 | 2);
}
@@ -142,7 +143,7 @@ public class BlockPrism extends BlockMod implements IManaTrigger, ILexiconable,
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
boolean power = world.isBlockIndirectlyGettingPowered(pos) > 0 || world.isBlockIndirectlyGettingPowered(pos.up()) > 0;
boolean powered = state.getValue(BotaniaStateProps.POWERED);
@@ -65,21 +65,22 @@ public class BlockRuneAltar extends BlockMod implements IWandable, ILexiconable
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float par7, float par8, float par9) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float par7, float par8, float par9) {
if(world.isRemote)
return true;
TileRuneAltar altar = (TileRuneAltar) world.getTileEntity(pos);
ItemStack stack = player.getHeldItem(hand);
if(player.isSneaking()) {
if(altar.manaToGet == 0) {
InventoryHelper.withdrawFromInventory(altar, player);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar);
}
} else if(altar.isEmpty() && stack == null) {
} else if(altar.isEmpty() && stack.isEmpty()) {
altar.trySetLastRecipe(player);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar);
} else if(stack != null) {
} else if(!stack.isEmpty()) {
boolean result = altar.addItem(player, stack, hand);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(altar);
return result;
@@ -102,7 +102,7 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, ILex
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
EnumFacing orientation = BlockPistonBase.getFacingFromEntity(pos, par5EntityLivingBase);
EnumFacing orientation = EnumFacing.getDirectionFromEntityLiving(pos, par5EntityLivingBase);
TileSpreader spreader = (TileSpreader) world.getTileEntity(pos);
world.setBlockState(pos, getStateFromMeta(par6ItemStack.getItemDamage()), 1 | 2);
@@ -149,40 +149,41 @@ public class BlockSpreader extends BlockMod implements IWandable, IWandHUD, ILex
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing par6, float par7, float par8, float par9) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
TileEntity tile = world.getTileEntity(pos);
if(!(tile instanceof TileSpreader))
return false;
TileSpreader spreader = (TileSpreader) tile;
ItemStack lens = spreader.getItemHandler().getStackInSlot(0);
boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens;
boolean wool = heldItem != null && heldItem.getItem() == Item.getItemFromBlock(Blocks.WOOL);
ItemStack heldItem = player.getHeldItem(hand);
boolean isHeldItemLens = !heldItem.isEmpty() && heldItem.getItem() instanceof ILens;
boolean wool = !heldItem.isEmpty() && heldItem.getItem() == Item.getItemFromBlock(Blocks.WOOL);
if(heldItem != null)
if(!heldItem.isEmpty())
if(heldItem.getItem() == ModItems.twigWand)
return false;
if(lens == null && isHeldItemLens) {
if(lens.isEmpty() && isHeldItemLens) {
if (!player.capabilities.isCreativeMode)
player.setHeldItem(hand, null);
player.setHeldItem(hand, ItemStack.EMPTY);
spreader.getItemHandler().setStackInSlot(0, heldItem.copy());
spreader.markDirty();
} else if(lens != null && !wool) {
} else if(!lens.isEmpty() && !wool) {
ItemStack add = lens.copy();
if(!player.inventory.addItemStackToInventory(add))
player.dropItem(add, false);
spreader.getItemHandler().setStackInSlot(0, null);
spreader.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
spreader.markDirty();
}
if(wool && spreader.paddingColor == -1) {
spreader.paddingColor = heldItem.getItemDamage();
heldItem.stackSize--;
if(heldItem.stackSize == 0)
player.setHeldItem(hand, null);
} else if(heldItem == null && spreader.paddingColor != -1 && lens == null) {
heldItem.shrink(1);
if(heldItem.isEmpty())
player.setHeldItem(hand, ItemStack.EMPTY);
} else if(heldItem.isEmpty() && spreader.paddingColor != -1 && lens.isEmpty()) {
ItemStack pad = new ItemStack(Blocks.WOOL, 1, spreader.paddingColor);
if(!player.inventory.addItemStackToInventory(pad))
player.dropItem(pad, false);
@@ -53,16 +53,17 @@ public class BlockTerraPlate extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing s, float xs, float ys, float zs) {
if(stack != null && stack.getItem() == ModItems.manaResource && stack.getItemDamage() < 3) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing s, float xs, float ys, float zs) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty() && stack.getItem() == ModItems.manaResource && stack.getItemDamage() < 3) {
if(player == null || !player.capabilities.isCreativeMode) {
stack.stackSize--;
if(stack.stackSize == 0 && player != null)
player.setHeldItem(hand, null);
stack.shrink(1);
if(stack.isEmpty() && player != null)
player.setHeldItem(hand, ItemStack.EMPTY);
}
ItemStack target = stack.copy();
target.stackSize = 1;
target.setCount(1);
EntityItem item = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, target);
item.setPickupDelay(40);
item.motionX = item.motionY = item.motionZ = 0;
@@ -49,7 +49,7 @@ public abstract class BlockRedString extends BlockMod implements ILexiconable {
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
EnumFacing orientation = BlockPistonBase.getFacingFromEntity(pos, par5EntityLivingBase);
EnumFacing orientation = EnumFacing.getDirectionFromEntityLiving(pos, par5EntityLivingBase);
world.setBlockState(pos, state.withProperty(BotaniaStateProps.FACING, orientation), 1 | 2);
}
@@ -65,7 +65,7 @@ public class BlockRedStringDispenser extends BlockRedString {
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) {
boolean power = world.isBlockIndirectlyGettingPowered(pos) > 0 || world.isBlockIndirectlyGettingPowered(pos.up()) > 0;
boolean powered = state.getValue(BotaniaStateProps.POWERED);