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:
Justin Vitale 2020-01-03 08:24:46 +11:00 committed by drcrazy
parent 2fc9557516
commit 9328c47bed
207 changed files with 1830 additions and 928 deletions

View file

@ -37,7 +37,7 @@ import reborncore.common.config.Configuration;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.Torus;
import reborncore.common.world.DataAttachment;
import techreborn.blockentity.storage.idsu.IDSUManager;
import techreborn.blockentity.storage.energy.idsu.IDSUManager;
import techreborn.client.GuiHandler;
import techreborn.config.TechRebornConfig;
import techreborn.events.ModRegistry;

View file

@ -33,7 +33,7 @@ import net.minecraft.util.JsonHelper;
import reborncore.common.crafting.RebornRecipe;
import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.crafting.ingredient.RebornIngredient;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
/**
* @author drcrazy

View file

@ -1,257 +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;
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.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.ItemUtils;
import java.util.ArrayList;
import java.util.List;
public class TechStorageBaseBlockEntity extends MachineBaseBlockEntity
implements InventoryProvider, IToolDrop, IListInfoProvider {
public final int maxCapacity;
public final RebornInventory<TechStorageBaseBlockEntity> inventory;
public ItemStack storedItem;
public TechStorageBaseBlockEntity(BlockEntityType<?> blockEntityTypeIn, String name, int maxCapacity) {
super(blockEntityTypeIn);
this.maxCapacity = maxCapacity;
storedItem = ItemStack.EMPTY;
inventory = new RebornInventory<>(3, name, maxCapacity, this);
}
public void readWithoutCoords(CompoundTag tagCompound) {
storedItem = ItemStack.EMPTY;
if (tagCompound.contains("storedStack")) {
storedItem = ItemStack.fromTag(tagCompound.getCompound("storedStack"));
}
if (!storedItem.isEmpty()) {
storedItem.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity));
}
inventory.read(tagCompound);
}
public CompoundTag writeWithoutCoords(CompoundTag tagCompound) {
if (!storedItem.isEmpty()) {
ItemStack temp = storedItem.copy();
if (storedItem.getCount() > storedItem.getMaxCount()) {
temp.setCount(storedItem.getMaxCount());
}
tagCompound.put("storedStack", temp.toTag(new CompoundTag()));
tagCompound.putInt("storedQuantity", Math.min(storedItem.getCount(), maxCapacity));
} else {
tagCompound.putInt("storedQuantity", 0);
}
inventory.write(tagCompound);
return tagCompound;
}
public ItemStack getDropWithNBT() {
CompoundTag blockEntity = new CompoundTag();
ItemStack dropStack = new ItemStack(getBlockType(), 1);
writeWithoutCoords(blockEntity);
dropStack.setTag(new CompoundTag());
dropStack.getTag().put("blockEntity", blockEntity);
storedItem.setCount(0);
inventory.setInvStack(1, ItemStack.EMPTY);
syncWithAll();
return dropStack;
}
public int getStoredCount() {
return storedItem.getCount();
}
public List<ItemStack> getContentDrops() {
ArrayList<ItemStack> stacks = new ArrayList<>();
if (!getStoredItemType().isEmpty()) {
if (!inventory.getInvStack(1).isEmpty()) {
stacks.add(inventory.getInvStack(1));
}
int size = storedItem.getMaxCount();
for (int i = 0; i < getStoredCount() / size; i++) {
ItemStack droped = storedItem.copy();
droped.setCount(size);
stacks.add(droped);
}
if (getStoredCount() % size != 0) {
ItemStack droped = storedItem.copy();
droped.setCount(getStoredCount() % size);
stacks.add(droped);
}
}
return stacks;
}
// TileMachineBase
@Override
public void tick() {
super.tick();
if (!world.isClient) {
ItemStack outputStack = ItemStack.EMPTY;
if (!inventory.getInvStack(1).isEmpty()) {
outputStack = inventory.getInvStack(1);
}
if (!inventory.getInvStack(0).isEmpty()
&& (storedItem.getCount() + outputStack.getCount()) < maxCapacity) {
ItemStack inputStack = inventory.getInvStack(0);
if (getStoredItemType().isEmpty()
|| (storedItem.isEmpty() && ItemUtils.isItemEqual(inputStack, outputStack, true, true))) {
storedItem = inputStack;
inventory.setInvStack(0, ItemStack.EMPTY);
} else if (ItemUtils.isItemEqual(getStoredItemType(), inputStack, true, true)) {
int reminder = maxCapacity - storedItem.getCount() - outputStack.getCount();
if (inputStack.getCount() <= reminder) {
setStoredItemCount(inputStack.getCount());
inventory.setInvStack(0, ItemStack.EMPTY);
} else {
setStoredItemCount(maxCapacity - outputStack.getCount());
inventory.getInvStack(0).decrement(reminder);
}
}
markDirty();
syncWithAll();
}
if (!storedItem.isEmpty()) {
if (outputStack.isEmpty()) {
ItemStack delivered = storedItem.copy();
delivered.setCount(Math.min(storedItem.getCount(), delivered.getMaxCount()));
storedItem.decrement(delivered.getCount());
if (storedItem.isEmpty()) {
storedItem = ItemStack.EMPTY;
}
inventory.setInvStack(1, delivered);
markDirty();
syncWithAll();
} else if (ItemUtils.isItemEqual(storedItem, outputStack, true, true)
&& outputStack.getCount() < outputStack.getMaxCount()) {
int wanted = Math.min(storedItem.getCount(),
outputStack.getMaxCount() - outputStack.getCount());
outputStack.setCount(outputStack.getCount() + wanted);
storedItem.decrement(wanted);
if (storedItem.isEmpty()) {
storedItem = ItemStack.EMPTY;
}
markDirty();
syncWithAll();
}
}
}
}
@Override
public boolean canBeUpgraded() {
return false;
}
@Override
public void fromTag(CompoundTag tagCompound) {
super.fromTag(tagCompound);
readWithoutCoords(tagCompound);
}
@Override
public CompoundTag toTag(CompoundTag tagCompound) {
super.toTag(tagCompound);
writeWithoutCoords(tagCompound);
return tagCompound;
}
// ItemHandlerProvider
@Override
public RebornInventory<TechStorageBaseBlockEntity> getInventory() {
return inventory;
}
// IToolDrop
@Override
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
return getDropWithNBT();
}
// IListInfoProvider
@Override
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
if (isReal || hasData) {
int size = 0;
String name = "of nothing";
if (!storedItem.isEmpty()) {
name = storedItem.getName().getString();
size += storedItem.getCount();
}
if (!inventory.getInvStack(1).isEmpty()) {
name = inventory.getInvStack(1).getName().getString();
size += inventory.getInvStack(1).getCount();
}
info.add(new LiteralText(size + " " + name));
}
}
public ItemStack getStoredItemType() {
return storedItem.isEmpty() ? inventory.getInvStack(1) : storedItem;
}
public void setStoredItemCount(int amount) {
storedItem.increment(amount);
markDirty();
}
public void setStoredItemType(ItemStack type, int amount) {
storedItem = type;
storedItem.setCount(amount);
markDirty();
}
public int getMaxStoredCount() {
return maxCapacity;
}
}

View file

@ -45,7 +45,7 @@ import reborncore.common.crafting.RebornRecipeType;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.serialization.SerializationUtil;
import techreborn.blockentity.GenericMachineBlockEntity;
import techreborn.blockentity.machine.GenericMachineBlockEntity;
import techreborn.init.ModRecipes;
import javax.annotation.Nullable;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity;
package techreborn.blockentity.machine;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntityType;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity;
package techreborn.blockentity.machine.misc;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -35,7 +35,7 @@ import net.minecraft.util.Tickable;
import reborncore.api.IToolDrop;
import reborncore.common.util.ChatUtils;
import reborncore.common.util.StringUtils;
import techreborn.blocks.BlockAlarm;
import techreborn.blocks.misc.BlockAlarm;
import techreborn.init.ModSounds;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity;
package techreborn.blockentity.machine.misc;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;

View file

@ -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;

View file

@ -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;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.fusionReactor;
package techreborn.blockentity.machine.multiblock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity;
package techreborn.blockentity.machine.multiblock.casing;
import reborncore.common.multiblock.MultiblockControllerBase;
import reborncore.common.multiblock.rectangular.RectangularMultiblockBlockEntityBase;

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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;

View file

@ -1,53 +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 reborncore.common.fluid.FluidValue;
import techreborn.init.TRBlockEntities;
public class CreativeQuantumTankBlockEntity extends QuantumTankBlockEntity {
public CreativeQuantumTankBlockEntity() {
super(TRBlockEntities.CREATIVE_QUANTUM_TANK);
}
@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;
}
}

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity;
package techreborn.blockentity.machine.tier3;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.PlayerEntity;
@ -35,6 +35,7 @@ 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;

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage;
package techreborn.blockentity.storage.energy;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage;
package techreborn.blockentity.storage.energy;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntityType;
@ -35,7 +35,7 @@ import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
import team.reborn.energy.Energy;
import team.reborn.energy.EnergyTier;
import techreborn.blocks.storage.EnergyStorageBlock;
import techreborn.blocks.storage.energy.EnergyStorageBlock;
/**
* Created by Rushmead

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage;
package techreborn.blockentity.storage.energy;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.IContainerProvider;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage;
package techreborn.blockentity.storage.energy;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.IContainerProvider;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage;
package techreborn.blockentity.storage.energy;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.IContainerProvider;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage.idsu;
package techreborn.blockentity.storage.energy.idsu;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.World;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage.idsu;
package techreborn.blockentity.storage.energy.idsu;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
@ -32,7 +32,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.containerBuilder.builder.ContainerBuilder;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
import techreborn.blockentity.storage.EnergyStorageBlockEntity;
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage.lesu;
package techreborn.blockentity.storage.energy.lesu;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage.lesu;
package techreborn.blockentity.storage.energy.lesu;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
@ -33,8 +33,8 @@ import reborncore.client.containerBuilder.IContainerProvider;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.containerBuilder.builder.ContainerBuilder;
import team.reborn.energy.EnergyTier;
import techreborn.blockentity.storage.EnergyStorageBlockEntity;
import techreborn.blocks.storage.LapotronicSUBlock;
import techreborn.blockentity.storage.energy.EnergyStorageBlockEntity;
import techreborn.blocks.storage.energy.LapotronicSUBlock;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blockentity.storage.lesu;
package techreborn.blockentity.storage.energy.lesu;
import java.util.ArrayList;

View file

@ -0,0 +1,41 @@
package techreborn.blockentity.storage.fluid;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.util.Tank;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@Deprecated
public class CreativeQuantumTankBlockEntity extends TankUnitBaseBlockEntity {
// Save
public CreativeQuantumTankBlockEntity() {
super(TRBlockEntities.CREATIVE_QUANTUM_TANK, TRContent.TankUnit.QUANTUM);
}
@Override
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
inventory.clear();
}
@Override
public void tick() {
if (world.isClient()) {
return;
}
Tank tank = this.getTank();
inventory.clear();
world.setBlockState(pos, TRContent.TankUnit.CREATIVE.block.getDefaultState());
TankUnitBaseBlockEntity tankEntity = (TankUnitBaseBlockEntity) world.getBlockEntity(pos);
tankEntity.setTank(tank);
}
}

View file

@ -0,0 +1,47 @@
package techreborn.blockentity.storage.fluid;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.util.Tank;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@Deprecated
public class QuantumTankBlockEntity extends TankUnitBaseBlockEntity {
// Save
public QuantumTankBlockEntity() {
super(TRBlockEntities.QUANTUM_TANK, TRContent.TankUnit.QUANTUM);
}
@Override
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
inventory.clear();
}
@Override
public void tick() {
if (world.isClient()) {
return;
}
Tank tank = this.getTank();
ItemStack inputSlotStack = getInvStack(0).copy();
ItemStack outputSlotStack = getInvStack(1).copy();
inventory.clear();
world.setBlockState(pos, TRContent.TankUnit.QUANTUM.block.getDefaultState());
TankUnitBaseBlockEntity tankEntity = (TankUnitBaseBlockEntity) world.getBlockEntity(pos);
tankEntity.setTank(tank);
tankEntity.setInvStack(0, inputSlotStack);
tankEntity.setInvStack(1, outputSlotStack);
}
}

View file

@ -0,0 +1,162 @@
package techreborn.blockentity.storage.fluid;
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 net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
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.StringUtils;
import reborncore.common.util.Tank;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import javax.annotation.Nonnull;
import java.util.List;
public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, IContainerProvider {
protected Tank tank;
protected RebornInventory<TankUnitBaseBlockEntity> inventory = new RebornInventory<>(2, "TankInventory", 64, this);
private TRContent.TankUnit type;
public TankUnitBaseBlockEntity() {
super(TRBlockEntities.TANK_UNIT);
}
public TankUnitBaseBlockEntity(TRContent.TankUnit type) {
super(TRBlockEntities.TANK_UNIT);
configureEntity(type);
}
public TankUnitBaseBlockEntity(BlockEntityType<?> blockEntityTypeIn, TRContent.TankUnit type) {
super(blockEntityTypeIn);
this.type = type;
}
private void configureEntity(TRContent.TankUnit type) {
this.type = type;
this.tank = new Tank("TankStorage", type.capacity, this);
}
@Override
public void tick() {
super.tick();
if (world.isClient()) {
return;
}
if (FluidUtils.drainContainers(tank, inventory, 0, 1)
|| FluidUtils.fillContainers(tank, inventory, 0, 1, tank.getFluid())) {
if (type == TRContent.TankUnit.CREATIVE) {
if (!tank.isEmpty() && !tank.isFull()) {
tank.setFluidAmount(FluidValue.INFINITE);
}
}
syncWithAll();
}
}
@Override
public boolean canBeUpgraded() {
return false;
}
@Override
public void fromTag(final CompoundTag tagCompound) {
super.fromTag(tagCompound);
if (tagCompound.contains("unitType")) {
this.type = TRContent.TankUnit.valueOf(tagCompound.getString("unitType"));
configureEntity(type);
tank.read(tagCompound);
} else {
// SAVE COMPAT
if (tagCompound.contains("QuantumTankBlockEntity")) {
this.type = TRContent.TankUnit.QUANTUM;
Tank temp = new Tank("QuantumTankBlockEntity", type.capacity, this);
temp.read(tagCompound);
// Set tank name to what it should be
tank = new Tank("TankStorage", type.capacity, this);
tank.setFluid(null, temp.getFluidInstance().copy());
}
}
}
@Override
public CompoundTag toTag(final CompoundTag tagCompound) {
super.toTag(tagCompound);
tagCompound.putString("unitType", this.type.name());
tank.write(tagCompound);
return tagCompound;
}
public ItemStack getDropWithNBT() {
ItemStack dropStack = new ItemStack(getBlockType(), 1);
final CompoundTag blockEntity = new CompoundTag();
this.toTag(blockEntity);
dropStack.setTag(new CompoundTag());
dropStack.getTag().put("blockEntity", blockEntity);
return dropStack;
}
// ItemHandlerProvider
@Override
public RebornInventory<TankUnitBaseBlockEntity> getInventory() {
return this.inventory;
}
// 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() + StringUtils.t("techreborn.tooltip.unit.divider") + this.tank.getFluid()));
} else {
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
}
}
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.unit.capacity") + ":" + Formatting.GOLD + this.tank.getCapacity() + " (" + this.tank.getCapacity().getRawValue() / 1000 + ")"));
}
// IContainerProvider
@Override
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
return new ContainerBuilder("tank").player(player.inventory).inventory().hotbar()
.addInventory().blockEntity(this).fluidSlot(0, 100, 53).outputSlot(1, 140, 53)
.sync(tank).addInventory().create(this, syncID);
}
@Nonnull
@Override
public Tank getTank() {
return tank;
}
@Deprecated
public void setTank(Tank tank) {
this.tank.setFluid(null, tank.getFluidInstance());
}
@Override
public ItemStack getToolDrop(PlayerEntity playerEntity) {
return getDropWithNBT();
}
}

View file

@ -22,31 +22,44 @@
* SOFTWARE.
*/
package techreborn.blockentity.machine.tier3;
package techreborn.blockentity.storage.item;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class CreativeQuantumChestBlockEntity extends QuantumChestBlockEntity {
@Deprecated
public class CreativeQuantumChestBlockEntity extends StorageUnitBaseBlockEntity {
public CreativeQuantumChestBlockEntity() {
super(TRBlockEntities.CREATIVE_QUANTUM_CHEST);
super(TRBlockEntities.CREATIVE_QUANTUM_CHEST, "QuantumChestBlockEntity", Integer.MAX_VALUE);
}
@Override
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
super.inventory.clear();
}
@Override
public void tick() {
super.tick();
ItemStack stack = inventory.getInvStack(1);
if (!stack.isEmpty() && storedItem.isEmpty()) {
stack.setCount(stack.getMaxCount());
storedItem = stack.copy();
if (world.isClient()) {
return;
}
storedItem.setCount(maxCapacity - storedItem.getMaxCount());
}
ItemStack storedStack = this.getAll();
@Override
public int slotTransferSpeed() {
return 1;
this.clear();
world.setBlockState(pos, TRContent.StorageUnit.CREATIVE.block.getDefaultState());
StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
if (!storedStack.isEmpty() && storageEntity != null) {
storageEntity.setStoredStack(storedStack);
}
}
}

View file

@ -22,24 +22,46 @@
* SOFTWARE.
*/
package techreborn.blockentity;
package techreborn.blockentity.storage.item;
import net.minecraft.block.BlockState;
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.config.TechRebornConfig;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class DigitalChestBlockEntity extends TechStorageBaseBlockEntity implements IContainerProvider {
@Deprecated
public class DigitalChestBlockEntity extends StorageUnitBaseBlockEntity {
public DigitalChestBlockEntity() {
super(TRBlockEntities.DIGITAL_CHEST, "DigitalChestBlockEntity", TechRebornConfig.digitalChestMaxStorage);
super(TRBlockEntities.DIGITAL_CHEST, "DigitalChestBlockEntity", 32768);
}
@Override
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
return new ContainerBuilder("digitalchest").player(player.inventory).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 80, 24).outputSlot(1, 80, 64).addInventory().create(this, syncID);
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
super.inventory.clear();
}
@Override
public void tick() {
if (world.isClient()) {
return;
}
ItemStack storedStack = this.getAll();
ItemStack inputSlotStack = this.getInvStack(0).copy();
this.clear();
world.setBlockState(pos, TRContent.StorageUnit.INDUSTRIAL.block.getDefaultState());
StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
if (!storedStack.isEmpty() && storageEntity != null) {
storageEntity.setStoredStack(storedStack);
storageEntity.setInvStack(0, inputSlotStack);
}
}
}

