Added check for config for block break with pickaxe. Closes #1172

This commit is contained in:
drcrazy 2017-09-28 02:03:16 +03:00
parent ffe13d0c79
commit 40e470629d
25 changed files with 188 additions and 121 deletions

View file

@ -24,19 +24,20 @@
package techreborn.blocks.storage;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
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.storage.TileAdjustableSU;
import java.util.ArrayList;
import java.util.List;
public class BlockAdjustableSU extends BlockEnergyStorage {
public BlockAdjustableSU() {
super("AESU", EGui.AESU.ordinal());
@ -49,8 +50,15 @@ public class BlockAdjustableSU extends BlockEnergyStorage {
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 2));
return list;
List<ItemStack> items = new ArrayList<ItemStack>();
if (RebornCoreConfig.wrenchRequired){
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 2));
}
else {
items.add(new ItemStack(this));
}
return items;
}
}

View file

@ -32,17 +32,22 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.api.IToolDrop;
import reborncore.api.IToolHandler;
import reborncore.common.BaseTileBlock;
import techreborn.Core;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModSounds;
import techreborn.lib.ModInfo;
import java.util.Iterator;
@ -69,10 +74,28 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack heldStack = player.getHeldItem(hand);
if(heldStack.getItem() instanceof IToolHandler){
if(((IToolHandler) heldStack.getItem()).handleTool(heldStack, pos, world, player, side, true)){
if (state.getBlock() instanceof BlockEnergyStorage) {
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
if(!stack.isEmpty() && stack.getItem() instanceof IToolHandler){
IToolHandler toolHandler = (IToolHandler) stack.getItem();
if(toolHandler.handleTool(stack, pos, world, player, side, true) && state.getBlock() instanceof BlockEnergyStorage){
if (player.isSneaking()) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof IToolDrop) {
ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(player);
if (drop == null) {
return false;
}
if (!drop.isEmpty()) {
spawnAsEntity(world, pos, drop);
}
world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.BLOCK_DISMANTLE,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!world.isRemote) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return true;
}
} else {
EnumFacing facing2 = state.getValue(BlockEnergyStorage.FACING);
if (facing2.getOpposite() == side) {
facing2 = side;
@ -83,11 +106,11 @@ public abstract class BlockEnergyStorage extends BaseTileBlock {
return true;
}
}
} else if (!player.isSneaking()){
player.openGui(Core.INSTANCE, guiID, world, pos.getX(), pos.getY(), pos.getZ());
}
if (!player.isSneaking())
player.openGui(Core.INSTANCE, guiID, world, pos.getX(), pos.getY(), pos.getZ());
return true;
return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
protected BlockStateContainer createBlockState() {

View file

@ -24,19 +24,20 @@
package techreborn.blocks.storage;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
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.storage.TileHighVoltageSU;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 14/03/2016.
*/
@ -53,8 +54,15 @@ public class BlockHighVoltageSU extends BlockEnergyStorage {
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
return list;
List<ItemStack> items = new ArrayList<ItemStack>();
if (RebornCoreConfig.wrenchRequired){
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
}
else {
items.add(new ItemStack(this));
}
return items;
}
}

View file

@ -30,14 +30,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.client.EGui;
import techreborn.tiles.idsu.TileInterdimensionalSU;
import java.util.ArrayList;
import java.util.List;
public class BlockInterdimensionalSU extends BlockEnergyStorage {
public BlockInterdimensionalSU() {
super("IDSU", EGui.IDSU.ordinal());
@ -58,13 +54,6 @@ public class BlockInterdimensionalSU extends BlockEnergyStorage {
return this.getDefaultState();
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(this, 1, 2));
return list;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);

View file

@ -45,7 +45,6 @@ import java.util.ArrayList;
import java.util.List;
public class BlockLSUStorage extends BaseTileBlock {
;
public BlockLSUStorage() {
super(Material.IRON);

View file

@ -24,18 +24,11 @@
package techreborn.blocks.storage;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.client.EGui;
import techreborn.tiles.lesu.TileLapotronicSU;
import java.util.ArrayList;
import java.util.List;
public class BlockLapotronicSU extends BlockEnergyStorage {
public BlockLapotronicSU() {
super("LESU", EGui.LESU.ordinal());
@ -45,11 +38,4 @@ public class BlockLapotronicSU extends BlockEnergyStorage {
public TileEntity createNewTileEntity(final World world, final int p_149915_2_) {
return new TileLapotronicSU();
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(this, 1, 2));
return list;
}
}

View file

@ -24,18 +24,11 @@
package techreborn.blocks.storage;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.client.EGui;
import techreborn.tiles.storage.TileLowVoltageSU;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 14/03/2016.
*/
@ -48,11 +41,4 @@ public class BlockLowVoltageSU extends BlockEnergyStorage {
public TileEntity createNewTileEntity(final World world, final int p_149915_2_) {
return new TileLowVoltageSU();
}
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(this));
return list;
}
}

View file

@ -24,19 +24,20 @@
package techreborn.blocks.storage;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
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.storage.TileMediumVoltageSU;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 14/03/2016.
*/
@ -52,8 +53,15 @@ public class BlockMediumVoltageSU extends BlockEnergyStorage {
@Override
public List<ItemStack> getDrops(final IBlockAccess world, final BlockPos pos, final IBlockState state, final int fortune) {
final ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 0, 1));
return list;
List<ItemStack> items = new ArrayList<ItemStack>();
if (RebornCoreConfig.wrenchRequired){
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
}
else {
items.add(new ItemStack(this));
}
return items;
}
}

View file

@ -24,18 +24,19 @@
package techreborn.blocks.transformers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import reborncore.common.RebornCoreConfig;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileHVTransformer;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -49,12 +50,17 @@ public class BlockHVTransformer extends BlockTransformer {
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileHVTransformer();
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 1));
return list;
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));
}
else {
items.add(new ItemStack(this));
}
return items;
}
}

