Compiles base block

This commit is contained in:
Vincent Lee committed 2017-01-05 01:02:50 -06:00
1 parent d4db9902e3
commit 44a8fe17eb
18 files changed
+70 -61

No files matched your search

@@ -152,15 +152,16 @@ public class BlockAltar extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, 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) {
TileAltar tile = (TileAltar) world.getTileEntity(pos);
ItemStack stack = player.getHeldItem(hand);
if(player.isSneaking()) {
InventoryHelper.withdrawFromInventory(tile, player);
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(tile);
} else if(tile.isEmpty() && tile.hasWater && stack == null)
} else if(tile.isEmpty() && tile.hasWater && stack.isEmpty())
tile.trySetLastRecipe(player);
else {
if(stack != null && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, false))) {
if(!stack.isEmpty() && (isValidWaterContainer(stack) || stack.getItem() == ModItems.waterRod && ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, false))) {
if(!tile.hasWater) {
if(stack.getItem() == ModItems.waterRod)
ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, true);
@@ -185,12 +186,12 @@ public class BlockAltar extends BlockMod implements ILexiconable {
return true;
} else if(stack != null && stack.getItem() == Items.BUCKET && (tile.hasWater || tile.hasLava) && !Botania.gardenOfGlassLoaded) {
ItemStack bucket = tile.hasLava ? new ItemStack(Items.LAVA_BUCKET) : new ItemStack(Items.WATER_BUCKET);
if(stack.stackSize == 1)
if(stack.getCount() == 1)
player.setHeldItem(hand, bucket);
else {
if(!player.inventory.addItemStackToInventory(bucket))
player.dropItem(bucket, false);
stack.stackSize--;
stack.shrink(1);
}
if(tile.hasLava)
@@ -225,7 +226,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
}
private boolean isValidWaterContainer(ItemStack stack) {
if(stack == null || stack.stackSize != 1)
if(stack.isEmpty() || stack.getCount() != 1)
return false;
if(stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) {
@@ -47,8 +47,8 @@ public class BlockAnimatedTorch extends BlockMod implements IWandable, IManaTrig
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
if(hand == EnumHand.MAIN_HAND && playerIn.isSneaking() && playerIn.getHeldItem(hand) == null) {
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if(hand == EnumHand.MAIN_HAND && playerIn.isSneaking() && playerIn.getHeldItem(hand).isEmpty()) {
((TileAnimatedTorch) worldIn.getTileEntity(pos)).handRotate();
return true;
}
@@ -89,19 +89,20 @@ public class BlockAvatar extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stackOnPlayer, 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) {
TileAvatar avatar = (TileAvatar) world.getTileEntity(pos);
ItemStack stackOnAvatar = avatar.getItemHandler().getStackInSlot(0);
ItemStack stackOnPlayer = player.getHeldItem(hand);
if(stackOnAvatar != null) {
ItemStack copyStack = stackOnAvatar.copy();
avatar.getItemHandler().setStackInSlot(0, null);
avatar.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
if(!player.inventory.addItemStackToInventory(copyStack))
player.dropItem(copyStack, true);
return true;
} else if(stackOnPlayer != null && stackOnPlayer.getItem() instanceof IAvatarWieldable) {
ItemStack copyStack = stackOnPlayer.copy();
avatar.getItemHandler().setStackInSlot(0, copyStack);
stackOnPlayer.stackSize--;
stackOnPlayer.shrink(1);
return true;
}
@@ -70,7 +70,7 @@ public class BlockCacophonium extends BlockMod {
}
@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);
@@ -34,13 +34,14 @@ public abstract class BlockCamo extends BlockMod {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack currentStack, EnumFacing side, float hitX, float hitY, float hitZ) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity tile = world.getTileEntity(pos);
if(world.isRemote)
return true;
if(currentStack != null
ItemStack currentStack = player.getHeldItem(hand);
if(!currentStack.isEmpty()
&& Block.getBlockFromItem(currentStack.getItem()) != null
&& tile instanceof TileCamo) {
TileCamo camo = (TileCamo) tile;
@@ -69,11 +69,12 @@ public class BlockCocoon extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack item, 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) {
TileCocoon cocoon = (TileCocoon) world.getTileEntity(pos);
if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && item != null && item.getItem() == Items.EMERALD) {
ItemStack item = player.getHeldItem(hand);
if(cocoon.emeraldsGiven < TileCocoon.MAX_EMERALDS && !item.isEmpty() && item.getItem() == Items.EMERALD) {
if(!player.capabilities.isCreativeMode)
item.stackSize--;
item.shrink(1);
cocoon.emeraldsGiven++;
world.playEvent(2005, pos, 6 + world.rand.nextInt(4));
}
@@ -58,7 +58,7 @@ public class BlockFakeAir extends BlockMod {
public void registerItemForm() {}
@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) {
if(shouldRemove(world, pos))
world.scheduleUpdate(pos, this, tickRate(world));
}
@@ -120,8 +120,8 @@ public class BlockFakeAir extends BlockMod {
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos) {
return null;
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) {
return NULL_AABB;
}
@Override
@@ -83,9 +83,9 @@ public class BlockFelPumpkin extends BlockMod implements ILexiconable {
blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F);
blaze.getEntityData().setBoolean(TAG_FEL_SPAWNED, true);
world.spawnEntity(blaze);
world.notifyNeighborsOfStateChange(pos, Blocks.AIR);
world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR);
world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR);
world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false);
world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false);
world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false);
}
}
@@ -102,7 +102,7 @@ public class BlockFelPumpkin extends BlockMod implements ILexiconable {
else for(EntityItem item : event.getDrops()) {
ItemStack stack = item.getEntityItem();
if(stack.getItem() == Items.BLAZE_ROD)
item.setEntityItemStack(new ItemStack(Items.BLAZE_POWDER, stack.stackSize * 10));
item.setEntityItemStack(new ItemStack(Items.BLAZE_POWDER, stack.getCount() * 10));
}
}
@@ -91,10 +91,11 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable,
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float xs, float ys, float zs) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float xs, float ys, float zs) {
TileHourglass hourglass = (TileHourglass) world.getTileEntity(pos);
ItemStack hgStack = hourglass.getItemHandler().getStackInSlot(0);
if(stack != null && stack.getItem() == ModItems.twigWand)
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty() && stack.getItem() == ModItems.twigWand)
return false;
if(hourglass.lock) {
@@ -103,16 +104,16 @@ public class BlockHourglass extends BlockMod implements IManaTrigger, IWandable,
return true;
}
if(hgStack == null && TileHourglass.getStackItemTime(stack) > 0) {
if(hgStack.isEmpty() && TileHourglass.getStackItemTime(stack) > 0) {
hourglass.getItemHandler().setStackInSlot(0, stack.copy());
hourglass.markDirty();
stack.stackSize = 0;
stack.setCount(0);
return true;
} else if(hgStack != null) {
} else if(!hgStack.isEmpty()) {
ItemStack copy = hgStack.copy();
if(!player.inventory.addItemStackToInventory(copy))
player.dropItem(copy, false);
hourglass.getItemHandler().setStackInSlot(0, null);
hourglass.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
hourglass.markDirty();
return true;
}
@@ -72,20 +72,21 @@ public class BlockIncensePlate 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) {
TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(pos);
ItemStack plateStack = plate.getItemHandler().getStackInSlot(0);
ItemStack stack = player.getHeldItem(hand);
boolean did = false;
if(world.isRemote)
return true;
if(plateStack == null && plate.acceptsItem(stack)) {
if(plateStack.isEmpty() && plate.acceptsItem(stack)) {
plate.getItemHandler().setStackInSlot(0, stack.copy());
stack.stackSize--;
stack.shrink(1);
did = true;
} else if(plateStack != null && !plate.burning) {
if(stack != null && stack.getItem() == Items.FLINT_AND_STEEL) {
} else if(!plateStack.isEmpty() && !plate.burning) {
if(!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL) {
plate.ignite();
stack.damageItem(1, player);
did = true;
@@ -93,7 +94,7 @@ public class BlockIncensePlate extends BlockMod implements ILexiconable {
ItemStack addStack = plateStack.copy();
if(!player.inventory.addItemStackToInventory(addStack))
player.dropItem(addStack, false);
plate.getItemHandler().setStackInSlot(0, null);
plate.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
did = true;
}
@@ -92,7 +92,7 @@ public class BlockLightLauncher extends BlockMod implements 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);
@@ -113,14 +113,14 @@ public class BlockLightRelay extends BlockMod implements IWandable, 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) {
((TileLightRelay) world.getTileEntity(pos)).mountEntity(player);
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos) {
return null;
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos) {
return NULL_AABB;
}
@Override
@@ -129,7 +129,7 @@ public class BlockLightRelay extends BlockMod implements IWandable, ILexiconable
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) {
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
if(!worldIn.isRemote && state.getValue(BotaniaStateProps.LUMINIZER_VARIANT) == LuminizerVariant.TOGGLE) {
if(state.getValue(BotaniaStateProps.POWERED) && !worldIn.isBlockPowered(pos))
worldIn.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false));
@@ -128,10 +128,10 @@ public class BlockPlatform extends BlockCamo implements ILexiconable, IWandable,
}
@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) {
PlatformVariant variant = state.getValue(BotaniaStateProps.PLATFORM_VARIANT);
if(variant == PlatformVariant.INFRANGIBLE || variant == PlatformVariant.ABSTRUSE && par7Entity != null && par7Entity.posY > pos.getY() + 0.9 && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking()))
super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity);
super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity, useActualState);
}
@Override
@@ -45,7 +45,7 @@ public class BlockSolidVines extends BlockVine implements ILexiconable {
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, World world, BlockPos pos) {
public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
return getBoundingBox(state, world, pos);
}
@@ -91,7 +91,7 @@ public class BlockSparkChanger extends BlockMod implements 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);
@@ -103,24 +103,25 @@ public class BlockSparkChanger extends BlockMod implements ILexiconable {
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack pstack, 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) {
TileSparkChanger changer = (TileSparkChanger) world.getTileEntity(pos);
ItemStack pstack = player.getHeldItem(hand);
ItemStack cstack = changer.getItemHandler().getStackInSlot(0);
if(cstack != null) {
changer.getItemHandler().setStackInSlot(0, null);
if(!cstack.isEmpty()) {
changer.getItemHandler().setStackInSlot(0, ItemStack.EMPTY);
world.updateComparatorOutputLevel(pos, this);
changer.markDirty();
if(!player.inventory.addItemStackToInventory(cstack))
player.dropItem(cstack, false);
return true;
} else if(pstack != null && pstack.getItem() == ModItems.sparkUpgrade) {
} else if(!pstack.isEmpty() && pstack.getItem() == ModItems.sparkUpgrade) {
changer.getItemHandler().setStackInSlot(0, pstack.copy().splitStack(1));
world.updateComparatorOutputLevel(pos, this);
changer.markDirty();
pstack.stackSize--;
if(pstack.stackSize == 0)
player.setHeldItem(hand, null);
pstack.shrink(1);
if(pstack.isEmpty())
player.setHeldItem(hand, ItemStack.EMPTY);
return true;
}
@@ -325,8 +325,9 @@ public class BlockSpecialFlower extends BlockFlower implements ISpecialFlower, I
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) {
if(stack != null && stack.getItem() == ModItems.dye) {
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if(!stack.isEmpty() && stack.getItem() == ModItems.dye) {
EnumDyeColor newColor = EnumDyeColor.byMetadata(stack.getItemDamage());
EnumDyeColor oldColor = state.getValue(BotaniaStateProps.COLOR);
if(newColor != oldColor)
@@ -58,18 +58,19 @@ public class BlockTeruTeruBozu extends BlockMod implements ILexiconable {
EntityItem item = (EntityItem) e;
ItemStack stack = item.getEntityItem();
if(isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world)) {
stack.stackSize--;
if(stack.stackSize == 0)
stack.shrink(1);
if(stack.isEmpty())
e.setDead();
}
}
}
@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 && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) {
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() && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) {
if(!player.capabilities.isCreativeMode)
stack.stackSize--;
stack.shrink(1);
return true;
}
return false;
@@ -12,14 +12,14 @@ package vazkii.botania.common.block;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBanner;
import net.minecraft.tileentity.BannerPattern;
import net.minecraftforge.common.util.EnumHelper;
import vazkii.botania.common.item.ModItems;
public final class ModBanners {
public static void init() {
Class<? extends Enum<?>> clazz = TileEntityBanner.EnumBannerPattern.class;
Class<? extends Enum<?>> clazz = BannerPattern.class;
addPattern(clazz, "flower", "flr", new ItemStack(ModItems.manaResource, 1, 3));
addPattern(clazz, "lexicon", "lex", new ItemStack(ModItems.lexicon));
addPattern(clazz, "logo", "lgo", new ItemStack(ModItems.manaResource, 1, 4));