View file

@ -22,40 +22,47 @@
* SOFTWARE.
*/
package techreborn.blocks.tier3;
package techreborn.blockentity.storage.item;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import techreborn.client.EGui;
import techreborn.blockentity.machine.tier3.CreativeQuantumChestBlockEntity;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
public class BlockCreativeQuantumChest extends BlockMachineBase {
@Deprecated
public class QuantumChestBlockEntity extends StorageUnitBaseBlockEntity {
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new CreativeQuantumChestBlockEntity();
public QuantumChestBlockEntity() {
super(TRBlockEntities.QUANTUM_CHEST, "QuantumChestBlockEntity", Integer.MAX_VALUE);
}
@Override
public IMachineGuiHandler getGui() {
return EGui.QUANTUM_CHEST;
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
super.inventory.clear();
super.onBreak(world, playerEntity, blockPos, blockState);
}
@Override
public boolean isAdvanced() {
return true;
}
@Override
public void onBlockRemoved(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (state.getBlock() != newState.getBlock()) {
//lets not drop max int items into the world, that sounds like a bad idea
worldIn.removeBlockEntity(pos);
public void tick() {
if (world.isClient()) {
return;
}
ItemStack storedStack = this.getAll();
ItemStack inputSlotStack = this.getInvStack(0).copy();
this.clear();
world.setBlockState(pos, TRContent.StorageUnit.QUANTUM.block.getDefaultState());
StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) world.getBlockEntity(pos);
if (!storedStack.isEmpty() && storageEntity != null) {
storageEntity.setStoredStack(storedStack);
storageEntity.setInvStack(0, inputSlotStack);
}
}
}

View file

@ -0,0 +1,384 @@
/*
* 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.storage.item;
import net.minecraft.block.BlockState;
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 net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
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.util.ItemUtils;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.StringUtils;
import reborncore.common.util.WorldUtils;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import java.util.List;
public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
implements InventoryProvider, IToolDrop, IListInfoProvider, IContainerProvider {
// Inventory constants
private static final int INPUT_SLOT = 0;
private static final int OUTPUT_SLOT = 1;
protected RebornInventory<StorageUnitBaseBlockEntity> inventory;
private int maxCapacity;
private boolean shouldUpdate = false;
private ItemStack storeItemStack;
private TRContent.StorageUnit type;
public StorageUnitBaseBlockEntity() {
super(TRBlockEntities.STORAGE_UNIT);
}
public StorageUnitBaseBlockEntity(TRContent.StorageUnit type) {
super(TRBlockEntities.STORAGE_UNIT);
configureEntity(type);
}
@Deprecated
public StorageUnitBaseBlockEntity(BlockEntityType<?> blockEntityTypeIn, String name, int maxCapacity) {
super(blockEntityTypeIn);
this.maxCapacity = maxCapacity;
storeItemStack = ItemStack.EMPTY;
type = TRContent.StorageUnit.QUANTUM;
inventory = new RebornInventory<>(3, name, maxCapacity, this);
}
private void configureEntity(TRContent.StorageUnit type) {
this.maxCapacity = type.capacity;
storeItemStack = ItemStack.EMPTY;
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
this.type = type;
}
// TileMachineBase
@Override
public void tick() {
super.tick();
if (world.isClient) {
return;
}
// If there is an item in the input AND stored is less than max capacity
if (!inventory.getInvStack(INPUT_SLOT).isEmpty() && !isFull()) {
inventory.setInvStack(INPUT_SLOT, processInput(inventory.getInvStack(INPUT_SLOT)));
shouldUpdate = true;
}
// Fill output slot with goodies when stored has items and output count is less than max stack size
if (storeItemStack.getCount() > 0 && inventory.getInvStack(OUTPUT_SLOT).getCount() < getStoredStack().getMaxCount()) {
populateOutput();
shouldUpdate = true;
}
if (type == TRContent.StorageUnit.CREATIVE) {
if (!isFull() && !isEmpty()) {
fillToCapacity();
shouldUpdate = true;
}
}
if (shouldUpdate) {
inventory.setChanged();
markDirty();
syncWithAll();
shouldUpdate = false;
}
}
private void populateOutput() {
// Set to storeItemStack to get the stack type
ItemStack output = storeItemStack.copy();
int outputSlotCount = inventory.getInvStack(OUTPUT_SLOT).getCount();
// Set to current outputSlot count
output.setCount(outputSlotCount);
// Calculate amount needed to fill stack in output slot
int amountToFill = getStoredStack().getMaxCount() - outputSlotCount;
if (storeItemStack.getCount() >= amountToFill) {
storeItemStack.decrement(amountToFill);
if (storeItemStack.isEmpty()) {
storeItemStack = ItemStack.EMPTY;
}
output.increment(amountToFill);
} else {
output.increment(storeItemStack.getCount());
storeItemStack = ItemStack.EMPTY;
}
inventory.setInvStack(OUTPUT_SLOT, output);
}
private void addStoredItemCount(int amount) {
storeItemStack.increment(amount);
}
public ItemStack getStoredStack() {
return storeItemStack.isEmpty() ? inventory.getInvStack(OUTPUT_SLOT) : storeItemStack;
}
public ItemStack getAll() {
ItemStack returnStack = ItemStack.EMPTY;
if (!isEmpty()) {
returnStack = getStoredStack().copy();
returnStack.setCount(getCurrentCapacity());
}
return returnStack;
}
public void setStoredStack(ItemStack itemStack) {
storeItemStack = itemStack;
}
public ItemStack processInput(ItemStack inputStack) {
boolean isSameStack = isSameType(inputStack);
if (storeItemStack == ItemStack.EMPTY && (isSameStack || getCurrentCapacity() == 0)) {
// Check if storage is empty, NOT including the output slot
storeItemStack = inputStack.copy();
if (inputStack.getCount() <= maxCapacity) {
inputStack = ItemStack.EMPTY;
} else {
// Stack is higher than capacity
storeItemStack.setCount(maxCapacity);
inputStack.decrement(maxCapacity);
}
} else if (isSameStack) {
// Not empty but same type
// Amount of items that can be added before reaching capacity
int reminder = maxCapacity - getCurrentCapacity();
if (inputStack.getCount() <= reminder) {
// Add full stack
addStoredItemCount(inputStack.getCount());
inputStack = ItemStack.EMPTY;
} else {
// Add only what is needed to reach max capacity
addStoredItemCount(reminder);
inputStack.decrement(reminder);
}
}
return inputStack;
}
public boolean isSameType(ItemStack inputStack) {
if (inputStack != ItemStack.EMPTY) {
return ItemUtils.isItemEqual(getStoredStack(), inputStack, true, true);
}
return false;
}
// Creative function
private void fillToCapacity() {
storeItemStack = getStoredStack();
storeItemStack.setCount(maxCapacity);
inventory.setInvStack(OUTPUT_SLOT, ItemStack.EMPTY);
}
public boolean isFull() {
return getCurrentCapacity() == maxCapacity;
}
public boolean isEmpty() {
return getCurrentCapacity() == 0;
}
public int getCurrentCapacity() {
return storeItemStack.getCount() + inventory.getInvStack(OUTPUT_SLOT).getCount();
}
public int getMaxCapacity() {
return maxCapacity;
}
// Other stuff
@Override
public boolean canBeUpgraded() {
return false;
}
@Override
public void fromTag(CompoundTag tagCompound) {
super.fromTag(tagCompound);
if (tagCompound.contains("unitType")) {
this.type = TRContent.StorageUnit.valueOf(tagCompound.getString("unitType"));
configureEntity(type);
} else {
this.type = TRContent.StorageUnit.QUANTUM;
}
storeItemStack = ItemStack.EMPTY;
if (tagCompound.contains("storedStack")) {
storeItemStack = ItemStack.fromTag(tagCompound.getCompound("storedStack"));
}
if (!storeItemStack.isEmpty()) {
storeItemStack.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity));
}
inventory.read(tagCompound);
}
@Override
public CompoundTag toTag(CompoundTag tagCompound) {
super.toTag(tagCompound);
tagCompound.putString("unitType", this.type.name());
if (!storeItemStack.isEmpty()) {
ItemStack temp = storeItemStack.copy();
if (storeItemStack.getCount() > storeItemStack.getMaxCount()) {
temp.setCount(storeItemStack.getMaxCount());
}
tagCompound.put("storedStack", temp.toTag(new CompoundTag()));
tagCompound.putInt("storedQuantity", Math.min(storeItemStack.getCount(), maxCapacity));
} else {
tagCompound.putInt("storedQuantity", 0);
}
inventory.write(tagCompound);
return tagCompound;
}
// ItemHandlerProvider
@Override
public RebornInventory<StorageUnitBaseBlockEntity> getInventory() {
return inventory;
}
// IToolDrop
@Override
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
return getDropWithNBT();
}
public ItemStack getDropWithNBT() {
ItemStack dropStack = new ItemStack(getBlockType(), 1);
final CompoundTag blockEntity = new CompoundTag();
this.toTag(blockEntity);
dropStack.setTag(new CompoundTag());
dropStack.getTag().put("blockEntity", blockEntity);
return dropStack;
}
// IListInfoProvider
@Override
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
if (isReal || hasData) {
if (!this.isEmpty()) {
info.add(new LiteralText(this.getCurrentCapacity() + StringUtils.t("techreborn.tooltip.unit.divider") + this.getStoredStack().getName().asString()));
} else {
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));
}
}
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.unit.capacity") + ": " + Formatting.GOLD + this.getMaxCapacity() +
" items (" + this.getMaxCapacity() / 64 + ")"));
}
@Override
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
super.onBreak(world, playerEntity, blockPos, blockState);
// No need to drop anything for creative peeps
if (type == TRContent.StorageUnit.CREATIVE) {
this.inventory.clear();
return;
}
if (storeItemStack != ItemStack.EMPTY) {
if (storeItemStack.getMaxCount() == 64) {
// Drop stacks (In one clump, reduce lag)
WorldUtils.dropItem(storeItemStack, world, pos);
} else {
int size = storeItemStack.getMaxCount();
for (int i = 0; i < storeItemStack.getCount() / size; i++) {
ItemStack toDrop = storeItemStack.copy();
toDrop.setCount(size);
WorldUtils.dropItem(toDrop, world, pos);
}
if (storeItemStack.getCount() % size != 0) {
ItemStack toDrop = storeItemStack.copy();
toDrop.setCount(storeItemStack.getCount() % size);
WorldUtils.dropItem(toDrop, world, pos);
}
}
}
// Inventory gets dropped automatically
}
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
return new ContainerBuilder("chest").player(player.inventory).inventory().hotbar().addInventory()
.blockEntity(this).slot(0, 100, 53).outputSlot(1, 140, 53).addInventory().create(this, syncID);
}
}

View file

@ -55,6 +55,8 @@ public class GenericMachineBlock extends BlockMachineBase {
return blockEntityClass.get();
}
@Override
public IMachineGuiHandler getGui() {
return gui;

View file

@ -41,7 +41,7 @@ import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.Torus;
import techreborn.client.EGui;
import techreborn.init.TRContent;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.utils.damageSources.FusionDamageSource;
import java.util.List;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.tier0;
package techreborn.blocks.machine.tier0;
import java.util.Random;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.tier0;
package techreborn.blocks.machine.tier0;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.tier1;
package techreborn.blocks.machine.tier1;
import net.minecraft.text.LiteralText;
import net.minecraft.util.ActionResult;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks;
package techreborn.blocks.misc;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
@ -53,7 +53,7 @@ import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.AlarmBlockEntity;
import techreborn.blockentity.machine.misc.AlarmBlockEntity;
import javax.annotation.Nullable;
import java.util.List;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks;
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;
@ -32,7 +32,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.world.BlockView;
import reborncore.common.multiblock.BlockMultiblockBase;
import techreborn.blockentity.MachineCasingBlockEntity;
import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity;
public class BlockMachineCasing extends BlockMultiblockBase {

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks;
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Material;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks;
package techreborn.blocks.misc;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Material;

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks;
package techreborn.blocks.misc;
import net.minecraft.util.Formatting;
import net.minecraft.block.Material;

View file

@ -0,0 +1,16 @@
package techreborn.blocks.storage;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import techreborn.blocks.GenericMachineBlock;
import techreborn.client.EGui;
import java.util.function.Supplier;
@Deprecated
public class OldBlock extends GenericMachineBlock {
public OldBlock(EGui gui, Supplier<BlockEntity> blockEntityClass) {
super(gui, blockEntityClass);
}
}

View file

@ -22,11 +22,11 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.client.EGui;
public class AdjustableSUBlock extends EnergyStorageBlock {

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block;

View file

@ -22,11 +22,11 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import techreborn.blockentity.storage.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity;
import techreborn.client.EGui;
/**

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -32,7 +32,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import techreborn.blockentity.storage.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
import techreborn.client.EGui;
public class InterdimensionalSUBlock extends EnergyStorageBlock {

View file

@ -22,7 +22,7 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
@ -41,7 +41,7 @@ import reborncore.api.ToolManager;
import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blocks.BlockWrenchEventHandler;
import reborncore.common.util.WrenchUtils;
import techreborn.blockentity.storage.lesu.LSUStorageBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity;
/**
* Energy storage block for LESU

View file

@ -22,11 +22,11 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import techreborn.blockentity.storage.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
import techreborn.client.EGui;
public class LapotronicSUBlock extends EnergyStorageBlock {

View file

@ -22,12 +22,12 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import techreborn.client.EGui;
import techreborn.blockentity.storage.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity;
/**
* Created by modmuss50 on 14/03/2016.

View file

@ -22,11 +22,11 @@
* SOFTWARE.
*/
package techreborn.blocks.storage;
package techreborn.blocks.storage.energy;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import techreborn.blockentity.storage.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity;
import techreborn.client.EGui;
/**

View file

@ -0,0 +1,29 @@
package techreborn.blocks.storage.fluid;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.client.EGui;
import techreborn.init.TRContent;
public class TankUnitBlock extends BlockMachineBase {
public final TRContent.TankUnit unitType;
public TankUnitBlock(TRContent.TankUnit unitType) {
super();
this.unitType = unitType;
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new TankUnitBaseBlockEntity(unitType);
}
@Override
public IMachineGuiHandler getGui() {
return EGui.TANK_UNIT;
}
}

View file

@ -0,0 +1,61 @@
package techreborn.blocks.storage.item;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.api.blockentity.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.EGui;
import techreborn.init.TRContent;
public class StorageUnitBlock extends BlockMachineBase {
public final TRContent.StorageUnit unitType;
public StorageUnitBlock(TRContent.StorageUnit unitType) {
super();
this.unitType = unitType;
}
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new StorageUnitBaseBlockEntity(unitType);
}
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) {
if (unitType == TRContent.StorageUnit.CREATIVE) {
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
}
final StorageUnitBaseBlockEntity storageEntity = (StorageUnitBaseBlockEntity) worldIn.getBlockEntity(pos);
ItemStack stackInHand = playerIn.getStackInHand(Hand.MAIN_HAND);
if (storageEntity != null && storageEntity.isSameType(stackInHand)) {
// Add item which is the same type (in users inventory) into storage
for (int i = 0; i < playerIn.inventory.getInvSize() && !storageEntity.isFull(); i++) {
ItemStack curStack = playerIn.inventory.getInvStack(i);
if (storageEntity.isSameType(curStack)) {
playerIn.inventory.setInvStack(i, storageEntity.processInput(curStack));
}
}
return ActionResult.SUCCESS;
}
return super.onUse(state, worldIn, pos, playerIn, hand, hitResult);
}
@Override
public IMachineGuiHandler getGui() {
return EGui.STORAGE_UNIT;
}
}

View file

@ -49,7 +49,6 @@ public enum EGui implements IMachineGuiHandler {
CHUNK_LOADER,
COMPRESSOR,
DIESEL_GENERATOR,
DIGITAL_CHEST,
DISTILLATION_TOWER,
ELECTRIC_FURNACE,
EXTRACTOR,
@ -68,8 +67,8 @@ public enum EGui implements IMachineGuiHandler {
MATTER_FABRICATOR,
MEDIUM_VOLTAGE_SU,
PLASMA_GENERATOR,
QUANTUM_CHEST,
QUANTUM_TANK,
STORAGE_UNIT,
TANK_UNIT,
RECYCLER,
ROLLING_MACHINE,
SAWMILL,

View file

@ -34,12 +34,12 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import reborncore.RebornCore;
import reborncore.client.containerBuilder.IContainerProvider;
import techreborn.blockentity.ChargeOMatBlockEntity;
import techreborn.blockentity.DigitalChestBlockEntity;
import techreborn.blockentity.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.data.DataDrivenBEProvider;
import techreborn.blockentity.data.DataDrivenGui;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
import techreborn.blockentity.generator.SolarPanelBlockEntity;
import techreborn.blockentity.generator.advanced.DieselGeneratorBlockEntity;
@ -53,14 +53,13 @@ import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.tier1.*;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.machine.tier3.MatterFabricatorBlockEntity;
import techreborn.blockentity.machine.tier3.QuantumChestBlockEntity;
import techreborn.blockentity.machine.tier3.QuantumTankBlockEntity;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.client.gui.*;
public class GuiHandler {
@ -108,8 +107,6 @@ public class GuiHandler {
return new GuiCompressor(syncID, player, (CompressorBlockEntity) blockEntity);
case DIESEL_GENERATOR:
return new GuiDieselGenerator(syncID, player, (DieselGeneratorBlockEntity) blockEntity);
case DIGITAL_CHEST:
return new GuiDigitalChest(syncID, player, (DigitalChestBlockEntity) blockEntity);
case ELECTRIC_FURNACE:
return new GuiElectricFurnace(syncID, player, (ElectricFurnaceBlockEntity) blockEntity);
case EXTRACTOR:
@ -138,10 +135,10 @@ public class GuiHandler {
return new GuiMFE(syncID, player, (MediumVoltageSUBlockEntity) blockEntity);
case HIGH_VOLTAGE_SU:
return new GuiMFSU(syncID, player, (HighVoltageSUBlockEntity) blockEntity);
case QUANTUM_CHEST:
return new GuiQuantumChest(syncID, player, (QuantumChestBlockEntity) blockEntity);
case QUANTUM_TANK:
return new GuiQuantumTank(syncID, player, (QuantumTankBlockEntity) blockEntity);
case STORAGE_UNIT:
return new GuiStorageUnit(syncID, player, (StorageUnitBaseBlockEntity) blockEntity);
case TANK_UNIT:
return new GuiTankUnit(syncID, player, (TankUnitBaseBlockEntity) blockEntity);
case RECYCLER:
return new GuiRecycler(syncID, player, (RecyclerBlockEntity) blockEntity);
case ROLLING_MACHINE:

View file

@ -33,7 +33,7 @@ import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
import reborncore.common.network.NetworkManager;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.packets.ServerboundPackets;
public class GuiAESU extends GuiBase<BuiltContainer> {

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.blockentity.storage.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity;
public class GuiBatbox extends GuiBase<BuiltContainer> {

View file

@ -28,7 +28,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.guibuilder.GuiBuilder;
import techreborn.blockentity.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity;
public class GuiCentrifuge extends GuiBase<BuiltContainer> {

View file

@ -27,7 +27,7 @@ package techreborn.client.gui;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import techreborn.blockentity.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
public class GuiChargeBench extends GuiBase<BuiltContainer> {

View file

@ -40,7 +40,7 @@ import reborncore.common.network.NetworkManager;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.util.Color;
import reborncore.common.util.Torus;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.init.TRContent;
import techreborn.packets.ServerboundPackets;

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.blockentity.storage.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
public class GuiIDSU extends GuiBase<BuiltContainer> {

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.blockentity.storage.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
public class GuiLESU extends GuiBase<BuiltContainer> {

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.blockentity.storage.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity;
public class GuiMFE extends GuiBase<BuiltContainer> {

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.blockentity.storage.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity;
public class GuiMFSU extends GuiBase<BuiltContainer> {

View file

@ -1,62 +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.client.gui;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import techreborn.blockentity.machine.tier3.QuantumChestBlockEntity;
public class GuiQuantumChest extends GuiBase<BuiltContainer> {
QuantumChestBlockEntity quantumChest;
public GuiQuantumChest(int syncID, final PlayerEntity player, final QuantumChestBlockEntity quantumChest) {
super(player, quantumChest, quantumChest.createContainer(syncID, player));
this.quantumChest = quantumChest;
}
@Override
protected void drawBackground(final float f, final int mouseX, final int mouseY) {
super.drawBackground(f, mouseX, mouseY);
final Layer layer = Layer.BACKGROUND;
drawSlot(80, 24, layer);
drawSlot(80, 64, layer);
}
@Override
protected void drawForeground(final int mouseX, final int mouseY) {
super.drawForeground(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if (!this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getInvStack(1).isEmpty()) {
this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.storedItem.getCount() + this.quantumChest.inventory.getInvStack(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.x, mouseY - this.y, "Stored", layer);
}
if (this.quantumChest.storedItem.isEmpty() && !this.quantumChest.inventory.getInvStack(1).isEmpty()) {
this.builder.drawBigBlueBar(this, 31, 43, this.quantumChest.inventory.getInvStack(1).getCount(), this.quantumChest.maxCapacity, mouseX - this.x, mouseY - this.y, "Stored", layer);
}
}
}

View file

@ -27,15 +27,16 @@ package techreborn.client.gui;
import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import techreborn.blockentity.DigitalChestBlockEntity;
import reborncore.common.util.StringUtils;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
public class GuiDigitalChest extends GuiBase<BuiltContainer> {
public class GuiStorageUnit extends GuiBase<BuiltContainer> {
DigitalChestBlockEntity blockEntity;
StorageUnitBaseBlockEntity storageEntity;
public GuiDigitalChest(int syncID, final PlayerEntity player, final DigitalChestBlockEntity blockEntity) {
super(player, blockEntity, blockEntity.createContainer(syncID, player));
this.blockEntity = blockEntity;
public GuiStorageUnit(int syncID, final PlayerEntity player, final StorageUnitBaseBlockEntity storageEntity) {
super(player, storageEntity, storageEntity.createContainer(syncID, player));
this.storageEntity = storageEntity;
}
@Override
@ -43,23 +44,32 @@ public class GuiDigitalChest extends GuiBase<BuiltContainer> {
super.drawBackground(f, mouseX, mouseY);
final Layer layer = Layer.BACKGROUND;
drawSlot(80, 24, layer);
drawSlot(80, 64, layer);
drawString(StringUtils.t("gui.techreborn.unit.in"), 100, 43, 4210752, layer);
drawSlot(100, 53, layer);
drawString(StringUtils.t("gui.techreborn.unit.out"), 140, 43, 4210752, layer);
drawSlot(140, 53, layer);
}
@Override
protected void drawForeground(final int mouseX, final int mouseY) {
super.drawForeground(mouseX, mouseY);
final Layer layer = Layer.FOREGROUND;
if (!blockEntity.storedItem.isEmpty() && blockEntity.inventory.getInvStack(1) != null) {
builder.drawBigBlueBar(this, 31, 43,
blockEntity.storedItem.getCount() + blockEntity.inventory.getInvStack(1).getCount(),
blockEntity.maxCapacity, mouseX - x, mouseY - y, "Stored", layer);
}
if (blockEntity.storedItem.isEmpty() && blockEntity.inventory.getInvStack(1) != null) {
builder.drawBigBlueBar(this, 31, 43, blockEntity.inventory.getInvStack(1).getCount(),
blockEntity.maxCapacity, mouseX - x, mouseY - y, "Stored", layer);
if (storageEntity.isEmpty()) {
font.draw(StringUtils.t("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
} else {
font.draw(StringUtils.t("gui.techreborn.storage.store"), 10, 20, 4210752);
font.draw(storageEntity.getStoredStack().getName().asString(), 10, 30, 4210752);
font.draw(StringUtils.t("gui.techreborn.storage.amount"), 10, 50, 4210752);
font.draw(String.valueOf(storageEntity.getCurrentCapacity()), 10, 60, 4210752);
String percentFilled = String.valueOf((int) ((double) storageEntity.getCurrentCapacity() / (double) storageEntity.getMaxCapacity() * 100));
font.draw(StringUtils.t("gui.techreborn.unit.used") + percentFilled + "%", 10, 70, 4210752);
font.draw(StringUtils.t("gui.techreborn.unit.wrenchtip"), 10, 80, 16711680);
}
}
}

View file

@ -29,15 +29,16 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.container.FluidInstance;
import techreborn.blockentity.machine.tier3.QuantumTankBlockEntity;
import reborncore.common.util.StringUtils;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
public class GuiQuantumTank extends GuiBase<BuiltContainer> {
public class GuiTankUnit extends GuiBase<BuiltContainer> {
QuantumTankBlockEntity quantumTank;
TankUnitBaseBlockEntity tankEntity;
public GuiQuantumTank(int syncID, final PlayerEntity player, final QuantumTankBlockEntity quantumTank) {
super(player, quantumTank, quantumTank.createContainer(syncID, player));
this.quantumTank = quantumTank;
public GuiTankUnit(int syncID, final PlayerEntity player, final TankUnitBaseBlockEntity tankEntity) {
super(player, tankEntity, tankEntity.createContainer(syncID, player));
this.tankEntity = tankEntity;
}
@Override
@ -45,24 +46,35 @@ public class GuiQuantumTank extends GuiBase<BuiltContainer> {
super.drawBackground(f, mouseX, mouseY);
final GuiBase.Layer layer = GuiBase.Layer.BACKGROUND;
drawSlot(80, 17, layer);
drawSlot(80, 53, layer);
drawString(StringUtils.t("gui.techreborn.unit.in"), 100, 43, 4210752, layer);
drawSlot(100, 53, layer);
drawString(StringUtils.t("gui.techreborn.unit.out"), 140, 43, 4210752, layer);
drawSlot(140, 53, layer);
}
@Override
protected void drawForeground(final int mouseX, final int mouseY) {
super.drawForeground(mouseX, mouseY);
FluidInstance fluid = quantumTank.tank.getFluidInstance();
if(fluid != null){
font.draw( "Fluid Type:", 10, 20, 4210752);
font.draw(FluidUtil.getFluidName(fluid) + "", 10, 30, 4210752);
FluidInstance fluid = tankEntity.getTank().getFluidInstance();
font.draw("Fluid Amount:", 10, 50, 4210752);
font.draw(quantumTank.tank.getFluidAmount().toString() , 10, 60, 4210752);
if (fluid.isEmpty()) {
font.draw(StringUtils.t("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
} else {
font.draw(StringUtils.t("gui.techreborn.tank.type"), 10, 20, 4210752);
font.draw(FluidUtil.getFluidName(fluid).replace("_", " "), 10, 30, 4210752);
font.draw(StringUtils.t("gui.techreborn.tank.amount"), 10, 50, 4210752);
font.draw(fluid.getAmount().toString(), 10, 60, 4210752);
String percentFilled = String.valueOf((int) ((double) fluid.getAmount().getRawValue() / (double) tankEntity.getTank().getCapacity().getRawValue() * 100));
font.draw(StringUtils.t("gui.techreborn.unit.used") + percentFilled + "%", 10, 70, 4210752);
font.draw(StringUtils.t("gui.techreborn.unit.wrenchtip"), 10, 80, 16711680);
}
}
@Override

View file

@ -269,9 +269,6 @@ public class TechRebornConfig {
@Config(config = "machines", category = "player_detector", key = "PlayerDetectorEUPerSecond", comment = "Player Detector Energy Consumption per second (Value in EU)")
public static int playerDetectorEuPerTick = 10;
@Config(config = "machines", category = "quantum_chest", key = "QuantumChestMaxStorage", comment = "Maximum amount of items a Quantum Chest can store")
public static int quantumChestMaxStorage = Integer.MAX_VALUE;
@Config(config = "machines", category = "Distillation_tower", key = "DistillationTowerMaxInput", comment = "Distillation Tower Max Input (Value in EU)")
public static int distillationTowerMaxInput = 128;
@ -377,8 +374,32 @@ public class TechRebornConfig {
@Config(config = "machines", category = "electric_furnace", key = "ElectricFurnaceMaxEnergy", comment = "Electric Furnace Max Energy (Value in EU)")
public static int electricFurnaceMaxEnergy = 1000;
@Config(config = "machines", category = "digital_chest", key = "DigitalChestMaxStorage", comment = "Maximum amount of items a Digital Chest can store")
public static int digitalChestMaxStorage = 32768;
@Config(config = "machines", category = "storage", key = "CrudeStorageUnitMaxStorage", comment = "Maximum amount of items a Crude Storage Unit can store")
public static int crudeStorageUnitMaxStorage = 3200;
@Config(config = "machines", category = "storage", key = "BasicStorageUnitMaxStorage", comment = "Maximum amount of items a Basic Storage Unit can store")
public static int basicStorageUnitMaxStorage = 12800;
@Config(config = "machines", category = "storage", key = "BasicTankUnitCapacity", comment = "How much liquid a Basic Tank Unit can take (Value in buckets, 1000 Mb)")
public static int basicTankUnitCapacity = 2500;
@Config(config = "machines", category = "storage", key = "AdvancedStorageMaxStorage", comment = "Maximum amount of items an Advanced Storage Unit can store")
public static int advancedStorageUnitMaxStorage = 44800;
@Config(config = "machines", category = "storage", key = "AdvancedTankUnitMaxStorage", comment = "How much liquid an Advanced Tank Unit can take (Value in buckets, 1000 Mb)")
public static int advancedTankUnitMaxStorage = 7000;
@Config(config = "machines", category = "storage", key = "IndustrialStorageMaxStorage", comment = "Maximum amount of items an Industrial Storage Unit can store (Compat: >= 32768)")
public static int industrialStorageUnitMaxStorage = 96000;
@Config(config = "machines", category = "storage", key = "IndustrialTankUnitCapacity", comment = "How much liquid an Industrial Tank Unit can take (Value in buckets, 1000 Mb)")
public static int industrialTankUnitCapacity = 10000;
@Config(config = "machines", category = "storage", key = "QuantumStorageUnitMaxStorage", comment = "Maximum amount of items a Quantum Storage Unit can store (Compat: == MAX_VALUE)")
public static int quantumStorageUnitMaxStorage = Integer.MAX_VALUE;
@Config(config = "machines", category = "storage", key = "QuantumTankUnitCapacity", comment = "How much liquid a Quantum Tank Unit can take (Value in buckets, 1000 Mb)(Compat: == MAX_VALUE)")
public static int quantumTankUnitCapacity = Integer.MAX_VALUE / 1000;
@Config(config = "machines", category = "charge_bench", key = "ChargeBenchMaxOutput", comment = "Charge Bench Max Output (Value in EU)")
public static int chargeOMatBMaxOutput = 512;

View file

@ -104,6 +104,8 @@ public class ModRegistry {
RebornRegistry.registerBlock(value.casing, itemGroup);
});
Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block, itemGroup));
Arrays.stream(StorageUnit.values()).forEach(value -> RebornRegistry.registerBlock(value.block, itemGroup));
Arrays.stream(TankUnit.values()).forEach(value -> RebornRegistry.registerBlock(value.block, itemGroup));
Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block, itemGroup));
Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block, itemGroup));

View file

@ -32,9 +32,9 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import org.apache.commons.lang3.Validate;
import techreborn.TechReborn;
import techreborn.blockentity.*;
import techreborn.blockentity.cable.CableBlockEntity;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.multiblock.casing.MachineCasingBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.blockentity.generator.LightningRodBlockEntity;
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
import techreborn.blockentity.generator.SolarPanelBlockEntity;
@ -45,16 +45,22 @@ import techreborn.blockentity.generator.basic.WindMillBlockEntity;
import techreborn.blockentity.lighting.LampBlockEntity;
import techreborn.blockentity.machine.iron.IronAlloyFurnaceBlockEntity;
import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.blockentity.machine.misc.AlarmBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.tier1.*;
import techreborn.blockentity.machine.tier3.*;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.lesu.LSUStorageBlockEntity;
import techreborn.blockentity.storage.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.HighVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.LowVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.MediumVoltageSUBlockEntity;
import techreborn.blockentity.storage.energy.idsu.InterdimensionalSUBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity;
import techreborn.blockentity.storage.energy.lesu.LapotronicSUBlockEntity;
import techreborn.blockentity.storage.fluid.CreativeQuantumTankBlockEntity;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
import techreborn.blockentity.storage.item.*;
import techreborn.blockentity.storage.fluid.QuantumTankBlockEntity;
import techreborn.blockentity.transformers.EVTransformerBlockEntity;
import techreborn.blockentity.transformers.HVTransformerBlockEntity;
import techreborn.blockentity.transformers.LVTransformerBlockEntity;
@ -68,10 +74,18 @@ public class TRBlockEntities {
private static List<BlockEntityType<?>> TYPES = new ArrayList<>();
public static final BlockEntityType<ThermalGeneratorBlockEntity> THERMAL_GEN = register(ThermalGeneratorBlockEntity.class, "thermal_generator", TRContent.Machine.THERMAL_GENERATOR);
public static final BlockEntityType<StorageUnitBaseBlockEntity> STORAGE_UNIT = register(StorageUnitBaseBlockEntity.class, "storage_unit", TRContent.StorageUnit.values());
public static final BlockEntityType<TankUnitBaseBlockEntity> TANK_UNIT = register(TankUnitBaseBlockEntity.class, "tank_unit", TRContent.TankUnit.values());
public static final BlockEntityType<QuantumTankBlockEntity> QUANTUM_TANK = register(QuantumTankBlockEntity.class, "quantum_tank", TRContent.Machine.QUANTUM_TANK);
public static final BlockEntityType<QuantumChestBlockEntity> QUANTUM_CHEST = register(QuantumChestBlockEntity.class, "quantum_chest", TRContent.Machine.QUANTUM_CHEST);
public static final BlockEntityType<DigitalChestBlockEntity> DIGITAL_CHEST = register(DigitalChestBlockEntity.class, "digital_chest", TRContent.Machine.DIGITAL_CHEST);
public static final BlockEntityType<CreativeQuantumChestBlockEntity> CREATIVE_QUANTUM_CHEST = register(CreativeQuantumChestBlockEntity.class, "creative_quantum_chest", TRContent.Machine.CREATIVE_QUANTUM_CHEST);
public static final BlockEntityType<CreativeQuantumTankBlockEntity> CREATIVE_QUANTUM_TANK = register(CreativeQuantumTankBlockEntity.class, "creative_quantum_tank", TRContent.Machine.CREATIVE_QUANTUM_TANK);
public static final BlockEntityType<ThermalGeneratorBlockEntity> THERMAL_GEN = register(ThermalGeneratorBlockEntity.class, "thermal_generator", TRContent.Machine.THERMAL_GENERATOR);
public static final BlockEntityType<IndustrialCentrifugeBlockEntity> INDUSTRIAL_CENTRIFUGE = register(IndustrialCentrifugeBlockEntity.class, "industrial_centrifuge", TRContent.Machine.INDUSTRIAL_CENTRIFUGE);
public static final BlockEntityType<RollingMachineBlockEntity> ROLLING_MACHINE = register(RollingMachineBlockEntity.class, "rolling_machine", TRContent.Machine.ROLLING_MACHINE);
public static final BlockEntityType<IndustrialBlastFurnaceBlockEntity> INDUSTRIAL_BLAST_FURNACE = register(IndustrialBlastFurnaceBlockEntity.class, "industrial_blast_furnace", TRContent.Machine.INDUSTRIAL_BLAST_FURNACE);
@ -106,8 +120,6 @@ public class TRBlockEntities {
public static final BlockEntityType<CompressorBlockEntity> COMPRESSOR = register(CompressorBlockEntity.class, "compressor", TRContent.Machine.COMPRESSOR);
public static final BlockEntityType<ElectricFurnaceBlockEntity> ELECTRIC_FURNACE = register(ElectricFurnaceBlockEntity.class, "electric_furnace", TRContent.Machine.ELECTRIC_FURNACE);
public static final BlockEntityType<SolarPanelBlockEntity> SOLAR_PANEL = register(SolarPanelBlockEntity.class, "solar_panel", TRContent.SolarPanels.values());
public static final BlockEntityType<CreativeQuantumTankBlockEntity> CREATIVE_QUANTUM_TANK = register(CreativeQuantumTankBlockEntity.class, "creative_quantum_tank", TRContent.Machine.CREATIVE_QUANTUM_TANK);
public static final BlockEntityType<CreativeQuantumChestBlockEntity> CREATIVE_QUANTUM_CHEST = register(CreativeQuantumChestBlockEntity.class, "creative_quantum_chest", TRContent.Machine.CREATIVE_QUANTUM_CHEST);
public static final BlockEntityType<WaterMillBlockEntity> WATER_MILL = register(WaterMillBlockEntity.class, "water_mill", TRContent.Machine.WATER_MILL);
public static final BlockEntityType<WindMillBlockEntity> WIND_MILL = register(WindMillBlockEntity.class, "wind_mill", TRContent.Machine.WIND_MILL);
public static final BlockEntityType<RecyclerBlockEntity> RECYCLER = register(RecyclerBlockEntity.class, "recycler", TRContent.Machine.RECYCLER);

View file

@ -33,13 +33,15 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import reborncore.api.blockentity.IUpgrade;
import reborncore.common.fluid.FluidValue;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyTier;
import techreborn.TechReborn;
import techreborn.blockentity.ChargeOMatBlockEntity;
import techreborn.blockentity.DigitalChestBlockEntity;
import techreborn.blockentity.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.machine.misc.ChargeOMatBlockEntity;
import techreborn.blockentity.storage.fluid.CreativeQuantumTankBlockEntity;
import techreborn.blockentity.storage.fluid.QuantumTankBlockEntity;
import techreborn.blockentity.machine.tier3.IndustrialCentrifugeBlockEntity;
import techreborn.blockentity.generator.LightningRodBlockEntity;
import techreborn.blockentity.generator.PlasmaGeneratorBlockEntity;
import techreborn.blockentity.generator.advanced.*;
@ -49,16 +51,25 @@ import techreborn.blockentity.generator.basic.WindMillBlockEntity;
import techreborn.blockentity.machine.multiblock.*;
import techreborn.blockentity.machine.tier1.*;
import techreborn.blockentity.machine.tier3.*;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.item.CreativeQuantumChestBlockEntity;
import techreborn.blockentity.storage.item.DigitalChestBlockEntity;
import techreborn.blockentity.storage.item.QuantumChestBlockEntity;
import techreborn.blocks.*;
import techreborn.blocks.cable.CableBlock;
import techreborn.blocks.generator.*;
import techreborn.blocks.lighting.BlockLamp;
import techreborn.blocks.storage.*;
import techreborn.blocks.tier0.IronAlloyFurnaceBlock;
import techreborn.blocks.tier0.IronFurnaceBlock;
import techreborn.blocks.tier1.BlockPlayerDetector;
import techreborn.blocks.tier3.BlockCreativeQuantumChest;
import techreborn.blocks.misc.BlockAlarm;
import techreborn.blocks.misc.BlockMachineCasing;
import techreborn.blocks.misc.BlockMachineFrame;
import techreborn.blocks.misc.BlockStorage;
import techreborn.blocks.storage.OldBlock;
import techreborn.blocks.storage.energy.*;
import techreborn.blocks.machine.tier0.IronAlloyFurnaceBlock;
import techreborn.blocks.machine.tier0.IronFurnaceBlock;
import techreborn.blocks.machine.tier1.BlockPlayerDetector;
import techreborn.blocks.storage.item.StorageUnitBlock;
import techreborn.blocks.storage.fluid.TankUnitBlock;
import techreborn.blocks.transformers.BlockEVTransformer;
import techreborn.blocks.transformers.BlockHVTransformer;
import techreborn.blocks.transformers.BlockLVTransformer;
@ -254,6 +265,63 @@ public class TRContent {
}
}
public enum StorageUnit implements ItemConvertible {
CRUDE(TechRebornConfig.crudeStorageUnitMaxStorage),
BASIC(TechRebornConfig.basicStorageUnitMaxStorage),
ADVANCED(TechRebornConfig.advancedStorageUnitMaxStorage),
INDUSTRIAL(TechRebornConfig.industrialStorageUnitMaxStorage),
QUANTUM(TechRebornConfig.quantumStorageUnitMaxStorage),
CREATIVE(Integer.MAX_VALUE);
public final String name;
public final Block block;
// How many blocks it can hold
public int capacity;
StorageUnit(int capacity) {
name = this.toString().toLowerCase(Locale.ROOT);
block = new StorageUnitBlock(this);
this.capacity = capacity;
InitUtils.setup(block, name + "_storage_unit");
}
@Override
public Item asItem() {
return block.asItem();
}
}
public enum TankUnit implements ItemConvertible {
BASIC(TechRebornConfig.basicTankUnitCapacity),
ADVANCED(TechRebornConfig.advancedTankUnitMaxStorage),
INDUSTRIAL(TechRebornConfig.industrialTankUnitCapacity),
QUANTUM(TechRebornConfig.quantumTankUnitCapacity),
CREATIVE(Integer.MAX_VALUE / 1000);
public final String name;
public final Block block;
// How many blocks it can hold
public FluidValue capacity;
TankUnit(int capacity) {
name = this.toString().toLowerCase(Locale.ROOT);
block = new TankUnitBlock(this);
this.capacity = FluidValue.BUCKET.multiply(capacity);
InitUtils.setup(block, name + "_tank_unit");
}
@Override
public Item asItem() {
return block.asItem();
}
}
public enum Cables implements ItemConvertible {
COPPER(128, 12.0, true, EnergyTier.MEDIUM),
TIN(32, 12.0, true, EnergyTier.LOW),
@ -433,13 +501,16 @@ public class TRContent {
THERMAL_GENERATOR(new GenericGeneratorBlock(EGui.THERMAL_GENERATOR, ThermalGeneratorBlockEntity::new)),
WATER_MILL(new GenericGeneratorBlock(null, WaterMillBlockEntity::new)),
WIND_MILL(new GenericGeneratorBlock(null, WindMillBlockEntity::new)),
CREATIVE_QUANTUM_CHEST(new BlockCreativeQuantumChest()),
CREATIVE_QUANTUM_TANK(new GenericMachineBlock(EGui.QUANTUM_TANK, CreativeQuantumTankBlockEntity::new)),
DIGITAL_CHEST(new GenericMachineBlock(EGui.DIGITAL_CHEST, DigitalChestBlockEntity::new)),
QUANTUM_CHEST(new GenericMachineBlock(EGui.QUANTUM_CHEST, QuantumChestBlockEntity::new)),
QUANTUM_TANK(new GenericMachineBlock(EGui.QUANTUM_TANK, QuantumTankBlockEntity::new)),
//TODO DEPRECATED
DIGITAL_CHEST(new OldBlock(null, DigitalChestBlockEntity::new)),
QUANTUM_CHEST(new OldBlock(null, QuantumChestBlockEntity::new)),
QUANTUM_TANK(new OldBlock(null, QuantumTankBlockEntity::new)),
CREATIVE_QUANTUM_CHEST(new OldBlock(null, CreativeQuantumChestBlockEntity::new)),
CREATIVE_QUANTUM_TANK(new OldBlock(null, CreativeQuantumTankBlockEntity::new)),
ADJUSTABLE_SU(new AdjustableSUBlock()),
CHARGE_O_MAT(new GenericMachineBlock(EGui.CHARGEBENCH, ChargeOMatBlockEntity::new)),
INTERDIMENSIONAL_SU(new InterdimensionalSUBlock()),
@ -629,6 +700,7 @@ public class TRContent {
INDUSTRIAL_CIRCUIT,
MACHINE_PARTS,
BASIC_DISPLAY,
DIGITAL_DISPLAY,
DATA_STORAGE_CORE,

View file

@ -69,7 +69,7 @@ import javax.annotation.Nullable;
public class ItemDynamicCell extends Item implements ItemFluidInfo {
public ItemDynamicCell() {
super(new Item.Settings().group(TechReborn.ITEMGROUP));
super( new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(16));
}
@Override
@ -95,6 +95,8 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
return super.getName(itemStack);
}
public static ItemStack getCellWithFluid(Fluid fluid, int stackSize) {
Validate.notNull(fluid);
ItemStack stack = new ItemStack(TRContent.CELL);
@ -182,7 +184,7 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
}
}
//Thanks vanilla :)
// Thanks vanilla :)
private void playEmptyingSound(@Nullable PlayerEntity playerEntity, IWorld world, BlockPos blockPos, Fluid fluid) {
SoundEvent soundEvent = fluid.matches(FluidTags.LAVA) ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
world.playSound(playerEntity, blockPos, soundEvent, SoundCategory.BLOCKS, 1.0F, 1.0F);

View file

@ -36,7 +36,7 @@ import reborncore.common.multiblock.MultiblockControllerBase;
import reborncore.common.multiblock.MultiblockValidationException;
import reborncore.common.multiblock.rectangular.RectangularMultiblockControllerBase;
import reborncore.common.multiblock.rectangular.RectangularMultiblockBlockEntityBase;
import techreborn.blocks.BlockMachineCasing;
import techreborn.blocks.misc.BlockMachineCasing;
public class MultiBlockCasing extends RectangularMultiblockControllerBase {

View file

@ -37,12 +37,12 @@ import net.minecraft.util.math.BlockPos;
import reborncore.common.network.ExtendedPacketBuffer;
import reborncore.common.network.NetworkManager;
import techreborn.TechReborn;
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.multiblock.FusionControlComputerBlockEntity;
import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity;
import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent;

View file

@ -71,7 +71,7 @@ public class FluidUtils {
FluidValue freeSpace = target.getCapacity(null).subtract(targetFluidInstance.getAmount());
if(!outputStack.isEmpty()){
if(outputStack.getCount() + 1 >= outputStack.getMaxCount()){
if(outputStack.getCount() >= outputStack.getMaxCount()){
return false;
}
}
@ -128,7 +128,7 @@ public class FluidUtils {
inputStack.decrement(1);
return false;
return true;
}
public static boolean fluidEquals(@Nonnull Fluid fluid, @Nonnull Fluid fluid1) {

View file

@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "techreborn:block/machines/tier1_machines/advanced_storage_unit" },
"facing=south": { "model": "techreborn:block/machines/tier1_machines/advanced_storage_unit", "y": 180 },
"facing=west": { "model": "techreborn:block/machines/tier1_machines/advanced_storage_unit", "y": 270 },
"facing=east": { "model": "techreborn:block/machines/tier1_machines/advanced_storage_unit", "y": 90 }
}
}

View file

@ -0,0 +1,6 @@
{
"variants": {
"": { "model": "techreborn:block/machines/tier1_machines/advanced_tank_unit" }
}
}

View file

@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "techreborn:block/machines/tier0_machines/basic_storage_unit" },
"facing=south": { "model": "techreborn:block/machines/tier0_machines/basic_storage_unit", "y": 180 },
"facing=west": { "model": "techreborn:block/machines/tier0_machines/basic_storage_unit", "y": 270 },
"facing=east": { "model": "techreborn:block/machines/tier0_machines/basic_storage_unit", "y": 90 }
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "techreborn:block/machines/tier0_machines/basic_tank_unit" }
}
}

View file

@ -1,5 +1,5 @@
{
"variants": {
"": { "model": "techreborn:block/machines/tier3_machines/creative_quantum_chest" }
}
}
{
"variants": {
"": { "model": "techreborn:block/machines/tier3_machines/creative_quantum_chest" }
}
}

View file

@ -1,5 +1,5 @@
{
"variants": {
"": { "model": "techreborn:block/machines/tier3_machines/creative_quantum_tank" }
}
}
{
"variants": {
"": { "model": "techreborn:block/machines/tier3_machines/creative_quantum_tank" }
}
}

View file

@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "techreborn:block/machines/tier3_machines/creative_storage_unit" },
"facing=south": { "model": "techreborn:block/machines/tier3_machines/creative_storage_unit", "y": 180 },
"facing=west": { "model": "techreborn:block/machines/tier3_machines/creative_storage_unit", "y": 270 },
"facing=east": { "model": "techreborn:block/machines/tier3_machines/creative_storage_unit", "y": 90 }
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "techreborn:block/machines/tier3_machines/creative_tank_unit" }
}
}

View file

@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "techreborn:block/machines/tier0_machines/crude_storage_unit" },
"facing=south": { "model": "techreborn:block/machines/tier0_machines/crude_storage_unit", "y": 180 },
"facing=west": { "model": "techreborn:block/machines/tier0_machines/crude_storage_unit", "y": 270 },
"facing=east": { "model": "techreborn:block/machines/tier0_machines/crude_storage_unit", "y": 90 }
}
}

View file

@ -1,5 +1,5 @@
{
"variants": {
"": { "model": "techreborn:block/machines/tier2_machines/digital_chest" }
}
}
{
"variants": {
"": { "model": "techreborn:block/machines/tier2_machines/digital_chest" }
}
}

Some files were not shown because too many files have changed in this diff Show more