Migrated getDrops

This commit is contained in:
drcrazy 2019-02-21 13:54:49 +03:00
parent bdb8834a3e
commit bd00135137
14 changed files with 29 additions and 46 deletions

View file

@ -25,12 +25,12 @@
package techreborn.blocks; package techreborn.blocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.registration.RebornRegister; import reborncore.common.registration.RebornRegister;
import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.OreDrop; import reborncore.common.util.OreDrop;
@ -71,7 +71,7 @@ public class BlockOre extends Block {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
Block ore = state.getBlock(); Block ore = state.getBlock();
Random random = new Random(); Random random = new Random();

View file

@ -37,6 +37,7 @@ import net.minecraft.init.Blocks;
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.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -204,14 +205,12 @@ public class BlockRubberLog extends Block {
} }
@Override @Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
List<ItemStack> drops = new ArrayList<>();
drops.add(new ItemStack(this)); drops.add(new ItemStack(this));
if (state.getValue(HAS_SAP)) { if (state.getValue(HAS_SAP)) {
if (new Random().nextInt(4) == 0) { if (new Random().nextInt(4) == 0) {
drops.add(TRContent.Parts.SAP.getStack()); drops.add(TRContent.Parts.SAP.getStack());
} }
} }
return drops;
} }
} }

View file

@ -131,7 +131,7 @@ public class BlockCable extends BlockContainer {
// Block // Block
@Override @Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(IBlockState state, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND); ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
TileEntity tileEntity = worldIn.getTileEntity(pos); TileEntity tileEntity = worldIn.getTileEntity(pos);
@ -145,7 +145,7 @@ public class BlockCable extends BlockContainer {
return true; return true;
} }
} }
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ); return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ);
} }
@Override @Override
@ -186,16 +186,6 @@ public class BlockCable extends BlockContainer {
return getStateFromMeta(meta); return getStateFromMeta(meta);
} }
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState();
}
@Override @Override
public boolean isFullCube(IBlockState state) { public boolean isFullCube(IBlockState state) {
return false; return false;

View file

@ -29,7 +29,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList; 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.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
@ -49,11 +48,11 @@ public class BlockAdjustableSU extends BlockEnergyStorage {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired) { if (RebornCoreConfig.wrenchRequired) {
drops.add(new ItemStack(TRContent.MachineBlocks.INDUSTRIAL.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.INDUSTRIAL.getFrame()));
} else { } else {
super.getDrops(drops, world, pos, state, fortune); super.getDrops(state, drops, world, pos, fortune);
} }
} }
} }

View file

@ -51,11 +51,11 @@ public class BlockHighVoltageSU extends BlockEnergyStorage {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockReader world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired) { if (RebornCoreConfig.wrenchRequired) {
drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame()));
} else { } else {
super.getDrops(drops, world, pos, state, fortune); super.getDrops(state, drops, world, pos, fortune);
} }
} }
} }

View file

@ -70,11 +70,11 @@ public class BlockInterdimensionalSU extends BlockEnergyStorage {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired) { if (RebornCoreConfig.wrenchRequired) {
drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame()));
} else { } else {
super.getDrops(drops, world, pos, state, fortune); super.getDrops(state, drops, world, pos, fortune);
} }
} }
} }

View file

@ -108,11 +108,11 @@ public class BlockLSUStorage extends BaseTileBlock {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired) { if (RebornCoreConfig.wrenchRequired) {
drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame()));
} else { } else {
super.getDrops(drops, world, pos, state, fortune); super.getDrops(state, drops, world, pos, fortune);
} }
} }

View file

@ -29,7 +29,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList; 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.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
@ -49,11 +48,11 @@ public class BlockLapotronicSU extends BlockEnergyStorage {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired) { if (RebornCoreConfig.wrenchRequired) {
drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame()));
} else { } else {
super.getDrops(drops, world, pos, state, fortune); super.getDrops(state, drops, world, pos, fortune);
} }
} }
} }

View file

@ -52,11 +52,11 @@ public class BlockMediumVoltageSU extends BlockEnergyStorage {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired) { if (RebornCoreConfig.wrenchRequired) {
drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame()));
} else { } else {
super.getDrops(drops, world, pos, state, fortune); super.getDrops(state, drops, world, pos, fortune);
} }
} }
} }

View file

@ -27,6 +27,7 @@ package techreborn.blocks.tier0;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -37,8 +38,6 @@ import reborncore.common.blocks.BlockMachineBase;
import techreborn.TechReborn; import techreborn.TechReborn;
import techreborn.client.EGui; import techreborn.client.EGui;
import techreborn.tiles.machine.iron.TileIronAlloyFurnace; import techreborn.tiles.machine.iron.TileIronAlloyFurnace;
import java.util.ArrayList;
import java.util.List;
public class BlockIronAlloyFurnace extends BlockMachineBase { public class BlockIronAlloyFurnace extends BlockMachineBase {
@ -58,9 +57,7 @@ public class BlockIronAlloyFurnace extends BlockMachineBase {
} }
@Override @Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
final List<ItemStack> items = new ArrayList<>(); drops.add(new ItemStack(this));
items.add(new ItemStack(this));
return items;
} }
} }

View file

@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.EnumParticleTypes;
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.IBlockReader; import net.minecraft.world.IBlockReader;
@ -100,9 +101,7 @@ public class BlockIronFurnace extends BlockMachineBase {
} }
@Override @Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
final List<ItemStack> items = new ArrayList<>(); drops.add(new ItemStack(this));
items.add(new ItemStack(this));
return items;
} }
} }

View file

@ -29,7 +29,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList; 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.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
@ -51,7 +50,7 @@ public class BlockHVTransformer extends BlockTransformer {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired){ if (RebornCoreConfig.wrenchRequired){
drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.ADVANCED.getFrame()));
} }

View file

@ -29,7 +29,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList; 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.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.common.RebornCoreConfig; import reborncore.common.RebornCoreConfig;
@ -51,7 +50,7 @@ public class BlockMVTransformer extends BlockTransformer {
} }
@Override @Override
public void getDrops(NonNullList<ItemStack> drops, final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) { public void getDrops(IBlockState state, NonNullList<ItemStack> drops, World world, BlockPos pos, int fortune) {
if (RebornCoreConfig.wrenchRequired){ if (RebornCoreConfig.wrenchRequired){
drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame())); drops.add(new ItemStack(TRContent.MachineBlocks.BASIC.getFrame()));
} }

View file

@ -27,6 +27,8 @@ package techreborn.events;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -98,7 +100,7 @@ public class BlockBreakHandler {
for (int i = 1; i < 10; i++) { for (int i = 1; i < 10; i++) {
BlockPos nextPos = pos.up(i); BlockPos nextPos = pos.up(i);
IBlockState nextState = worldIn.getBlockState(nextPos); IBlockState nextState = worldIn.getBlockState(nextPos);
if(nextState.getBlock().isWood(worldIn, nextPos)){ if(nextState.getBlock().isIn(BlockTags.LOGS)){
blocks ++; blocks ++;
} }
} }