mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
Merge branch 'development' into 1.8.9
This commit is contained in:
commit
0cb18773aa
1288 files changed
+11316
-7212
No files matched your search
@@ -12,9 +12,13 @@ import mekanism.common.base.ISustainedInventory;
|
||||
import mekanism.common.block.states.BlockStateEnergyCube;
|
||||
import mekanism.common.block.states.BlockStateFacing;
|
||||
import mekanism.common.item.ItemBlockEnergyCube;
|
||||
import mekanism.common.security.ISecurityItem;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.security.ISecurityTile.SecurityMode;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityEnergyCube;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.SecurityUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -26,6 +30,7 @@ import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -178,6 +183,19 @@ public class BlockEnergyCube extends BlockContainer
|
||||
list.add(charged);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof ISecurityTile)
|
||||
{
|
||||
return SecurityUtils.getSecurity((ISecurityTile)tile) == SecurityMode.PUBLIC ? blockHardness : -1;
|
||||
}
|
||||
|
||||
return blockHardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
@@ -195,24 +213,28 @@ public class BlockEnergyCube extends BlockContainer
|
||||
|
||||
if(MekanismUtils.hasUsableWrench(entityplayer, pos))
|
||||
{
|
||||
if(entityplayer.isSneaking())
|
||||
if(SecurityUtils.canAccess(entityplayer, tileEntity))
|
||||
{
|
||||
dismantleBlock(world, pos, false);
|
||||
return true;
|
||||
if(entityplayer.isSneaking())
|
||||
{
|
||||
dismantleBlock(world, x, y, z, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if(MekanismUtils.isBCWrench(tool))
|
||||
{
|
||||
((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z);
|
||||
}
|
||||
|
||||
int change = ForgeDirection.ROTATION_MATRIX[side][tileEntity.facing];
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
world.notifyBlocksOfNeighborChange(x, y, z, this);
|
||||
}
|
||||
else {
|
||||
SecurityUtils.displayNoAccess(entityplayer);
|
||||
}
|
||||
|
||||
if(MekanismUtils.isBCWrench(tool))
|
||||
{
|
||||
((IToolWrench) tool).wrenchUsed(entityplayer, pos);
|
||||
}
|
||||
|
||||
EnumFacing rotated = tileEntity.facing.rotateAround(side.getAxis());
|
||||
rotated = side.getAxisDirection() == AxisDirection.POSITIVE ? rotated : rotated.getOpposite();
|
||||
|
||||
int change = rotated.ordinal();
|
||||
|
||||
tileEntity.setFacing((short)change);
|
||||
world.notifyNeighborsOfStateChange(pos, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -222,7 +244,14 @@ public class BlockEnergyCube extends BlockContainer
|
||||
{
|
||||
if(!entityplayer.isSneaking())
|
||||
{
|
||||
entityplayer.openGui(Mekanism.instance, 8, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
if(SecurityUtils.canAccess(entityplayer, tileEntity))
|
||||
{
|
||||
entityplayer.openGui(Mekanism.instance, 8, world, x, y, z);
|
||||
}
|
||||
else {
|
||||
SecurityUtils.displayNoAccess(entityplayer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -270,6 +299,22 @@ public class BlockEnergyCube extends BlockContainer
|
||||
{
|
||||
TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(pos);
|
||||
ItemStack itemStack = new ItemStack(MekanismBlocks.EnergyCube);
|
||||
|
||||
if(itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if(tileEntity instanceof ISecurityTile)
|
||||
{
|
||||
ISecurityItem securityItem = (ISecurityItem)itemStack.getItem();
|
||||
|
||||
if(securityItem.hasSecurity(itemStack))
|
||||
{
|
||||
securityItem.setOwner(itemStack, ((ISecurityTile)tileEntity).getSecurity().getOwner());
|
||||
securityItem.setSecurity(itemStack, ((ISecurityTile)tileEntity).getSecurity().getMode());
|
||||
}
|
||||
}
|
||||
|
||||
IEnergyCube energyCube = (IEnergyCube)itemStack.getItem();
|
||||
energyCube.setEnergyCubeTier(itemStack, tileEntity.tier);
|
||||
|
||||
Reference in new issue
Block a user