Updated wrenching logic for energy storages and casings. Closes #1543
This commit is contained in:
parent
24bce3ce66
commit
7be239adca
8 changed files with 101 additions and 51 deletions
|
@ -30,9 +30,12 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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;
|
||||
|
@ -41,8 +44,11 @@ import net.minecraftforge.fml.relauncher.Side;
|
|||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import prospector.shootingstar.ShootingStar;
|
||||
import prospector.shootingstar.model.ModelCompound;
|
||||
import reborncore.api.ToolManager;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.blocks.BlockWrenchEventHandler;
|
||||
import reborncore.common.blocks.PropertyString;
|
||||
import reborncore.common.items.WrenchHelper;
|
||||
import reborncore.common.multiblock.BlockMultiblockBase;
|
||||
import reborncore.common.util.ArrayUtils;
|
||||
import techreborn.utils.TechRebornCreativeTab;
|
||||
|
@ -68,6 +74,7 @@ public class BlockMachineCasing extends BlockMultiblockBase {
|
|||
for (int i = 0; i < types.length; i++) {
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, i, "machines/structure").setInvVariant("type=" + types[i]));
|
||||
}
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
}
|
||||
|
||||
public static ItemStack getStackByName(String name, int count) {
|
||||
|
@ -104,12 +111,40 @@ public class BlockMachineCasing extends BlockMultiblockBase {
|
|||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired){
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
|
||||
if (state.getValue(TYPE) == "reinforced") {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
|
||||
}
|
||||
else if (state.getValue(TYPE) == "advanced") {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 2));
|
||||
}
|
||||
else {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
|
||||
EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
|
||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||
|
||||
// We extended BaseTileBlock. Thus we should always have tile entity. I hope.
|
||||
if (tileEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchHelper.handleWrench(stack, worldIn, pos, playerIn, side)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.blocks.storage;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -35,9 +36,6 @@ import techreborn.client.EGui;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.storage.TileAdjustableSU;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockAdjustableSU extends BlockEnergyStorage {
|
||||
|
||||
public BlockAdjustableSU() {
|
||||
|
@ -50,16 +48,11 @@ public class BlockAdjustableSU extends BlockEnergyStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
if (RebornCoreConfig.wrenchRequired){
|
||||
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 2));
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired) {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 2));
|
||||
} else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
else {
|
||||
items.add(new ItemStack(this));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.blocks.storage;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -35,9 +36,6 @@ import techreborn.client.EGui;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.storage.TileHighVoltageSU;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
|
@ -53,16 +51,11 @@ public class BlockHighVoltageSU extends BlockEnergyStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
if (RebornCoreConfig.wrenchRequired){
|
||||
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired) {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
|
||||
} else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
else {
|
||||
items.add(new ItemStack(this));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,13 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import techreborn.client.EGui;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.idsu.TileInterdimensionalSU;
|
||||
|
||||
public class BlockInterdimensionalSU extends BlockEnergyStorage {
|
||||
|
@ -63,4 +67,13 @@ public class BlockInterdimensionalSU extends BlockEnergyStorage {
|
|||
((TileInterdimensionalSU) tile).ownerUdid = placer.getUniqueID().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired) {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
|
||||
} else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,14 +42,13 @@ import prospector.shootingstar.model.ModelCompound;
|
|||
import reborncore.api.ToolManager;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.blocks.BlockWrenchEventHandler;
|
||||
import reborncore.common.items.WrenchHelper;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.lesu.TileLSUStorage;
|
||||
import techreborn.utils.TechRebornCreativeTab;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Energy storage block for LESU
|
||||
*/
|
||||
|
@ -59,6 +58,7 @@ public class BlockLSUStorage extends BaseTileBlock {
|
|||
super(Material.IRON);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy"));
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
}
|
||||
|
||||
// BaseTileBlock
|
||||
|
@ -111,16 +111,12 @@ public class BlockLSUStorage extends BaseTileBlock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
NonNullList<ItemStack> items = NonNullList.create();
|
||||
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired) {
|
||||
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
|
||||
} else {
|
||||
super.getDrops(items, world, pos, state, fortune);
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,9 +24,16 @@
|
|||
|
||||
package techreborn.blocks.storage;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import techreborn.client.EGui;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.lesu.TileLapotronicSU;
|
||||
|
||||
public class BlockLapotronicSU extends BlockEnergyStorage {
|
||||
|
@ -39,4 +46,13 @@ public class BlockLapotronicSU extends BlockEnergyStorage {
|
|||
public TileEntity createNewTileEntity(final World world, final int meta) {
|
||||
return new TileLapotronicSU();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired) {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
|
||||
} else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.blocks.storage;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -35,9 +36,6 @@ import techreborn.client.EGui;
|
|||
import techreborn.init.ModBlocks;
|
||||
import techreborn.tiles.storage.TileMediumVoltageSU;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
|
@ -53,16 +51,11 @@ public class BlockMediumVoltageSU extends BlockEnergyStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
if (RebornCoreConfig.wrenchRequired){
|
||||
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
if (RebornCoreConfig.wrenchRequired) {
|
||||
drops.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
|
||||
} else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
else {
|
||||
items.add(new ItemStack(this));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,13 +24,18 @@
|
|||
|
||||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.multiblock.MultiblockControllerBase;
|
||||
import reborncore.common.multiblock.MultiblockValidationException;
|
||||
import reborncore.common.multiblock.rectangular.RectangularMultiblockTileEntityBase;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.multiblocks.MultiBlockCasing;
|
||||
|
||||
public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
|
||||
|
||||
public class TileMachineCasing extends RectangularMultiblockTileEntityBase
|
||||
implements IToolDrop {
|
||||
|
||||
@Override
|
||||
public void onMachineActivated() {
|
||||
|
||||
|
@ -85,4 +90,10 @@ public class TileMachineCasing extends RectangularMultiblockTileEntityBase {
|
|||
public void update() {
|
||||
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||
return BlockMachineCasing.getStackByName(world.getBlockState(pos).getValue(BlockMachineCasing.TYPE));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue