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:
Shadows_of_Fire 2017-08-09 12:20:55 -04:00
parent ed736f3c66
commit 2239a8a783
10 changed files with 37 additions and 38 deletions

View file

@ -71,16 +71,15 @@ public class BlockLampPowerer extends BlockBase{
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block instanceof BlockColoredLamp){
boolean isOn = ((BlockColoredLamp)block).isOn;
int meta = block.getMetaFromState(state);
boolean isOn = ((BlockColoredLamp) block).isOn;
if(powered){
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{
if(isOn){
world.setBlockState(pos, InitBlocks.blockColoredLamp.getStateFromMeta(meta), 2);
world.setBlockState(pos, InitBlocks.blockColoredLamp.getDefaultState().withProperty(BlockColoredLamp.TYPE, state.getValue(BlockColoredLamp.TYPE)), 2);
}
}

View file

@ -37,20 +37,18 @@ 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);
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 int meta;
private final IBlockState fullBlockState;
public BlockSlabs(String name, Block fullBlock){
this(name, fullBlock, 0);
this(name, fullBlock.getDefaultState());
}
public BlockSlabs(String name, Block fullBlock, int meta){
super(fullBlock.getDefaultState().getMaterial(), name);
public BlockSlabs(String name, IBlockState fullBlockState){
super(fullBlockState.getMaterial(), name);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.fullBlock = fullBlock;
this.meta = meta;
this.fullBlockState = fullBlockState;
}
/*@Override
@ -140,11 +138,11 @@ public class BlockSlabs extends BlockBase{
if(state.getBlock() == 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)){
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
IBlockState newState = theBlock.fullBlockState;
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
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);
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
}
@ -179,11 +177,11 @@ public class BlockSlabs extends BlockBase{
if(iblockstate.getBlock() == this.block){
BlockSlabs theBlock = (BlockSlabs)this.block;
IBlockState newState = theBlock.fullBlock.getStateFromMeta(theBlock.meta);
IBlockState newState = theBlock.fullBlockState;
AxisAlignedBB bound = newState.getCollisionBoundingBox(world, pos);
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);
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));

View file

@ -130,7 +130,7 @@ public class BlockWallAA extends BlockBase{
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos){
IBlockState state = worldIn.getBlockState(pos);
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));
}

View file

@ -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.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
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.SideOnly;
import java.util.List;
public class BlockWildPlant extends BlockBushBase{
public static final TheWildPlants[] ALL_WILD_PLANTS = TheWildPlants.values();
@ -73,9 +72,10 @@ public class BlockWildPlant extends BlockBushBase{
}
@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);
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

View file

@ -213,11 +213,11 @@ public final class InitBlocks{
blockQuartzWall = new BlockWallAA("block_quartz_wall", blockMisc, TheMiscBlocks.QUARTZ.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());
blockQuartzStair = new BlockStair(blockMisc, "block_quartz_stair", TheMiscBlocks.QUARTZ.ordinal());
blockChiseledQuartzStair = new BlockStair(blockMisc, "block_chiseled_quartz_stair", TheMiscBlocks.QUARTZ_CHISELED.ordinal());
blockPillarQuartzStair = new BlockStair(blockMisc, "block_pillar_quartz_stair", TheMiscBlocks.QUARTZ_PILLAR.ordinal());
blockQuartzSlab = new BlockSlabs("block_quartz_slab", blockMisc, TheMiscBlocks.QUARTZ.ordinal());
blockChiseledQuartzSlab = new BlockSlabs("block_chiseled_quartz_slab", blockMisc, TheMiscBlocks.QUARTZ_CHISELED.ordinal());
blockPillarQuartzSlab = new BlockSlabs("block_pillar_quartz_slab", blockMisc, TheMiscBlocks.QUARTZ_PILLAR.ordinal());
blockQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ), "block_quartz_stair");
blockChiseledQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_CHISELED), "block_chiseled_quartz_stair");
blockPillarQuartzStair = new BlockStair(blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_PILLAR), "block_pillar_quartz_stair");
blockQuartzSlab = new BlockSlabs("block_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ));
blockChiseledQuartzSlab = new BlockSlabs("block_chiseled_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_CHISELED));
blockPillarQuartzSlab = new BlockSlabs("block_pillar_quartz_slab", blockMisc.getDefaultState().withProperty(BlockMisc.TYPE, TheMiscBlocks.QUARTZ_PILLAR));
}
}

View file

@ -23,12 +23,12 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import java.util.List;
import java.util.Random;
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(!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;
for(ItemStack drop : drops){
if(StackUtil.isValid(drop)){

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -24,11 +25,11 @@ public class BlockStair extends BlockStairs implements ItemBlockBase.ICustomRari
private final String name;
public BlockStair(Block block, String name){
this(block, name, 0);
this(block.getDefaultState(), name);
}
public BlockStair(Block block, String name, int meta){
super(block.getStateFromMeta(meta));
public BlockStair(IBlockState state, String name){
super(state);
this.name = name;
this.setLightOpacity(0);

View file

@ -89,7 +89,7 @@ public class WorldGenLushCaves{
IBlockState state = world.getBlockState(pos);
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)];
world.setBlockState(pos, block.getDefaultState().withProperty(BlockDirectional.FACING, side.getOpposite()), 2);
}

View file

@ -44,7 +44,7 @@ public class ItemAllToolAA extends ItemToolAA implements IColorProvidingItem{
super(4.0F, -2F, toolMat, repairItem, unlocalizedName, rarity, new HashSet<Block>());
this.color = color;
this.setMaxDamage(this.getMaxDamage()*4);
this.setMaxDamage(toolMat.getMaxUses()*4);
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>());
this.color = color;
this.setMaxDamage(this.getMaxDamage()*4);
this.setMaxDamage(toolMat.getMaxUses()*4);
this.setHarvestLevels(toolMat.getHarvestLevel());
}

View file

@ -19,11 +19,10 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.List;
public class CactusFarmerBehavior implements IFarmerBehavior{
@Override
@ -62,7 +61,8 @@ public class CactusFarmerBehavior implements IFarmerBehavior{
BlockPos up = pos.up(i);
IBlockState upState = world.getBlockState(up);
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(farmer.addToOutputInventory(drops, false)){