Use new canAccept/canProvide methods
This commit is contained in:
parent
df974ef5da
commit
aa18079315
23 changed files with 317 additions and 343 deletions
|
@ -28,7 +28,6 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
|
@ -39,6 +38,7 @@ import reborncore.common.fluid.container.ItemFluidInfo;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import reborncore.common.util.Tank;
|
import reborncore.common.util.Tank;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.api.generator.EFluidGenerator;
|
import techreborn.api.generator.EFluidGenerator;
|
||||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||||
import techreborn.api.generator.FluidGeneratorRecipeList;
|
import techreborn.api.generator.FluidGeneratorRecipeList;
|
||||||
|
@ -157,15 +157,10 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canAcceptEnergy(EnergySide side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RebornInventory<?> getInventory() {
|
public RebornInventory<?> getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import net.minecraft.world.Heightmap;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -53,6 +54,10 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
|
if (world == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (onStatusHoldTicks > 0) {
|
if (onStatusHoldTicks > 0) {
|
||||||
--onStatusHoldTicks;
|
--onStatusHoldTicks;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +115,9 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidIronFence(int y) {
|
public boolean isValidIronFence(int y) {
|
||||||
|
if (world == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Block block = this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock();
|
Block block = this.world.getBlockState(new BlockPos(pos.getX(), y, pos.getZ())).getBlock();
|
||||||
return block == TRContent.REFINED_IRON_FENCE;
|
return block == TRContent.REFINED_IRON_FENCE;
|
||||||
}
|
}
|
||||||
|
@ -120,15 +128,10 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
public boolean canAcceptEnergy(EnergySide side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return TechRebornConfig.lightningRodMaxOutput;
|
return TechRebornConfig.lightningRodMaxOutput;
|
||||||
|
|
|
@ -33,7 +33,6 @@ import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
|
@ -42,6 +41,7 @@ import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.powerSystem.PowerSystem;
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
import reborncore.common.util.StringUtils;
|
import reborncore.common.util.StringUtils;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import team.reborn.energy.EnergyTier;
|
import team.reborn.energy.EnergyTier;
|
||||||
import techreborn.blocks.generator.BlockSolarPanel;
|
import techreborn.blocks.generator.BlockSolarPanel;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
|
@ -179,14 +179,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
protected boolean canAcceptEnergy(EnergySide side) { return false; }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
|
|
|
@ -28,12 +28,12 @@ import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -57,11 +57,15 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
|
if (world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
|
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
|
||||||
.getBlock() == Blocks.DRAGON_EGG) {
|
.getBlock() == Blocks.DRAGON_EGG) {
|
||||||
|
@ -83,15 +87,10 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canAcceptEnergy(EnergySide side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return TechRebornConfig.dragonEggSyphonMaxOutput;
|
return TechRebornConfig.dragonEggSyphonMaxOutput;
|
||||||
|
@ -108,7 +107,7 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return TRContent.Machine.DRAGON_EGG_SYPHON.getStack();
|
return TRContent.Machine.DRAGON_EGG_SYPHON.getStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemHandlerProvider
|
// InventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public RebornInventory<DragonEggSyphonBlockEntity> getInventory() {
|
public RebornInventory<DragonEggSyphonBlockEntity> getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
|
|
|
@ -31,7 +31,6 @@ import net.minecraft.item.BucketItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -40,6 +39,7 @@ import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -77,6 +77,9 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
if (world == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -131,15 +134,10 @@ public class SolidFuelGeneratorBlockEntity extends PowerAcceptorBlockEntity impl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canAcceptEnergy(EnergySide side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return TechRebornConfig.solidFuelGeneratorMaxOutput;
|
return TechRebornConfig.solidFuelGeneratorMaxOutput;
|
||||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.util.math.Direction;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.blocks.BlockMachineBase;
|
import reborncore.common.blocks.BlockMachineBase;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -75,15 +76,10 @@ public class WaterMillBlockEntity extends PowerAcceptorBlockEntity implements IT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canAcceptEnergy(EnergySide side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return TechRebornConfig.waterMillMaxOutput;
|
return TechRebornConfig.waterMillMaxOutput;
|
||||||
|
|
|
@ -26,9 +26,9 @@ package techreborn.blockentity.generator.basic;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -50,6 +50,10 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
|
if (world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean generating = pos.getY() > 64;
|
boolean generating = pos.getY() > 64;
|
||||||
|
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
|
@ -79,12 +83,7 @@ public class WindMillBlockEntity extends PowerAcceptorBlockEntity implements ITo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.blocks.lighting.LampBlock;
|
import techreborn.blocks.lighting.LampBlock;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
|
|
||||||
public class LampBlockEntity extends PowerAcceptorBlockEntity
|
public class LampBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop {
|
||||||
implements IToolDrop {
|
|
||||||
|
|
||||||
private static final int capacity = 33;
|
private static final int capacity = 33;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity
|
||||||
super(TRBlockEntities.LAMP);
|
super(TRBlockEntities.LAMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
@ -52,16 +52,41 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
BlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
Block b = state.getBlock();
|
Block b = state.getBlock();
|
||||||
if (b instanceof LampBlock) {
|
if (!(b instanceof LampBlock)) {
|
||||||
double cost = getEuPerTick(((LampBlock) b).getCost());
|
return;
|
||||||
if (getEnergy() > cost) {
|
|
||||||
useEnergy(getEuPerTick(cost));
|
|
||||||
if (!LampBlock.isActive(state))
|
|
||||||
LampBlock.setActive(true, world, pos);
|
|
||||||
} else if (LampBlock.isActive(state)) {
|
|
||||||
LampBlock.setActive(false, world, pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double cost = getEuPerTick(((LampBlock) b).getCost());
|
||||||
|
if (getStored(EnergySide.UNKNOWN) > cost) {
|
||||||
|
useEnergy(cost);
|
||||||
|
if (!LampBlock.isActive(state)) {
|
||||||
|
LampBlock.setActive(true, world, pos);
|
||||||
|
}
|
||||||
|
} else if (LampBlock.isActive(state)) {
|
||||||
|
LampBlock.setActive(false, world, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public boolean canAcceptEnergy(final Direction direction) {
|
||||||
|
// if (world == null) {
|
||||||
|
// // Blame tooltip for this
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// Direction me = LampBlock.getFacing(world.getBlockState(pos)).getOpposite();
|
||||||
|
// return direction == me;
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canAcceptEnergy(EnergySide side) {
|
||||||
|
return side == EnergySide.UNKNOWN || getFacing().getOpposite() != Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,21 +94,6 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
|
||||||
if (world == null) {
|
|
||||||
// Blame tooltip for this
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Direction me = LampBlock.getFacing(world.getBlockState(pos)).getOpposite();
|
|
||||||
return direction == me;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -99,6 +109,4 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity
|
||||||
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
||||||
return new ItemStack(world.getBlockState(pos).getBlock());
|
return new ItemStack(world.getBlockState(pos).getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,13 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.recipes.RecipeCrafter;
|
import reborncore.common.recipes.RecipeCrafter;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author drcrazy
|
* @author drcrazy
|
||||||
|
@ -67,6 +67,12 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
checkTier();
|
checkTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns progress scaled to input value
|
||||||
|
*
|
||||||
|
* @param scale int Maximum value for progress
|
||||||
|
* @return int Scale of progress
|
||||||
|
*/
|
||||||
public int getProgressScaled(int scale) {
|
public int getProgressScaled(int scale) {
|
||||||
if (crafter != null && crafter.currentTickTime != 0) {
|
if (crafter != null && crafter.currentTickTime != 0) {
|
||||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||||
|
@ -78,7 +84,10 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (!world.isClient && energySlot != -1) {
|
if (world == null || world.isClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (energySlot != -1) {
|
||||||
charge(energySlot);
|
charge(energySlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,12 +98,7 @@ public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ package techreborn.blockentity.machine.misc;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -35,6 +34,7 @@ import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.Energy;
|
||||||
|
import team.reborn.energy.EnergySide;
|
||||||
import techreborn.config.TechRebornConfig;
|
import techreborn.config.TechRebornConfig;
|
||||||
import techreborn.init.TRBlockEntities;
|
import techreborn.init.TRBlockEntities;
|
||||||
import techreborn.init.TRContent;
|
import techreborn.init.TRContent;
|
||||||
|
@ -76,13 +76,8 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return direction == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,7 +32,6 @@ import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||||
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
import reborncore.client.screen.builder.ScreenHandlerBuilder;
|
||||||
|
@ -53,9 +52,7 @@ import techreborn.init.TRContent;
|
||||||
|
|
||||||
public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {
|
||||||
|
|
||||||
public RebornInventory<FusionControlComputerBlockEntity> inventory;
|
public int craftingTickTime = 0;
|
||||||
|
|
||||||
public int crafingTickTime = 0;
|
|
||||||
public int neededPower = 0;
|
public int neededPower = 0;
|
||||||
public int size = 6;
|
public int size = 6;
|
||||||
public int state = -1;
|
public int state = -1;
|
||||||
|
@ -74,10 +71,44 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
this.inventory = new RebornInventory<>(3, "FusionControlComputerBlockEntity", 64, this);
|
this.inventory = new RebornInventory<>(3, "FusionControlComputerBlockEntity", 64, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeMultiblock(MultiblockWriter writer) {
|
|
||||||
BlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState();
|
public FusionReactorRecipe getCurrentRecipeFromID() {
|
||||||
Torus.generate(BlockPos.ORIGIN, size).forEach(pos -> writer.add(pos.getX(), pos.getY(), pos.getZ(), coil));
|
if (currentRecipeID == null) return null;
|
||||||
|
return ModRecipes.FUSION_REACTOR.getRecipes(world).stream()
|
||||||
|
.filter(recipe -> recipe.getId().equals(currentRecipeID))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: translate
|
||||||
|
public Text getStateText() {
|
||||||
|
if (state == -1) {
|
||||||
|
return LiteralText.EMPTY;
|
||||||
|
} else if (state == 0) {
|
||||||
|
return new LiteralText("No recipe");
|
||||||
|
} else if (state == 1) {
|
||||||
|
FusionReactorRecipe r = getCurrentRecipeFromID();
|
||||||
|
if (r == null) {
|
||||||
|
return new LiteralText("Charging");
|
||||||
|
}
|
||||||
|
int percentage = percentage(r.getStartEnergy(), getEnergy());
|
||||||
|
return new LiteralText("Charging (")
|
||||||
|
.append(StringUtils.getPercentageText(percentage));
|
||||||
|
} else if (state == 2) {
|
||||||
|
return new LiteralText("Crafting");
|
||||||
|
}
|
||||||
|
return LiteralText.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes size of fusion reactor ring after GUI button click
|
||||||
|
*
|
||||||
|
* @param sizeDelta int Size increment
|
||||||
|
*/
|
||||||
|
public void changeSize(int sizeDelta) {
|
||||||
|
int newSize = size + sizeDelta;
|
||||||
|
this.size = Math.max(6, Math.min(TechRebornConfig.fusionControlComputerMaxCoilSize, newSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +116,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
*/
|
*/
|
||||||
private void resetCrafter() {
|
private void resetCrafter() {
|
||||||
currentRecipe = null;
|
currentRecipe = null;
|
||||||
crafingTickTime = 0;
|
craftingTickTime = 0;
|
||||||
neededPower = 0;
|
neededPower = 0;
|
||||||
hasStartedCrafting = false;
|
hasStartedCrafting = false;
|
||||||
}
|
}
|
||||||
|
@ -113,20 +144,6 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns progress scaled to input value
|
|
||||||
*
|
|
||||||
* @param scale int Maximum value for progress
|
|
||||||
* @return int Scale of progress
|
|
||||||
*/
|
|
||||||
public int getProgressScaled(int scale) {
|
|
||||||
FusionReactorRecipe reactorRecipe = getCurrentRecipeFromID();
|
|
||||||
if (crafingTickTime != 0 && reactorRecipe != null && reactorRecipe.getTime() != 0) {
|
|
||||||
return crafingTickTime * scale / reactorRecipe.getTime();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to set current recipe based in inputs in reactor
|
* Tries to set current recipe based in inputs in reactor
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +151,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
for (RebornRecipe recipe : ModRecipes.FUSION_REACTOR.getRecipes(getWorld())) {
|
for (RebornRecipe recipe : ModRecipes.FUSION_REACTOR.getRecipes(getWorld())) {
|
||||||
if (validateRecipe((FusionReactorRecipe) recipe)) {
|
if (validateRecipe((FusionReactorRecipe) recipe)) {
|
||||||
currentRecipe = (FusionReactorRecipe) recipe;
|
currentRecipe = (FusionReactorRecipe) recipe;
|
||||||
crafingTickTime = 0;
|
craftingTickTime = 0;
|
||||||
neededPower = currentRecipe.getStartEnergy();
|
neededPower = currentRecipe.getStartEnergy();
|
||||||
hasStartedCrafting = false;
|
hasStartedCrafting = false;
|
||||||
break;
|
break;
|
||||||
|
@ -192,13 +209,50 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int percentage(double MaxValue, double CurrentValue) {
|
||||||
|
if (CurrentValue == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||||
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// GenericMachineBlockEntity
|
||||||
|
@Override
|
||||||
|
public int getProgressScaled(int scale) {
|
||||||
|
FusionReactorRecipe reactorRecipe = getCurrentRecipeFromID();
|
||||||
|
if (craftingTickTime != 0 && reactorRecipe != null && reactorRecipe.getTime() != 0) {
|
||||||
|
return craftingTickTime * scale / reactorRecipe.getTime();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBaseMaxPower() {
|
||||||
|
return Math.min(TechRebornConfig.fusionControlComputerMaxEnergy * getPowerMultiplier(), Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBaseMaxOutput() {
|
||||||
|
if (!hasStartedCrafting) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return TechRebornConfig.fusionControlComputerMaxOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getBaseMaxInput() {
|
||||||
|
if (hasStartedCrafting) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return TechRebornConfig.fusionControlComputerMaxInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (world.isClient) {
|
if (world == null || world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +267,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastTick == world.getTime()) {
|
if (lastTick == world.getTime()) {
|
||||||
//Prevent tick accerators, blame obstinate for this.
|
//Prevent tick accelerators, blame obstinate for this.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastTick = world.getTime();
|
lastTick = world.getTime();
|
||||||
|
@ -248,21 +302,21 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
useInput(bottomStackSlot);
|
useInput(bottomStackSlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasStartedCrafting && crafingTickTime < currentRecipe.getTime()) {
|
if (hasStartedCrafting && craftingTickTime < currentRecipe.getTime()) {
|
||||||
// Power gen
|
// Power gen
|
||||||
if (currentRecipe.getPower() > 0) {
|
if (currentRecipe.getPower() > 0) {
|
||||||
// Waste power if it has no where to go
|
// Waste power if it has no where to go
|
||||||
double power = Math.abs(currentRecipe.getPower()) * getPowerMultiplier();
|
double power = Math.abs(currentRecipe.getPower()) * getPowerMultiplier();
|
||||||
addEnergy(power);
|
addEnergy(power);
|
||||||
powerChange = (power);
|
powerChange = (power);
|
||||||
crafingTickTime++;
|
craftingTickTime++;
|
||||||
} else { // Power user
|
} else { // Power user
|
||||||
if (getStored(EnergySide.UNKNOWN) > currentRecipe.getPower()) {
|
if (getStored(EnergySide.UNKNOWN) > currentRecipe.getPower()) {
|
||||||
setEnergy(getEnergy() - currentRecipe.getPower());
|
setEnergy(getEnergy() - currentRecipe.getPower());
|
||||||
crafingTickTime++;
|
craftingTickTime++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (crafingTickTime >= currentRecipe.getTime()) {
|
} else if (craftingTickTime >= currentRecipe.getTime()) {
|
||||||
ItemStack result = currentRecipe.getOutputs().get(0);
|
ItemStack result = currentRecipe.getOutputs().get(0);
|
||||||
if (canFitStack(result, outputStackSlot, true)) {
|
if (canFitStack(result, outputStackSlot, true)) {
|
||||||
if (inventory.getStack(outputStackSlot).isEmpty()) {
|
if (inventory.getStack(outputStackSlot).isEmpty()) {
|
||||||
|
@ -271,7 +325,7 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
inventory.shrinkSlot(outputStackSlot, -result.getCount());
|
inventory.shrinkSlot(outputStackSlot, -result.getCount());
|
||||||
}
|
}
|
||||||
if (validateRecipe(this.currentRecipe)) {
|
if (validateRecipe(this.currentRecipe)) {
|
||||||
crafingTickTime = 0;
|
craftingTickTime = 0;
|
||||||
useInput(topStackSlot);
|
useInput(topStackSlot);
|
||||||
useInput(bottomStackSlot);
|
useInput(bottomStackSlot);
|
||||||
} else {
|
} else {
|
||||||
|
@ -285,48 +339,22 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
inventory.resetChanged();
|
inventory.resetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPowerMultiplier() {
|
protected boolean canAcceptEnergy(EnergySide side) {
|
||||||
double calc = (1F / 2F) * Math.pow(size - 5, 1.8);
|
// Accept from sides
|
||||||
return Math.max(Math.round(calc * 100D) / 100D, 1D);
|
return !(side == EnergySide.DOWN || side == EnergySide.UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return Math.min(TechRebornConfig.fusionControlComputerMaxEnergy * getPowerMultiplier(), Integer.MAX_VALUE);
|
// Provide from top and bottom
|
||||||
}
|
return side == EnergySide.DOWN || side == EnergySide.UP;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
|
||||||
return !(direction == Direction.DOWN || direction == Direction.UP);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return direction == Direction.DOWN || direction == Direction.UP;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getBaseMaxOutput() {
|
|
||||||
if (!hasStartedCrafting) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return TechRebornConfig.fusionControlComputerMaxOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getBaseMaxInput() {
|
|
||||||
if (hasStartedCrafting) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return TechRebornConfig.fusionControlComputerMaxInput;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(BlockState blockState, final CompoundTag tagCompound) {
|
public void fromTag(BlockState blockState, final CompoundTag tagCompound) {
|
||||||
super.fromTag(blockState, tagCompound);
|
super.fromTag(blockState, tagCompound);
|
||||||
this.crafingTickTime = tagCompound.getInt("crafingTickTime");
|
this.craftingTickTime = tagCompound.getInt("craftingTickTime");
|
||||||
this.neededPower = tagCompound.getInt("neededPower");
|
this.neededPower = tagCompound.getInt("neededPower");
|
||||||
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
|
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
|
||||||
if (tagCompound.contains("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null) {
|
if (tagCompound.contains("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null) {
|
||||||
|
@ -335,13 +363,14 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
if (tagCompound.contains("size")) {
|
if (tagCompound.contains("size")) {
|
||||||
this.size = tagCompound.getInt("size");
|
this.size = tagCompound.getInt("size");
|
||||||
}
|
}
|
||||||
this.size = Math.min(size, TechRebornConfig.fusionControlComputerMaxCoilSize);//Done here to force the samller size, will be useful if people lag out on a large one.
|
//Done here to force the smaller size, will be useful if people lag out on a large one.
|
||||||
|
this.size = Math.min(size, TechRebornConfig.fusionControlComputerMaxCoilSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag toTag(final CompoundTag tagCompound) {
|
public CompoundTag toTag(final CompoundTag tagCompound) {
|
||||||
super.toTag(tagCompound);
|
super.toTag(tagCompound);
|
||||||
tagCompound.putInt("crafingTickTime", this.crafingTickTime);
|
tagCompound.putInt("craftingTickTime", this.craftingTickTime);
|
||||||
tagCompound.putInt("neededPower", this.neededPower);
|
tagCompound.putInt("neededPower", this.neededPower);
|
||||||
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);
|
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);
|
||||||
tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null);
|
tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null);
|
||||||
|
@ -349,23 +378,30 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//MachineBaseBlockEntity
|
||||||
|
@Override
|
||||||
|
public double getPowerMultiplier() {
|
||||||
|
double calc = (1F / 2F) * Math.pow(size - 5, 1.8);
|
||||||
|
return Math.max(Math.round(calc * 100D) / 100D, 1D);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeMultiblock(MultiblockWriter writer) {
|
||||||
|
BlockState coil = TRContent.Machine.FUSION_COIL.block.getDefaultState();
|
||||||
|
Torus.generate(BlockPos.ORIGIN, size).forEach(pos -> writer.add(pos.getX(), pos.getY(), pos.getZ(), coil));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeUpgraded() {
|
public boolean canBeUpgraded() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemHandlerProvider
|
// BuiltScreenHandlerProvider
|
||||||
@Override
|
|
||||||
public RebornInventory<FusionControlComputerBlockEntity> getInventory() {
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
// IContainerProvider
|
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("fusionreactor").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("fusionreactor").player(player.inventory).inventory().hotbar()
|
||||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
||||||
.sync(this::getCrafingTickTime, this::setCrafingTickTime)
|
.sync(this::getCraftingTickTime, this::setCraftingTickTime)
|
||||||
.sync(this::getSize, this::setSize)
|
.sync(this::getSize, this::setSize)
|
||||||
.sync(this::getState, this::setState)
|
.sync(this::getState, this::setState)
|
||||||
.sync(this::getNeededPower, this::setNeededPower)
|
.sync(this::getNeededPower, this::setNeededPower)
|
||||||
|
@ -374,20 +410,12 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
.create(this, syncID);
|
.create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCrafingTickTime() {
|
public int getCraftingTickTime() {
|
||||||
return crafingTickTime;
|
return craftingTickTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCrafingTickTime(int crafingTickTime) {
|
public void setCraftingTickTime(int craftingTickTime) {
|
||||||
this.crafingTickTime = crafingTickTime;
|
this.craftingTickTime = craftingTickTime;
|
||||||
}
|
|
||||||
|
|
||||||
public int getNeededPower() {
|
|
||||||
return neededPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNeededPower(int neededPower) {
|
|
||||||
this.neededPower = neededPower;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
|
@ -398,11 +426,6 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeSize(int sizeDelta) {
|
|
||||||
int newSize = size + sizeDelta;
|
|
||||||
this.size = Math.max(6, Math.min(TechRebornConfig.fusionControlComputerMaxCoilSize, newSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getState() {
|
public int getState() {
|
||||||
if (currentRecipe == null) {
|
if (currentRecipe == null) {
|
||||||
return 0; //No Recipe
|
return 0; //No Recipe
|
||||||
|
@ -417,6 +440,14 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNeededPower() {
|
||||||
|
return neededPower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNeededPower(int neededPower) {
|
||||||
|
this.neededPower = neededPower;
|
||||||
|
}
|
||||||
|
|
||||||
public Identifier getCurrentRecipeID() {
|
public Identifier getCurrentRecipeID() {
|
||||||
if (currentRecipe == null) {
|
if (currentRecipe == null) {
|
||||||
return new Identifier("null", "null");
|
return new Identifier("null", "null");
|
||||||
|
@ -430,38 +461,4 @@ public class FusionControlComputerBlockEntity extends GenericMachineBlockEntity
|
||||||
}
|
}
|
||||||
this.currentRecipeID = currentRecipeID;
|
this.currentRecipeID = currentRecipeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FusionReactorRecipe getCurrentRecipeFromID() {
|
|
||||||
if (currentRecipeID == null) return null;
|
|
||||||
return ModRecipes.FUSION_REACTOR.getRecipes(world).stream()
|
|
||||||
.filter(recipe -> recipe.getId().equals(currentRecipeID))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Text getStateText() {
|
|
||||||
if (state == -1) {
|
|
||||||
return LiteralText.EMPTY;
|
|
||||||
} else if (state == 0) {
|
|
||||||
return new LiteralText("No recipe");
|
|
||||||
} else if (state == 1) {
|
|
||||||
FusionReactorRecipe r = getCurrentRecipeFromID();
|
|
||||||
if (r == null) {
|
|
||||||
return new LiteralText("Charging");
|
|
||||||
}
|
|
||||||
int percentage = percentage(r.getStartEnergy(), getEnergy());
|
|
||||||
return new LiteralText("Charging (")
|
|
||||||
.append(StringUtils.getPercentageText(percentage));
|
|
||||||
} else if (state == 2) {
|
|
||||||
return new LiteralText("Crafting");
|
|
||||||
}
|
|
||||||
return LiteralText.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int percentage(double MaxValue, double CurrentValue) {
|
|
||||||
if (CurrentValue == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,12 +412,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction enumFacing) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction enumFacing) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.recipe.RecipeType;
|
import net.minecraft.recipe.RecipeType;
|
||||||
import net.minecraft.recipe.SmeltingRecipe;
|
import net.minecraft.recipe.SmeltingRecipe;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -194,7 +193,7 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
super.tick();
|
super.tick();
|
||||||
charge(2);
|
charge(2);
|
||||||
|
|
||||||
if (world.isClient) {
|
if (world == null || world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,21 +230,16 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
setInvDirty(false);
|
setInvDirty(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canProvideEnergy(EnergySide side) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return TechRebornConfig.electricFurnaceMaxEnergy;
|
return TechRebornConfig.electricFurnaceMaxEnergy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -262,13 +256,13 @@ public class ElectricFurnaceBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return TRContent.Machine.ELECTRIC_FURNACE.getStack();
|
return TRContent.Machine.ELECTRIC_FURNACE.getStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemHandlerProvider
|
// InventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public RebornInventory<ElectricFurnaceBlockEntity> getInventory() {
|
public RebornInventory<ElectricFurnaceBlockEntity> getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// BuiltScreenHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory()
|
return new ScreenHandlerBuilder("electricfurnace").player(player.inventory).inventory().hotbar().addInventory()
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.WorldUtils;
|
import reborncore.common.util.WorldUtils;
|
||||||
|
@ -53,36 +52,47 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
||||||
return redstone;
|
return redstone;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
if (!world.isClient && world.getTime() % 20 == 0) {
|
|
||||||
boolean lastRedstone = redstone;
|
if (world == null) {
|
||||||
redstone = false;
|
return;
|
||||||
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.playerDetectorEuPerTick) {
|
}
|
||||||
for (PlayerEntity player : world.getPlayers()) {
|
|
||||||
if (player.distanceTo(player) <= 256.0D) {
|
if (world.isClient) {
|
||||||
PlayerDetectorType type = world.getBlockState(pos).get(PlayerDetectorBlock.TYPE);
|
return;
|
||||||
if (type == PlayerDetectorType.ALL) {// ALL
|
}
|
||||||
|
|
||||||
|
if (world.getTime() % 20 != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean lastRedstone = redstone;
|
||||||
|
redstone = false;
|
||||||
|
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.playerDetectorEuPerTick) {
|
||||||
|
for (PlayerEntity player : world.getPlayers()) {
|
||||||
|
if (player.distanceTo(player) <= 256.0D) {
|
||||||
|
PlayerDetectorType type = world.getBlockState(pos).get(PlayerDetectorBlock.TYPE);
|
||||||
|
if (type == PlayerDetectorType.ALL) {// ALL
|
||||||
|
redstone = true;
|
||||||
|
} else if (type == PlayerDetectorType.OTHERS) {// Others
|
||||||
|
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUuid().toString())) {
|
||||||
|
redstone = true;
|
||||||
|
}
|
||||||
|
} else {// You
|
||||||
|
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUuid().toString())) {
|
||||||
redstone = true;
|
redstone = true;
|
||||||
} else if (type == PlayerDetectorType.OTHERS) {// Others
|
|
||||||
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUuid().toString())) {
|
|
||||||
redstone = true;
|
|
||||||
}
|
|
||||||
} else {// You
|
|
||||||
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUuid().toString())) {
|
|
||||||
redstone = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
useEnergy(TechRebornConfig.playerDetectorEuPerTick);
|
|
||||||
}
|
|
||||||
if (lastRedstone != redstone) {
|
|
||||||
WorldUtils.updateBlock(world, pos);
|
|
||||||
world.updateNeighborsAlways(pos, world.getBlockState(pos).getBlock());
|
|
||||||
}
|
}
|
||||||
|
useEnergy(TechRebornConfig.playerDetectorEuPerTick);
|
||||||
|
}
|
||||||
|
if (lastRedstone != redstone) {
|
||||||
|
WorldUtils.updateBlock(world, pos);
|
||||||
|
world.updateNeighborsAlways(pos, world.getBlockState(pos).getBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,12 +102,7 @@ public class PlayerDectectorBlockEntity extends PowerAcceptorBlockEntity impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.IUpgrade;
|
import reborncore.api.blockentity.IUpgrade;
|
||||||
|
@ -152,12 +151,7 @@ public class RecyclerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.recipe.Ingredient;
|
import net.minecraft.recipe.Ingredient;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
|
@ -85,12 +84,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(final Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(final Direction direction) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ package techreborn.blockentity.machine.tier3;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import reborncore.api.IToolDrop;
|
import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||||
|
@ -157,12 +156,7 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,15 +33,14 @@ import reborncore.api.IToolDrop;
|
||||||
import reborncore.api.blockentity.InventoryProvider;
|
import reborncore.api.blockentity.InventoryProvider;
|
||||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||||
import reborncore.common.util.RebornInventory;
|
import reborncore.common.util.RebornInventory;
|
||||||
import team.reborn.energy.Energy;
|
import team.reborn.energy.EnergySide;
|
||||||
import team.reborn.energy.EnergyTier;
|
import team.reborn.energy.EnergyTier;
|
||||||
import techreborn.blocks.storage.energy.EnergyStorageBlock;
|
import techreborn.blocks.storage.energy.EnergyStorageBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Rushmead
|
* Created by Rushmead
|
||||||
*/
|
*/
|
||||||
public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, InventoryProvider {
|
||||||
implements IToolDrop, InventoryProvider {
|
|
||||||
|
|
||||||
public RebornInventory<EnergyStorageBlockEntity> inventory;
|
public RebornInventory<EnergyStorageBlockEntity> inventory;
|
||||||
public String name;
|
public String name;
|
||||||
|
@ -68,6 +67,9 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
if (world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,21 +81,21 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAcceptEnergy(EnergySide side) {
|
||||||
|
return side == EnergySide.UNKNOWN || getFacing() != Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvideEnergy(EnergySide side) {
|
||||||
|
return side == EnergySide.UNKNOWN || getFacing() == Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return maxStorage;
|
return maxStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
|
||||||
return direction == null || getFacing() != direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
return direction == null || getFacing() == direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return maxOutput;
|
return maxOutput;
|
||||||
|
|
|
@ -90,6 +90,11 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldHandleEnergyNBT() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(BlockState blockState, CompoundTag nbttagcompound) {
|
public void fromTag(BlockState blockState, CompoundTag nbttagcompound) {
|
||||||
super.fromTag(blockState, nbttagcompound);
|
super.fromTag(blockState, nbttagcompound);
|
||||||
|
@ -112,9 +117,4 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
||||||
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
.complete(8, 18).addArmor().addInventory().blockEntity(this).energySlot(0, 62, 45).energySlot(1, 98, 45)
|
||||||
.syncEnergyValue().addInventory().create(this, syncID);
|
.syncEnergyValue().addInventory().create(this, syncID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean shouldHandleEnergyNBT() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,14 +47,12 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Created by Rushmead
|
* Created by Rushmead
|
||||||
*/
|
*/
|
||||||
public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
public class TransformerBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, IListInfoProvider {
|
||||||
implements IToolDrop, IListInfoProvider {
|
|
||||||
|
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public Block wrenchDrop;
|
public Block wrenchDrop;
|
||||||
public EnergyTier inputTier;
|
public EnergyTier inputTier;
|
||||||
public EnergyTier ouputTier;
|
public EnergyTier outputTier;
|
||||||
public int maxInput;
|
public int maxInput;
|
||||||
public int maxOutput;
|
public int maxOutput;
|
||||||
public int maxStorage;
|
public int maxStorage;
|
||||||
|
@ -64,9 +62,9 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
this.wrenchDrop = wrenchDrop;
|
this.wrenchDrop = wrenchDrop;
|
||||||
this.inputTier = tier;
|
this.inputTier = tier;
|
||||||
if (tier != EnergyTier.MICRO) {
|
if (tier != EnergyTier.MICRO) {
|
||||||
ouputTier = EnergyTier.values()[tier.ordinal() - 1];
|
outputTier = EnergyTier.values()[tier.ordinal() - 1];
|
||||||
} else {
|
} else {
|
||||||
ouputTier = EnergyTier.MICRO;
|
outputTier = EnergyTier.MICRO;
|
||||||
}
|
}
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.maxInput = tier.getMaxInput();
|
this.maxInput = tier.getMaxInput();
|
||||||
|
@ -75,31 +73,37 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TilePowerAcceptor
|
// PowerAcceptorBlockEntity
|
||||||
|
@Override
|
||||||
|
protected boolean canAcceptEnergy(EnergySide side) {
|
||||||
|
if (side == EnergySide.UNKNOWN) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (TechRebornConfig.IC2TransformersStyle) {
|
||||||
|
return getFacing() == Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
return getFacing() != Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canProvideEnergy(EnergySide side) {
|
||||||
|
if (side == EnergySide.UNKNOWN) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (TechRebornConfig.IC2TransformersStyle) {
|
||||||
|
return getFacing() != Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
return getFacing() == Direction.values()[side.ordinal()];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxPower() {
|
public double getBaseMaxPower() {
|
||||||
return maxStorage;
|
return maxStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAcceptEnergy(Direction direction) {
|
|
||||||
if (TechRebornConfig.IC2TransformersStyle) {
|
|
||||||
return getFacingEnum() == direction;
|
|
||||||
}
|
|
||||||
return getFacingEnum() != direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canProvideEnergy(Direction direction) {
|
|
||||||
if (TechRebornConfig.IC2TransformersStyle) {
|
|
||||||
return getFacingEnum() != direction;
|
|
||||||
}
|
|
||||||
return getFacing() == direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseMaxOutput() {
|
public double getBaseMaxOutput() {
|
||||||
return ouputTier.getMaxOutput();
|
return outputTier.getMaxOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,7 +116,7 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
//Nope
|
//Nope
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileMachineBase
|
// MachineBaseBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public Direction getFacingEnum() {
|
public Direction getFacingEnum() {
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
|
@ -125,6 +129,11 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBeUpgraded() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// IToolDrop
|
// IToolDrop
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||||
|
@ -132,12 +141,12 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
// IListInfoProvider
|
// IListInfoProvider
|
||||||
|
// TO-DO: translate
|
||||||
@Override
|
@Override
|
||||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||||
info.add(new LiteralText(Formatting.GRAY + "Input Rate: " + Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput(EnergySide.UNKNOWN))));
|
info.add(new LiteralText(Formatting.GRAY + "Input Rate: " + Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput(EnergySide.UNKNOWN))));
|
||||||
info.add(new LiteralText(Formatting.GRAY + "Input Tier: " + Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString())));
|
info.add(new LiteralText(Formatting.GRAY + "Input Tier: " + Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString())));
|
||||||
info.add(new LiteralText(Formatting.GRAY + "Output Rate: " + Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput(EnergySide.UNKNOWN))));
|
info.add(new LiteralText(Formatting.GRAY + "Output Rate: " + Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput(EnergySide.UNKNOWN))));
|
||||||
info.add(new LiteralText(Formatting.GRAY + "Output Tier: " + Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(ouputTier.toString())));
|
info.add(new LiteralText(Formatting.GRAY + "Output Tier: " + Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(outputTier.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class BlockFusionControlComputer extends BlockMachineBase {
|
||||||
public void onSteppedOn(final World worldIn, final BlockPos pos, final Entity entityIn) {
|
public void onSteppedOn(final World worldIn, final BlockPos pos, final Entity entityIn) {
|
||||||
super.onSteppedOn(worldIn, pos, entityIn);
|
super.onSteppedOn(worldIn, pos, entityIn);
|
||||||
if (worldIn.getBlockEntity(pos) instanceof FusionControlComputerBlockEntity) {
|
if (worldIn.getBlockEntity(pos) instanceof FusionControlComputerBlockEntity) {
|
||||||
if (((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).crafingTickTime != 0
|
if (((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).craftingTickTime != 0
|
||||||
&& ((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).isMultiblockValid()) {
|
&& ((FusionControlComputerBlockEntity) worldIn.getBlockEntity(pos)).isMultiblockValid()) {
|
||||||
entityIn.damage(new FusionDamageSource(), 200F);
|
entityIn.damage(new FusionDamageSource(), 200F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,10 +122,10 @@ public class LampBlock extends BaseBlockEntityProvider {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockState getPlacementState(ItemPlacementContext context) {
|
public BlockState getPlacementState(ItemPlacementContext context) {
|
||||||
for (Direction enumfacing : context.getPlacementDirections()) {
|
for (Direction facing : context.getPlacementDirections()) {
|
||||||
BlockState iblockstate = this.getDefaultState().with(FACING, enumfacing.getOpposite());
|
BlockState state = this.getDefaultState().with(FACING, facing.getOpposite());
|
||||||
if (iblockstate.canPlaceAt(context.getWorld(), context.getBlockPos())) {
|
if (state.canPlaceAt(context.getWorld(), context.getBlockPos())) {
|
||||||
return iblockstate;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue