diff --git a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java index b451587a0..97fb8ff82 100644 --- a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java +++ b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java @@ -13,14 +13,14 @@ import com.google.common.base.Predicates; import net.minecraft.block.BlockRailBase; import net.minecraft.block.BlockRailPowered; import net.minecraft.block.BlockRotatedPillar; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.IBlockState; import net.minecraft.item.EnumDyeColor; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.EnumProperty; +import net.minecraft.state.properties.RailShape; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; import vazkii.botania.api.item.IFloatingFlower; import vazkii.botania.api.state.enums.AlfPortalState; import vazkii.botania.api.state.enums.BiomeBrickVariant; @@ -56,39 +56,39 @@ public final class BotaniaStateProps { /** Common properties to all blocks to use **/ // The 16 Minecraft colors - public static final PropertyEnum COLOR = PropertyEnum.create("color", EnumDyeColor.class); + public static final EnumProperty COLOR = EnumProperty.create("color", EnumDyeColor.class); // The four cardinal directions - public static final PropertyEnum CARDINALS = PropertyEnum.create("facing", EnumFacing.class, EnumFacing.Plane.HORIZONTAL); + public static final EnumProperty CARDINALS = EnumProperty.create("facing", EnumFacing.class, EnumFacing.Plane.HORIZONTAL); // All 6 directions - public static final PropertyEnum FACING = PropertyEnum.create("facing", EnumFacing.class); + public static final EnumProperty FACING = EnumProperty.create("facing", EnumFacing.class); // Redstone power - boolean // Also for any other simple boolean "on/off" state - public static final PropertyBool POWERED = PropertyBool.create("powered"); + public static final BooleanProperty POWERED = BooleanProperty.create("powered"); /** Properties for certain kinds of blocks **/ // The axis directions (think quartz pillars and wood logs) - public static final PropertyEnum AXIS_FACING = BlockRotatedPillar.AXIS; + public static final EnumProperty AXIS_FACING = BlockRotatedPillar.AXIS; // Extra Quartz Blocks - public static final PropertyEnum QUARTZ_VARIANT = PropertyEnum.create("variant", QuartzVariant.class); + public static final EnumProperty QUARTZ_VARIANT = EnumProperty.create("variant", QuartzVariant.class); /** Properties for individual blocks **/ // BlockAlfPortal - public static final PropertyEnum ALFPORTAL_STATE = PropertyEnum.create("state", AlfPortalState.class); + public static final EnumProperty ALFPORTAL_STATE = EnumProperty.create("state", AlfPortalState.class); // BlockBiomeStoneA - public static final PropertyEnum BIOMESTONE_VARIANT = PropertyEnum.create("variant", BiomeStoneVariant.class); + public static final EnumProperty BIOMESTONE_VARIANT = EnumProperty.create("variant", BiomeStoneVariant.class); // BlockBiomeStoneB - public static final PropertyEnum BIOMEBRICK_VARIANT = PropertyEnum.create("variant", BiomeBrickVariant.class); + public static final EnumProperty BIOMEBRICK_VARIANT = EnumProperty.create("variant", BiomeBrickVariant.class); // BlockBiomeStoneWall - public static final PropertyEnum BIOMESTONEWALL_VARIANT = PropertyEnum.create("bswall_variant", BiomeStoneVariant.class, new Predicate() { + public static final EnumProperty BIOMESTONEWALL_VARIANT = EnumProperty.create("bswall_variant", BiomeStoneVariant.class, new Predicate() { @Override public boolean apply(BiomeStoneVariant input) { return input.getName().contains("cobble"); @@ -96,22 +96,22 @@ public final class BotaniaStateProps { }); // BlockDreamWood, BlockLivingWood - public static final PropertyEnum LIVINGWOOD_VARIANT = PropertyEnum.create("variant", LivingWoodVariant.class); + public static final EnumProperty LIVINGWOOD_VARIANT = EnumProperty.create("variant", LivingWoodVariant.class); // BlockEnchanter - public static final PropertyEnum ENCHANTER_DIRECTION = PropertyEnum.create("facing", EnumFacing.Axis.class, Predicates.not(Predicates.equalTo(EnumFacing.Axis.Y))); + public static final EnumProperty ENCHANTER_DIRECTION = EnumProperty.create("facing", EnumFacing.Axis.class, Predicates.not(Predicates.equalTo(EnumFacing.Axis.Y))); // BlockGhostRail - public static final PropertyEnum RAIL_DIRECTION = BlockRailPowered.SHAPE; + public static final EnumProperty RAIL_DIRECTION = BlockRailPowered.SHAPE; // BlockLightRelay - public static final PropertyEnum LUMINIZER_VARIANT = PropertyEnum.create("variant", LuminizerVariant.class); + public static final EnumProperty LUMINIZER_VARIANT = EnumProperty.create("variant", LuminizerVariant.class); // BlockLivingRock - public static final PropertyEnum LIVINGROCK_VARIANT = PropertyEnum.create("variant", LivingRockVariant.class); + public static final EnumProperty LIVINGROCK_VARIANT = EnumProperty.create("variant", LivingRockVariant.class); // BlockModDoubleFlower (white to gray) - public static final PropertyEnum DOUBLEFLOWER_VARIANT_1 = PropertyEnum.create("df_variant", EnumDyeColor.class, new Predicate() { + public static final EnumProperty DOUBLEFLOWER_VARIANT_1 = EnumProperty.create("df_variant", EnumDyeColor.class, new Predicate() { @Override public boolean apply(EnumDyeColor input) { return input.ordinal() >= 0 && input.ordinal() <= 7; @@ -119,7 +119,7 @@ public final class BotaniaStateProps { }); // (silver to black) - public static final PropertyEnum DOUBLEFLOWER_VARIANT_2 = PropertyEnum.create("df_variant", EnumDyeColor.class, new Predicate() { + public static final EnumProperty DOUBLEFLOWER_VARIANT_2 = EnumProperty.create("df_variant", EnumDyeColor.class, new Predicate() { @Override public boolean apply(EnumDyeColor input) { return input.ordinal() >= 8 && input.ordinal() <= 15; @@ -127,10 +127,10 @@ public final class BotaniaStateProps { }); // BlockCraftyCrate - public static final PropertyEnum CRATE_PATTERN = PropertyEnum.create("pattern", CratePattern.class); + public static final EnumProperty CRATE_PATTERN = EnumProperty.create("pattern", CratePattern.class); // BlockPavement - public static final PropertyEnum PAVEMENT_COLOR = PropertyEnum.create("color", EnumDyeColor.class, new Predicate() { + public static final EnumProperty PAVEMENT_COLOR = EnumProperty.create("color", EnumDyeColor.class, new Predicate() { @Override public boolean apply(EnumDyeColor color) { return color == EnumDyeColor.WHITE || color == EnumDyeColor.BLACK @@ -140,7 +140,7 @@ public final class BotaniaStateProps { }); // BlockPrism - public static final PropertyBool HAS_LENS = PropertyBool.create("has_lens"); + public static final BooleanProperty HAS_LENS = BooleanProperty.create("has_lens"); private BotaniaStateProps() { } diff --git a/src/main/java/vazkii/botania/common/block/BlockMod.java b/src/main/java/vazkii/botania/common/block/BlockMod.java index e3329575b..32f21b57d 100644 --- a/src/main/java/vazkii/botania/common/block/BlockMod.java +++ b/src/main/java/vazkii/botania/common/block/BlockMod.java @@ -19,32 +19,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.client.core.handler.ModelHandler; import vazkii.botania.client.render.IModelRegister; import vazkii.botania.common.core.BotaniaCreativeTab; import vazkii.botania.common.lib.LibMisc; -public abstract class BlockMod extends Block implements IModelRegister { +public abstract class BlockMod extends Block { - public BlockMod(Material par2Material, String name) { - super(par2Material); - setTranslationKey(name); - setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name)); - if(registerInCreative()) - setCreativeTab(BotaniaCreativeTab.INSTANCE); - } - - protected boolean registerInCreative() { - return true; - } - - @SideOnly(Side.CLIENT) - @Override - public void registerModels() { - if(Item.getItemFromBlock(this) != Items.AIR) - ModelHandler.registerBlockToState(this, 0, getDefaultState()); + public BlockMod(Block.Builder builder) { + super(builder); } @Override diff --git a/src/main/java/vazkii/botania/common/block/ModBlocks.java b/src/main/java/vazkii/botania/common/block/ModBlocks.java index 3edce3642..ae1ee7b44 100644 --- a/src/main/java/vazkii/botania/common/block/ModBlocks.java +++ b/src/main/java/vazkii/botania/common/block/ModBlocks.java @@ -12,6 +12,8 @@ package vazkii.botania.common.block; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; @@ -197,10 +199,10 @@ public final class ModBlocks { public static final Block brewery = new BlockBrewery(); public static final Block manaGlass = new BlockManaGlass(); public static final Block terraPlate = new BlockTerraPlate(); - public static final Block redStringContainer = new BlockRedStringContainer(); - public static final Block redStringDispenser = new BlockRedStringDispenser(); - public static final Block redStringFertilizer = new BlockRedStringFertilizer(); - public static final Block redStringComparator = new BlockRedStringComparator(); + public static final Block redStringContainer = new BlockRedStringContainer(Block.Builder.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.RED_STRING_CONTAINER); + public static final Block redStringDispenser = new BlockRedStringDispenser(Block.Builder.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.RED_STRING_DISPENSER); + public static final Block redStringFertilizer = new BlockRedStringFertilizer(Block.Builder.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.RED_STRING_FERTILIZER); + public static final Block redStringComparator = new BlockRedStringComparator(Block.Builder.create(Material.ROCK).hardnessAndResistance(2, 10).sound(SoundType.STONE)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.RED_STRING_COMPARATOR); public static final Block redStringRelay = new BlockRedStringRelay(); public static final Block floatingSpecialFlower = new BlockFloatingSpecialFlower(); public static final Block manaFlame = new BlockManaFlame(); @@ -222,7 +224,7 @@ public final class ModBlocks { public static final Block petalBlockGreen = new BlockPetalBlock(EnumDyeColor.GREEN); public static final Block petalBlockRed = new BlockPetalBlock(EnumDyeColor.RED); public static final Block petalBlockBlack = new BlockPetalBlock(EnumDyeColor.BLACK); - public static final Block corporeaIndex = new BlockCorporeaIndex(); + public static final Block corporeaIndex = new BlockCorporeaIndex(Block.Builder.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.CORPOREA_INDEX); public static final Block corporeaFunnel = new BlockCorporeaFunnel(); public static final Block mushroom = new BlockModMushroom(); public static final Block pump = new BlockPump(); @@ -230,8 +232,8 @@ public final class ModBlocks { public static final Block doubleFlower2 = new BlockModDoubleFlower2(); public static final Block fakeAir = new BlockFakeAir(); public static final Block blazeBlock = new BlockBlaze(); - public static final Block corporeaInterceptor = new BlockCorporeaInterceptor(); - public static final Block corporeaCrystalCube = new BlockCorporeaCrystalCube(); + public static final Block corporeaInterceptor = new BlockCorporeaInterceptor(Block.Builder.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.CORPOREA_INTERCEPTOR); + public static final Block corporeaCrystalCube = new BlockCorporeaCrystalCube(Block.Builder.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.CORPOREA_CRYSTAL_CUBE); public static final Block incensePlate = new BlockIncensePlate(); public static final Block hourglass = new BlockHourglass(); public static final Block ghostRail = new BlockGhostRail(); @@ -248,7 +250,7 @@ public final class ModBlocks { public static final Block cellBlock = new BlockCell(); public static final Block redStringInterceptor = new BlockRedStringInterceptor(); public static final Block gaiaHead = new BlockGaiaHead(); - public static final Block corporeaRetainer = new BlockCorporeaRetainer(); + public static final Block corporeaRetainer = new BlockCorporeaRetainer(Block.Builder.create(Material.IRON).hardnessAndResistance(5.5F).sound(SoundType.METAL)).setRegistryName(LibMisc.MOD_ID, LibBlockNames.CORPOREA_RETAINER); public static final Block teruTeruBozu = new BlockTeruTeruBozu(); public static final Block shimmerrock = new BlockShimmerrock(); public static final Block shimmerwoodPlanks = new BlockShimmerwoodPlanks(); diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java index e9ab8fcbd..8fe760497 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaBase.java @@ -10,6 +10,7 @@ */ package vazkii.botania.common.block.corporea; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; @@ -22,17 +23,17 @@ import javax.annotation.Nonnull; public abstract class BlockCorporeaBase extends BlockMod { - public BlockCorporeaBase(Material material, String name) { - super(material, name); + public BlockCorporeaBase(Block.Builder builder) { + super(builder); } @Override - public void breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { + public void onReplaced(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newState, boolean isMoving) { TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos); InventoryHelper.dropInventory(inv, world, state, pos); - super.breakBlock(world, pos, state); + super.onReplaced(state, world, pos, newState, isMoving); } @Override diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java index a15c163c8..24569f08e 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaCrystalCube.java @@ -10,6 +10,7 @@ */ package vazkii.botania.common.block.corporea; +import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; @@ -24,6 +25,7 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.common.property.ExtendedBlockState; @@ -45,30 +47,17 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi private static final AxisAlignedBB AABB = new AxisAlignedBB(3.0/16, 0, 3.0/16, 13.0/16, 1, 13.0/16); - public BlockCorporeaCrystalCube() { - super(Material.IRON, LibBlockNames.CORPOREA_CRYSTAL_CUBE); - setHardness(5.5F); - setSoundType(SoundType.METAL); - setDefaultState(blockState.getBaseState().withProperty(Properties.StaticProperty, true)); + public BlockCorporeaCrystalCube(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().withProperty(Properties.StaticProperty, true)); } @Nonnull @Override - public BlockStateContainer createBlockState() { + public void createBlockState() { return new ExtendedBlockState(this, new IProperty[] { Properties.StaticProperty }, new IUnlistedProperty[] { Properties.AnimationProperty } ); } - @Override - public int getMetaFromState(IBlockState state) { - return 0; - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - return getDefaultState(); - } - @Nonnull @Override public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) { @@ -76,7 +65,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi } @Override - public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { + public void onBlockClicked(IBlockState state, World world, BlockPos pos, EntityPlayer player) { if(!world.isRemote) { TileCorporeaCrystalCube cube = (TileCorporeaCrystalCube) world.getTileEntity(pos); cube.doRequest(player.isSneaking()); @@ -90,7 +79,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing s, float xs, float ys, float zs) { + public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, 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); @@ -100,11 +89,6 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi return false; } - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; - } - @Override public boolean isFullCube(IBlockState state) { return false; @@ -112,7 +96,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi @Nonnull @Override - public TileCorporeaBase createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileCorporeaBase createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileCorporeaCrystalCube(); } @@ -133,7 +117,7 @@ public class BlockCorporeaCrystalCube extends BlockCorporeaBase implements ILexi @Nonnull @Override - public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { + public BlockFaceShape getBlockFaceShape(IBlockReader world, IBlockState state, BlockPos pos, EnumFacing side) { return BlockFaceShape.UNDEFINED; } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java index 7a002eb87..03634e61d 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaFunnel.java @@ -18,6 +18,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; @@ -44,32 +45,21 @@ public class BlockCorporeaFunnel extends BlockCorporeaBase implements ILexiconab return new BlockStateContainer(this, BotaniaStateProps.POWERED); } - @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BotaniaStateProps.POWERED) ? 8 : 0; - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - return getDefaultState().withProperty(BotaniaStateProps.POWERED, meta == 8); - } - @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; - boolean powered = state.getValue(BotaniaStateProps.POWERED); + boolean powered = state.get(BotaniaStateProps.POWERED); if(power && !powered) { ((TileCorporeaFunnel) world.getTileEntity(pos)).doRequest(); - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4); + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); } else if(!power && powered) - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4); + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); } @Nonnull @Override - public TileCorporeaBase createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileCorporeaBase createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileCorporeaFunnel(); } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java index b75616c07..a0447ec63 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaIndex.java @@ -17,13 +17,18 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.particle.ParticleDigging; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Particles; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.particles.BlockParticleData; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -41,15 +46,8 @@ import javax.annotation.Nonnull; public class BlockCorporeaIndex extends BlockCorporeaBase implements ILexiconable { - public BlockCorporeaIndex() { - super(Material.IRON, LibBlockNames.CORPOREA_INDEX); - setHardness(5.5F); - setSoundType(SoundType.METAL); - } - - @Override - public boolean isOpaqueCube(IBlockState state) { - return false; + public BlockCorporeaIndex(Block.Builder builder) { + super(builder); } @Override @@ -65,7 +63,7 @@ public class BlockCorporeaIndex extends BlockCorporeaBase implements ILexiconabl @Nonnull @Override - public TileCorporeaBase createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileCorporeaBase createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileCorporeaIndex(); } @@ -83,13 +81,13 @@ public class BlockCorporeaIndex extends BlockCorporeaBase implements ILexiconabl d0 = 2.5D; } int i = (int)(150.0D * d0); - world.spawnParticle(EnumParticleTypes.BLOCK_DUST, entity.posX, entity.posY, entity.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, Block.getStateId(ModBlocks.elementiumBlock.getDefaultState())); + world.spawnParticle(new BlockParticleData(Particles.BLOCK, ModBlocks.elementiumBlock.getDefaultState()), entity.posX, entity.posY, entity.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D); return true; } @Override - @SideOnly(Side.CLIENT) - public boolean addDestroyEffects(World world, BlockPos pos, net.minecraft.client.particle.ParticleManager effectRenderer) + @OnlyIn(Dist.CLIENT) + public boolean addDestroyEffects(IBlockState state, World world, BlockPos pos, net.minecraft.client.particle.ParticleManager effectRenderer) { if (world.getBlockState(pos).getBlock() == this) { int i = 4; @@ -100,7 +98,7 @@ public class BlockCorporeaIndex extends BlockCorporeaBase implements ILexiconabl double d0 = pos.getX() + (j + 0.5D) / i; double d1 = pos.getY() + (k + 0.5D) / i; double d2 = pos.getZ() + (l + 0.5D) / i; - effectRenderer.addEffect(factory.createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, Block.getStateId(ModBlocks.elementiumBlock.getDefaultState()))); + effectRenderer.addEffect(factory.makeParticle(new BlockParticleData(Particles.BLOCK, ModBlocks.elementiumBlock), world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D)); } } } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java index 350c62277..b0951ae09 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaInterceptor.java @@ -10,15 +10,17 @@ */ package vazkii.botania.common.block.corporea; +import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.state.StateContainer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReaderBase; import net.minecraft.world.World; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; @@ -33,33 +35,19 @@ import java.util.Random; public class BlockCorporeaInterceptor extends BlockCorporeaBase implements ILexiconable { - public BlockCorporeaInterceptor() { - super(Material.IRON, LibBlockNames.CORPOREA_INTERCEPTOR); - setHardness(5.5F); - setSoundType(SoundType.METAL); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.POWERED, false)); - } - - @Nonnull - @Override - public BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BotaniaStateProps.POWERED); + public BlockCorporeaInterceptor(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.POWERED, false)); } @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BotaniaStateProps.POWERED) ? 1 : 0; - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - return getDefaultState().withProperty(BotaniaStateProps.POWERED, meta == 1); + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(BotaniaStateProps.POWERED); } @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 1 | 2); + public void randomTick(IBlockState state, World world, BlockPos pos, Random rand) { + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 1 | 2); } @Override @@ -68,18 +56,18 @@ public class BlockCorporeaInterceptor extends BlockCorporeaBase implements ILexi } @Override - public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - return state.getValue(BotaniaStateProps.POWERED) ? 15 : 0; + public int getWeakPower(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing side) { + return state.get(BotaniaStateProps.POWERED) ? 15 : 0; } @Override - public int tickRate(World world) { + public int tickRate(IWorldReaderBase world) { return 2; } @Nonnull @Override - public TileCorporeaBase createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileCorporeaBase createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileCorporeaInterceptor(); } diff --git a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java index 359b5f082..3f9945bf7 100644 --- a/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java +++ b/src/main/java/vazkii/botania/common/block/corporea/BlockCorporeaRetainer.java @@ -17,8 +17,10 @@ import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; @@ -32,40 +34,26 @@ import javax.annotation.Nonnull; public class BlockCorporeaRetainer extends BlockMod implements ILexiconable { - public BlockCorporeaRetainer() { - super(Material.IRON, LibBlockNames.CORPOREA_RETAINER); - setHardness(5.5F); - setSoundType(SoundType.METAL); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.POWERED, false)); - } - - @Nonnull - @Override - public BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BotaniaStateProps.POWERED); + public BlockCorporeaRetainer(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.POWERED, false)); } @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BotaniaStateProps.POWERED) ? 8 : 0; - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - return getDefaultState().withProperty(BotaniaStateProps.POWERED, meta == 8); + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(BotaniaStateProps.POWERED); } @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; - boolean powered = state.getValue(BotaniaStateProps.POWERED); + boolean powered = state.get(BotaniaStateProps.POWERED); if(power && !powered) { ((TileCorporeaRetainer) world.getTileEntity(pos)).fulfilRequest(); - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4); + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); } else if(!power && powered) - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4); + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); } @Override @@ -85,7 +73,7 @@ public class BlockCorporeaRetainer extends BlockMod implements ILexiconable { @Nonnull @Override - public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileEntity createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileCorporeaRetainer(); } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java index ddc3a4336..034629f2e 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourCocoaBeans.java @@ -12,15 +12,11 @@ package vazkii.botania.common.block.dispenser; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; -import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.BlockOldLog; -import net.minecraft.block.BlockPlanks; import net.minecraft.block.state.IBlockState; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; -import net.minecraft.dispenser.IBehaviorDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.init.Blocks; -import net.minecraft.item.EnumDyeColor; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -29,31 +25,22 @@ import net.minecraft.world.World; import javax.annotation.Nonnull; public class BehaviourCocoaBeans extends BehaviorDefaultDispenseItem { - - IBehaviorDispenseItem vanillaBehaviour; - public BehaviourCocoaBeans(IBehaviorDispenseItem vanilla) { - vanillaBehaviour = vanilla; - } - @Nonnull @Override - public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - if(par2ItemStack.getItemDamage() == EnumDyeColor.BROWN.getDyeDamage()) { - Block block = Blocks.COCOA; - EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING); - BlockPos pos = par1IBlockSource.getBlockPos().offset(facing); - World world = par1IBlockSource.getWorld(); + public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { + Block block = Blocks.COCOA; + EnumFacing facing = source.getBlockState().get(BlockDispenser.FACING); + BlockPos pos = source.getBlockPos().offset(facing); + World world = source.getWorld(); - BlockPos logPos = pos.offset(facing); - 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.shrink(1); - return par2ItemStack; - } + IBlockState cocoa = block.getStateForPlacement(new BlockItemUseContext(world, null, ItemStack.EMPTY, pos, facing.getOpposite(), 0, 0, 0)); + if(cocoa != null && world.isAirBlock(pos)) { + world.setBlockState(pos, cocoa); + stack.shrink(1); + return stack; } - return vanillaBehaviour.dispense(par1IBlockSource, par2ItemStack); + return stack; } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java index 26595cdb9..0313874bb 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourFelPumpkin.java @@ -2,11 +2,10 @@ package vazkii.botania.common.block.dispenser; import net.minecraft.block.Block; import net.minecraft.block.BlockDispenser; -import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.init.Blocks; +import net.minecraft.init.Bootstrap; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import vazkii.botania.common.block.ModBlocks; @@ -14,46 +13,24 @@ import vazkii.botania.common.block.ModBlocks; import javax.annotation.Nonnull; // Taken from vanilla pumpkin dispense behaviour -public class BehaviourFelPumpkin extends BehaviorDefaultDispenseItem { - private boolean field_179241_b = true; - +public class BehaviourFelPumpkin extends Bootstrap.BehaviorDispenseOptional { @Nonnull @Override - protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) - { + protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); - EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING); - BlockPos blockpos = source.getBlockPos().offset(facing); - Block blockpumpkin = ModBlocks.felPumpkin; - + BlockPos blockpos = source.getBlockPos().offset(source.getBlockState().get(BlockDispenser.FACING)); + Block blockcarvedpumpkin = ModBlocks.felPumpkin; + this.successful = true; if (world.isAirBlock(blockpos) && world.getBlockState(blockpos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(blockpos.down(2)).getBlock() == Blocks.IRON_BARS) // Botania - Check for iron bars { - if (!world.isRemote) - { - world.setBlockState(blockpos, blockpumpkin.getDefaultState(), 3); + if (!world.isRemote) { + world.setBlockState(blockpos, blockcarvedpumpkin.getDefaultState(), 3); } stack.shrink(1); } - else - { - field_179241_b = false; - } return stack; } - - @Override - protected void playDispenseSound(IBlockSource source) - { - if (field_179241_b) - { - source.getWorld().playEvent(1000, source.getBlockPos(), 0); - } - else - { - source.getWorld().playEvent(1001, source.getBlockPos(), 0); - } - } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java index 15bbbcebb..2abfae5ed 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourPoolMinecart.java @@ -17,7 +17,10 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.item.ItemMinecart; import net.minecraft.item.ItemStack; +import net.minecraft.state.properties.RailShape; +import net.minecraft.tags.BlockTags; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -25,36 +28,49 @@ import vazkii.botania.common.entity.EntityPoolMinecart; import javax.annotation.Nonnull; +// [VanillaCopy] ItemMinecart public class BehaviourPoolMinecart extends BehaviorDefaultDispenseItem { + private final BehaviorDefaultDispenseItem behaviourDefaultDispenseItem = new BehaviorDefaultDispenseItem(); @Nonnull @Override public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { + EnumFacing enumfacing = source.getBlockState().get(BlockDispenser.FACING); World world = source.getWorld(); - EnumFacing enumfacing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING); - double d0 = source.getX() + enumfacing.getXOffset() * 1.125F; - double d1 = source.getY() + enumfacing.getYOffset() * 1.125F; - double d2 = source.getZ() + enumfacing.getZOffset() * 1.125F; - BlockPos pos = source.getBlockPos().offset(enumfacing); - IBlockState state = world.getBlockState(pos); + double d0 = source.getX() + (double)enumfacing.getXOffset() * 1.125D; + double d1 = Math.floor(source.getY()) + (double)enumfacing.getYOffset(); + double d2 = source.getZ() + (double)enumfacing.getZOffset() * 1.125D; + BlockPos blockpos = source.getBlockPos().offset(enumfacing); + IBlockState iblockstate = world.getBlockState(blockpos); + RailShape railshape = iblockstate.getBlock() instanceof BlockRailBase ? ((BlockRailBase)iblockstate.getBlock()).getRailDirection(iblockstate, world, blockpos, null) : RailShape.NORTH_SOUTH; double d3; + if (iblockstate.isIn(BlockTags.RAILS)) { + if (railshape.isAscending()) { + d3 = 0.6D; + } else { + d3 = 0.1D; + } + } else { + if (!iblockstate.isAir() || !world.getBlockState(blockpos.down()).isIn(BlockTags.RAILS)) { + return this.behaviourDefaultDispenseItem.dispense(source, stack); + } - if(BlockRailBase.isRailBlock(state)) - d3 = 0.0D; - else { - if(state.getMaterial() != Material.AIR || !BlockRailBase.isRailBlock(world.getBlockState(pos.down()))) - return super.dispenseStack(source, stack); - - d3 = -1.0D; + IBlockState iblockstate1 = world.getBlockState(blockpos.down()); + RailShape railshape1 = iblockstate1.getBlock() instanceof BlockRailBase ? ((BlockRailBase)iblockstate1.getBlock()).getRailDirection(iblockstate1, world, blockpos, null) : RailShape.NORTH_SOUTH; + if (enumfacing != EnumFacing.DOWN && railshape1.isAscending()) { + d3 = -0.4D; + } else { + d3 = -0.9D; + } } EntityMinecart entityminecart = new EntityPoolMinecart(world, d0, d1 + d3, d2); - - if(stack.hasDisplayName()) - entityminecart.setCustomNameTag(stack.getDisplayName()); + if (stack.hasDisplayName()) { + entityminecart.setCustomName(stack.getDisplayName()); + } world.spawnEntity(entityminecart); - stack.splitStack(1); + stack.shrink(1); return stack; } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java index aa528f88f..f16dba79a 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourSeeds.java @@ -22,8 +22,7 @@ import net.minecraft.world.World; import javax.annotation.Nonnull; public class BehaviourSeeds extends BehaviorDefaultDispenseItem { - - Block block; + private Block block; public BehaviourSeeds(Block block) { this.block = block; @@ -32,7 +31,7 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem { @Nonnull @Override public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { - EnumFacing facing = par1IBlockSource.getBlockState().getValue(BlockDispenser.FACING); + EnumFacing facing = par1IBlockSource.getBlockState().get(BlockDispenser.FACING); BlockPos pos = par1IBlockSource.getBlockPos().offset(facing); World world = par1IBlockSource.getWorld(); diff --git a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java index c96deaa09..fa30df540 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/BehaviourWand.java @@ -26,17 +26,17 @@ public class BehaviourWand extends BehaviorDefaultDispenseItem { @Nonnull @Override - protected ItemStack dispenseStack(IBlockSource source, ItemStack par2ItemStack) { + protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { World world = source.getWorld(); - EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING); + EnumFacing facing = world.getBlockState(source.getBlockPos()).get(BlockDispenser.FACING); BlockPos pos = source.getBlockPos().offset(facing); Block block = world.getBlockState(pos).getBlock(); if(block instanceof IWandable) { - ((IWandable) block).onUsedByWand(null, par2ItemStack, world, pos, facing.getOpposite()); - return par2ItemStack; + ((IWandable) block).onUsedByWand(null, stack, world, pos, facing.getOpposite()); + return stack; } - return super.dispenseStack(source, par2ItemStack); + return super.dispenseStack(source, stack); } } diff --git a/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java b/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java index 5cc126550..3397311d3 100644 --- a/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java +++ b/src/main/java/vazkii/botania/common/block/dispenser/SeedBehaviours.java @@ -21,16 +21,16 @@ public class SeedBehaviours { // Quark's own feature disables itself if Botania is present public static void init() { - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.WHEAT_SEEDS, new BehaviourSeeds(Blocks.WHEAT)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.POTATO, new BehaviourSeeds(Blocks.POTATOES)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.CARROT, new BehaviourSeeds(Blocks.CARROTS)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.NETHER_WART, new BehaviourSeeds(Blocks.NETHER_WART)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.PUMPKIN_SEEDS, new BehaviourSeeds(Blocks.PUMPKIN_STEM)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.MELON_SEEDS, new BehaviourSeeds(Blocks.MELON_STEM)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.BEETROOT_SEEDS, new BehaviourSeeds(Blocks.BEETROOTS)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Item.getItemFromBlock(Blocks.CHORUS_FLOWER), new BehaviourSeeds(Blocks.CHORUS_FLOWER)); + BlockDispenser.registerDispenseBehavior(Items.WHEAT_SEEDS, new BehaviourSeeds(Blocks.WHEAT)); + BlockDispenser.registerDispenseBehavior(Items.POTATO, new BehaviourSeeds(Blocks.POTATOES)); + BlockDispenser.registerDispenseBehavior(Items.CARROT, new BehaviourSeeds(Blocks.CARROTS)); + BlockDispenser.registerDispenseBehavior(Items.NETHER_WART, new BehaviourSeeds(Blocks.NETHER_WART)); + BlockDispenser.registerDispenseBehavior(Items.PUMPKIN_SEEDS, new BehaviourSeeds(Blocks.PUMPKIN_STEM)); + BlockDispenser.registerDispenseBehavior(Items.MELON_SEEDS, new BehaviourSeeds(Blocks.MELON_STEM)); + BlockDispenser.registerDispenseBehavior(Items.BEETROOT_SEEDS, new BehaviourSeeds(Blocks.BEETROOTS)); + BlockDispenser.registerDispenseBehavior(Blocks.CHORUS_FLOWER, new BehaviourSeeds(Blocks.CHORUS_FLOWER)); - BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.DYE, new BehaviourCocoaBeans(BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.getObject(Items.DYE))); + BlockDispenser.registerDispenseBehavior(Items.COCOA_BEANS, new BehaviourCocoaBeans(BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.getObject(Items.DYE))); } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java index b58eabde8..d5f3c2d51 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedString.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedString.java @@ -10,18 +10,18 @@ */ package vazkii.botania.common.block.string; +import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; +import net.minecraft.state.StateContainer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.state.BotaniaStateProps; @@ -33,34 +33,18 @@ import javax.annotation.Nonnull; public abstract class BlockRedString extends BlockMod implements ILexiconable { - public BlockRedString(String name) { - super(Material.ROCK, name); - setHardness(2.0F); - setResistance(10.0F); - setSoundType(SoundType.STONE); - } - - @Nonnull - @Override - public BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BotaniaStateProps.FACING); + public BlockRedString(Block.Builder builder) { + super(builder); } @Override - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { - EnumFacing orientation = EnumFacing.getDirectionFromEntityLiving(pos, par5EntityLivingBase); - world.setBlockState(pos, state.withProperty(BotaniaStateProps.FACING, orientation), 1 | 2); + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(BotaniaStateProps.FACING); } @Override - public int getMetaFromState(IBlockState state) { - return state.getValue(BotaniaStateProps.FACING).getIndex(); - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - return getDefaultState().withProperty(BotaniaStateProps.FACING, EnumFacing.byIndex(meta)); + public IBlockState getStateForPlacement(BlockItemUseContext context) { + return getDefaultState().with(BotaniaStateProps.FACING, context.getNearestLookingDirection()); } @Override @@ -73,10 +57,4 @@ public abstract class BlockRedString extends BlockMod implements ILexiconable { return LexiconData.redString; } - @SideOnly(Side.CLIENT) - @Override - public void registerModels() { - ModelHandler.registerBlockToState(this, 0, getDefaultState().withProperty(BotaniaStateProps.FACING, EnumFacing.NORTH)); - } - } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java index 788b77f3d..ec7fb1428 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringComparator.java @@ -10,9 +10,11 @@ */ package vazkii.botania.common.block.string; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; @@ -23,9 +25,9 @@ import javax.annotation.Nonnull; public class BlockRedStringComparator extends BlockRedString { - public BlockRedStringComparator() { - super(LibBlockNames.RED_STRING_COMPARATOR); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.FACING, EnumFacing.DOWN)); + public BlockRedStringComparator(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.FACING, EnumFacing.DOWN)); } @Override @@ -40,7 +42,7 @@ public class BlockRedStringComparator extends BlockRedString { @Nonnull @Override - public TileRedString createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileRedString createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileRedStringComparator(); } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java index 2985f172f..7d0de4584 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringContainer.java @@ -10,8 +10,10 @@ */ package vazkii.botania.common.block.string; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; @@ -22,14 +24,14 @@ import javax.annotation.Nonnull; public class BlockRedStringContainer extends BlockRedString { - public BlockRedStringContainer() { - super(LibBlockNames.RED_STRING_CONTAINER); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.FACING, EnumFacing.DOWN)); + public BlockRedStringContainer(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.FACING, EnumFacing.DOWN)); } @Nonnull @Override - public TileRedString createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileRedString createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileRedStringContainer(); } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java index 1d5b7a9af..7814b0a10 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringDispenser.java @@ -11,15 +11,13 @@ package vazkii.botania.common.block.string; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.statemap.StateMap; +import net.minecraft.state.StateContainer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringDispenser; @@ -29,60 +27,32 @@ import javax.annotation.Nonnull; public class BlockRedStringDispenser extends BlockRedString { - public BlockRedStringDispenser() { - super(LibBlockNames.RED_STRING_DISPENSER); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.FACING, EnumFacing.DOWN).withProperty(BotaniaStateProps.POWERED, false)); - } - - @Nonnull - @Override - public BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BotaniaStateProps.FACING, BotaniaStateProps.POWERED); + public BlockRedStringDispenser(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.FACING, EnumFacing.DOWN).with(BotaniaStateProps.POWERED, false)); } @Override - public int getMetaFromState(IBlockState state) { - int meta = state.getValue(BotaniaStateProps.FACING).getIndex(); - if (state.getValue(BotaniaStateProps.POWERED)) { - meta |= 8; - } else { - meta &= -9; - } - return meta; - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - boolean powered = (meta & 8) != 0; - meta &= -9; - EnumFacing facing = EnumFacing.byIndex(meta); - return getDefaultState().withProperty(BotaniaStateProps.FACING, facing).withProperty(BotaniaStateProps.POWERED, powered); + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(BotaniaStateProps.POWERED); } @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos fromPos) { boolean power = world.getRedstonePowerFromNeighbors(pos) > 0 || world.getRedstonePowerFromNeighbors(pos.up()) > 0; - boolean powered = state.getValue(BotaniaStateProps.POWERED); + boolean powered = state.get(BotaniaStateProps.POWERED); if(power && !powered) { ((TileRedStringDispenser) world.getTileEntity(pos)).tickDispenser(); - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, true), 4); + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, true), 4); } else if(!power && powered) - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 4); + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 4); } @Nonnull @Override - public TileRedString createTileEntity(@Nonnull World world, @Nonnull IBlockState meta) { + public TileRedString createTileEntity(@Nonnull IBlockState meta, IBlockReader world) { return new TileRedStringDispenser(); } - - @SideOnly(Side.CLIENT) - @Override - public void registerModels() { - ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(BotaniaStateProps.POWERED).build()); - super.registerModels(); - } - } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java index 0a2f02add..6a734a6c0 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringFertilizer.java @@ -10,10 +10,12 @@ */ package vazkii.botania.common.block.string; +import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; @@ -25,13 +27,13 @@ import java.util.Random; public class BlockRedStringFertilizer extends BlockRedString implements IGrowable { - public BlockRedStringFertilizer() { - super(LibBlockNames.RED_STRING_FERTILIZER); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.FACING, EnumFacing.DOWN)); + public BlockRedStringFertilizer(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.FACING, EnumFacing.DOWN)); } @Override - public boolean canGrow(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean isClient) { + public boolean canGrow(@Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean isClient) { return ((TileRedStringFertilizer) world.getTileEntity(pos)).canGrow(world, isClient); } @@ -47,7 +49,7 @@ public class BlockRedStringFertilizer extends BlockRedString implements IGrowabl @Nonnull @Override - public TileRedString createTileEntity(@Nonnull World world, @Nonnull IBlockState meta) { + public TileRedString createTileEntity(@Nonnull IBlockState meta, @Nonnull IBlockReader world) { return new TileRedStringFertilizer(); } } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java index a291a7cc8..6e181b6c2 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringInterceptor.java @@ -10,24 +10,21 @@ */ package vazkii.botania.common.block.string; -import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.statemap.StateMap; +import net.minecraft.state.StateContainer; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReaderBase; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; import vazkii.botania.common.block.tile.string.TileRedStringInterceptor; -import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; @@ -36,35 +33,15 @@ import java.util.Random; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class BlockRedStringInterceptor extends BlockRedString { - public BlockRedStringInterceptor() { - super(LibBlockNames.RED_STRING_INTERCEPTOR); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.FACING, EnumFacing.DOWN).withProperty(BotaniaStateProps.POWERED, false)); - } - - @Nonnull - @Override - public BlockStateContainer createBlockState() { - return new BlockStateContainer(this, BotaniaStateProps.FACING, BotaniaStateProps.POWERED); + public BlockRedStringInterceptor(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.FACING, EnumFacing.DOWN).with(BotaniaStateProps.POWERED, false)); } @Override - public int getMetaFromState(IBlockState state) { - int meta = state.getValue(BotaniaStateProps.FACING).getIndex(); - if (state.getValue(BotaniaStateProps.POWERED)) { - meta |= 8; - } else { - meta &= -9; - } - return meta; - } - - @Nonnull - @Override - public IBlockState getStateFromMeta(int meta) { - boolean powered = (meta & 8) != 0; - meta &= -9; - EnumFacing facing = EnumFacing.byIndex(meta); - return getDefaultState().withProperty(BotaniaStateProps.FACING, facing).withProperty(BotaniaStateProps.POWERED, powered); + protected void fillStateContainer(StateContainer.Builder builder) { + super.fillStateContainer(builder); + builder.add(BotaniaStateProps.POWERED); } @SubscribeEvent @@ -78,31 +55,23 @@ public class BlockRedStringInterceptor extends BlockRedString { } @Override - public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - return state.getValue(BotaniaStateProps.POWERED) ? 15 : 0; + public int getWeakPower(IBlockState state, IBlockReader world, BlockPos pos, EnumFacing side) { + return state.get(BotaniaStateProps.POWERED) ? 15 : 0; } @Override - public void updateTick(World world, BlockPos pos, IBlockState state, Random update) { - world.setBlockState(pos, state.withProperty(BotaniaStateProps.POWERED, false), 1 | 2); + public void tick(IBlockState state, World world, BlockPos pos, Random update) { + world.setBlockState(pos, state.with(BotaniaStateProps.POWERED, false), 1 | 2); } @Override - public int tickRate(World world) { + public int tickRate(IWorldReaderBase world) { return 2; } @Nonnull @Override - public TileRedString createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileRedString createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileRedStringInterceptor(); } - - @SideOnly(Side.CLIENT) - @Override - public void registerModels() { - ModelLoader.setCustomStateMapper(this, new StateMap.Builder().ignore(BotaniaStateProps.POWERED).build()); - super.registerModels(); - } - } diff --git a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java index 3c8353bcb..a2123b01c 100644 --- a/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java +++ b/src/main/java/vazkii/botania/common/block/string/BlockRedStringRelay.java @@ -10,8 +10,10 @@ */ package vazkii.botania.common.block.string; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import vazkii.botania.api.state.BotaniaStateProps; import vazkii.botania.common.block.tile.string.TileRedString; @@ -22,14 +24,14 @@ import javax.annotation.Nonnull; public class BlockRedStringRelay extends BlockRedString { - public BlockRedStringRelay() { - super(LibBlockNames.RED_STRING_RELAY); - setDefaultState(blockState.getBaseState().withProperty(BotaniaStateProps.FACING, EnumFacing.DOWN)); + public BlockRedStringRelay(Block.Builder builder) { + super(builder); + setDefaultState(stateContainer.getBaseState().with(BotaniaStateProps.FACING, EnumFacing.DOWN)); } @Nonnull @Override - public TileRedString createTileEntity(@Nonnull World world, @Nonnull IBlockState state) { + public TileRedString createTileEntity(@Nonnull IBlockState state, @Nonnull IBlockReader world) { return new TileRedStringRelay(); } diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java index d4ba4c1d8..7a1b3ce65 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTileManastar.java @@ -35,7 +35,7 @@ public class SubTileManastar extends SubTileEntity { Botania.proxy.wispFX(supertile.getPos().getX() + 0.55 + Math.random() * 0.2 - 0.1, supertile.getPos().getY() + 0.75 + Math.random() * 0.2 - 0.1, supertile.getPos().getZ() + 0.5, state == INCREASING ? 0.05F : 1F, 0.05F, state == INCREASING ? 1F : 0.05F, (float) Math.random() / 7, (float) -Math.random() / 50); } else { int mana = 0; - for(EnumFacing dir : EnumFacing.HORIZONTALS) { + for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) { BlockPos pos = supertile.getPos().offset(dir); if(getWorld().isBlockLoaded(pos)) { TileEntity tile = supertile.getWorld().getTileEntity(pos); @@ -46,7 +46,7 @@ public class SubTileManastar extends SubTileEntity { int newState = mana > lastMana ? INCREASING : mana < lastMana ? DECREASING : NONE; if(newState != state) - getWorld().addBlockEvent(getPos(), supertile.getBlockType(), SET_STATE_EVENT, newState); + getWorld().addBlockEvent(getPos(), supertile.getBlockState().getBlock(), SET_STATE_EVENT, newState); if(ticksExisted % 60 == 0) lastMana = mana; diff --git a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java index a2c7bace8..b3e4c648f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java +++ b/src/main/java/vazkii/botania/common/block/subtile/SubTilePureDaisy.java @@ -90,7 +90,7 @@ public class SubTilePureDaisy extends SubTileEntity { ticksRemaining[positionAt] = -1; if(recipe.set(world,coords, this)) { - world.addBlockEvent(getPos(), supertile.getBlockType(), RECIPE_COMPLETE_EVENT, positionAt); + world.addBlockEvent(getPos(), supertile.getBlockState().getBlock(), RECIPE_COMPLETE_EVENT, positionAt); if(ConfigHandler.blockBreakParticles) supertile.getWorld().playEvent(2001, coords, Block.getStateId(recipe.getOutputState())); } @@ -110,7 +110,7 @@ public class SubTilePureDaisy extends SubTileEntity { } if (newActivePositions != activePositions) { - getWorld().addBlockEvent(getPos(), supertile.getBlockType(), UPDATE_ACTIVE_EVENT, newActivePositions); + getWorld().addBlockEvent(getPos(), supertile.getBlockState().getBlock(), UPDATE_ACTIVE_EVENT, newActivePositions); } } @@ -155,18 +155,18 @@ public class SubTilePureDaisy extends SubTileEntity { @Override public void readFromPacketNBT(NBTTagCompound cmp) { - positionAt = cmp.getInteger(TAG_POSITION); + positionAt = cmp.getInt(TAG_POSITION); if(supertile.getWorld() != null && !supertile.getWorld().isRemote) for(int i = 0; i < ticksRemaining.length; i++) - ticksRemaining[i] = cmp.getInteger(TAG_TICKS_REMAINING + i); + ticksRemaining[i] = cmp.getInt(TAG_TICKS_REMAINING + i); } @Override public void writeToPacketNBT(NBTTagCompound cmp) { - cmp.setInteger(TAG_POSITION, positionAt); + cmp.setInt(TAG_POSITION, positionAt); for(int i = 0; i < ticksRemaining.length; i++) - cmp.setInteger(TAG_TICKS_REMAINING + i, ticksRemaining[i]); + cmp.setInt(TAG_TICKS_REMAINING + i, ticksRemaining[i]); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java b/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java index ab81b27dd..b82735267 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/BergamuteEventHandler.java @@ -8,12 +8,12 @@ import net.minecraft.client.audio.SoundEventAccessor; import net.minecraft.client.audio.SoundHandler; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.sound.PlaySoundEvent; +import net.minecraftforge.eventbus.api.EventPriority; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.botania.common.lib.LibMisc; @@ -23,7 +23,7 @@ import javax.annotation.Nullable; import java.awt.Color; import java.util.Random; -@Mod.EventBusSubscriber(value = Side.CLIENT, modid = LibMisc.MOD_ID) +@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID) public class BergamuteEventHandler { private BergamuteEventHandler() {} @@ -39,7 +39,7 @@ public class BergamuteEventHandler { if(sound instanceof ITickableSound) { evt.setResultSound(new WrappedTickableSound((ITickableSound) sound, MULTIPLIER)); } else { - SubTileBergamute berg = SubTileBergamute.getBergamuteNearby(sound.getXPosF(), sound.getYPosF(), sound.getZPosF()); + SubTileBergamute berg = SubTileBergamute.getBergamuteNearby(sound.getX(), sound.getY(), sound.getZ()); if (berg != null) { evt.setResultSound(new WrappedSound(sound, MULTIPLIER)); @@ -59,7 +59,7 @@ public class BergamuteEventHandler { && sound.getClass().getName().startsWith("net.minecraft.client.audio"); } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) private static class WrappedSound implements ISound { private final ISound compose; @@ -74,7 +74,7 @@ public class BergamuteEventHandler { @Override public float getVolume() { - float mult = recheck && SubTileBergamute.getBergamuteNearby(getXPosF(), getYPosF(), getZPosF()) == null ? 1F : volMult; + float mult = recheck && SubTileBergamute.getBergamuteNearby(getX(), getY(), getZ()) == null ? 1F : volMult; return compose.getVolume() * mult; } @@ -83,15 +83,17 @@ public class BergamuteEventHandler { @Nonnull @Override public Sound getSound() { return compose.getSound(); } @Nonnull @Override public SoundCategory getCategory() { return compose.getCategory(); } @Override public boolean canRepeat() { return compose.canRepeat(); } + @Override public boolean isPriority() { return compose.isPriority(); } + @Override public int getRepeatDelay() { return compose.getRepeatDelay(); } @Override public float getPitch() { return compose.getPitch(); } - @Override public float getXPosF() { return compose.getXPosF(); } - @Override public float getYPosF() { return compose.getYPosF(); } - @Override public float getZPosF() { return compose.getZPosF(); } + @Override public float getX() { return compose.getX(); } + @Override public float getY() { return compose.getY(); } + @Override public float getZ() { return compose.getZ(); } @Nonnull @Override public AttenuationType getAttenuationType() { return compose.getAttenuationType(); } } - @SideOnly(Side.CLIENT) + @OnlyIn(Dist.CLIENT) private static class WrappedTickableSound extends WrappedSound implements ITickableSound { private final ITickableSound compose; @@ -102,6 +104,7 @@ public class BergamuteEventHandler { } @Override public boolean isDonePlaying() { return compose.isDonePlaying(); } - @Override public void update() { compose.update(); } + @Override public void tick() { compose.tick(); } + @Override public boolean isPriority() { return compose.isPriority(); } } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java index 98262e99d..fb28eff9c 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileArcaneRose.java @@ -43,7 +43,7 @@ public class SubTileArcaneRose extends SubTileGenerating { List orbs = supertile.getWorld().getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1))); for(EntityXPOrb orb : orbs) { mana += orb.getXpValue() * 35; - orb.setDead(); + orb.remove(); return; } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java index 3b86d437d..024375aaf 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileDandelifeon.java @@ -170,7 +170,7 @@ public class SubTileDandelifeon extends SubTileGenerating { //world.setBlockToAir(x, y, z); } else if(blockAt == ModBlocks.cellBlock) { if(gen < 0) - world.setBlockToAir(pos); + world.removeBlock(pos); else ((TileCell) tile).setGeneration(supertile, gen); } else if(gen >= 0 && blockAt.isAir(stateAt, supertile.getWorld(), pos)) { world.setBlockState(pos, ModBlocks.cellBlock.getDefaultState()); diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java index 93fcb98dd..de7cd13f2 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEndoflame.java @@ -13,11 +13,11 @@ package vazkii.botania.common.block.subtile.generating; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Particles; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; @@ -47,7 +47,7 @@ public class SubTileEndoflame extends SubTileGenerating { if(getWorld().isRemote) { if(burnTime > 0 && supertile.getWorld().rand.nextInt(10) == 0) { Vec3d offset = getWorld().getBlockState(getPos()).getOffset(getWorld(), getPos()).add(0.4, 0.7, 0.4); - supertile.getWorld().spawnParticle(EnumParticleTypes.FLAME, supertile.getPos().getX() + offset.x + Math.random() * 0.2, supertile.getPos().getY() + offset.y, supertile.getPos().getZ() + offset.z + Math.random() * 0.2, 0.0D, 0.0D, 0.0D); + supertile.getWorld().spawnParticle(Particles.FLAME, supertile.getPos().getX() + offset.x + Math.random() * 0.2, supertile.getPos().getY() + offset.y, supertile.getPos().getZ() + offset.z + Math.random() * 0.2, 0.0D, 0.0D, 0.0D); } return; } @@ -58,7 +58,7 @@ public class SubTileEndoflame extends SubTileGenerating { int slowdown = getSlowdownFactor(); for(EntityItem item : supertile.getWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)))) { - if(item.age >= 59 + slowdown && !item.isDead) { + if(item.age >= 59 + slowdown && !item.removed) { ItemStack stack = item.getItem(); if(stack.isEmpty() || stack.getItem().hasContainerItem(stack)) continue; @@ -86,8 +86,8 @@ public class SubTileEndoflame extends SubTileGenerating { if(event == START_BURN_EVENT) { Entity e = getWorld().getEntityByID(param); if(e != null) { - e.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, e.posX, e.posY + 0.1, e.posZ, 0.0D, 0.0D, 0.0D); - e.world.spawnParticle(EnumParticleTypes.FLAME, e.posX, e.posY, e.posZ, 0.0D, 0.0D, 0.0D); + e.world.spawnParticle(Particles.LARGE_SMOKE, e.posX, e.posY + 0.1, e.posZ, 0.0D, 0.0D, 0.0D); + e.world.spawnParticle(Particles.FLAME, e.posX, e.posY, e.posZ, 0.0D, 0.0D, 0.0D); } return true; } else { @@ -124,14 +124,14 @@ public class SubTileEndoflame extends SubTileGenerating { public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_BURN_TIME, burnTime); + cmp.setInt(TAG_BURN_TIME, burnTime); } @Override public void readFromPacketNBT(NBTTagCompound cmp) { super.readFromPacketNBT(cmp); - burnTime = cmp.getInteger(TAG_BURN_TIME); + burnTime = cmp.getInt(TAG_BURN_TIME); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java index 7bf2237d3..e96b57b6f 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileEntropinnyum.java @@ -12,8 +12,8 @@ package vazkii.botania.common.block.subtile.generating; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.init.Particles; import net.minecraft.init.SoundEvents; -import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import vazkii.botania.api.lexicon.LexiconEntry; @@ -38,13 +38,13 @@ public class SubTileEntropinnyum extends SubTileGenerating { if(!supertile.getWorld().isRemote && mana == 0) { List tnts = supertile.getWorld().getEntitiesWithinAABB(EntityTNTPrimed.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1))); for(EntityTNTPrimed tnt : tnts) { - if(tnt.getFuse() == 1 && !tnt.isDead && !supertile.getWorld().getBlockState(new BlockPos(tnt)).getMaterial().isLiquid()) { + if(tnt.getFuse() == 1 && !tnt.removed && !supertile.getWorld().getBlockState(new BlockPos(tnt)).getMaterial().isLiquid()) { tnt.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 0.2F, (1F + (supertile.getWorld().rand.nextFloat() - supertile.getWorld().rand.nextFloat()) * 0.2F) * 0.7F); - tnt.setDead(); + tnt.remove(); mana += getMaxMana(); sync(); - getWorld().addBlockEvent(getPos(), supertile.getBlockType(), EXPLODE_EFFECT_EVENT, tnt.getEntityId()); + getWorld().addBlockEvent(getPos(), supertile.getBlockState().getBlock(), EXPLODE_EFFECT_EVENT, tnt.getEntityId()); break; } } @@ -60,7 +60,7 @@ public class SubTileEntropinnyum extends SubTileGenerating { for(int i = 0; i < 50; i++) Botania.proxy.sparkleFX(e.posX + Math.random() * 4 - 2, e.posY + Math.random() * 4 - 2, e.posZ + Math.random() * 4 - 2, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, (float) (Math.random() * 0.65F + 1.25F), 12); - getWorld().spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, e.posX, e.posY, e.posZ, 1D, 0D, 0D); + getWorld().spawnParticle(Particles.EXPLOSION_EMITTER, e.posX, e.posY, e.posZ, 1D, 0D, 0D); } return true; } else { diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java index 8cc6fa666..7dac681c0 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileGourmaryllis.java @@ -11,11 +11,13 @@ package vazkii.botania.common.block.subtile.generating; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Particles; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.particles.ItemParticleData; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; @@ -66,7 +68,7 @@ public class SubTileGourmaryllis extends SubTileGenerating { Vec3d offset = getWorld().getBlockState(getPos()).getOffset(getWorld(), getPos()).add(0.4, 0.6, 0.4); - ((WorldServer) supertile.getWorld()).spawnParticle(EnumParticleTypes.ITEM_CRACK, supertile.getPos().getX()+offset.x, supertile.getPos().getY()+offset.y, supertile.getPos().getZ()+offset.z, 10, 0.1D, 0.1D, 0.1D, 0.03D, Item.getIdFromItem(lastFood.getItem()), lastFood.getItemDamage()); + ((WorldServer) supertile.getWorld()).spawnParticle(new ItemParticleData(Particles.ITEM, lastFood), supertile.getPos().getX()+offset.x, supertile.getPos().getY()+offset.y, supertile.getPos().getZ()+offset.z, 10, 0.1D, 0.1D, 0.1D, 0.03D); } } @@ -77,7 +79,7 @@ public class SubTileGourmaryllis extends SubTileGenerating { for(EntityItem item : items) { ItemStack stack = item.getItem(); - if(!stack.isEmpty() && stack.getItem() instanceof ItemFood && !item.isDead && item.age >= slowdown) { + if(!stack.isEmpty() && stack.getItem() instanceof ItemFood && !item.removed && item.age >= slowdown) { if(cooldown <= 0) { if(ItemHandlerHelper.canItemStacksStack(lastFood, stack)) { lastFoodCount++; @@ -93,10 +95,10 @@ public class SubTileGourmaryllis extends SubTileGenerating { cooldown = val * 10; item.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.2F, 0.6F); sync(); - ((WorldServer) supertile.getWorld()).spawnParticle(EnumParticleTypes.ITEM_CRACK, false, item.posX, item.posY, item.posZ, 20, 0.1D, 0.1D, 0.1D, 0.05D, Item.getIdFromItem(stack.getItem()), stack.getItemDamage()); + ((WorldServer) supertile.getWorld()).spawnParticle(new ItemParticleData(Particles.ITEM, stack), false, item.posX, item.posY, item.posZ, 20, 0.1D, 0.1D, 0.1D, 0.05D); } - item.setDead(); + item.remove(); } } } @@ -104,19 +106,19 @@ public class SubTileGourmaryllis extends SubTileGenerating { @Override public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_COOLDOWN, cooldown); - cmp.setInteger(TAG_DIGESTING_MANA, digestingMana); - cmp.setTag(TAG_LAST_FOOD, lastFood.writeToNBT(new NBTTagCompound())); - cmp.setInteger(TAG_LAST_FOOD_COUNT, lastFoodCount); + cmp.setInt(TAG_COOLDOWN, cooldown); + cmp.setInt(TAG_DIGESTING_MANA, digestingMana); + cmp.setTag(TAG_LAST_FOOD, lastFood.write(new NBTTagCompound())); + cmp.setInt(TAG_LAST_FOOD_COUNT, lastFoodCount); } @Override public void readFromPacketNBT(NBTTagCompound cmp) { super.readFromPacketNBT(cmp); - cooldown = cmp.getInteger(TAG_COOLDOWN); - digestingMana = cmp.getInteger(TAG_DIGESTING_MANA); - lastFood = new ItemStack(cmp.getCompoundTag(TAG_LAST_FOOD)); - lastFoodCount = cmp.getInteger(TAG_LAST_FOOD_COUNT); + cooldown = cmp.getInt(TAG_COOLDOWN); + digestingMana = cmp.getInt(TAG_DIGESTING_MANA); + lastFood = ItemStack.read(cmp.getCompound(TAG_LAST_FOOD)); + lastFoodCount = cmp.getInt(TAG_LAST_FOOD_COUNT); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java index 29ad75ab9..60203762d 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileKekimurus.java @@ -42,10 +42,10 @@ public class SubTileKekimurus extends SubTileGenerating { IBlockState state = supertile.getWorld().getBlockState(pos); Block block = state.getBlock(); if(block instanceof BlockCake) { - int nextSlicesEaten = state.getValue(BlockCake.BITES) + 1; + int nextSlicesEaten = state.get(BlockCake.BITES) + 1; if(nextSlicesEaten > 6) - supertile.getWorld().setBlockToAir(pos); - else supertile.getWorld().setBlockState(pos, state.withProperty(BlockCake.BITES, nextSlicesEaten), 1 | 2); + supertile.getWorld().removeBlock(pos); + else supertile.getWorld().setBlockState(pos, state.with(BlockCake.BITES, nextSlicesEaten), 1 | 2); supertile.getWorld().playEvent(2001, pos, Block.getStateId(state)); supertile.getWorld().playSound(null, supertile.getPos(), SoundEvents.ENTITY_GENERIC_EAT, SoundCategory.BLOCKS, 1F, 0.5F + (float) Math.random() * 0.5F); diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java index 1dd18a32e..4df103a19 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileMunchdew.java @@ -65,7 +65,7 @@ public class SubTileMunchdew extends SubTileGenerating { for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-RANGE, 0, -RANGE), pos.add(RANGE, RANGE_Y, RANGE))) { if(supertile.getWorld().getBlockState(pos_).getMaterial() == Material.LEAVES) { boolean exposed = false; - for(EnumFacing dir : EnumFacing.VALUES) { + for(EnumFacing dir : EnumFacing.BY_INDEX) { IBlockState offState = supertile.getWorld().getBlockState(pos_.offset(dir)); if(offState.getBlock().isAir(offState, supertile.getWorld(), pos_.offset(dir))) { exposed = true; @@ -84,7 +84,7 @@ public class SubTileMunchdew extends SubTileGenerating { Collections.shuffle(coords); BlockPos breakCoords = coords.get(0); IBlockState state = supertile.getWorld().getBlockState(breakCoords); - supertile.getWorld().setBlockToAir(breakCoords); + supertile.getWorld().removeBlock(breakCoords); ticksWithoutEating = 0; ateOnce = true; if(ConfigHandler.blockBreakParticles) @@ -111,7 +111,7 @@ public class SubTileMunchdew extends SubTileGenerating { public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_COOLDOWN, cooldown); + cmp.setInt(TAG_COOLDOWN, cooldown); cmp.setBoolean(TAG_ATE_ONCE, ateOnce); } @@ -119,7 +119,7 @@ public class SubTileMunchdew extends SubTileGenerating { public void readFromPacketNBT(NBTTagCompound cmp) { super.readFromPacketNBT(cmp); - cooldown = cmp.getInteger(TAG_COOLDOWN); + cooldown = cmp.getInt(TAG_COOLDOWN); ateOnce = cmp.getBoolean(TAG_ATE_ONCE); } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java index 5b05f5955..e40b87f72 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileNarslimmus.java @@ -11,17 +11,19 @@ package vazkii.botania.common.block.subtile.generating; import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.init.Particles; import net.minecraft.init.SoundEvents; -import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.SharedSeedRandom; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import net.minecraftforge.eventbus.api.Event; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.Event.Result; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.SubTileGenerating; @@ -44,13 +46,13 @@ public class SubTileNarslimmus extends SubTileGenerating { if(ticksExisted % 5 == 0) { List slimes = supertile.getWorld().getEntitiesWithinAABB(EntitySlime.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1))); for(EntitySlime slime : slimes) { - if(slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && !slime.isDead) { + if(slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && slime.isAlive()) { int size = slime.getSlimeSize(); int mul = (int) Math.pow(2, size); int mana = 1200 * mul; if(!slime.world.isRemote) { - slime.setDead(); - slime.playSound(size > 1 ? SoundEvents.ENTITY_SLIME_SQUISH : SoundEvents.ENTITY_SMALL_SLIME_SQUISH, 1, 0.02F); + slime.remove(); + slime.playSound(size > 1 ? SoundEvents.ENTITY_SLIME_SQUISH : SoundEvents.ENTITY_SLIME_SQUISH_SMALL, 1, 0.02F); this.mana = Math.min(getMaxMana(), this.mana + mana); sync(); } @@ -61,7 +63,7 @@ public class SubTileNarslimmus extends SubTileGenerating { float f2 = MathHelper.sin(f) * size * 0.5F * f1; float f3 = MathHelper.cos(f) * size * 0.5F * f1; float f4 = slime.world.rand.nextFloat() * size * 0.5F * f1; - slime.world.spawnParticle(EnumParticleTypes.SLIME, slime.posX + f2, slime.getEntityBoundingBox().minY + f4, slime.posZ + f3, 0.0D, 0.0D, 0.0D); + slime.world.spawnParticle(Particles.ITEM_SLIME, slime.posX + f2, slime.getBoundingBox().minY + f4, slime.posZ + f3, 0.0D, 0.0D, 0.0D); } break; } @@ -91,13 +93,13 @@ public class SubTileNarslimmus extends SubTileGenerating { @SubscribeEvent public static void onSpawn(LivingSpawnEvent.CheckSpawn event) { - if(event.getEntityLiving() instanceof EntitySlime && event.getResult() != Result.DENY && isSlimeChunk(event.getEntityLiving().world, MathHelper.floor(event.getX()), MathHelper.floor(event.getZ()))) + if(event.getEntityLiving() instanceof EntitySlime && event.getResult() != Event.Result.DENY && isSlimeChunk(event.getEntityLiving().world, MathHelper.floor(event.getX()), MathHelper.floor(event.getZ()))) event.getEntityLiving().getEntityData().setBoolean(TAG_WORLD_SPAWNED, true); } - public static boolean isSlimeChunk(World world, int x, int z) { - Chunk chunk = world.getChunk(new BlockPos(x, 0, z)); - return chunk.getRandomWithSeed(987234911L).nextInt(10) == 0; + public static boolean isSlimeChunk(World world, BlockPos pos) { + ChunkPos chunkpos = new ChunkPos(pos); + return SharedSeedRandom.seedSlimeChunk(chunkpos.x, chunkpos.z, world.getSeed(), 987234911L).nextInt(10) == 0; } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java index 658164a23..7b7ea27d6 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileRafflowsia.java @@ -81,7 +81,7 @@ public class SubTileRafflowsia extends SubTileGenerating { super.writeToPacketNBT(cmp); cmp.setString(TAG_LAST_FLOWER, lastFlower); - cmp.setInteger(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); + cmp.setInt(TAG_LAST_FLOWER_TIMES, lastFlowerTimes); } @Override @@ -89,7 +89,7 @@ public class SubTileRafflowsia extends SubTileGenerating { super.readFromPacketNBT(cmp); lastFlower = cmp.getString(TAG_LAST_FLOWER); - lastFlowerTimes = cmp.getInteger(TAG_LAST_FLOWER_TIMES); + lastFlowerTimes = cmp.getInt(TAG_LAST_FLOWER_TIMES); } @Override diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java index 7ba2b7380..c9a31b24b 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileShulkMeNot.java @@ -7,6 +7,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityShulker; import net.minecraft.entity.monster.IMob; import net.minecraft.init.MobEffects; +import net.minecraft.init.Particles; import net.minecraft.init.SoundEvents; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; @@ -37,12 +38,12 @@ public class SubTileShulkMeNot extends SubTileGenerating { if(getMaxMana() - mana < generate) break; - if(!shulker.isDead && shulker.getDistanceSq(pos) < RADIUS * RADIUS) { + if(shulker.isAlive() && shulker.getDistanceSq(pos) < RADIUS * RADIUS) { EntityLivingBase target = shulker.getAttackTarget(); - if(target != null && target instanceof IMob && !target.isDead + if(target != null && target instanceof IMob && target.isAlive() && target.getDistanceSq(pos) < RADIUS * RADIUS && target.getActivePotionEffect(MobEffects.LEVITATION) != null) { - target.setDead(); - shulker.setDead(); + target.remove(); + shulker.remove(); for(int i = 0; i < 10; i++) // so it's really loud >_> world.playSound(null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ENTITY_SHULKER_DEATH, SoundCategory.BLOCKS, 10F, 0.1F); @@ -59,8 +60,8 @@ public class SubTileShulkMeNot extends SubTileGenerating { private void particles(World world, BlockPos pos, Entity entity) { if(world instanceof WorldServer) { WorldServer ws = (WorldServer) world; - ws.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, entity.posX + entity.width / 2, entity.posY + entity.height / 2, entity.posZ + entity.width / 2, 100, entity.width, entity.height, entity.width, 0.05); - ws.spawnParticle(EnumParticleTypes.PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 40, 0, 0, 0, 0.6); + ws.spawnParticle(Particles.EXPLOSION, entity.posX + entity.width / 2, entity.posY + entity.height / 2, entity.posZ + entity.width / 2, 100, entity.width, entity.height, entity.width, 0.05); + ws.spawnParticle(Particles.PORTAL, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 40, 0, 0, 0, 0.6); } } diff --git a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java index 758e159d8..a7929ae91 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java +++ b/src/main/java/vazkii/botania/common/block/subtile/generating/SubTileSpectrolus.java @@ -16,9 +16,11 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; +import net.minecraft.init.Particles; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.particles.ItemParticleData; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.WorldServer; @@ -63,10 +65,10 @@ public class SubTileSpectrolus extends SubTileGenerating { nextColor = nextColor == 15 ? 0 : nextColor + 1; sync(); - ((WorldServer) supertile.getWorld()).spawnParticle(EnumParticleTypes.ITEM_CRACK, false, item.posX, item.posY, item.posZ, 20, 0.1D, 0.1D, 0.1D, 0.05D, Item.getIdFromItem(stack.getItem()), stack.getItemDamage()); + ((WorldServer) supertile.getWorld()).spawnParticle(new ItemParticleData(Particles.ITEM, stack), false, item.posX, item.posY, item.posZ, 20, 0.1D, 0.1D, 0.1D, 0.05D); } - item.setDead(); + item.remove(); } } } @@ -120,13 +122,13 @@ public class SubTileSpectrolus extends SubTileGenerating { @Override public void writeToPacketNBT(NBTTagCompound cmp) { super.writeToPacketNBT(cmp); - cmp.setInteger(TAG_NEXT_COLOR, nextColor); + cmp.setInt(TAG_NEXT_COLOR, nextColor); } @Override public void readFromPacketNBT(NBTTagCompound cmp) { super.readFromPacketNBT(cmp); - nextColor = cmp.getInteger(TAG_NEXT_COLOR); + nextColor = cmp.getInt(TAG_NEXT_COLOR); } } diff --git a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java index 683c0377c..0a321698c 100644 --- a/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java +++ b/src/main/java/vazkii/botania/common/block/tile/string/TileRedStringFertilizer.java @@ -13,13 +13,14 @@ package vazkii.botania.common.block.tile.string; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import java.util.Random; public class TileRedStringFertilizer extends TileRedString { - public boolean canGrow(World world, boolean isClient) { + public boolean canGrow(IBlockReader world, boolean isClient) { BlockPos binding = getBinding(); Block block = getBlockAtBinding();