Tiered tank and storage blocks, GUI improvements, refactoring, cell nerf and misc organisation (#1932)
Tanks, storage blocks and variouse stuff. Thanks to Dimmerworld!!
This commit is contained in:
parent
2fc9557516
commit
9328c47bed
207 changed files with 1830 additions and 928 deletions
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public abstract class GenericMachineBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, IRecipeCrafterProvider{
|
||||
|
||||
public String name;
|
||||
public int maxInput;
|
||||
public int maxEnergy;
|
||||
public Block toolDrop;
|
||||
public int energySlot;
|
||||
public RebornInventory<?> inventory;
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
/**
|
||||
* @param name String Name for a blockEntity. Do we need it at all?
|
||||
* @param maxInput int Maximum energy input, value in EU
|
||||
* @param maxEnergy int Maximum energy buffer, value in EU
|
||||
* @param toolDrop Block Block to drop with wrench
|
||||
* @param energySlot int Energy slot to use to charge machine from battery
|
||||
*/
|
||||
public GenericMachineBlockEntity(BlockEntityType<?> blockEntityType, String name, int maxInput, int maxEnergy, Block toolDrop, int energySlot) {
|
||||
super(blockEntityType);
|
||||
this.name = "BlockEntity" + name;
|
||||
this.maxInput = maxInput;
|
||||
this.maxEnergy = maxEnergy;
|
||||
this.toolDrop = toolDrop;
|
||||
this.energySlot = energySlot;
|
||||
checkTier();
|
||||
}
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter != null && crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// PowerAcceptorBlockEntity
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!world.isClient) {
|
||||
charge(energySlot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(final Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(final Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return maxInput;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity p0) {
|
||||
return new ItemStack(toolDrop, 1);
|
||||
}
|
||||
|
||||
// InventoryProvider
|
||||
@Override
|
||||
public RebornInventory<?> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
// IRecipeCrafterProvider
|
||||
@Override
|
||||
public RecipeCrafter getRecipeCrafter() {
|
||||
return crafter;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.misc;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Tickable;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.blocks.misc.BlockAlarm;
|
||||
import techreborn.init.ModSounds;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.utils.MessageIDs;
|
||||
|
||||
public class AlarmBlockEntity extends BlockEntity
|
||||
implements Tickable, IToolDrop {
|
||||
private int selectedSound = 1;
|
||||
|
||||
public AlarmBlockEntity() {
|
||||
super(TRBlockEntities.ALARM);
|
||||
}
|
||||
|
||||
public void rightClick() {
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedSound < 3) {
|
||||
selectedSound++;
|
||||
} else {
|
||||
selectedSound = 1;
|
||||
}
|
||||
ChatUtils.sendNoSpamMessages(MessageIDs.alarmID, new LiteralText(
|
||||
Formatting.GRAY + StringUtils.t("techreborn.message.alarm") + " " + "Alarm " + selectedSound));
|
||||
}
|
||||
|
||||
// BlockEntity
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag compound) {
|
||||
if (compound == null) {
|
||||
compound = new CompoundTag();
|
||||
}
|
||||
compound.putInt("selectedSound", this.selectedSound);
|
||||
return super.toTag(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag compound) {
|
||||
if (compound != null && compound.contains("selectedSound")) {
|
||||
selectedSound = compound.getInt("selectedSound");
|
||||
}
|
||||
super.fromTag(compound);
|
||||
}
|
||||
|
||||
// ITickable
|
||||
@Override
|
||||
public void tick() {
|
||||
if (world.isClient()){
|
||||
return;
|
||||
}
|
||||
if (world.getTime() % 25 != 0) {
|
||||
return;
|
||||
}
|
||||
if (world.isReceivingRedstonePower(getPos())) {
|
||||
BlockAlarm.setActive(true, world, pos);
|
||||
switch (selectedSound) {
|
||||
case 1:
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
case 2:
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_2, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
case 3:
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.ALARM_3, SoundCategory.BLOCKS, 4F, 1F);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
BlockAlarm.setActive(false, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.ALARM.getStack();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.misc;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.Energy;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, IContainerProvider {
|
||||
|
||||
public RebornInventory<ChargeOMatBlockEntity> inventory = new RebornInventory<>(6, "ChargeOMatBlockEntity", 64, this);
|
||||
|
||||
public ChargeOMatBlockEntity() {
|
||||
super(TRBlockEntities.CHARGE_O_MAT);
|
||||
}
|
||||
|
||||
// TilePowerAcceptor
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if(world.isClient){
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
ItemStack stack = inventory.getInvStack(i);
|
||||
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(this)
|
||||
.into(
|
||||
Energy
|
||||
.of(stack)
|
||||
)
|
||||
.move();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return TechRebornConfig.chargeOMatBMaxEnergy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(final Direction direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(final Direction direction) {
|
||||
return direction == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxOutput() {
|
||||
return TechRebornConfig.chargeOMatBMaxOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
return TechRebornConfig.chargeOMatBMaxInput;
|
||||
}
|
||||
|
||||
// TileMachineBase
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
||||
return TRContent.Machine.CHARGE_O_MAT.getStack();
|
||||
}
|
||||
|
||||
// ItemHandlerProvider
|
||||
@Override
|
||||
public RebornInventory<ChargeOMatBlockEntity> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("chargebench").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).energySlot(0, 62, 25).energySlot(1, 98, 25).energySlot(2, 62, 45).energySlot(3, 98, 45)
|
||||
.energySlot(4, 62, 65).energySlot(5, 98, 65).syncEnergyValue().addInventory().create(this, syncID);
|
||||
}
|
||||
}
|
|
@ -33,7 +33,7 @@ import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
|||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -39,7 +39,7 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -0,0 +1,515 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.multiblock;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.api.recipe.recipes.FusionReactorRecipe;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FusionControlComputerBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, IContainerProvider {
|
||||
|
||||
public RebornInventory<FusionControlComputerBlockEntity> inventory;
|
||||
|
||||
public int coilCount = 0;
|
||||
public int crafingTickTime = 0;
|
||||
public int neededPower = 0;
|
||||
public int size = 6;
|
||||
public int state = -1;
|
||||
int topStackSlot = 0;
|
||||
int bottomStackSlot = 1;
|
||||
int outputStackSlot = 2;
|
||||
FusionReactorRecipe currentRecipe = null;
|
||||
Identifier currentRecipeID = null;
|
||||
boolean hasStartedCrafting = false;
|
||||
boolean checkNBTRecipe = false;
|
||||
long lastTick = -1;
|
||||
|
||||
public FusionControlComputerBlockEntity() {
|
||||
super(TRBlockEntities.FUSION_CONTROL_COMPUTER);
|
||||
checkOverfill = false;
|
||||
this.inventory = new RebornInventory<>(3, "FusionControlComputerBlockEntity", 64, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that reactor has all necessary coils in place
|
||||
*
|
||||
* @return boolean Return true if coils are present
|
||||
*/
|
||||
public boolean checkCoils() {
|
||||
List<BlockPos> coils = Torus.generate(pos, size);
|
||||
for(BlockPos coilPos : coils){
|
||||
if (!isCoil(coilPos)) {
|
||||
coilCount = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
coilCount = coils.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if block is fusion coil
|
||||
*
|
||||
* @param pos coordinate for block
|
||||
* @return boolean Returns true if block is fusion coil
|
||||
*/
|
||||
public boolean isCoil(BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == TRContent.Machine.FUSION_COIL.block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets crafter progress and recipe
|
||||
*/
|
||||
private void resetCrafter() {
|
||||
currentRecipe = null;
|
||||
crafingTickTime = 0;
|
||||
neededPower = 0;
|
||||
hasStartedCrafting = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that ItemStack could be inserted into slot provided, including check
|
||||
* for existing item in slot and maximum stack size
|
||||
*
|
||||
* @param stack ItemStack ItemStack to insert
|
||||
* @param slot int Slot ID to check
|
||||
* @param tags boolean Should we use tags
|
||||
* @return boolean Returns true if ItemStack will fit into slot
|
||||
*/
|
||||
public boolean canFitStack(ItemStack stack, int slot, boolean tags) {// Checks to see if it can
|
||||
// fit the stack
|
||||
if (stack.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (inventory.getInvStack(slot).isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (ItemUtils.isItemEqual(inventory.getInvStack(slot), stack, true, tags)) {
|
||||
if (stack.getCount() + inventory.getInvStack(slot).getCount() <= stack.getMaxCount()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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
|
||||
*/
|
||||
private void updateCurrentRecipe() {
|
||||
for (RebornRecipe recipe : ModRecipes.FUSION_REACTOR.getRecipes(getWorld())) {
|
||||
if (validateRecipe((FusionReactorRecipe) recipe)) {
|
||||
currentRecipe = (FusionReactorRecipe) recipe;
|
||||
crafingTickTime = 0;
|
||||
neededPower = currentRecipe.getStartEnergy();
|
||||
hasStartedCrafting = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if reactor has all inputs and can output result
|
||||
*
|
||||
* @param recipe
|
||||
* @return
|
||||
*/
|
||||
private boolean validateRecipe(FusionReactorRecipe recipe) {
|
||||
return hasAllInputs(recipe) && canFitStack(recipe.getOutputs().get(0), outputStackSlot, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if BlockEntity has all necessary inputs for recipe provided
|
||||
*
|
||||
* @param recipeType RebornRecipe Recipe to check inputs
|
||||
* @return Boolean True if reactor has all inputs for recipe
|
||||
*/
|
||||
private boolean hasAllInputs(RebornRecipe recipeType) {
|
||||
if (recipeType == null) {
|
||||
return false;
|
||||
}
|
||||
for (RebornIngredient ingredient : recipeType.getRebornIngredients()) {
|
||||
boolean hasItem = false;
|
||||
if (ingredient.test(inventory.getInvStack(topStackSlot))
|
||||
|| ingredient.test(inventory.getInvStack(bottomStackSlot))) {
|
||||
hasItem = true;
|
||||
}
|
||||
if (!hasItem) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease stack size on the given slot according to recipe input
|
||||
*
|
||||
* @param slot int Slot number
|
||||
*/
|
||||
private void useInput(int slot) {
|
||||
if (currentRecipe == null) {
|
||||
return;
|
||||
}
|
||||
for (RebornIngredient ingredient : currentRecipe.getRebornIngredients()) {
|
||||
if (ingredient.test(inventory.getInvStack(slot))) {
|
||||
inventory.shrinkSlot(slot, ingredient.getCount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TilePowerAcceptor
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Move this to here from the nbt read method, as it now requires the world as of 1.14
|
||||
if(checkNBTRecipe) {
|
||||
checkNBTRecipe = false;
|
||||
for (final RebornRecipe reactorRecipe : ModRecipes.FUSION_REACTOR.getRecipes(getWorld())) {
|
||||
if (validateRecipe((FusionReactorRecipe) reactorRecipe)) {
|
||||
this.currentRecipe = (FusionReactorRecipe) reactorRecipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(lastTick == world.getTime()){
|
||||
//Prevent tick accerators, blame obstinate for this.
|
||||
return;
|
||||
}
|
||||
lastTick = world.getTime();
|
||||
|
||||
// Force check every second
|
||||
if (world.getTime() % 20 == 0) {
|
||||
checkCoils();
|
||||
inventory.setChanged();
|
||||
}
|
||||
|
||||
if (coilCount == 0) {
|
||||
resetCrafter();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentRecipe == null && inventory.hasChanged()) {
|
||||
updateCurrentRecipe();
|
||||
}
|
||||
|
||||
if (currentRecipe != null) {
|
||||
if (!hasStartedCrafting && !validateRecipe(currentRecipe)) {
|
||||
resetCrafter();
|
||||
inventory.resetChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasStartedCrafting) {
|
||||
// Ignition!
|
||||
if (canUseEnergy(currentRecipe.getStartEnergy())) {
|
||||
useEnergy(currentRecipe.getStartEnergy());
|
||||
hasStartedCrafting = true;
|
||||
useInput(topStackSlot);
|
||||
useInput(bottomStackSlot);
|
||||
}
|
||||
}
|
||||
if (hasStartedCrafting && crafingTickTime < currentRecipe.getTime()) {
|
||||
// Power gen
|
||||
if (currentRecipe.getPower() < 0) {
|
||||
// Waste power if it has no where to go
|
||||
double power = Math.abs(currentRecipe.getPower()) * getPowerMultiplier();
|
||||
addEnergy(power);
|
||||
powerChange = (power);
|
||||
crafingTickTime++;
|
||||
} else { // Power user
|
||||
if (canUseEnergy(currentRecipe.getPower())) {
|
||||
setEnergy(getEnergy() - currentRecipe.getPower());
|
||||
crafingTickTime++;
|
||||
}
|
||||
}
|
||||
} else if (crafingTickTime >= currentRecipe.getTime()) {
|
||||
ItemStack result = currentRecipe.getOutputs().get(0);
|
||||
if (canFitStack(result, outputStackSlot, true)) {
|
||||
if (inventory.getInvStack(outputStackSlot).isEmpty()) {
|
||||
inventory.setInvStack(outputStackSlot, result.copy());
|
||||
} else {
|
||||
inventory.shrinkSlot(outputStackSlot, -result.getCount());
|
||||
}
|
||||
if (validateRecipe(this.currentRecipe)) {
|
||||
crafingTickTime = 0;
|
||||
useInput(topStackSlot);
|
||||
useInput(bottomStackSlot);
|
||||
} else {
|
||||
resetCrafter();
|
||||
}
|
||||
}
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
inventory.resetChanged();
|
||||
}
|
||||
|
||||
|
||||
@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 double getBaseMaxPower() {
|
||||
return Math.min(TechRebornConfig.fusionControlComputerMaxEnergy * getPowerMultiplier(), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@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 Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxInput() {
|
||||
if (hasStartedCrafting) {
|
||||
return 0;
|
||||
}
|
||||
return TechRebornConfig.fusionControlComputerMaxInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(final CompoundTag tagCompound) {
|
||||
super.fromTag(tagCompound);
|
||||
this.crafingTickTime = tagCompound.getInt("crafingTickTime");
|
||||
this.neededPower = tagCompound.getInt("neededPower");
|
||||
this.hasStartedCrafting = tagCompound.getBoolean("hasStartedCrafting");
|
||||
if(tagCompound.contains("hasActiveRecipe") && tagCompound.getBoolean("hasActiveRecipe") && this.currentRecipe == null){
|
||||
checkNBTRecipe = true;
|
||||
}
|
||||
if(tagCompound.contains("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.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(final CompoundTag tagCompound) {
|
||||
super.toTag(tagCompound);
|
||||
tagCompound.putInt("crafingTickTime", this.crafingTickTime);
|
||||
tagCompound.putInt("neededPower", this.neededPower);
|
||||
tagCompound.putBoolean("hasStartedCrafting", this.hasStartedCrafting);
|
||||
tagCompound.putBoolean("hasActiveRecipe", this.currentRecipe != null);
|
||||
tagCompound.putInt("size", size);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
// TileLegacyMachineBase
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
this.checkCoils();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity playerIn) {
|
||||
return TRContent.Machine.FUSION_CONTROL_COMPUTER.getStack();
|
||||
}
|
||||
|
||||
// ItemHandlerProvider
|
||||
@Override
|
||||
public RebornInventory<FusionControlComputerBlockEntity> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("fusionreactor").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).slot(0, 34, 47).slot(1, 126, 47).outputSlot(2, 80, 47).syncEnergyValue()
|
||||
.sync(this::getCoilStatus, this::setCoilStatus)
|
||||
.sync(this::getCrafingTickTime, this::setCrafingTickTime)
|
||||
.sync(this::getSize, this::setSize)
|
||||
.sync(this::getState, this::setState)
|
||||
.sync(this::getNeededPower, this::setNeededPower)
|
||||
.sync(this::getCurrentRecipeID, this::setCurrentRecipeID)
|
||||
.addInventory()
|
||||
.create(this, syncID);
|
||||
}
|
||||
|
||||
public int getCoilStatus() {
|
||||
return coilCount;
|
||||
}
|
||||
|
||||
public void setCoilStatus(int coilStatus) {
|
||||
this.coilCount = coilStatus;
|
||||
}
|
||||
|
||||
public int getCrafingTickTime() {
|
||||
return crafingTickTime;
|
||||
}
|
||||
|
||||
public void setCrafingTickTime(int crafingTickTime) {
|
||||
this.crafingTickTime = crafingTickTime;
|
||||
}
|
||||
|
||||
public int getNeededPower() {
|
||||
return neededPower;
|
||||
}
|
||||
|
||||
public void setNeededPower(int neededPower) {
|
||||
this.neededPower = neededPower;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(int 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(){
|
||||
if(currentRecipe == null ){
|
||||
return 0; //No Recipe
|
||||
}
|
||||
if(!hasStartedCrafting){
|
||||
return 1; //Waiting on power
|
||||
}
|
||||
if(hasStartedCrafting){
|
||||
return 2; //Crafting
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setState(int state){
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Identifier getCurrentRecipeID() {
|
||||
if(currentRecipe == null) {
|
||||
return new Identifier("null", "null");
|
||||
}
|
||||
return currentRecipe.getId();
|
||||
}
|
||||
|
||||
public void setCurrentRecipeID(Identifier currentRecipeID) {
|
||||
if(currentRecipeID.getPath().equals("null")) {
|
||||
currentRecipeID = null;
|
||||
}
|
||||
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 String getStateString(){
|
||||
if(state == -1){
|
||||
return "";
|
||||
} else if (state == 0){
|
||||
return "No recipe";
|
||||
} else if (state == 1){
|
||||
FusionReactorRecipe r = getCurrentRecipeFromID();
|
||||
if(r == null) {
|
||||
return "Charging";
|
||||
}
|
||||
int percentage = percentage(r.getStartEnergy(), getEnergy());
|
||||
return "Charging (" + percentage + "%)";
|
||||
} else if (state == 2){
|
||||
return "Crafting";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private int percentage(double MaxValue, double CurrentValue) {
|
||||
if (CurrentValue == 0) {
|
||||
return 0;
|
||||
}
|
||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
|||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -35,9 +35,9 @@ import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
|||
import reborncore.common.multiblock.IMultiblockPart;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.MachineCasingBlockEntity;
|
||||
import techreborn.blocks.BlockMachineCasing;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity;
|
||||
import techreborn.blocks.misc.BlockMachineCasing;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -42,7 +42,7 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -42,7 +42,7 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -36,7 +36,7 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
|
||||
public class VacuumFreezerBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
|
|
|
@ -22,32 +22,71 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.tier3;
|
||||
package techreborn.blockentity.machine.multiblock.casing;
|
||||
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.multiblock.MultiblockControllerBase;
|
||||
import reborncore.common.multiblock.rectangular.RectangularMultiblockBlockEntityBase;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.multiblocks.MultiBlockCasing;
|
||||
|
||||
public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
|
||||
public class MachineCasingBlockEntity extends RectangularMultiblockBlockEntityBase {
|
||||
|
||||
public CreativeQuantumTankBlockEntity() {
|
||||
super(TRBlockEntities.CREATIVE_QUANTUM_TANK);
|
||||
public MachineCasingBlockEntity() {
|
||||
super(TRBlockEntities.MACHINE_CASINGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineActivated() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineDeactivated() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiblockControllerBase createNewMultiblock() {
|
||||
return new MultiBlockCasing(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends MultiblockControllerBase> getMultiblockControllerType() {
|
||||
return MultiBlockCasing.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForFrame() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForSides() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForTop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForBottom() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isGoodForInterior() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiBlockCasing getMultiblockController() {
|
||||
return (MultiBlockCasing) super.getMultiblockController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!tank.isEmpty() && !tank.isFull()) {
|
||||
tank.setFluidAmount(FluidValue.INFINITE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int slotTransferSpeed() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fluidTransferAmount() {
|
||||
return 10000;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
|
|||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -30,7 +30,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
|
|||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -34,7 +34,7 @@ import techreborn.config.TechRebornConfig;
|
|||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
|
||||
public class ChemicalReactorBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
|
|||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -30,7 +30,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
|
|||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -36,7 +36,7 @@ import techreborn.init.ModRecipes;
|
|||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.items.ItemDynamicCell;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
|
||||
public class IndustrialElectrolyzerBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ import net.minecraft.util.math.Direction;
|
|||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import techreborn.blocks.tier1.BlockPlayerDetector;
|
||||
import techreborn.blocks.tier1.BlockPlayerDetector.PlayerDetectorType;
|
||||
import techreborn.blocks.machine.tier1.BlockPlayerDetector;
|
||||
import techreborn.blocks.machine.tier1.BlockPlayerDetector.PlayerDetectorType;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -33,7 +33,7 @@ import techreborn.api.recipe.ScrapboxRecipeCrafter;
|
|||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
|
||||
public class ScrapboxinatorBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
|
|||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
|
|
@ -30,7 +30,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
|
|||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.tier3;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
public class CreativeQuantumChestBlockEntity extends QuantumChestBlockEntity {
|
||||
|
||||
public CreativeQuantumChestBlockEntity() {
|
||||
super(TRBlockEntities.CREATIVE_QUANTUM_CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
ItemStack stack = inventory.getInvStack(1);
|
||||
if (!stack.isEmpty() && storedItem.isEmpty()) {
|
||||
stack.setCount(stack.getMaxCount());
|
||||
storedItem = stack.copy();
|
||||
}
|
||||
|
||||
storedItem.setCount(maxCapacity - storedItem.getMaxCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int slotTransferSpeed() {
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.tier3;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import techreborn.blockentity.machine.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.items.ItemDynamicCell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IndustrialCentrifugeBlockEntity extends GenericMachineBlockEntity implements IContainerProvider, IListInfoProvider {
|
||||
|
||||
public IndustrialCentrifugeBlockEntity() {
|
||||
super(TRBlockEntities.INDUSTRIAL_CENTRIFUGE, "IndustrialCentrifuge", TechRebornConfig.industrialCentrifugeMaxInput, TechRebornConfig.industrialCentrifugeMaxEnergy, TRContent.Machine.INDUSTRIAL_CENTRIFUGE.block, 6);
|
||||
final int[] inputs = new int[] { 0, 1 };
|
||||
final int[] outputs = new int[] { 2, 3, 4, 5 };
|
||||
this.inventory = new RebornInventory<>(7, "IndustrialCentrifugeBlockEntity", 64, this);
|
||||
this.crafter = new RecipeCrafter(ModRecipes.CENTRIFUGE, this, 2, 4, this.inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("centrifuge").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this)
|
||||
.filterSlot(1, 40, 54, stack -> ItemUtils.isItemEqual(stack, ItemDynamicCell.getEmptyCell(1), true, true))
|
||||
.filterSlot(0, 40, 34, stack -> !ItemUtils.isItemEqual(stack, ItemDynamicCell.getEmptyCell(1), true, true))
|
||||
.outputSlot(2, 82, 44).outputSlot(3, 101, 25)
|
||||
.outputSlot(4, 120, 44).outputSlot(5, 101, 63).energySlot(6, 8, 72).syncEnergyValue()
|
||||
.syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
// IListInfoProvider
|
||||
@Override
|
||||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||
super.addInfo(info, isReal, hasData);
|
||||
if(Screen.hasControlDown()) {
|
||||
info.add(new LiteralText("Round and round it goes"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.tier3;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import techreborn.blockentity.TechStorageBaseBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
public class QuantumChestBlockEntity extends TechStorageBaseBlockEntity implements IContainerProvider {
|
||||
|
||||
public QuantumChestBlockEntity() {
|
||||
this(TRBlockEntities.QUANTUM_CHEST);
|
||||
}
|
||||
|
||||
public QuantumChestBlockEntity(BlockEntityType<?> blockEntityType) {
|
||||
super(blockEntityType, "QuantumChestBlockEntity", TechRebornConfig.quantumChestMaxStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("quantumchest").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.tier3;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.Text;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class QuantumTankBlockEntity extends MachineBaseBlockEntity
|
||||
implements InventoryProvider, IToolDrop, IListInfoProvider, IContainerProvider {
|
||||
|
||||
public Tank tank = new Tank("QuantumTankBlockEntity", FluidValue.INFINITE, this);
|
||||
public RebornInventory<QuantumTankBlockEntity> inventory = new RebornInventory<>(3, "QuantumTankBlockEntity", 64, this);
|
||||
|
||||
public QuantumTankBlockEntity(){
|
||||
this(TRBlockEntities.QUANTUM_TANK);
|
||||
}
|
||||
|
||||
public QuantumTankBlockEntity(BlockEntityType<?> blockEntityTypeIn) {
|
||||
super(blockEntityTypeIn);
|
||||
}
|
||||
|
||||
public void readWithoutCoords(final CompoundTag tagCompound) {
|
||||
tank.read(tagCompound);
|
||||
}
|
||||
|
||||
public CompoundTag writeWithoutCoords(final CompoundTag tagCompound) {
|
||||
tank.write(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public ItemStack getDropWithNBT() {
|
||||
final CompoundTag blockEntity = new CompoundTag();
|
||||
final ItemStack dropStack = TRContent.Machine.QUANTUM_TANK.getStack();
|
||||
this.writeWithoutCoords(blockEntity);
|
||||
dropStack.setTag(new CompoundTag());
|
||||
dropStack.getTag().put("blockEntity", blockEntity);
|
||||
return dropStack;
|
||||
}
|
||||
|
||||
// TileMachineBase
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!world.isClient) {
|
||||
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|
||||
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
|
||||
this.syncWithAll();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(final CompoundTag tagCompound) {
|
||||
super.fromTag(tagCompound);
|
||||
readWithoutCoords(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(final CompoundTag tagCompound) {
|
||||
super.toTag(tagCompound);
|
||||
writeWithoutCoords(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
// ItemHandlerProvider
|
||||
@Override
|
||||
public RebornInventory<QuantumTankBlockEntity> getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final PlayerEntity entityPlayer) {
|
||||
return this.getDropWithNBT();
|
||||
}
|
||||
|
||||
// IListInfoProvider
|
||||
@Override
|
||||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||
if (isReal | hasData) {
|
||||
if (!this.tank.getFluidInstance().isEmpty()) {
|
||||
info.add(new LiteralText(this.tank.getFluidAmount() + " of " + this.tank.getFluid()));
|
||||
} else {
|
||||
info.add(new LiteralText("Empty"));
|
||||
}
|
||||
}
|
||||
info.add(new LiteralText("Capacity " + this.tank.getCapacity()));
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("quantumtank").player(player.inventory).inventory().hotbar()
|
||||
.addInventory().blockEntity(this).fluidSlot(0, 80, 17).outputSlot(1, 80, 53)
|
||||
.sync(tank).addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Tank getTank() {
|
||||
return tank;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue