Add cargo crate
This commit is contained in:
parent
ac0c72abb1
commit
b81c76e2e5
2
.gitignore
vendored
2
.gitignore
vendored
@ -126,3 +126,5 @@ forge*changelog.txt
|
|||||||
/src/main/resources/assets/overdrive_that_matters/models/item/matter_transform_matrix.json
|
/src/main/resources/assets/overdrive_that_matters/models/item/matter_transform_matrix.json
|
||||||
/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_ingot.json
|
/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_ingot.json
|
||||||
/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_plate.json
|
/src/main/resources/assets/overdrive_that_matters/models/item/tritanium_plate.json
|
||||||
|
/src/main/resources/assets/overdrive_that_matters/blockstates/cargo_crate.json
|
||||||
|
/src/main/resources/data/overdrive_that_matters/loot_tables/blocks/cargo_crate.json
|
||||||
|
@ -384,6 +384,7 @@ const facings = [
|
|||||||
// просто дропы блоков
|
// просто дропы блоков
|
||||||
{
|
{
|
||||||
const blocks = [
|
const blocks = [
|
||||||
|
'cargo_crate',
|
||||||
'matter_cable',
|
'matter_cable',
|
||||||
'tritanium_block',
|
'tritanium_block',
|
||||||
'tritanium_striped_block',
|
'tritanium_striped_block',
|
||||||
@ -417,6 +418,24 @@ const facings = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cargo Crate
|
||||||
|
{
|
||||||
|
const blockstate = {
|
||||||
|
variants: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const face of facings) {
|
||||||
|
for (const open of [true, false]) {
|
||||||
|
blockstate.variants['facing=' + face.facing + ',open=' + open] = {
|
||||||
|
model: 'overdrive_that_matters:block/cargo_crate_' + (open ? 'open' : 'closed'),
|
||||||
|
y: face.y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(_root + 'blockstates/cargo_crate.json', JSON.stringify(blockstate, null, '\t'))
|
||||||
|
}
|
||||||
|
|
||||||
// Обычные блокстейты
|
// Обычные блокстейты
|
||||||
{
|
{
|
||||||
const blocks = [
|
const blocks = [
|
||||||
|
@ -105,6 +105,7 @@ public class Registry {
|
|||||||
public static final ResourceLocation DRIVE_VIEWER = new ResourceLocation(OverdriveThatMatters.MOD_ID, "drive_viewer");
|
public static final ResourceLocation DRIVE_VIEWER = new ResourceLocation(OverdriveThatMatters.MOD_ID, "drive_viewer");
|
||||||
|
|
||||||
public static final ResourceLocation BLACK_HOLE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "black_hole");
|
public static final ResourceLocation BLACK_HOLE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "black_hole");
|
||||||
|
public static final ResourceLocation CARGO_CRATE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "cargo_crate");
|
||||||
|
|
||||||
// building blocks
|
// building blocks
|
||||||
public static final ResourceLocation TRITANIUM_BLOCK = new ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium_block");
|
public static final ResourceLocation TRITANIUM_BLOCK = new ResourceLocation(OverdriveThatMatters.MOD_ID, "tritanium_block");
|
||||||
@ -214,19 +215,20 @@ public class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Blocks {
|
public static class Blocks {
|
||||||
public static final Block ANDROID_STATION = new BlockAndroidStation();
|
public static final BlockAndroidStation ANDROID_STATION = new BlockAndroidStation();
|
||||||
public static final Block BATTERY_BANK = new BlockBatteryBank();
|
public static final BlockBatteryBank BATTERY_BANK = new BlockBatteryBank();
|
||||||
public static final Block MATTER_DECOMPOSER = new BlockMatterDecomposer();
|
public static final BlockMatterDecomposer MATTER_DECOMPOSER = new BlockMatterDecomposer();
|
||||||
public static final Block MATTER_CAPACITOR_BANK = new BlockMatterCapacitorBank();
|
public static final BlockMatterCapacitorBank MATTER_CAPACITOR_BANK = new BlockMatterCapacitorBank();
|
||||||
public static final Block MATTER_CABLE = new BlockMatterCable();
|
public static final BlockMatterCable MATTER_CABLE = new BlockMatterCable();
|
||||||
public static final Block PATTERN_STORAGE = new BlockPatternStorage();
|
public static final BlockPatternStorage PATTERN_STORAGE = new BlockPatternStorage();
|
||||||
public static final Block MATTER_SCANNER = new BlockMatterScanner();
|
public static final BlockMatterScanner MATTER_SCANNER = new BlockMatterScanner();
|
||||||
public static final Block MATTER_PANEL = new BlockMatterPanel();
|
public static final BlockMatterPanel MATTER_PANEL = new BlockMatterPanel();
|
||||||
public static final Block MATTER_REPLICATOR = new BlockMatterReplicator();
|
public static final BlockMatterReplicator MATTER_REPLICATOR = new BlockMatterReplicator();
|
||||||
public static final Block MATTER_BOTTLER = new BlockMatterBottler();
|
public static final BlockMatterBottler MATTER_BOTTLER = new BlockMatterBottler();
|
||||||
public static final Block DRIVE_VIEWER = new BlockDriveViewer();
|
public static final BlockDriveViewer DRIVE_VIEWER = new BlockDriveViewer();
|
||||||
|
public static final BlockCargoCrate CARGO_CRATE = new BlockCargoCrate();
|
||||||
|
|
||||||
public static final Block BLACK_HOLE = new BlockBlackHole();
|
public static final BlockBlackHole BLACK_HOLE = new BlockBlackHole();
|
||||||
|
|
||||||
public static final Block[] CRATES = new Block[Registry.CRATES.length];
|
public static final Block[] CRATES = new Block[Registry.CRATES.length];
|
||||||
|
|
||||||
@ -276,6 +278,7 @@ public class Registry {
|
|||||||
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
||||||
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
||||||
BLACK_HOLE.setRegistryName(Names.BLACK_HOLE);
|
BLACK_HOLE.setRegistryName(Names.BLACK_HOLE);
|
||||||
|
CARGO_CRATE.setRegistryName(Names.CARGO_CRATE);
|
||||||
|
|
||||||
TRITANIUM_BLOCK.setRegistryName(Names.TRITANIUM_BLOCK);
|
TRITANIUM_BLOCK.setRegistryName(Names.TRITANIUM_BLOCK);
|
||||||
TRITANIUM_STRIPED_BLOCK.setRegistryName(Names.TRITANIUM_STRIPED_BLOCK);
|
TRITANIUM_STRIPED_BLOCK.setRegistryName(Names.TRITANIUM_STRIPED_BLOCK);
|
||||||
@ -299,6 +302,7 @@ public class Registry {
|
|||||||
event.getRegistry().register(TRITANIUM_STRIPED_BLOCK);
|
event.getRegistry().register(TRITANIUM_STRIPED_BLOCK);
|
||||||
event.getRegistry().register(CARBON_FIBRE_BLOCK);
|
event.getRegistry().register(CARBON_FIBRE_BLOCK);
|
||||||
event.getRegistry().register(BLACK_HOLE);
|
event.getRegistry().register(BLACK_HOLE);
|
||||||
|
event.getRegistry().register(CARGO_CRATE);
|
||||||
|
|
||||||
for (var crate : CRATES) {
|
for (var crate : CRATES) {
|
||||||
event.getRegistry().register(crate);
|
event.getRegistry().register(crate);
|
||||||
@ -320,6 +324,7 @@ public class Registry {
|
|||||||
public static final Item MATTER_REPLICATOR = new BlockItem(Blocks.MATTER_REPLICATOR, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
public static final Item MATTER_REPLICATOR = new BlockItem(Blocks.MATTER_REPLICATOR, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
||||||
public static final Item MATTER_BOTTLER = new BlockItem(Blocks.MATTER_BOTTLER, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
public static final Item MATTER_BOTTLER = new BlockItem(Blocks.MATTER_BOTTLER, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
||||||
public static final Item DRIVE_VIEWER = new BlockItem(Blocks.DRIVE_VIEWER, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
public static final Item DRIVE_VIEWER = new BlockItem(Blocks.DRIVE_VIEWER, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
||||||
|
public static final Item CARGO_CRATE = new BlockItem(Blocks.CARGO_CRATE, new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
||||||
|
|
||||||
public static final Item TRITANIUM_INGOT = new Item(new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
public static final Item TRITANIUM_INGOT = new Item(new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
||||||
public static final Item MATTER_IO_PORT = new Item(new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
public static final Item MATTER_IO_PORT = new Item(new Item.Properties().stacksTo(64).tab(OverdriveThatMatters.CREATIVE_TAB));
|
||||||
@ -387,6 +392,7 @@ public class Registry {
|
|||||||
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
||||||
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
||||||
BLACK_HOLE.setRegistryName(Names.BLACK_HOLE);
|
BLACK_HOLE.setRegistryName(Names.BLACK_HOLE);
|
||||||
|
CARGO_CRATE.setRegistryName(Names.CARGO_CRATE);
|
||||||
|
|
||||||
TRITANIUM_INGOT.setRegistryName(Names.TRITANIUM_INGOT);
|
TRITANIUM_INGOT.setRegistryName(Names.TRITANIUM_INGOT);
|
||||||
MATTER_IO_PORT.setRegistryName(Names.MATTER_IO_PORT);
|
MATTER_IO_PORT.setRegistryName(Names.MATTER_IO_PORT);
|
||||||
@ -445,6 +451,7 @@ public class Registry {
|
|||||||
event.getRegistry().register(MATTER_BOTTLER);
|
event.getRegistry().register(MATTER_BOTTLER);
|
||||||
event.getRegistry().register(DRIVE_VIEWER);
|
event.getRegistry().register(DRIVE_VIEWER);
|
||||||
event.getRegistry().register(BLACK_HOLE);
|
event.getRegistry().register(BLACK_HOLE);
|
||||||
|
event.getRegistry().register(CARGO_CRATE);
|
||||||
|
|
||||||
event.getRegistry().register(TRITANIUM_INGOT);
|
event.getRegistry().register(TRITANIUM_INGOT);
|
||||||
event.getRegistry().register(MATTER_IO_PORT);
|
event.getRegistry().register(MATTER_IO_PORT);
|
||||||
@ -509,6 +516,7 @@ public class Registry {
|
|||||||
public static final BlockEntityType<BlockEntityMatterBottler> MATTER_BOTTLER = BlockEntityType.Builder.of(BlockEntityMatterBottler::new, Blocks.MATTER_BOTTLER).build(null);
|
public static final BlockEntityType<BlockEntityMatterBottler> MATTER_BOTTLER = BlockEntityType.Builder.of(BlockEntityMatterBottler::new, Blocks.MATTER_BOTTLER).build(null);
|
||||||
public static final BlockEntityType<BlockEntityDriveViewer> DRIVE_VIEWER = BlockEntityType.Builder.of(BlockEntityDriveViewer::new, Blocks.DRIVE_VIEWER).build(null);
|
public static final BlockEntityType<BlockEntityDriveViewer> DRIVE_VIEWER = BlockEntityType.Builder.of(BlockEntityDriveViewer::new, Blocks.DRIVE_VIEWER).build(null);
|
||||||
public static final BlockEntityType<BlockEntityBlackHole> BLACK_HOLE = BlockEntityType.Builder.of(BlockEntityBlackHole::new, Blocks.BLACK_HOLE).build(null);
|
public static final BlockEntityType<BlockEntityBlackHole> BLACK_HOLE = BlockEntityType.Builder.of(BlockEntityBlackHole::new, Blocks.BLACK_HOLE).build(null);
|
||||||
|
public static final BlockEntityType<BlockEntityCargoCrate> CARGO_CRATE = BlockEntityType.Builder.of(BlockEntityCargoCrate::new, Blocks.CARGO_CRATE).build(null);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ANDROID_STATION.setRegistryName(Names.ANDROID_STATION);
|
ANDROID_STATION.setRegistryName(Names.ANDROID_STATION);
|
||||||
@ -523,6 +531,7 @@ public class Registry {
|
|||||||
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
||||||
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
||||||
BLACK_HOLE.setRegistryName(Names.BLACK_HOLE);
|
BLACK_HOLE.setRegistryName(Names.BLACK_HOLE);
|
||||||
|
CARGO_CRATE.setRegistryName(Names.CARGO_CRATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@ -539,6 +548,7 @@ public class Registry {
|
|||||||
event.getRegistry().register(MATTER_BOTTLER);
|
event.getRegistry().register(MATTER_BOTTLER);
|
||||||
event.getRegistry().register(DRIVE_VIEWER);
|
event.getRegistry().register(DRIVE_VIEWER);
|
||||||
event.getRegistry().register(BLACK_HOLE);
|
event.getRegistry().register(BLACK_HOLE);
|
||||||
|
event.getRegistry().register(CARGO_CRATE);
|
||||||
|
|
||||||
// OverdriveThatMatters.LOGGER.info("Registered block entities");
|
// OverdriveThatMatters.LOGGER.info("Registered block entities");
|
||||||
}
|
}
|
||||||
@ -781,6 +791,7 @@ public class Registry {
|
|||||||
public static final MenuType<MatterReplicatorMenu> MATTER_REPLICATOR = new MenuType<>(MatterReplicatorMenu::new);
|
public static final MenuType<MatterReplicatorMenu> MATTER_REPLICATOR = new MenuType<>(MatterReplicatorMenu::new);
|
||||||
public static final MenuType<MatterBottlerMenu> MATTER_BOTTLER = new MenuType<>(MatterBottlerMenu::new);
|
public static final MenuType<MatterBottlerMenu> MATTER_BOTTLER = new MenuType<>(MatterBottlerMenu::new);
|
||||||
public static final MenuType<DriveViewerMenu> DRIVE_VIEWER = new MenuType<>(DriveViewerMenu::new);
|
public static final MenuType<DriveViewerMenu> DRIVE_VIEWER = new MenuType<>(DriveViewerMenu::new);
|
||||||
|
public static final MenuType<CargoCrateMenu> CARGO_CRATE = new MenuType<>(CargoCrateMenu::new);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ANDROID_STATION.setRegistryName(Names.ANDROID_STATION);
|
ANDROID_STATION.setRegistryName(Names.ANDROID_STATION);
|
||||||
@ -793,6 +804,7 @@ public class Registry {
|
|||||||
MATTER_REPLICATOR.setRegistryName(Names.MATTER_REPLICATOR);
|
MATTER_REPLICATOR.setRegistryName(Names.MATTER_REPLICATOR);
|
||||||
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
MATTER_BOTTLER.setRegistryName(Names.MATTER_BOTTLER);
|
||||||
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
DRIVE_VIEWER.setRegistryName(Names.DRIVE_VIEWER);
|
||||||
|
CARGO_CRATE.setRegistryName(Names.CARGO_CRATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@ -807,6 +819,7 @@ public class Registry {
|
|||||||
event.getRegistry().register(MATTER_REPLICATOR);
|
event.getRegistry().register(MATTER_REPLICATOR);
|
||||||
event.getRegistry().register(MATTER_BOTTLER);
|
event.getRegistry().register(MATTER_BOTTLER);
|
||||||
event.getRegistry().register(DRIVE_VIEWER);
|
event.getRegistry().register(DRIVE_VIEWER);
|
||||||
|
event.getRegistry().register(CARGO_CRATE);
|
||||||
|
|
||||||
// OverdriveThatMatters.LOGGER.info("Registered menus");
|
// OverdriveThatMatters.LOGGER.info("Registered menus");
|
||||||
}
|
}
|
||||||
@ -823,6 +836,7 @@ public class Registry {
|
|||||||
MenuScreens.register(MATTER_REPLICATOR, MatterReplicatorScreen::new);
|
MenuScreens.register(MATTER_REPLICATOR, MatterReplicatorScreen::new);
|
||||||
MenuScreens.register(MATTER_BOTTLER, MatterBottlerScreen::new);
|
MenuScreens.register(MATTER_BOTTLER, MatterBottlerScreen::new);
|
||||||
MenuScreens.register(DRIVE_VIEWER, DriveViewerScreen::new);
|
MenuScreens.register(DRIVE_VIEWER, DriveViewerScreen::new);
|
||||||
|
MenuScreens.register(CARGO_CRATE, CargoCrateScreen::new);
|
||||||
|
|
||||||
// OverdriveThatMatters.LOGGER.info("Registered screens");
|
// OverdriveThatMatters.LOGGER.info("Registered screens");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.block;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.world.Container;
|
||||||
|
import net.minecraft.world.Containers;
|
||||||
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||||
|
import ru.dbotthepony.mc.otm.block.entity.BlockEntityCargoCrate;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class BlockCargoCrate extends BlockMatteryRotatable implements EntityBlock {
|
||||||
|
public static final BooleanProperty IS_OPEN = BooleanProperty.create("open");
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
|
return new BlockEntityCargoCrate(blockPos, blockState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
|
super.createBlockStateDefinition(builder);
|
||||||
|
builder.add(IS_OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||||
|
return super.getStateForPlacement(context).setValue(IS_OPEN, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemove(BlockState old_block_state, Level level, BlockPos block_pos, BlockState new_block_state, boolean p_51542_) {
|
||||||
|
if (!old_block_state.is(new_block_state.getBlock())) {
|
||||||
|
BlockEntity blockentity = level.getBlockEntity(block_pos);
|
||||||
|
|
||||||
|
if (blockentity instanceof BlockEntityCargoCrate crate) {
|
||||||
|
Containers.dropContents(level, block_pos, crate.slots);
|
||||||
|
level.updateNeighbourForOutputSignal(block_pos, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
super.onRemove(old_block_state, level, block_pos, new_block_state, p_51542_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.block.entity;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import ru.dbotthepony.mc.otm.Registry;
|
||||||
|
import ru.dbotthepony.mc.otm.block.BlockCargoCrate;
|
||||||
|
import ru.dbotthepony.mc.otm.container.MatteryContainer;
|
||||||
|
import ru.dbotthepony.mc.otm.menu.CargoCrateMenu;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class BlockEntityCargoCrate extends BlockEntityMattery {
|
||||||
|
private static final TranslatableComponent NAME = new TranslatableComponent("block.overdrive_that_matters.cargo_crate");
|
||||||
|
public int open_amount = 0;
|
||||||
|
|
||||||
|
public void onPlayerOpen() {
|
||||||
|
if (open_amount++ == 0 && level != null) {
|
||||||
|
level.setBlock(getBlockPos(), getBlockState().setValue(BlockCargoCrate.IS_OPEN, true), Block.UPDATE_CLIENTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerClose() {
|
||||||
|
if (--open_amount == 0 && level != null) {
|
||||||
|
level.setBlock(getBlockPos(), getBlockState().setValue(BlockCargoCrate.IS_OPEN, false), Block.UPDATE_CLIENTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final MatteryContainer slots = new MatteryContainer(this::setChanged, 9 * 6);
|
||||||
|
|
||||||
|
public BlockEntityCargoCrate(BlockPos p_155229_, BlockState p_155230_) {
|
||||||
|
super(Registry.BlockEntities.CARGO_CRATE, p_155229_, p_155230_);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag save(CompoundTag nbt) {
|
||||||
|
nbt.put("slots", slots.serializeNBT());
|
||||||
|
return super.save(nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag nbt) {
|
||||||
|
super.load(nbt);
|
||||||
|
slots.deserializeNBT(nbt.get("slots"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Component getDefaultDisplayName() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AbstractContainerMenu createMenu(int containerID, Inventory inventory, Player ply) {
|
||||||
|
return new CargoCrateMenu(containerID, inventory, this);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.client.screen;
|
||||||
|
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import ru.dbotthepony.mc.otm.client.screen.panels.Dock;
|
||||||
|
import ru.dbotthepony.mc.otm.client.screen.panels.FramePanel;
|
||||||
|
import ru.dbotthepony.mc.otm.client.screen.panels.GridPanel;
|
||||||
|
import ru.dbotthepony.mc.otm.client.screen.panels.SlotPanel;
|
||||||
|
import ru.dbotthepony.mc.otm.menu.CargoCrateMenu;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class CargoCrateScreen extends MatteryScreen<CargoCrateMenu> {
|
||||||
|
public CargoCrateScreen(CargoCrateMenu menu, Inventory inventory, Component title) {
|
||||||
|
super(menu, inventory, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
protected FramePanel makeMainFrame() {
|
||||||
|
var frame = new FramePanel(this, null, 0, 0, INVENTORY_FRAME_WIDTH, 22 + 4 + 6 * 18, getTitle());
|
||||||
|
|
||||||
|
var grid = new GridPanel(this, frame, 8, 18, 9 * 18, 6 * 18, 9, 6);
|
||||||
|
|
||||||
|
for (var slot : menu.crate_slots)
|
||||||
|
new SlotPanel<>(this, grid, slot);
|
||||||
|
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
}
|
@ -115,13 +115,16 @@ public abstract class MatteryScreen<T extends MatteryMenu> extends AbstractConta
|
|||||||
public FramePanel main_frame;
|
public FramePanel main_frame;
|
||||||
private boolean made_main_frame = false;
|
private boolean made_main_frame = false;
|
||||||
|
|
||||||
|
public static final int INVENTORY_FRAME_WIDTH = 18 * 9 + 16;
|
||||||
|
public static final int INVENTORY_FRAME_HEIGHT = 3 * 18 + 18 + 24;
|
||||||
|
|
||||||
public MatteryScreen(T menu, Inventory inventory, Component title) {
|
public MatteryScreen(T menu, Inventory inventory, Component title) {
|
||||||
super(menu, inventory, title);
|
super(menu, inventory, title);
|
||||||
this.menu = menu;
|
this.menu = menu;
|
||||||
playerInventoryTitle = inventory.getDisplayName();
|
playerInventoryTitle = inventory.getDisplayName();
|
||||||
|
|
||||||
if (menu.inventory_slots.size() != 0) {
|
if (menu.inventory_slots.size() != 0) {
|
||||||
inventory_frame = new FramePanel(this, null, 0, 0, 18 * 9 + 16, 3 * 18 + 18 + 24, inventory.getDisplayName());
|
inventory_frame = new FramePanel(this, null, 0, 0, INVENTORY_FRAME_WIDTH, INVENTORY_FRAME_HEIGHT, inventory.getDisplayName());
|
||||||
panels.add(inventory_frame);
|
panels.add(inventory_frame);
|
||||||
|
|
||||||
for (var slot : menu.inventory_slots) {
|
for (var slot : menu.inventory_slots) {
|
||||||
|
50
src/main/java/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.java
Normal file
50
src/main/java/ru/dbotthepony/mc/otm/menu/CargoCrateMenu.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package ru.dbotthepony.mc.otm.menu;
|
||||||
|
|
||||||
|
import net.minecraft.world.SimpleContainer;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import ru.dbotthepony.mc.otm.Registry;
|
||||||
|
import ru.dbotthepony.mc.otm.block.entity.BlockEntityCargoCrate;
|
||||||
|
import ru.dbotthepony.mc.otm.menu.slot.MatterySlot;
|
||||||
|
|
||||||
|
public class CargoCrateMenu extends MatteryMenu {
|
||||||
|
public CargoCrateMenu(int p_38852_, Inventory inventory) {
|
||||||
|
this(p_38852_, inventory, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final MatterySlot[] crate_slots = new MatterySlot[9 * 6];
|
||||||
|
|
||||||
|
public CargoCrateMenu(int p_38852_, Inventory inventory, BlockEntityCargoCrate tile) {
|
||||||
|
super(Registry.Menus.CARGO_CRATE, p_38852_, inventory, tile);
|
||||||
|
var container = tile != null ? tile.slots : new SimpleContainer(9 * 6);
|
||||||
|
|
||||||
|
for (int i = 0; i < container.getContainerSize(); i++) {
|
||||||
|
crate_slots[i] = new MatterySlot(container, i);
|
||||||
|
addSlot(crate_slots[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tile != null)
|
||||||
|
tile.onPlayerOpen();
|
||||||
|
|
||||||
|
addInventorySlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removed(Player p_38940_) {
|
||||||
|
super.removed(p_38940_);
|
||||||
|
|
||||||
|
if (tile != null)
|
||||||
|
((BlockEntityCargoCrate) tile).onPlayerClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getWorkingSlotStart() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getWorkingSlotEnd() {
|
||||||
|
return 9 * 6 + 1;
|
||||||
|
}
|
||||||
|
}
|
@ -154,7 +154,8 @@
|
|||||||
"block.overdrive_that_matters.carbon_fibre_block": "Carbon fibre Block",
|
"block.overdrive_that_matters.carbon_fibre_block": "Carbon fibre Block",
|
||||||
"block.overdrive_that_matters.tritanium_block": "Tritanium Block",
|
"block.overdrive_that_matters.tritanium_block": "Tritanium Block",
|
||||||
"block.overdrive_that_matters.tritanium_striped_block": "Tritanium Striped Block",
|
"block.overdrive_that_matters.tritanium_striped_block": "Tritanium Striped Block",
|
||||||
|
"block.overdrive_that_matters.cargo_crate": "Cargo Crate",
|
||||||
|
|
||||||
"item.overdrive_that_matters.pill_android": "Android Pill",
|
"item.overdrive_that_matters.pill_android": "Android Pill",
|
||||||
"item.overdrive_that_matters.pill_humane": "Humane Pill",
|
"item.overdrive_that_matters.pill_humane": "Humane Pill",
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
"overdrive_that_matters:crate_green",
|
"overdrive_that_matters:crate_green",
|
||||||
"overdrive_that_matters:crate_black",
|
"overdrive_that_matters:crate_black",
|
||||||
"overdrive_that_matters:crate_pink",
|
"overdrive_that_matters:crate_pink",
|
||||||
"overdrive_that_matters:crate_purple"
|
"overdrive_that_matters:crate_purple",
|
||||||
|
"overdrive_that_matters:cargo_crate"
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user