Merge branch '1.15' into 1.16

Need to fix up storage unit UI
This commit is contained in:
Justin Vitale 2020-06-18 22:39:26 +10:00
commit 390d9f7059
34 changed files with 311 additions and 87 deletions

View file

@ -76,7 +76,7 @@ dependencies {
//Fabric api //Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.11.6+build.355-1.16" 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 ('io.github.cottonmc:LibCD:2.3.0+1.15.2')
disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.4.2') disabledOptionalDependency ('com.github.emilyploszaj:trinkets:2.4.2')

View file

@ -24,17 +24,24 @@
package techreborn.blockentity.machine.misc; 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.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.Inventory; import net.minecraft.fluid.Fluids;
import reborncore.api.IListInfoProvider; import net.minecraft.util.math.BlockPos;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.common.blockentity.MachineBaseBlockEntity; 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; 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(){ public DrainBlockEntity(){
this(TRBlockEntities.DRAIN); this(TRBlockEntities.DRAIN);
@ -45,12 +52,41 @@ public class DrainBlockEntity extends MachineBaseBlockEntity implements Inventor
} }
@Override @Override
public Inventory getInventory() { public void tick() {
return null; super.tick();
if(world.isClient){
return;
}
if (world.getTime() % 10 == 0) {
if(internalTank.isEmpty()) {
tryDrain();
}
}
} }
@Nullable
@Override @Override
public BuiltScreenHandler createScreenHandler(int syncID, PlayerEntity player) { public Tank getTank() {
return null; 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));
}
}
} }
} }

View file

