mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Directional (Advanced?) Breaker
This commit is contained in:
parent
8d766ce83f
commit
486541c794
12 changed files with 486 additions and 12 deletions
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* This file ("BlockDirectionalBreaker.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.ActuallyAdditions;
|
||||
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityDirectionalBreaker;
|
||||
import ellpeck.actuallyadditions.util.IActAddItemOrBlock;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockPistonBase;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockDirectionalBreaker extends BlockContainerBase implements IActAddItemOrBlock{
|
||||
|
||||
private IIcon frontIcon;
|
||||
private IIcon topIcon;
|
||||
|
||||
public BlockDirectionalBreaker(){
|
||||
super(Material.rock);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
this.setHardness(1.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2){
|
||||
return new TileEntityDirectionalBreaker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(side != meta && (side == 0 || side == 1)){
|
||||
return this.topIcon;
|
||||
}
|
||||
if(side == meta){
|
||||
return this.frontIcon;
|
||||
}
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta){
|
||||
if(side == 0 || side == 1){
|
||||
return this.topIcon;
|
||||
}
|
||||
if(side == 3){
|
||||
return this.frontIcon;
|
||||
}
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(!world.isRemote){
|
||||
TileEntityDirectionalBreaker breaker = (TileEntityDirectionalBreaker)world.getTileEntity(x, y, z);
|
||||
if(breaker != null){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.DIRECTIONAL_BREAKER.ordinal(), world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
|
||||
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
||||
world.setBlockMetadataWithNotify(x, y, z, rotation, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
|
||||
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Front");
|
||||
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName()+"Top");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "blockDirectionalBreaker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
||||
this.dropInventory(world, x, y, z);
|
||||
super.breakBlock(world, x, y, z, block, par6);
|
||||
}
|
||||
|
||||
public static class TheItemBlock extends ItemBlock{
|
||||
|
||||
public TheItemBlock(Block block){
|
||||
super(block);
|
||||
this.setHasSubtypes(false);
|
||||
this.setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack){
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage){
|
||||
return damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.epic;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -88,7 +88,7 @@ public class BlockLampPowerer extends Block implements IActAddItemOrBlock{
|
|||
|
||||
private void updateLamp(World world, int x, int y, int z){
|
||||
if(!world.isRemote){
|
||||
WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), world, x, y, z);
|
||||
WorldPos coords = WorldUtil.getCoordsFromSide(ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)), world, x, y, z, 0);
|
||||
if(coords != null && coords.getBlock() instanceof BlockColoredLamp){
|
||||
if(world.isBlockIndirectlyGettingPowered(x, y, z)){
|
||||
if(!((BlockColoredLamp)coords.getBlock()).isOn){
|
||||
|
|
|
@ -94,10 +94,14 @@ public class InitBlocks{
|
|||
public static Block blockSmileyCloud;
|
||||
|
||||
public static Block blockLeafGenerator;
|
||||
public static Block blockDirectionalBreaker;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
||||
blockDirectionalBreaker = new BlockDirectionalBreaker();
|
||||
BlockUtil.register(blockDirectionalBreaker);
|
||||
|
||||
blockLeafGenerator = new BlockLeafGenerator();
|
||||
BlockUtil.register(blockLeafGenerator);
|
||||
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* This file ("ContainerDirectionalBreaker.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.inventory;
|
||||
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityDirectionalBreaker;
|
||||
import invtweaks.api.container.InventoryContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@InventoryContainer
|
||||
public class ContainerDirectionalBreaker extends Container{
|
||||
|
||||
private TileEntityDirectionalBreaker breaker;
|
||||
|
||||
public ContainerDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile){
|
||||
this.breaker = (TileEntityDirectionalBreaker)tile;
|
||||
|
||||
for(int i = 0; i < 3; i++){
|
||||
for(int j = 0; j < 3; j++){
|
||||
this.addSlotToContainer(new Slot(this.breaker, j+i*3, 74+j*18, 21+i*18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 3; i++){
|
||||
for(int j = 0; j < 9; j++){
|
||||
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < 9; i++){
|
||||
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||
final int inventoryStart = 9;
|
||||
final int inventoryEnd = inventoryStart+26;
|
||||
final int hotbarStart = inventoryEnd+1;
|
||||
final int hotbarEnd = hotbarStart+8;
|
||||
|
||||
Slot theSlot = (Slot)this.inventorySlots.get(slot);
|
||||
|
||||
if(theSlot != null && theSlot.getHasStack()){
|
||||
ItemStack newStack = theSlot.getStack();
|
||||
ItemStack currentStack = newStack.copy();
|
||||
|
||||
//Other Slots in Inventory excluded
|
||||
if(slot >= inventoryStart){
|
||||
//Shift from Inventory
|
||||
if(!this.mergeItemStack(newStack, 0, 9, false)){
|
||||
//
|
||||
if(slot >= inventoryStart && slot <= inventoryEnd){
|
||||
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(newStack.stackSize == 0){
|
||||
theSlot.putStack(null);
|
||||
}
|
||||
else{
|
||||
theSlot.onSlotChanged();
|
||||
}
|
||||
|
||||
if(newStack.stackSize == currentStack.stackSize){
|
||||
return null;
|
||||
}
|
||||
theSlot.onPickupFromSlot(player, newStack);
|
||||
|
||||
return currentStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player){
|
||||
return this.breaker.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
|
@ -82,6 +82,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
return new ContainerOreMagnet(entityPlayer.inventory, tile);
|
||||
case CLOUD:
|
||||
return new ContainerSmileyCloud();
|
||||
case DIRECTIONAL_BREAKER:
|
||||
return new ContainerDirectionalBreaker(entityPlayer.inventory, tile);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -144,6 +146,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
return new GuiSmileyCloud(tile, x, y, z, world);
|
||||
case BOOK:
|
||||
return new GuiBooklet(null);
|
||||
case DIRECTIONAL_BREAKER:
|
||||
return new GuiDirectionalBreaker(entityPlayer.inventory, tile);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -174,7 +178,8 @@ public class GuiHandler implements IGuiHandler{
|
|||
XP_SOLIDIFIER,
|
||||
ORE_MAGNET,
|
||||
CLOUD,
|
||||
BOOK(false);
|
||||
BOOK(false),
|
||||
DIRECTIONAL_BREAKER;
|
||||
|
||||
public boolean checkTileEntity;
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* This file ("GuiDirectionalBreaker.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.inventory.gui;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.inventory.ContainerDirectionalBreaker;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityBase;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityDirectionalBreaker;
|
||||
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiDirectionalBreaker extends GuiContainer{
|
||||
|
||||
private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiDirectionalBreaker");
|
||||
private TileEntityDirectionalBreaker breaker;
|
||||
|
||||
public GuiDirectionalBreaker(InventoryPlayer inventory, TileEntityBase tile){
|
||||
super(new ContainerDirectionalBreaker(inventory, tile));
|
||||
this.breaker = (TileEntityDirectionalBreaker)tile;
|
||||
this.xSize = 176;
|
||||
this.ySize = 93+86;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float f){
|
||||
super.drawScreen(x, y, f);
|
||||
|
||||
String text1 = this.breaker.storage.getEnergyStored()+"/"+this.breaker.storage.getMaxEnergyStored()+" RF";
|
||||
if(x >= guiLeft+43 && y >= guiTop+6 && x <= guiLeft+58 && y <= guiTop+88){
|
||||
this.func_146283_a(Collections.singletonList(text1), x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerForegroundLayer(int x, int y){
|
||||
AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.breaker.getInventoryName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGuiContainerBackgroundLayer(float f, int x, int y){
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86);
|
||||
|
||||
this.mc.getTextureManager().bindTexture(resLoc);
|
||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
|
||||
|
||||
if(this.breaker.storage.getEnergyStored() > 0){
|
||||
int i = this.breaker.getEnergyScaled(83);
|
||||
drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 29, 16, i);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@ public class TileEntityBase extends TileEntity{
|
|||
GameRegistry.registerTileEntity(TileEntityOreMagnet.class, ModUtil.MOD_ID_LOWER+":tileEntityOreMagnet");
|
||||
GameRegistry.registerTileEntity(TileEntitySmileyCloud.class, ModUtil.MOD_ID_LOWER+":tileEntityCloud");
|
||||
GameRegistry.registerTileEntity(TileEntityLeafGenerator.class, ModUtil.MOD_ID_LOWER+":tileEntityLeafGenerator");
|
||||
GameRegistry.registerTileEntity(TileEntityDirectionalBreaker.class, ModUtil.MOD_ID_LOWER+":tileEntityDirectionalBreaker");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,7 @@ import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
|||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
@ -44,10 +45,10 @@ public class TileEntityBreaker extends TileEntityInventoryBase{
|
|||
if(this.currentTime <= 0){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord);
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, 0);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(!this.isPlacer && blockToBreak != null && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||
if(!this.isPlacer && blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
int meta = worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), meta, 0));
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* This file ("TileEntityDirectionalBreaker.java") is part of the Actually Additions Mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015 Ellpeck
|
||||
*/
|
||||
|
||||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
|
||||
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
||||
import ellpeck.actuallyadditions.util.WorldPos;
|
||||
import ellpeck.actuallyadditions.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{
|
||||
|
||||
public EnergyStorage storage = new EnergyStorage(10000);
|
||||
private int lastEnergy;
|
||||
|
||||
private int currentTime;
|
||||
|
||||
public TileEntityDirectionalBreaker(){
|
||||
super(9, "directionalBreaker");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateEntity(){
|
||||
if(!worldObj.isRemote){
|
||||
if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){
|
||||
int usagePerBlock = 5; //TODO Config
|
||||
int range = 8; //TODO Config
|
||||
if(this.storage.getEnergyStored() >= usagePerBlock*range){
|
||||
if(this.currentTime > 0){
|
||||
this.currentTime--;
|
||||
if(this.currentTime <= 0){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
for(int i = 0; i < range; i++){
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(blockToBreak != null && !(blockToBreak instanceof BlockAir) && blockToBreak.getBlockHardness(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) > -1.0F){
|
||||
ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
int meta = worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), meta, 0));
|
||||
|
||||
if(WorldUtil.addToInventory(this.slots, drops, false)){
|
||||
worldObj.playAuxSFX(2001, coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ(), Block.getIdFromBlock(blockToBreak)+(meta << 12));
|
||||
WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, i);
|
||||
WorldUtil.addToInventory(this.slots, drops, true);
|
||||
this.storage.extractEnergy(usagePerBlock, false);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.currentTime = ConfigIntValues.BREAKER_TIME_NEEDED.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.storage.getEnergyStored() != this.lastEnergy){
|
||||
this.lastEnergy = this.storage.getEnergyStored();
|
||||
this.sendUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getEnergyScaled(int i){
|
||||
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
this.storage.readFromNBT(compound);
|
||||
this.currentTime = compound.getInteger("CurrentTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
this.storage.writeToNBT(compound);
|
||||
compound.setInteger("CurrentTime", this.currentTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
return this.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){
|
||||
return this.storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from){
|
||||
return this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from){
|
||||
return this.storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getValues(){
|
||||
return new int[]{this.storage.getEnergyStored()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValues(int[] values){
|
||||
this.storage.setEnergyStored(values[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendUpdate(){
|
||||
PacketSyncerToClient.sendPacket(this);
|
||||
}
|
||||
}
|
|
@ -109,7 +109,7 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements
|
|||
if(this.currentTime <= 0){
|
||||
ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
|
||||
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord);
|
||||
WorldPos coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, 0);
|
||||
if(coordsBlock != null){
|
||||
Block blockToBreak = worldObj.getBlock(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ());
|
||||
if(!this.isPlacer && blockToBreak != null && worldObj.getBlockMetadata(coordsBlock.getX(), coordsBlock.getY(), coordsBlock.getZ()) == 0 && FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){
|
||||
|
|
|
@ -32,7 +32,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
|
|||
ArrayList<Integer> blocksAround = new ArrayList<Integer>();
|
||||
if(ConfigIntValues.HEAT_COLLECTOR_ENERGY_PRODUCED.getValue() <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
|
||||
for(int i = 1; i <= 5; i++){
|
||||
WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), worldObj, xCoord, yCoord, zCoord);
|
||||
WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), worldObj, xCoord, yCoord, zCoord, 0);
|
||||
if(coords != null){
|
||||
Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ());
|
||||
if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){
|
||||
|
|
|
@ -48,22 +48,26 @@ public class WorldUtil{
|
|||
*/
|
||||
public static final ForgeDirection[] CARDINAL_DIRECTIONS_ORDER = new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.WEST};
|
||||
|
||||
public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z){
|
||||
public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z, int offset){
|
||||
if(side == ForgeDirection.UNKNOWN){
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
WorldPos c = getCoordsFromSide(side, world, x, y, z);
|
||||
WorldPos c = getCoordsFromSide(side, world, x, y, z, offset);
|
||||
if(c != null){
|
||||
world.setBlockToAir(c.getX(), c.getY(), c.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
public static WorldPos getCoordsFromSide(ForgeDirection side, World world, int x, int y, int z){
|
||||
public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z){
|
||||
breakBlockAtSide(side, world, x, y, z, 0);
|
||||
}
|
||||
|
||||
public static WorldPos getCoordsFromSide(ForgeDirection side, World world, int x, int y, int z, int offset){
|
||||
if(side == ForgeDirection.UNKNOWN){
|
||||
return null;
|
||||
}
|
||||
return new WorldPos(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ);
|
||||
return new WorldPos(world, x+side.offsetX*(offset+1), y+side.offsetY*(offset+1), z+side.offsetZ*(offset+1));
|
||||
}
|
||||
|
||||
public static void pushEnergy(World world, int x, int y, int z, ForgeDirection side, EnergyStorage storage){
|
||||
|
@ -77,7 +81,7 @@ public class WorldUtil{
|
|||
}
|
||||
|
||||
public static TileEntity getTileEntityFromSide(ForgeDirection side, World world, int x, int y, int z){
|
||||
WorldPos c = getCoordsFromSide(side, world, x, y, z);
|
||||
WorldPos c = getCoordsFromSide(side, world, x, y, z, 0);
|
||||
if(c != null){
|
||||
return world.getTileEntity(c.getX(), c.getY(), c.getZ());
|
||||
}
|
||||
|
@ -163,7 +167,7 @@ public class WorldUtil{
|
|||
|
||||
public static boolean dropItemAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){
|
||||
if(side != ForgeDirection.UNKNOWN){
|
||||
WorldPos coords = getCoordsFromSide(side, world, x, y, z);
|
||||
WorldPos coords = getCoordsFromSide(side, world, x, y, z, 0);
|
||||
if(coords != null){
|
||||
EntityItem item = new EntityItem(world, coords.getX()+0.5, coords.getY()+0.5, coords.getZ()+0.5, stack);
|
||||
item.motionX = 0;
|
||||
|
|
Loading…
Reference in a new issue