mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Added the coolest block in the mod so far
This commit is contained in:
parent
fc1005ee0a
commit
312484bcfc
37 changed files with 467 additions and 45 deletions
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* This file ("BlockBatteryBox.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockBatteryBox extends BlockContainerBase{
|
||||
|
||||
public BlockBatteryBox(String name){
|
||||
super(Material.ROCK, name);
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
this.setHardness(1.5F);
|
||||
this.setResistance(10.0F);
|
||||
this.setSoundType(SoundType.STONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
|
||||
return BlockSlabs.AABB_BOTTOM_HALF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta){
|
||||
return new TileEntityBatteryBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof TileEntityBatteryBox){
|
||||
TileEntityBatteryBox box = (TileEntityBatteryBox)tile;
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
|
||||
if(StackUtil.isValid(stack)){
|
||||
if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.slots.getStackInSlot(0))){
|
||||
box.slots.setStackInSlot(0, stack.copy());
|
||||
player.setHeldItem(hand, StackUtil.getNull());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
ItemStack inSlot = box.slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(inSlot)){
|
||||
player.setHeldItem(hand, inSlot.copy());
|
||||
box.slots.setStackInSlot(0, StackUtil.getNull());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
}
|
|
@ -109,10 +109,12 @@ public final class InitBlocks{
|
|||
public static Block blockBioReactor;
|
||||
public static Block blockTinyTorch;
|
||||
public static Block blockFarmer;
|
||||
public static Block blockBatteryBox;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Blocks...");
|
||||
|
||||
blockBatteryBox = new BlockBatteryBox("block_battery_box");
|
||||
blockItemViewerHopping = new BlockItemViewerHopping("block_item_viewer_hopping");
|
||||
blockFarmer = new BlockFarmer("block_farmer");
|
||||
blockBioReactor = new BlockBioReactor("block_bio_reactor");
|
||||
|
|
|
@ -135,7 +135,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
|||
TileEntity tile = world.getTileEntity(pos);
|
||||
if(tile instanceof TileEntityBase){
|
||||
TileEntityBase base = (TileEntityBase)tile;
|
||||
if(base.isRedstoneToggle() && base.isPulseMode){
|
||||
if(base.respondsToPulses()){
|
||||
base.activateOnPulse();
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
|||
boolean powered = world.isBlockIndirectlyGettingPowered(pos) > 0;
|
||||
boolean wasPowered = base.isRedstonePowered;
|
||||
if(powered && !wasPowered){
|
||||
if(base.isRedstoneToggle() && base.isPulseMode){
|
||||
if(base.respondsToPulses()){
|
||||
world.scheduleUpdate(pos, this, this.tickRate(world));
|
||||
}
|
||||
base.setRedstonePowered(true);
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* This file ("RenderBatteryBox.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderBatteryBox extends TileEntitySpecialRenderer{
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5, int par6){
|
||||
if(!(tile instanceof TileEntityBatteryBox)){
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = ((TileEntityBatteryBox)tile).slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
GlStateManager.scale(0.0075F, 0.0075F, 0.0075F);
|
||||
GlStateManager.rotate(180F, 1F, 0F, 0F);
|
||||
GlStateManager.translate(0F, 0F, -50F);
|
||||
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage cap = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
|
||||
|
||||
String s = format.format(cap.getEnergyStored())+"/"+format.format(cap.getMaxEnergyStored());
|
||||
float lengthS = -font.getStringWidth(s)/2F;
|
||||
String s2 = "Crystal Flux";
|
||||
float lengthS2 = -font.getStringWidth(s2)/2F;
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
font.drawString(s, lengthS, 10F, 0xFFFFFF, false);
|
||||
font.drawString(s2, lengthS2, 20F, 0xFFFFFF, false);
|
||||
|
||||
GlStateManager.translate(-50F, 0F, 50F);
|
||||
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
double boop = Minecraft.getSystemTime()/800D;
|
||||
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.065, 0D);
|
||||
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
|
||||
|
||||
float scale = stack.getItem() instanceof ItemBlock ? 0.85F : 0.65F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
try{
|
||||
AssetUtil.renderItemInWorld(stack);
|
||||
}
|
||||
catch(Exception e){
|
||||
ModUtil.LOGGER.error("Something went wrong trying to render an item in a battery box! The item is "+stack.getItem().getRegistryName()+"!", e);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,10 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderCompost extends TileEntitySpecialRenderer{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,10 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderDisplayStand extends TileEntitySpecialRenderer{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,10 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderEmpowerer extends TileEntitySpecialRenderer{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,10 @@ import io.netty.util.internal.ConcurrentSet;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderLaserRelay extends TileEntitySpecialRenderer{
|
||||
|
||||
private static final float[] COLOR = new float[]{1F, 0F, 0F};
|
||||
|
|
|
@ -20,7 +20,10 @@ import net.minecraft.client.renderer.GlStateManager;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderReconstructorLens extends TileEntitySpecialRenderer{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,10 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderSmileyCloud extends TileEntitySpecialRenderer{
|
||||
|
||||
@Override
|
||||
|
|
|
@ -112,6 +112,7 @@ public class CreativeTab extends CreativeTabs{
|
|||
this.add(InitBlocks.blockDropper);
|
||||
this.add(InitBlocks.blockFluidPlacer);
|
||||
this.add(InitBlocks.blockFluidCollector);
|
||||
this.add(InitBlocks.blockBatteryBox);
|
||||
|
||||
this.add(InitBlocks.blockMisc);
|
||||
this.add(InitBlocks.blockFeeder);
|
||||
|
|
|
@ -238,11 +238,11 @@ public final class InitItems{
|
|||
itemTeleStaff = new ItemTeleStaff("item_tele_staff");
|
||||
itemWingsOfTheBats = new ItemWingsOfTheBats("item_wings_of_the_bats");
|
||||
itemDrill = new ItemDrill("item_drill");
|
||||
itemBattery = new ItemBattery("item_battery", 200000, 500);
|
||||
itemBatteryDouble = new ItemBattery("item_battery_double", 350000, 1000);
|
||||
itemBatteryTriple = new ItemBattery("item_battery_triple", 600000, 2000);
|
||||
itemBatteryQuadruple = new ItemBattery("item_battery_quadruple", 1000000, 4000);
|
||||
itemBatteryQuintuple = new ItemBattery("item_battery_quintuple", 2000000, 8000);
|
||||
itemBattery = new ItemBattery("item_battery", 200000, 1000);
|
||||
itemBatteryDouble = new ItemBattery("item_battery_double", 350000, 5000);
|
||||
itemBatteryTriple = new ItemBattery("item_battery_triple", 600000, 10000);
|
||||
itemBatteryQuadruple = new ItemBattery("item_battery_quadruple", 1000000, 30000);
|
||||
itemBatteryQuintuple = new ItemBattery("item_battery_quintuple", 2000000, 100000);
|
||||
itemDrillUpgradeSpeed = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED, "item_drill_upgrade_speed");
|
||||
itemDrillUpgradeSpeedII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II, "item_drill_upgrade_speed_ii");
|
||||
itemDrillUpgradeSpeedIII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_III, "item_drill_upgrade_speed_iii");
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ItemBattery extends ItemEnergy{
|
|||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected){
|
||||
if(!world.isRemote && entity instanceof EntityPlayer && ItemUtil.isEnabled(stack)){
|
||||
if(!world.isRemote && entity instanceof EntityPlayer && ItemUtil.isEnabled(stack) && !isSelected){
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
|
||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||
|
|
|
@ -191,7 +191,7 @@ public abstract class ItemEnergy extends ItemBase{
|
|||
|
||||
private static class EnergyCapabilityProvider implements ICapabilityProvider{
|
||||
|
||||
private final CustomEnergyStorage storage;
|
||||
public final CustomEnergyStorage storage;
|
||||
private Object teslaWrapper;
|
||||
|
||||
public EnergyCapabilityProvider(final ItemStack stack, ItemEnergy item){
|
||||
|
|
|
@ -84,6 +84,7 @@ public class ClientProxy implements IProxy{
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayStand.class, new RenderDisplayStand());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEmpowerer.class, new RenderEmpowerer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBatteryBox.class, new RenderBatteryBox());
|
||||
|
||||
TileEntitySpecialRenderer laser = new RenderLaserRelay();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserRelayEnergy.class, laser);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface ISharingEnergyProvider{
|
||||
|
@ -20,4 +21,5 @@ public interface ISharingEnergyProvider{
|
|||
|
||||
EnumFacing[] getEnergyShareSides();
|
||||
|
||||
boolean canShareTo(TileEntity tile);
|
||||
}
|
||||
|
|
|
@ -161,12 +161,6 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
return StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(){
|
||||
super.markDirty();
|
||||
this.sendUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack){
|
||||
return true;
|
||||
|
|
|
@ -120,6 +120,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
register(TileEntityBioReactor.class);
|
||||
register(TileEntityFarmer.class);
|
||||
register(TileEntityItemViewerHopping.class);
|
||||
register(TileEntityBatteryBox.class);
|
||||
}
|
||||
|
||||
private static void register(Class<? extends TileEntityBase> tileClass){
|
||||
|
@ -253,7 +254,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
|
||||
for(EnumFacing side : sides){
|
||||
TileEntity tile = this.tilesAround[side.ordinal()];
|
||||
if(tile != null){
|
||||
if(tile != null && provider.canShareTo(tile)){
|
||||
WorldUtil.doEnergyInteraction(this, tile, side, amount);
|
||||
}
|
||||
}
|
||||
|
@ -381,6 +382,10 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
|
|||
|
||||
}
|
||||
|
||||
public boolean respondsToPulses(){
|
||||
return this.isRedstoneToggle() && this.isPulseMode;
|
||||
}
|
||||
|
||||
public enum NBTType{
|
||||
SAVE_TILE,
|
||||
SYNC,
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
* This file ("TileEntityBatteryBox.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://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2016 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.tile;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||
|
||||
private int lastEnergyStored;
|
||||
|
||||
public TileEntityBatteryBox(){
|
||||
super(1, "batteryBox");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
ItemStack stack = this.slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
return stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
super.updateEntity();
|
||||
|
||||
if(!this.world.isRemote){
|
||||
int currStorage = 0;
|
||||
|
||||
IEnergyStorage storage = this.getEnergyStorage(null);
|
||||
if(storage != null){
|
||||
ItemStack stack = this.slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)){
|
||||
if(storage.getEnergyStored() > 0){
|
||||
List<TileEntityBatteryBox> tiles = new ArrayList<TileEntityBatteryBox>();
|
||||
this.energyPushOffLoop(this, tiles);
|
||||
|
||||
if(!tiles.isEmpty()){
|
||||
int amount = tiles.size();
|
||||
|
||||
int energyPer = storage.getEnergyStored()/amount;
|
||||
if(energyPer <= 0){
|
||||
energyPer = storage.getEnergyStored();
|
||||
}
|
||||
int maxPer = storage.extractEnergy(energyPer, true);
|
||||
|
||||
for(TileEntityBatteryBox tile : tiles){
|
||||
ItemStack battery = tile.slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)){
|
||||
if(tile.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(cap != null){
|
||||
int received = cap.receiveEnergy(maxPer, false);
|
||||
storage.extractEnergy(received, false);
|
||||
|
||||
if(storage.getEnergyStored() <= 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currStorage = storage.getEnergyStored();
|
||||
}
|
||||
|
||||
if(this.lastEnergyStored != currStorage && this.sendUpdateWithInterval()){
|
||||
this.lastEnergyStored = currStorage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean respondsToPulses(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activateOnPulse(){
|
||||
ItemStack stack = this.slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(stack)){
|
||||
ItemUtil.changeEnabled(stack);
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void energyPushOffLoop(TileEntityBatteryBox startTile, List<TileEntityBatteryBox> pushOffTo){
|
||||
if(pushOffTo.size() >= 15){
|
||||
return;
|
||||
}
|
||||
|
||||
for(TileEntity tile : startTile.tilesAround){
|
||||
if(tile instanceof TileEntityBatteryBox){
|
||||
TileEntityBatteryBox box = (TileEntityBatteryBox)tile;
|
||||
if(!pushOffTo.contains(box)){
|
||||
pushOffTo.add(box);
|
||||
|
||||
this.energyPushOffLoop(box, pushOffTo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
||||
return StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSyncSlots(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
IEnergyStorage storage = this.getEnergyStorage(null);
|
||||
if(storage != null){
|
||||
return storage.getEnergyStored();
|
||||
}
|
||||
else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesShareEnergy(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return !(tile instanceof TileEntityBatteryBox);
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import net.minecraft.item.ItemBlock;
|
|||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -152,6 +153,11 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -128,6 +129,11 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -94,12 +94,6 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
|||
return getRecipeForInput(stack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(){
|
||||
super.markDirty();
|
||||
this.sendUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack){
|
||||
return getRecipeForInput(stack) == null;
|
||||
|
|
|
@ -57,12 +57,6 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(){
|
||||
super.markDirty();
|
||||
this.sendUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack){
|
||||
return true;
|
||||
|
|
|
@ -126,12 +126,6 @@ public class TileEntityDistributorItem extends TileEntityInventoryBase{
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(){
|
||||
super.markDirty();
|
||||
this.sendUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveDataOnChangeOrWorldStart(){
|
||||
return true;
|
||||
|
|
|
@ -157,12 +157,6 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(){
|
||||
super.markDirty();
|
||||
this.sendUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack){
|
||||
return !getRecipesForInput(stack).isEmpty();
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.darkhax.tesla.api.ITeslaHolder;
|
|||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -122,6 +123,11 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -102,6 +103,11 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEn
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -115,6 +116,11 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -107,6 +107,15 @@ public abstract class TileEntityInventoryBase extends TileEntityBase{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty(){
|
||||
super.markDirty();
|
||||
|
||||
if(this.shouldSyncSlots()){
|
||||
this.sendUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorStrength(){
|
||||
return ItemHandlerHelper.calcRedstoneFromInventory(this.slots);
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -119,6 +120,11 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
|||
import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
@ -190,6 +191,11 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
|||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
||||
return this.storage;
|
||||
|
|
|
@ -58,4 +58,9 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
public EnumFacing[] getEnergyShareSides(){
|
||||
return EnumFacing.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShareTo(TileEntity tile){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -171,8 +171,10 @@ public final class ItemUtil{
|
|||
}
|
||||
|
||||
public static void changeEnabled(EntityPlayer player, EnumHand hand){
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
changeEnabled(player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
public static void changeEnabled(ItemStack stack){
|
||||
if(!stack.hasTagCompound()){
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
|
|
@ -67,9 +67,10 @@ public final class WorldUtil{
|
|||
|
||||
public static void doEnergyInteraction(TileEntity tileFrom, TileEntity tileTo, EnumFacing sideTo, int maxTransfer){
|
||||
if(maxTransfer > 0){
|
||||
if(tileFrom.hasCapability(CapabilityEnergy.ENERGY, sideTo) && tileTo.hasCapability(CapabilityEnergy.ENERGY, sideTo.getOpposite())){
|
||||
EnumFacing opp = sideTo == null ? null : sideTo.getOpposite();
|
||||
if(tileFrom.hasCapability(CapabilityEnergy.ENERGY, sideTo) && tileTo.hasCapability(CapabilityEnergy.ENERGY, opp)){
|
||||
IEnergyStorage handlerFrom = tileFrom.getCapability(CapabilityEnergy.ENERGY, sideTo);
|
||||
IEnergyStorage handlerTo = tileTo.getCapability(CapabilityEnergy.ENERGY, sideTo.getOpposite());
|
||||
IEnergyStorage handlerTo = tileTo.getCapability(CapabilityEnergy.ENERGY, opp);
|
||||
|
||||
if(handlerFrom != null && handlerTo != null){
|
||||
int drain = handlerFrom.extractEnergy(maxTransfer, true);
|
||||
|
@ -82,8 +83,8 @@ public final class WorldUtil{
|
|||
}
|
||||
|
||||
if(ActuallyAdditions.teslaLoaded){
|
||||
if(tileTo.hasCapability(TeslaUtil.teslaConsumer, sideTo.getOpposite()) && tileFrom.hasCapability(TeslaUtil.teslaProducer, sideTo)){
|
||||
ITeslaConsumer handlerTo = tileTo.getCapability(TeslaUtil.teslaConsumer, sideTo.getOpposite());
|
||||
if(tileTo.hasCapability(TeslaUtil.teslaConsumer, opp) && tileFrom.hasCapability(TeslaUtil.teslaProducer, sideTo)){
|
||||
ITeslaConsumer handlerTo = tileTo.getCapability(TeslaUtil.teslaConsumer, opp);
|
||||
ITeslaProducer handlerFrom = tileFrom.getCapability(TeslaUtil.teslaProducer, sideTo);
|
||||
|
||||
if(handlerTo != null && handlerFrom != null){
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"defaults": {
|
||||
"model": "minecraft:half_slab",
|
||||
"textures": {
|
||||
"bottom": "actuallyadditions:blocks/block_battery_box",
|
||||
"top": "#bottom",
|
||||
"side": "#bottom"
|
||||
},
|
||||
"transform": "forge:default-block"
|
||||
},
|
||||
"variants": {
|
||||
"normal": [{}],
|
||||
"inventory": [{}]
|
||||
}
|
||||
}
|
|
@ -238,6 +238,7 @@ tile.actuallyadditions.block_empowerer.name=Empowerer
|
|||
tile.actuallyadditions.block_distributor_item.name=Item Distributor
|
||||
tile.actuallyadditions.block_bio_reactor.name=Bio Reactor
|
||||
tile.actuallyadditions.block_farmer.name=Farmer
|
||||
tile.actuallyadditions.block_battery_box.name=Battery Box
|
||||
|
||||
#ESD
|
||||
tile.actuallyadditions.block_inputter.name=ESD
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in a new issue