more deprecation things, mainly moving away from all uses of getStateFromMeta

Changes in LensColor, LensMining, and MethodHandler might all catch on
fire, idk.
i checked them and they worked tho so blahr
This commit is contained in:
Shadows_of_Fire 2017-08-17 01:06:09 -04:00
parent 2d3e90068f
commit 6ef76a16ea
9 changed files with 31 additions and 28 deletions

View file

@ -66,23 +66,15 @@ public class ItemFillingWand extends ItemEnergy{
if(!stack.hasTagCompound()){
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound compound = stack.getTagCompound();
Block block = state.getBlock();
compound.setString("Block", block.getRegistryName().toString());
compound.setInteger("Meta", block.getMetaFromState(state));
stack.getTagCompound().setInteger("state", Block.getStateId(state));
}
//I think changing these to state ID is a good idea, but it will break all currently in-use wands, but whatever. It'll have to be done in 1.13 anyway.
private static IBlockState loadBlock(ItemStack stack){
if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound();
String blockName = compound.getString("Block");
int meta = compound.getInteger("Meta");
Block block = Block.getBlockFromName(blockName);
if(block != null){
return block.getStateFromMeta(meta);
}
return Block.getStateById(stack.getTagCompound().getInteger("state"));
}
return null;
}

View file

@ -23,8 +23,11 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import java.util.ArrayList;
import java.util.Map;
@ -59,9 +62,10 @@ public class LensColor extends Lens{
int meta = block.getMetaFromState(state);
ItemStack returnStack = this.tryConvert(new ItemStack(block, 1, meta), hitState, hitBlock, tile);
if(returnStack != null && returnStack.getItem() instanceof ItemBlock){
tile.getWorldObject().setBlockState(hitBlock, Block.getBlockFromItem(returnStack.getItem()).getStateFromMeta(returnStack.getItemDamage()), 2);
tile.extractEnergy(ENERGY_USE);
Block toPlace = Block.getBlockFromItem(returnStack.getItem());
IBlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), hitBlock, EnumFacing.UP, 0, 0, 0, returnStack.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND);
tile.getWorldObject().setBlockState(hitBlock, state2Place, 2);
tile.extractEnergy(ENERGY_USE);
}
}

View file

@ -22,10 +22,15 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockNetherrack;
import net.minecraft.block.BlockStone;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.oredict.OreDictionary;
import java.util.List;
@ -159,8 +164,8 @@ public class LensMining extends Lens{
if(tile.getEnergy() >= adaptedUse){
Block block = Block.getBlockFromItem(stack.getItem());
if(block != null){
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
if(block != Blocks.AIR){
IBlockState state = block.getStateForPlacement(tile.getWorldObject(), hitPos, EnumFacing.UP, 0, 0, 0, stack.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND);
tile.getWorldObject().setBlockState(hitPos, state, 2);
tile.getWorldObject().playEvent(2001, hitPos, Block.getStateId(state));

View file

@ -40,9 +40,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import java.util.ArrayList;
import java.util.List;
@ -171,9 +174,11 @@ public class MethodHandler implements IMethodHandler{
ItemStack output = recipe.outputStack;
if(StackUtil.isValid(output)){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos)));
//This change might break something? Not sure. It could.
if(output.getItem() instanceof ItemBlock){
tile.getWorldObject().setBlockState(pos, Block.getBlockFromItem(output.getItem()).getStateFromMeta(output.getItemDamage()), 2);
Block toPlace = Block.getBlockFromItem(output.getItem());
IBlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND);
tile.getWorldObject().setBlockState(pos, state2Place, 2);
}
else{
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5, output.copy());

View file

@ -25,8 +25,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import java.util.List;
public class NetherWartFarmerBehavior implements IFarmerBehavior{
@Override

View file

@ -83,7 +83,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
for(int i = 0; i < RANGE; i++){
BlockPos coordsBlock = this.pos.offset(sideToManipulate, i+1);
Block blockToBreak = this.world.getBlockState(coordsBlock).getBlock();
if(blockToBreak != null && !this.world.isAirBlock(coordsBlock) && blockToBreak.getBlockHardness(this.world.getBlockState(coordsBlock), this.world, this.pos) > -1.0F){
if(blockToBreak != null && !this.world.isAirBlock(coordsBlock) && this.world.getBlockState(coordsBlock).getBlockHardness(this.world, coordsBlock) > -1.0F){
List<ItemStack> drops = blockToBreak.getDrops(this.world, coordsBlock, this.world.getBlockState(coordsBlock), 0);
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, coordsBlock);

View file

@ -133,7 +133,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
if(this.isBoundThingInRange()){
if(this.isBreaker){
Block blockToBreak = this.world.getBlockState(this.boundPosition).getBlock();
if(blockToBreak != null && blockToBreak.getBlockHardness(this.world.getBlockState(this.boundPosition), this.world, this.boundPosition) > -1.0F){
if(blockToBreak != null && this.world.getBlockState(this.boundPosition).getBlockHardness(this.world, this.boundPosition) > -1.0F){
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
drops.addAll(blockToBreak.getDrops(this.world, this.boundPosition, this.world.getBlockState(this.boundPosition), 0));

View file

@ -39,8 +39,8 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{
if(boundBlock != null){
for(int i = 0; i < EnumFacing.values().length; i++){
EnumFacing facing = EnumFacing.values()[i];
this.providesWeak[i] = boundBlock.getWeakPower(boundState, this.world, this.boundPosition, facing);
this.providesStrong[i] = boundBlock.getStrongPower(boundState, this.world, this.boundPosition, facing);
this.providesWeak[i] = boundState.getWeakPower(this.world, this.boundPosition, facing);
this.providesStrong[i] = boundState.getStrongPower(this.world, this.boundPosition, facing);
}
}
}

View file

@ -208,10 +208,9 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl
if(this.isBoundThingInRange()){
BlockPos pos = this.getBoundPosition();
IBlockState state = this.world.getBlockState(pos);
Block block = state.getBlock();
if(block.hasComparatorInputOverride(state)){
return block.getComparatorInputOverride(state, this.world, pos);
if(state.hasComparatorInputOverride()){
return state.getComparatorInputOverride(this.world, pos);
}
}
return 0;