@ -68,6 +68,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
private TRContent.StorageUnit type; 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() { public StorageUnitBaseBlockEntity() {
super(TRBlockEntities.STORAGE_UNIT); super(TRBlockEntities.STORAGE_UNIT);
} }
@ -170,6 +174,16 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
return storeItemStack.isEmpty() ? inventory.getStack(OUTPUT_SLOT) : storeItemStack; 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() { public ItemStack getAll() {
ItemStack returnStack = ItemStack.EMPTY; ItemStack returnStack = ItemStack.EMPTY;
@ -222,6 +236,10 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
} }
public boolean isSameType(ItemStack inputStack) { public boolean isSameType(ItemStack inputStack) {
if (isLocked()) {
return ItemUtils.isItemEqual(lockedItemStack, inputStack, true, true);
}
if (inputStack != ItemStack.EMPTY) { if (inputStack != ItemStack.EMPTY) {
return ItemUtils.isItemEqual(getStoredStack(), inputStack, true, true); 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)); storeItemStack.setCount(Math.min(tagCompound.getInt("storedQuantity"), this.maxCapacity));
} }
if (tagCompound.contains("lockedItem")) {
lockedItemStack = ItemStack.fromTag(tagCompound.getCompound("lockedItem"));
}
inventory.read(tagCompound); inventory.read(tagCompound);
} }
@ -300,6 +322,11 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
} else { } else {
tagCompound.putInt("storedQuantity", 0); tagCompound.putInt("storedQuantity", 0);
} }
if (isLocked()) {
tagCompound.put("lockedItem", lockedItemStack.toTag(new CompoundTag()));
}
inventory.write(tagCompound); inventory.write(tagCompound);
return tagCompound; return tagCompound;
} }
@ -390,9 +417,43 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity
// Inventory gets dropped automatically // Inventory gets dropped automatically
} }
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) { // The int methods are only for ContainerBuilder.sync()
return new ScreenHandlerBuilder("chest").player(player.inventory).inventory().hotbar().addInventory() private int isLockedInt() {
.blockEntity(this).slot(0, 100, 53).outputSlot(1, 140, 53).addInventory().create(this, syncID); 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 @Override

View file

@ -26,7 +26,7 @@ package techreborn.blocks.generator;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -53,7 +53,7 @@ import java.util.List;
public class BlockFusionCoil extends Block { public class BlockFusionCoil extends Block {
public BlockFusionCoil() { 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 @Override

View file

@ -24,7 +24,7 @@
package techreborn.blocks.lighting; 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.*;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -61,10 +61,7 @@ public class BlockLamp extends BaseBlockEntityProvider {
private static int brightness = 15; private static int brightness = 15;
public BlockLamp(int cost, double depth, double width) { public BlockLamp(int cost, double depth, double width) {
super(AbstractBlock.Settings.of(Material.REDSTONE_LAMP) super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness));
.strength(2f, 2f)
.lightLevel(value -> value.get(ACTIVE) ? brightness : 0)
);
this.shape = genCuboidShapes(depth, width); this.shape = genCuboidShapes(depth, width);
this.cost = cost; this.cost = cost;
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false)); this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
@ -39,7 +39,7 @@ public class BlockMachineCasing extends BlockMultiblockBase {
public final int heatCapacity; public final int heatCapacity;
public BlockMachineCasing(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; this.heatCapacity = heatCapacity;
} }

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.Material;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import reborncore.common.BaseBlock; import reborncore.common.BaseBlock;
@ -32,6 +32,6 @@ import reborncore.common.BaseBlock;
public class BlockMachineFrame extends BaseBlock { public class BlockMachineFrame extends BaseBlock {
public BlockMachineFrame() { 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));
} }
} }

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.BlockState;
import net.minecraft.block.FenceBlock; import net.minecraft.block.FenceBlock;
import net.minecraft.block.Material; import net.minecraft.block.Material;
@ -35,7 +35,7 @@ import net.minecraft.util.math.Direction;
public class BlockRefinedIronFence extends FenceBlock { public class BlockRefinedIronFence extends FenceBlock {
public BlockRefinedIronFence() { 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 @Override

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.GlassBlock;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
@ -32,7 +32,7 @@ import net.minecraft.sound.BlockSoundGroup;
public class BlockReinforcedGlass extends GlassBlock { public class BlockReinforcedGlass extends GlassBlock {
public BlockReinforcedGlass() { 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());
} }
} }

View file

@ -24,22 +24,15 @@
package techreborn.blocks.misc; 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.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.Block; import net.minecraft.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.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.DirectionProperty;

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -38,7 +38,7 @@ import net.minecraft.sound.BlockSoundGroup;
public class BlockRubberPlank extends Block { public class BlockRubberPlank extends Block {
public BlockRubberPlank() { 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); FlammableBlockRegistry.getDefaultInstance().add(this, 5, 20);
} }
} }

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.Material;
import net.minecraft.block.SaplingBlock; import net.minecraft.block.SaplingBlock;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
@ -36,6 +36,6 @@ import techreborn.world.RubberSaplingGenerator;
public class BlockRubberSapling extends SaplingBlock { public class BlockRubberSapling extends SaplingBlock {
public BlockRubberSapling() { 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());
} }
} }

View file

@ -24,7 +24,7 @@
package techreborn.blocks.misc; 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.Material;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import reborncore.common.BaseBlock; import reborncore.common.BaseBlock;
@ -32,16 +32,6 @@ import reborncore.common.BaseBlock;
public class BlockStorage extends BaseBlock { public class BlockStorage extends BaseBlock {
public BlockStorage() { 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);
// }
} }

View file