View file

@ -24,17 +24,10 @@
package techreborn.blocks.transformers;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import techreborn.tiles.transformers.TileLVTransformer;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -48,11 +41,4 @@ public class BlockLVTransformer extends BlockTransformer {
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileLVTransformer();
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(this, 1, 0));
return list;
}
}

View file

@ -24,18 +24,19 @@
package techreborn.blocks.transformers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import reborncore.common.RebornCoreConfig;
import techreborn.init.ModBlocks;
import techreborn.tiles.transformers.TileMVTransformer;
import java.util.ArrayList;
import java.util.List;
/**
* Created by modmuss50 on 16/03/2016.
*/
@ -51,9 +52,16 @@ public class BlockMVTransformer extends BlockTransformer {
}
@Override
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
ArrayList<ItemStack> list = new ArrayList<>();
list.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
return list;
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));
}
else {
items.add(new ItemStack(this));
}
return items;
}
}

View file

@ -33,19 +33,26 @@ import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidBase;
import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound;
import reborncore.api.IToolDrop;
import reborncore.api.IToolHandler;
import reborncore.common.BaseTileBlock;
import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModSounds;
import techreborn.lib.ModInfo;
import java.util.ArrayList;
@ -115,6 +122,46 @@ public abstract class BlockTransformer extends BaseTileBlock {
setFacing(facing, worldIn, pos);
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
if(!stack.isEmpty() && stack.getItem() instanceof IToolHandler){
IToolHandler toolHandler = (IToolHandler) stack.getItem();
if(toolHandler.handleTool(stack, pos, world, player, side, true) && state.getBlock() instanceof BlockTransformer){
if (player.isSneaking()) {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof IToolDrop) {
ItemStack drop = ((IToolDrop) tileEntity).getToolDrop(player);
if (drop == null) {
return false;
}
if (!drop.isEmpty()) {
spawnAsEntity(world, pos, drop);
}
world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.BLOCK_DISMANTLE,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!world.isRemote) {
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);
}
return true;
}
} else {
EnumFacing facing2 = state.getValue(BlockTransformer.FACING);
if (facing2.getOpposite() == side) {
facing2 = side;
} else {
facing2 = side.getOpposite();
}
world.setBlockState(pos, state.withProperty(BlockTransformer.FACING, facing2));
return true;
}
}
}
return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
protected List<ItemStack> dropInventory(IBlockAccess world, BlockPos pos, ItemStack itemToDrop) {
TileEntity tileEntity = world.getTileEntity(pos);

View file

@ -40,7 +40,6 @@ import techreborn.tiles.multiblock.TileIndustrialSawmill;
import javax.annotation.Nonnull;
@SuppressWarnings("deprecation")
public class IndustrialSawmillRecipeCategory implements IRecipeCategory<IndustrialSawmillRecipeWrapper> {
private final String title;

View file

@ -70,8 +70,8 @@ public class TileAssemblingMachine extends TilePowerAcceptor
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
this.charge(3);
}

View file

@ -63,8 +63,8 @@ public class TilePump extends TilePowerAcceptor {
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!world.isRemote && world.getTotalWorldTime() % 10 == 0 && !tank.isFull() && tank.getCapacity() - tank.getFluidAmount() >= 1000 && canUseEnergy(pumpExtractEU)) {
FluidStack fluidStack = drainBlock(world, pos.down(), false);
if (fluidStack != null) {
@ -167,6 +167,7 @@ public class TilePump extends TilePowerAcceptor {
return super.hasCapability(capability, facing);
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {

View file

@ -91,8 +91,8 @@ public class TileQuantumTank extends TileLegacyMachineBase
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!this.world.isRemote) {
if (FluidUtils.drainContainers(this.tank, this.inventory, 0, 1)
|| FluidUtils.fillContainers(this.tank, this.inventory, 0, 1, this.tank.getFluidType()))
@ -114,6 +114,7 @@ public class TileQuantumTank extends TileLegacyMachineBase
return super.hasCapability(capability, facing);
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {

View file

@ -174,6 +174,7 @@ public abstract class TileBaseFluidGenerator extends TilePowerAcceptor implement
return super.hasCapability(capability, facing);
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {

View file

@ -57,8 +57,8 @@ public class TileDragonEggSyphon extends TilePowerAcceptor implements IToolDrop,
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!world.isRemote) {
if (world.getBlockState(new BlockPos(getPos().getX(), getPos().getY() + 1, getPos().getZ()))

View file

@ -61,8 +61,8 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (!this.world.isRemote) {
if (this.world.getTotalWorldTime() % 60 == 0) {
this.shouldMakePower = this.isSunOut();

View file

@ -73,8 +73,8 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (this.world.isRemote) {
return;
}

View file

@ -57,8 +57,8 @@ public class TileWindMill extends TilePowerAcceptor implements IToolDrop {
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (this.pos.getY() > 64) {
int actualPower = this.basePower;
if (this.world.isThundering()) {

View file

@ -34,8 +34,8 @@ public class TileLSUStorage extends TileLegacyMachineBase {
public LesuNetwork network;
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (network == null) {
findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ());
} else {

View file

@ -25,19 +25,23 @@
package techreborn.tiles.lesu;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.api.IToolDrop;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.util.Inventory;
import techreborn.blocks.storage.BlockLapotronicSU;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import java.util.ArrayList;
@RebornRegistry(modID = ModInfo.MOD_ID)
public class TileLapotronicSU extends TilePowerAcceptor {// TODO wrench
public class TileLapotronicSU extends TilePowerAcceptor implements IToolDrop{// TODO wrench
@ConfigRegistry(config = "machines", category = "lesu", key = "LesuMaxInput", comment = "LESU Max Input (Value in EU)")
public static int maxInput = 8192;
@ -62,8 +66,8 @@ public class TileLapotronicSU extends TilePowerAcceptor {// TODO wrench
}
@Override
public void updateEntity() {
super.updateEntity();
public void update() {
super.update();
if (world.isRemote) {
return;
}
@ -150,4 +154,9 @@ public class TileLapotronicSU extends TilePowerAcceptor {// TODO wrench
}
return null;
}
@Override
public ItemStack getToolDrop(EntityPlayer p0) {
return new ItemStack(ModBlocks.LAPOTRONIC_SU, 1);
}
}

View file

@ -156,6 +156,7 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDro
return super.hasCapability(capability, facing);
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {

View file

@ -195,6 +195,7 @@ public class TileIndustrialSawmill extends TilePowerAcceptor
return super.hasCapability(capability, facing);
}
@SuppressWarnings("unchecked")
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {