Merge branch '1.15' into 1.16
Need to fix up storage unit UI
This commit is contained in:
commit
390d9f7059
34 changed files with 311 additions and 87 deletions
|
@ -76,7 +76,7 @@ dependencies {
|
|||
//Fabric api
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:0.11.6+build.355-1.16"
|
||||
|
||||
optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.3.7-unstable")
|
||||
optionalDependency ("me.shedaniel:RoughlyEnoughItems:4.5.1")
|
||||
disabledOptionalDependency ('io.github.cottonmc:LibCD:2.3.0+1.15.2')
|
||||
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.4.2')
|
||||
|
||||
|
|
|
@ -24,17 +24,24 @@
|
|||
|
||||
package techreborn.blockentity.machine.misc;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FluidDrainable;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.client.screen.BuiltScreenHandlerProvider;
|
||||
import reborncore.client.screen.builder.BuiltScreenHandler;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.fluid.FluidValue;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
|
||||
public class DrainBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IListInfoProvider, BuiltScreenHandlerProvider {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DrainBlockEntity extends MachineBaseBlockEntity {
|
||||
|
||||
protected Tank internalTank = new Tank("tank", FluidValue.BUCKET, this);
|
||||
|
||||
public DrainBlockEntity(){
|
||||
this(TRBlockEntities.DRAIN);
|
||||
|
@ -45,12 +52,41 @@ public class DrainBlockEntity extends MachineBaseBlockEntity implements Inventor
|
|||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return null;
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(world.isClient){
|
||||
return;
|
||||
}
|
||||
|
||||
if (world.getTime() % 10 == 0) {
|
||||
|
||||
if(internalTank.isEmpty()) {
|
||||
tryDrain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) {
|
||||
return null;
|
||||
public Tank getTank() {
|
||||
return internalTank;
|
||||
}
|
||||
|
||||
private void tryDrain(){
|
||||
// Position above drain
|
||||
BlockPos above = this.getPos().up();
|
||||
|
||||
// Block and state above drain
|
||||
BlockState aboveBlockState = world.getBlockState(above);
|
||||
Block aboveBlock = aboveBlockState.getBlock();
|
||||
|
||||
if (aboveBlock instanceof FluidDrainable) {
|
||||
|
||||
Fluid drainFluid = ((FluidDrainable) aboveBlock).tryDrainFluid(world, above, aboveBlockState);
|
||||
|
||||
if (drainFluid != Fluids.EMPTY) {
|
||||
internalTank.setFluidInstance(new FluidInstance(drainFluid, FluidValue.BUCKET));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
|
||||
private TRContent.StorageUnit type;
|
||||
|
||||
// A locked storage unit will continue behaving as if it contains
|
||||
// the locked-in item, even if the stored amount drops to zero.
|
||||
private ItemStack lockedItemStack = ItemStack.EMPTY;
|
||||
|
||||
public StorageUnitBaseBlockEntity() {
|
||||
super(TRBlockEntities.STORAGE_UNIT);
|
||||
}
|
||||
|
@ -170,6 +174,16 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
return storeItemStack.isEmpty() ? inventory.getStack(OUTPUT_SLOT) : storeItemStack;
|
||||
}
|
||||
|
||||
// Returns the ItemStack to be displayed to the player via UI / model
|
||||
public ItemStack getDisplayedStack() {
|
||||
if (!isLocked()) {
|
||||
return getStoredStack();
|
||||
} else {
|
||||
// Render the locked stack even if the unit is empty
|
||||
return lockedItemStack;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getAll() {
|
||||
ItemStack returnStack = ItemStack.EMPTY;
|
||||
|
||||
|
@ -222,6 +236,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
}
|
||||
|
||||
public boolean isSameType(ItemStack inputStack) {
|
||||
if (isLocked()) {
|
||||
return ItemUtils.isItemEqual(lockedItemStack, inputStack, true, true);
|
||||
}
|
||||
|
||||
if (inputStack != ItemStack.EMPTY) {
|
||||
return ItemUtils.isItemEqual(getStoredStack(), inputStack, true, true);
|
||||
}
|
||||
|
@ -281,6 +299,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
storeItemStack.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity));
|
||||
}
|
||||
|
||||
if (tagCompound.contains("lockedItem")) {
|
||||
lockedItemStack = ItemStack.fromTag(tagCompound.getCompound("lockedItem"));
|
||||
}
|
||||
|
||||
inventory.read(tagCompound);
|
||||
}
|
||||
|
||||
|
@ -300,6 +322,11 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
} else {
|
||||
tagCompound.putInt("storedQuantity", 0);
|
||||
}
|
||||
|
||||
if (isLocked()) {
|
||||
tagCompound.put("lockedItem", lockedItemStack.toTag(new CompoundTag()));
|
||||
}
|
||||
|
||||
inventory.write(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
@ -390,9 +417,43 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
|
|||
// Inventory gets dropped automatically
|
||||
}
|
||||
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||
return new ScreenHandlerBuilder("chest").player(player.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).slot(0, 100, 53).outputSlot(1, 140, 53).addInventory().create(this, syncID);
|
||||
// The int methods are only for ContainerBuilder.sync()
|
||||
private int isLockedInt() {
|
||||
return isLocked() ? 1 : 0;
|
||||
}
|
||||
|
||||
private void setLockedInt(int lockedInt) {
|
||||
setLocked(lockedInt == 1);
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return lockedItemStack != ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void setLocked(boolean value) {
|
||||
// Only set lockedItem in response to user input
|
||||
if (isLocked() == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
lockedItemStack = value ? getStoredStack().copy() : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public boolean canModifyLocking() {
|
||||
// Can always be unlocked
|
||||
if (isLocked()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Can only lock if there is an item to lock
|
||||
return !isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity playerEntity) {
|
||||
return new ScreenHandlerBuilder("chest").player(playerEntity.inventory).inventory().hotbar().addInventory()
|
||||
.blockEntity(this).slot(0, 100, 53).outputSlot(1, 140, 53)
|
||||
.sync(this::isLockedInt, this::setLockedInt).addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,7 @@ package techreborn.blocks.generator;
|
|||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -53,7 +53,7 @@ import java.util.List;
|
|||
public class BlockFusionCoil extends Block {
|
||||
|
||||
public BlockFusionCoil() {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.lighting;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -61,10 +61,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
|||
private static int brightness = 15;
|
||||
|
||||
public BlockLamp(int cost, double depth, double width) {
|
||||
super(AbstractBlock.Settings.of(Material.REDSTONE_LAMP)
|
||||
.strength(2f, 2f)
|
||||
.lightLevel(value -> value.get(ACTIVE) ? brightness : 0)
|
||||
);
|
||||
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness));
|
||||
this.shape = genCuboidShapes(depth, width);
|
||||
this.cost = cost;
|
||||
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
|
@ -39,7 +39,7 @@ public class BlockMachineCasing extends BlockMultiblockBase {
|
|||
public final int heatCapacity;
|
||||
|
||||
public BlockMachineCasing(int heatCapacity) {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL));
|
||||
this.heatCapacity = heatCapacity;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import reborncore.common.BaseBlock;
|
||||
|
@ -32,6 +32,6 @@ import reborncore.common.BaseBlock;
|
|||
public class BlockMachineFrame extends BaseBlock {
|
||||
|
||||
public BlockMachineFrame() {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(1f, 1f).sounds(BlockSoundGroup.METAL).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(1f, 1f).sounds(BlockSoundGroup.METAL));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.block.Material;
|
||||
|
@ -35,7 +35,7 @@ import net.minecraft.util.math.Direction;
|
|||
public class BlockRefinedIronFence extends FenceBlock {
|
||||
|
||||
public BlockRefinedIronFence() {
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.WOOD).strength(2.0F, 3.0F).sounds(BlockSoundGroup.METAL).build());
|
||||
super(FabricBlockSettings.of(Material.METAL, MaterialColor.WOOD).strength(2.0F, 3.0F).sounds(BlockSoundGroup.METAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.GlassBlock;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
@ -32,7 +32,7 @@ import net.minecraft.sound.BlockSoundGroup;
|
|||
public class BlockReinforcedGlass extends GlassBlock {
|
||||
|
||||
public BlockReinforcedGlass() {
|
||||
super(FabricBlockSettings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE).nonOpaque().build());
|
||||
super(FabricBlockSettings.of(Material.GLASS).strength(4f, 60f).sounds(BlockSoundGroup.STONE).nonOpaque());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,22 +24,15 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.PillarBlock;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -38,7 +38,7 @@ import net.minecraft.sound.BlockSoundGroup;
|
|||
public class BlockRubberPlank extends Block {
|
||||
|
||||
public BlockRubberPlank() {
|
||||
super(FabricBlockSettings.of(Material.WOOD).strength(2f, 2f).sounds(BlockSoundGroup.WOOD).build());
|
||||
super(FabricBlockSettings.of(Material.WOOD).strength(2f, 2f).sounds(BlockSoundGroup.WOOD));
|
||||
FlammableBlockRegistry.getDefaultInstance().add(this, 5, 20);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.SaplingBlock;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
|
@ -36,6 +36,6 @@ import techreborn.world.RubberSaplingGenerator;
|
|||
public class BlockRubberSapling extends SaplingBlock {
|
||||
|
||||
public BlockRubberSapling() {
|
||||
super(new RubberSaplingGenerator(), FabricBlockSettings.of(Material.PLANT).sounds(BlockSoundGroup.GRASS).noCollision().ticksRandomly().breakInstantly().build());
|
||||
super(new RubberSaplingGenerator(), FabricBlockSettings.of(Material.PLANT).sounds(BlockSoundGroup.GRASS).noCollision().ticksRandomly().breakInstantly());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.misc;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.sound.BlockSoundGroup;
|
||||
import reborncore.common.BaseBlock;
|
||||
|
@ -32,16 +32,6 @@ import reborncore.common.BaseBlock;
|
|||
public class BlockStorage extends BaseBlock {
|
||||
|
||||
public BlockStorage() {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).sounds(BlockSoundGroup.METAL));
|
||||
}
|
||||
|
||||
// public static ItemStack getStorageBlockByName(String name, int count) {
|
||||
// for (int i = 0; i < types.length; i++) {
|
||||
// if (types[i].equals(name)) {
|
||||
// return new ItemStack(ModBlocks.STORAGE, count, i);
|
||||
// }
|
||||
// }
|
||||
// return BlockStorage2.getStorageBlockByName(name, count);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.storage.energy;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
|
@ -60,7 +60,7 @@ public abstract class EnergyStorageBlock extends BaseBlockEntityProvider {
|
|||
public IMachineGuiHandler gui;
|
||||
|
||||
public EnergyStorageBlock(String name, IMachineGuiHandler gui) {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
|
||||
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
|
||||
this.name = name;
|
||||
this.gui = gui;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.storage.energy;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
|
@ -49,7 +49,7 @@ import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity;
|
|||
public class LSUStorageBlock extends BaseBlockEntityProvider {
|
||||
|
||||
public LSUStorageBlock() {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.blocks.transformers;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
|
@ -55,7 +55,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
|
|||
public String name;
|
||||
|
||||
public BlockTransformer(String name) {
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).build());
|
||||
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
|
||||
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
|
||||
this.name = name;
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
|
|
|
@ -31,6 +31,8 @@ import reborncore.client.screen.builder.BuiltScreenHandler;
|
|||
import reborncore.client.gui.builder.GuiBase;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import techreborn.packets.ServerboundPackets;
|
||||
|
||||
public class GuiStorageUnit extends GuiBase<BuiltScreenHandler> {
|
||||
|
||||
|
@ -57,13 +59,12 @@ public class GuiStorageUnit extends GuiBase<BuiltScreenHandler> {
|
|||
protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
|
||||
super.drawForeground(matrixStack, mouseX, mouseY);
|
||||
|
||||
if (storageEntity.isEmpty()) {
|
||||
if (storageEntity.isEmpty() && !storageEntity.isLocked()) {
|
||||
textRenderer.draw(matrixStack, new TranslatableText("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
|
||||
} else {
|
||||
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.store"), 10, 20, 4210752);
|
||||
textRenderer.draw(matrixStack, storageEntity.getStoredStack().getName(), 10, 30, 4210752);
|
||||
|
||||
|
||||
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.amount"), 10, 50, 4210752);
|
||||
textRenderer.draw(matrixStack, String.valueOf(storageEntity.getCurrentCapacity()), 10, 60, 4210752);
|
||||
|
||||
|
@ -74,4 +75,13 @@ public class GuiStorageUnit extends GuiBase<BuiltScreenHandler> {
|
|||
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.unit.wrenchtip"), 10, 80, 16711680);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||
if (isPointInRect(150, 4, 20, 12, mouseX, mouseY) && storageEntity.canModifyLocking()) {
|
||||
NetworkManager.sendToServer(ServerboundPackets.createPacketStorageUnitLock(storageEntity, !storageEntity.isLocked()));
|
||||
return true;
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBloc
|
|||
if (storage.getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = storage.getStoredStack();
|
||||
ItemStack stack = storage.getDisplayedStack();
|
||||
if (stack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
|
|||
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
|
||||
|
||||
// WIP injection
|
||||
wipBlocks.add(TRContent.Machine.DRAIN.block);
|
||||
// wipBlocks.add(TRContent.Machine.NAME.block);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.init;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.block.OreBlock;
|
||||
|
@ -436,7 +436,7 @@ public class TRContent {
|
|||
|
||||
Ores(int veinSize, int veinsPerChunk, int minY, int maxY) {
|
||||
name = this.toString().toLowerCase(Locale.ROOT);
|
||||
block = new OreBlock(FabricBlockSettings.of(Material.STONE).strength(2f, 2f).build());
|
||||
block = new OreBlock(FabricBlockSettings.of(Material.STONE).strength(2f, 2f));
|
||||
this.veinSize = veinSize;
|
||||
this.veinsPerChunk = veinsPerChunk;
|
||||
this.minY = minY;
|
||||
|
|
|
@ -43,6 +43,7 @@ import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity;
|
|||
import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity;
|
||||
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
|
||||
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
|
||||
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
|
@ -53,6 +54,7 @@ public class ServerboundPackets {
|
|||
public static final Identifier AESU = new Identifier(TechReborn.MOD_ID, "aesu");
|
||||
public static final Identifier AUTO_CRAFTING_LOCK = new Identifier(TechReborn.MOD_ID, "auto_crafting_lock");
|
||||
public static final Identifier ROLLING_MACHINE_LOCK = new Identifier(TechReborn.MOD_ID, "rolling_machine_lock");
|
||||
public static final Identifier STORAGE_UNIT_LOCK = new Identifier(TechReborn.MOD_ID, "storage_unit_lock");
|
||||
public static final Identifier FUSION_CONTROL_SIZE = new Identifier(TechReborn.MOD_ID, "fusion_control_size");
|
||||
public static final Identifier REFUND = new Identifier(TechReborn.MOD_ID, "refund");
|
||||
public static final Identifier CHUNKLOADER = new Identifier(TechReborn.MOD_ID, "chunkloader");
|
||||
|
@ -109,6 +111,18 @@ public class ServerboundPackets {
|
|||
});
|
||||
});
|
||||
|
||||
registerPacketHandler(STORAGE_UNIT_LOCK, (extendedPacketBuffer, context) -> {
|
||||
BlockPos machinePos = extendedPacketBuffer.readBlockPos();
|
||||
boolean locked = extendedPacketBuffer.readBoolean();
|
||||
|
||||
context.getTaskQueue().execute(() -> {
|
||||
BlockEntity BlockEntity = context.getPlayer().world.getBlockEntity(machinePos);
|
||||
if (BlockEntity instanceof StorageUnitBaseBlockEntity) {
|
||||
((StorageUnitBaseBlockEntity) BlockEntity).setLocked(locked);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
registerPacketHandler(REFUND, (extendedPacketBuffer, context) -> {
|
||||
if(!TechRebornConfig.allowManualRefund){
|
||||
return;
|
||||
|
@ -188,6 +202,13 @@ public class ServerboundPackets {
|
|||
});
|
||||
}
|
||||
|
||||
public static Packet<ServerPlayPacketListener> createPacketStorageUnitLock(StorageUnitBaseBlockEntity machine, boolean locked) {
|
||||
return NetworkManager.createServerBoundPacket(STORAGE_UNIT_LOCK, extendedPacketBuffer -> {
|
||||
extendedPacketBuffer.writeBlockPos(machine.getPos());
|
||||
extendedPacketBuffer.writeBoolean(locked);
|
||||
});
|
||||
}
|
||||
|
||||
public static Packet<ServerPlayPacketListener> createRefundPacket(){
|
||||
return NetworkManager.createServerBoundPacket(REFUND, extendedPacketBuffer -> {
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
package techreborn.utils;
|
||||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
|
@ -75,7 +75,7 @@ public class InitUtils {
|
|||
settings.noCollision();
|
||||
}
|
||||
settings.materialColor(MaterialColor.SPRUCE);
|
||||
return settings.build();
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static AbstractBlock.Settings setupRubberBlockSettings(float hardness, float resistance) {
|
||||
|
|
|
@ -690,6 +690,8 @@
|
|||
"techreborn.message.info.block.techreborn.quantum_tank": "Stores near-infinite of a single liquid",
|
||||
"techreborn.message.info.block.techreborn.charge_o_mat": "Charges up to 6 items simultaneously",
|
||||
"techreborn.message.info.block.techreborn.chunk_loader": "Keeps chunks loaded, allows machines to run when you're not nearby",
|
||||
"techreborn.message.info.block.techreborn.drain": "Pulls any fluid directly above it, pairs nicely with a tank unit underneath",
|
||||
|
||||
|
||||
"keys.techreborn.category": "TechReborn Category",
|
||||
"keys.techreborn.config": "Config",
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"type": "techreborn:compressor",
|
||||
"power": 10,
|
||||
"time": 180,
|
||||
|
||||
"ingredients" : [
|
||||
{
|
||||
"item": "minecraft:prismarine_crystals"
|
||||
}
|
||||
],
|
||||
|
||||
"results" : [
|
||||
{
|
||||
"item": "minecraft:prismarine_shard"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -2,16 +2,16 @@
|
|||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
"item": "techreborn:coal_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
"item": "techreborn:obsidian_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
"item": "techreborn:coal_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
"item": "techreborn:obsidian_small_dust"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:basalt_small_dust"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "techreborn:basalt_dust"
|
||||
}
|
||||
}
|
|
@ -2,16 +2,16 @@
|
|||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
"item": "techreborn:obsidian_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
"item": "techreborn:diorite_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
"item": "techreborn:diorite_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
"item": "techreborn:diorite_dust"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
},
|
||||
{
|
||||
"item": "techreborn:marble_small_dust"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "techreborn:marble_dust"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"PHP",
|
||||
"FBF",
|
||||
"PFP"
|
||||
],
|
||||
"key": {
|
||||
"P": {
|
||||
"item": "techreborn:refined_iron_plate"
|
||||
},
|
||||
"B": {
|
||||
"item": "minecraft:bucket"
|
||||
},
|
||||
"H": {
|
||||
"item": "minecraft:hopper"
|
||||
},
|
||||
"F": {
|
||||
"item": "techreborn:basic_machine_frame"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "techreborn:drain"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"type": "techreborn:grinder",
|
||||
"power": 4,
|
||||
"time": 270,
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:andesite"
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"item": "techreborn:andesite_dust",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
|
@ -5,12 +5,12 @@
|
|||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:diorite",
|
||||
"count": 8
|
||||
"count": 1
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"item": "techreborn:quartz_dust"
|
||||
"item": "techreborn:diorite_dust"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,16 +1,17 @@
|
|||
{
|
||||
"type": "techreborn:grinder",
|
||||
"power": 2,
|
||||
"time": 720,
|
||||
"power": 4,
|
||||
"time": 270,
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:granite",
|
||||
"count": 4
|
||||
"count": 1
|
||||
}
|
||||
],
|
||||
"results": [
|
||||
{
|
||||
"item": "techreborn:quartz_dust"
|
||||
"item": "techreborn:granite_dust",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"type": "techreborn:grinder",
|
||||
"power": 2,
|
||||
"time": 180,
|
||||
"ingredients" : [
|
||||
{
|
||||
"item": "minecraft:cobblestone"
|
||||
}
|
||||
],
|
||||
"results" : [
|
||||
{
|
||||
"item": "minecraft:gravel"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
"time": 180,
|
||||
"ingredients" : [
|
||||
{
|
||||
"item": "minecraft:cobblestone"
|
||||
"item": "minecraft:gravel"
|
||||
}
|
||||
],
|
||||
"results" : [
|
||||
|
|
Loading…
Add table
Reference in a new issue