mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-29 18:28:34 +01:00
More deprecation stuffs
1.13 will remove metadata so expect a few more of these for the remainig getStateFromMeta stuff... Hopefully this doesn't set anything on fire
This commit is contained in:
parent
ed736f3c66
commit
2239a8a783
10 changed files with 37 additions and 38 deletions
|
@ -71,16 +71,15 @@ public class BlockLampPowerer extends BlockBase{
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if(block instanceof BlockColoredLamp){
|
if(block instanceof BlockColoredLamp){
|
||||||
boolean isOn = ((BlockColoredLamp)block).isOn;
|
boolean isOn = ((BlockColoredLamp) block).isOn;
|
||||||
int meta = block.getMetaFromState(state);
|
|
||||||
if(powered){
|
if(powered){
|
||||||
if(!isOn){
|
if(!isOn){
|
||||||
world.setBlockState(pos, InitBlocks.blockColoredLampOn.getStateFromMeta(meta), 2);
|
world.setBlockState(pos, InitBlocks.blockColoredLampOn.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(isOn){
|
if(isOn){
|
||||||
world.setBlockState(pos, InitBlocks.blockColoredLamp.getStateFromMeta(meta), 2);
|
world.setBlockState(pos, InitBlocks.blockColoredLamp.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,19 +38,17 @@ public class BlockSlabs extends BlockBase{
|
||||||
public static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
|
public static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
|
||||||
private static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
|
private static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||||
|
|
||||||
private final Block fullBlock;
|
private final IBlockState fullBlockState;
|
||||||
private final int meta;
|
|
||||||
|
|
||||||
public BlockSlabs(String name, Block fullBlock){
|
public BlockSlabs(String name, Block fullBlock){
|
||||||
this(name, fullBlock, 0);
|
this(name, fullBlock.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockSlabs(String name, Block fullBlock, int meta){
|
public BlockSlabs(String name, IBlockState fullBlockState){
|
||||||
super(fullBlock.getDefaultState().getMaterial(), name);
|
super(fullBlockState.getMaterial(), name);
|
||||||
this.setHardness(1.5F);
|
this.setHardness(1.5F);
|
||||||
this.setResistance(10.0F);
|
this.setResistance(10.0F);
|
||||||
this.fullBlock = fullBlock;
|
this.fullBlockState = fullBlockState;
|
||||||
this.meta = meta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
/*@Override
|
||||||
|
@ -140,11 +138,11 @@ public class BlockSlabs extends BlockBase{
|
||||||
if(state.getBlock() == this.block){
|
if(state.getBlock() == this.block){
|
||||||
BlockSlabs theBlock = (BlockSlabs)this.block;
|
BlockSlabs theBlock = (BlockSlabs)this.block;
|
||||||
if((facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) || (facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP)){
|
if((facing == EnumFacing.UP && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.BOTTOM) || (facing == EnumFacing.DOWN && state.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP)){
|
||||||
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
|
IBlockState newState = theBlock.fullBlockState;
|
||||||
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
|
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
|
||||||
|
|
||||||
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
|
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
|
||||||
SoundType soundtype = theBlock.fullBlock.getSoundType(theBlock.fullBlock.getDefaultState(), world, pos, player);
|
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
|
||||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
||||||
}
|
}
|
||||||
|
@ -179,11 +177,11 @@ public class BlockSlabs extends BlockBase{
|
||||||
|
|
||||||
if(iblockstate.getBlock() == this.block){
|
if(iblockstate.getBlock() == this.block){
|
||||||
BlockSlabs theBlock = (BlockSlabs)this.block;
|
BlockSlabs theBlock = (BlockSlabs)this.block;
|
||||||
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
|
IBlockState newState = theBlock.fullBlockState;
|
||||||
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
|
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
|
||||||
|
|
||||||
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
|
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
|
||||||
SoundType soundtype = theBlock.fullBlock.getSoundType(theBlock.fullBlock.getDefaultState(), world, pos, player);
|
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
|
||||||
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
|
||||||
|
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class BlockWallAA extends BlockBase{
|
||||||
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){
|
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){
|
||||||
IBlockState state = worldIn.getBlockState(pos);
|
IBlockState state = worldIn.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || ((state.getMaterial().isOpaque() && block.isFullCube(state)) && state.getMaterial() != Material.GOURD));
|
return block != Blocks.BARRIER && (!(block != this && !(block instanceof BlockFenceGate)) || ((state.getMaterial().isOpaque() && state.isFullCube()) && state.getMaterial() != Material.GOURD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheWildPlants;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockCrops;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.PropertyEnum;
|
import net.minecraft.block.properties.PropertyEnum;
|
||||||
|
@ -36,8 +37,6 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BlockWildPlant extends BlockBushBase{
|
public class BlockWildPlant extends BlockBushBase{
|
||||||
|
|
||||||
public static final TheWildPlants[] ALL_WILD_PLANTS = TheWildPlants.values();
|
public static final TheWildPlants[] ALL_WILD_PLANTS = TheWildPlants.values();
|
||||||
|
@ -73,9 +72,10 @@ public class BlockWildPlant extends BlockBushBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
|
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune){
|
||||||
int metadata = this.getMetaFromState(state);
|
int metadata = this.getMetaFromState(state);
|
||||||
return metadata >= ALL_WILD_PLANTS.length ? null : ALL_WILD_PLANTS[metadata].wildVersionOf.getDrops(world, pos, ALL_WILD_PLANTS[metadata].wildVersionOf.getStateFromMeta(7), fortune);
|
if(metadata < ALL_WILD_PLANTS.length)
|
||||||
|
ALL_WILD_PLANTS[metadata].wildVersionOf.getDrops(drops, world, pos, ALL_WILD_PLANTS[metadata].wildVersionOf.getDefaultState().withProperty(BlockCrops.AGE, 7), fortune);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -213,11 +213,11 @@ public final class InitBlocks{
|
||||||
blockQuartzWall = new BlockWallAA("block_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ.ordinal());
|
blockQuartzWall = new BlockWallAA("block_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ.ordinal());
|
||||||
blockChiseledQuartzWall = new BlockWallAA("block_chiseled_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ_CHISELED.ordinal());
|
blockChiseledQuartzWall = new BlockWallAA("block_chiseled_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ_CHISELED.ordinal());
|
||||||
blockPillarQuartzWall = new BlockWallAA("block_pillar_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ_PILLAR.ordinal());
|
blockPillarQuartzWall = new BlockWallAA("block_pillar_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ_PILLAR.ordinal());
|
||||||
blockQuartzStair = new BlockStair(blockMisc, "block_quartz_stair", TheMiscBlocks.QUARTZ.ordinal());
|
blockQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ), "block_quartz_stair");
|
||||||
blockChiseledQuartzStair = new BlockStair(blockMisc, "block_chiseled_quartz_stair", TheMiscBlocks.QUARTZ_CHISELED.ordinal());
|
blockChiseledQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_CHISELED), "block_chiseled_quartz_stair");
|
||||||
blockPillarQuartzStair = new BlockStair(blockMisc, "block_pillar_quartz_stair", TheMiscBlocks.QUARTZ_PILLAR.ordinal());
|
blockPillarQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_PILLAR), "block_pillar_quartz_stair");
|
||||||
blockQuartzSlab = new BlockSlabs("block_quartz_slab", blockMisc, TheMiscBlocks.QUARTZ.ordinal());
|
blockQuartzSlab = new BlockSlabs("block_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ));
|
||||||
blockChiseledQuartzSlab = new BlockSlabs("block_chiseled_quartz_slab", blockMisc, TheMiscBlocks.QUARTZ_CHISELED.ordinal());
|
blockChiseledQuartzSlab = new BlockSlabs("block_chiseled_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_CHISELED));
|
||||||
blockPillarQuartzSlab = new BlockSlabs("block_pillar_quartz_slab", blockMisc, TheMiscBlocks.QUARTZ_PILLAR.ordinal());
|
blockPillarQuartzSlab = new BlockSlabs("block_pillar_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_PILLAR));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,12 +23,12 @@ import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.EnumPlantType;
|
import net.minecraftforge.common.EnumPlantType;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel{
|
public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarity, IHasModel{
|
||||||
|
@ -93,7 +93,8 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit
|
||||||
if(this.getMetaFromState(state) >= 7){
|
if(this.getMetaFromState(state) >= 7){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
|
|
||||||
List<ItemStack> drops = this.getDrops(world, pos, state, 0);
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
|
this.getDrops(drops, world, pos, state, 0);
|
||||||
boolean deductedSeedSize = false;
|
boolean deductedSeedSize = false;
|
||||||
for(ItemStack drop : drops){
|
for(ItemStack drop : drops){
|
||||||
if(StackUtil.isValid(drop)){
|
if(StackUtil.isValid(drop)){
|
||||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockStairs;
|
import net.minecraft.block.BlockStairs;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
@ -24,11 +25,11 @@ public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRari
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public BlockStair(Block block, String name){
|
public BlockStair(Block block, String name){
|
||||||
this(block, name, 0);
|
this(block.getDefaultState(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockStair(Block block, String name, int meta){
|
public BlockStair(IBlockState state, String name){
|
||||||
super(block.getStateFromMeta(meta));
|
super(state);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.setLightOpacity(0);
|
this.setLightOpacity(0);
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class WorldGenLushCaves{
|
||||||
IBlockState state = world.getBlockState(pos);
|
IBlockState state = world.getBlockState(pos);
|
||||||
IBlockState stateSide = world.getBlockState(posSide);
|
IBlockState stateSide = world.getBlockState(posSide);
|
||||||
|
|
||||||
if(state.getBlock().isAir(state, world, pos) && stateSide.getBlock().isSideSolid(stateSide, world, posSide, side.getOpposite())){
|
if(state.getBlock().isAir(state, world, pos) && stateSide.isSideSolid(world, posSide, side.getOpposite())){
|
||||||
Block block = CRYSTAL_CLUSTERS[rand.nextInt(CRYSTAL_CLUSTERS.length)];
|
Block block = CRYSTAL_CLUSTERS[rand.nextInt(CRYSTAL_CLUSTERS.length)];
|
||||||
world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2);
|
world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{
|
||||||
super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<Block>());
|
super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<Block>());
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
this.setMaxDamage(this.getMaxDamage()*4);
|
this.setMaxDamage(toolMat.getMaxUses()*4);
|
||||||
this.setHarvestLevels(toolMat.getHarvestLevel());
|
this.setHarvestLevels(toolMat.getHarvestLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{
|
||||||
super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<Block>());
|
super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<Block>());
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
|
||||||
this.setMaxDamage(this.getMaxDamage()*4);
|
this.setMaxDamage(toolMat.getMaxUses()*4);
|
||||||
this.setHarvestLevels(toolMat.getHarvestLevel());
|
this.setHarvestLevels(toolMat.getHarvestLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,10 @@ import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CactusFarmerBehavior implements IFarmerBehavior{
|
public class CactusFarmerBehavior implements IFarmerBehavior{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +61,8 @@ public class CactusFarmerBehavior implements IFarmerBehavior{
|
||||||
BlockPos up = pos.up(i);
|
BlockPos up = pos.up(i);
|
||||||
IBlockState upState = world.getBlockState(up);
|
IBlockState upState = world.getBlockState(up);
|
||||||
if(upState.getBlock() instanceof BlockCactus){
|
if(upState.getBlock() instanceof BlockCactus){
|
||||||
List<ItemStack> drops = upState.getBlock().getDrops(world, up, upState, 0);
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
|
upState.getBlock().getDrops(drops, world, up, upState, 0);
|
||||||
|
|
||||||
if(drops != null && !drops.isEmpty()){
|
if(drops != null && !drops.isEmpty()){
|
||||||
if(farmer.addToOutputInventory(drops, false)){
|
if(farmer.addToOutputInventory(drops, false)){
|
||||||
|
|
Loading…
Reference in a new issue