@ -24,7 +24,7 @@
package techreborn.blocks.storage.energy; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
@ -60,7 +60,7 @@ public abstract class EnergyStorageBlock extends BaseBlockEntityProvider {
public IMachineGuiHandler gui; public IMachineGuiHandler gui;
public EnergyStorageBlock(String name, 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.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
this.name = name; this.name = name;
this.gui = gui; this.gui = gui;

View file

@ -24,7 +24,7 @@
package techreborn.blocks.storage.energy; 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.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -49,7 +49,7 @@ import techreborn.blockentity.storage.energy.lesu.LSUStorageBlockEntity;
public class LSUStorageBlock extends BaseBlockEntityProvider { public class LSUStorageBlock extends BaseBlockEntityProvider {
public LSUStorageBlock() { public LSUStorageBlock() {
super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f).build()); super(FabricBlockSettings.of(Material.METAL).strength(2f, 2f));
BlockWrenchEventHandler.wrenableBlocks.add(this); BlockWrenchEventHandler.wrenableBlocks.add(this);
} }

View file

@ -24,7 +24,7 @@
package techreborn.blocks.transformers; 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.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
@ -55,7 +55,7 @@ public abstract class BlockTransformer extends BaseBlockEntityProvider {
public String name; public String name;
public BlockTransformer(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.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
this.name = name; this.name = name;
BlockWrenchEventHandler.wrenableBlocks.add(this); BlockWrenchEventHandler.wrenableBlocks.add(this);

View file

@ -31,6 +31,8 @@ import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.builder.GuiBase;
import reborncore.common.util.StringUtils; import reborncore.common.util.StringUtils;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity; import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import reborncore.common.network.NetworkManager;
import techreborn.packets.ServerboundPackets;
public class GuiStorageUnit extends GuiBase<BuiltScreenHandler> { 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) { protected void drawForeground(MatrixStack matrixStack, final int mouseX, final int mouseY) {
super.drawForeground(matrixStack, mouseX, 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); textRenderer.draw(matrixStack, new TranslatableText("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
} else { } else {
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.store"), 10, 20, 4210752); textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.storage.store"), 10, 20, 4210752);
textRenderer.draw(matrixStack, storageEntity.getStoredStack().getName(), 10, 30, 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, new TranslatableText("gui.techreborn.storage.amount"), 10, 50, 4210752);
textRenderer.draw(matrixStack, String.valueOf(storageEntity.getCurrentCapacity()), 10, 60, 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); 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);
}
} }

View file

@ -50,7 +50,7 @@ public class StorageUnitRenderer extends BlockEntityRenderer<StorageUnitBaseBloc
if (storage.getWorld() == null) { if (storage.getWorld() == null) {
return; return;
} }
ItemStack stack = storage.getStoredStack(); ItemStack stack = storage.getDisplayedStack();
if (stack.isEmpty()) { if (stack.isEmpty()) {
return; return;
} }

View file

@ -66,7 +66,7 @@ public class StackToolTipHandler implements ItemTooltipCallback {
ItemTooltipCallback.EVENT.register(new StackToolTipHandler()); ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
// WIP injection // WIP injection
wipBlocks.add(TRContent.Machine.DRAIN.block); // wipBlocks.add(TRContent.Machine.NAME.block);
} }

View file

@ -24,7 +24,7 @@
package techreborn.init; 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.Block;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.OreBlock; import net.minecraft.block.OreBlock;
@ -436,7 +436,7 @@ public class TRContent {
Ores(int veinSize, int veinsPerChunk, int minY, int maxY) { Ores(int veinSize, int veinsPerChunk, int minY, int maxY) {
name = this.toString().toLowerCase(Locale.ROOT); 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.veinSize = veinSize;
this.veinsPerChunk = veinsPerChunk; this.veinsPerChunk = veinsPerChunk;
this.minY = minY; this.minY = minY;

View file

@ -43,6 +43,7 @@ import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity;
import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity; import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity; import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity; import techreborn.blockentity.storage.energy.AdjustableSUBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.config.TechRebornConfig; import techreborn.config.TechRebornConfig;
import techreborn.init.TRContent; 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 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 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 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 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 REFUND = new Identifier(TechReborn.MOD_ID, "refund");
public static final Identifier CHUNKLOADER = new Identifier(TechReborn.MOD_ID, "chunkloader"); 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) -> { registerPacketHandler(REFUND, (extendedPacketBuffer, context) -> {
if(!TechRebornConfig.allowManualRefund){ if(!TechRebornConfig.allowManualRefund){
return; 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(){ public static Packet<ServerPlayPacketListener> createRefundPacket(){
return NetworkManager.createServerBoundPacket(REFUND, extendedPacketBuffer -> { return NetworkManager.createServerBoundPacket(REFUND, extendedPacketBuffer -> {

View file

@ -24,7 +24,7 @@
package techreborn.utils; 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.AbstractBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.Material; import net.minecraft.block.Material;
@ -65,9 +65,9 @@ public class InitUtils {
itemList.add(uncharged); itemList.add(uncharged);
itemList.add(charged); itemList.add(charged);
} }
public static AbstractBlock.Settings setupRubberBlockSettings(boolean noCollision, float hardness, float resistance) { public static AbstractBlock.Settings setupRubberBlockSettings(boolean noCollision, float hardness, float resistance) {
FabricBlockSettings settings = FabricBlockSettings.of(Material.WOOD, MaterialColor.SPRUCE); FabricBlockSettings settings = FabricBlockSettings.of(Material.WOOD, MaterialColor.SPRUCE);
settings.strength(hardness, resistance); settings.strength(hardness, resistance);
settings.sounds(BlockSoundGroup.WOOD); settings.sounds(BlockSoundGroup.WOOD);
@ -75,9 +75,9 @@ public class InitUtils {
settings.noCollision(); settings.noCollision();
} }
settings.materialColor(MaterialColor.SPRUCE); settings.materialColor(MaterialColor.SPRUCE);
return settings.build(); return settings;
} }
public static AbstractBlock.Settings setupRubberBlockSettings(float hardness, float resistance) { public static AbstractBlock.Settings setupRubberBlockSettings(float hardness, float resistance) {
return setupRubberBlockSettings(false, hardness, resistance); return setupRubberBlockSettings(false, hardness, resistance);
} }

View file

@ -690,6 +690,8 @@
"techreborn.message.info.block.techreborn.quantum_tank": "Stores near-infinite of a single liquid", "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.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.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.category": "TechReborn Category",
"keys.techreborn.config": "Config", "keys.techreborn.config": "Config",

View file

@ -0,0 +1,17 @@
{
"type": "techreborn:compressor",
"power": 10,
"time": 180,
"ingredients" : [
{
"item": "minecraft:prismarine_crystals"
}
],
"results" : [
{
"item": "minecraft:prismarine_shard"
}
]
}

View file

@ -2,16 +2,16 @@
"type": "minecraft:crafting_shapeless", "type": "minecraft:crafting_shapeless",
"ingredients": [ "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": { "result": {

View file

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

View file

@ -2,16 +2,16 @@
"type": "minecraft:crafting_shapeless", "type": "minecraft:crafting_shapeless",
"ingredients": [ "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": { "result": {

View file

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

View file

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

View file

@ -0,0 +1,16 @@
{
"type": "techreborn:grinder",
"power": 4,
"time": 270,
"ingredients": [
{
"item": "minecraft:andesite"
}
],
"results": [
{
"item": "techreborn:andesite_dust",
"count": 2
}
]
}

View file

@ -5,12 +5,12 @@
"ingredients": [ "ingredients": [
{ {
"item": "minecraft:diorite", "item": "minecraft:diorite",
"count": 8 "count": 1
} }
], ],
"results": [ "results": [
{ {
"item": "techreborn:quartz_dust" "item": "techreborn:diorite_dust"
} }
] ]
} }

View file

@ -1,16 +1,17 @@
{ {
"type": "techreborn:grinder", "type": "techreborn:grinder",
"power": 2, "power": 4,
"time": 720, "time": 270,
"ingredients": [ "ingredients": [
{ {
"item": "minecraft:granite", "item": "minecraft:granite",
"count": 4 "count": 1
} }
], ],
"results": [ "results": [
{ {
"item": "techreborn:quartz_dust" "item": "techreborn:granite_dust",
"count": 2
} }
] ]
} }

View file

@ -0,0 +1,15 @@
{
"type": "techreborn:grinder",
"power": 2,
"time": 180,
"ingredients" : [
{
"item": "minecraft:cobblestone"
}
],
"results" : [
{
"item": "minecraft:gravel"
}
]
}

View file

@ -4,7 +4,7 @@
"time": 180, "time": 180,
"ingredients" : [ "ingredients" : [
{ {
"item": "minecraft:cobblestone" "item": "minecraft:gravel"
} }
], ],
"results" : [ "results" : [