diff --git a/src/main/java/ru/dbotthepony/mc/otm/IMatterGridCell.java b/src/main/java/ru/dbotthepony/mc/otm/IMatterGridCell.java new file mode 100644 index 000000000..0933670f1 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/IMatterGridCell.java @@ -0,0 +1,66 @@ +package ru.dbotthepony.mc.otm; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.SectionPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.chunk.LevelChunk; +import ru.dbotthepony.mc.otm.capability.IMatterHandler; + +import javax.annotation.Nullable; + +public interface IMatterGridCell { + @Nullable + MatterGrid getMatterGrid(); + + @Nullable + IMatterHandler getMatterHandler(); + + boolean isValidMatterCell(); + + void setMatterGrid(MatterGrid grid); + + default boolean connectOrCreateMatterGrid(BlockPos pos, Level level) { + return connectOrCreateMatterGrid(pos, level, false); + } + + default boolean connectOrCreateMatterGrid(BlockPos pos, Level level, boolean force) { + if (getMatterGrid() != null && !force) + return true; + + boolean full_discovery = true; + + for (Direction direction : Direction.values()) { + BlockPos offset = pos.offset(direction.getNormal()); + + // level.getBlockEntity can suck big cuks of deadlocks + LevelChunk get_chunk = level.getChunkSource().getChunkNow(SectionPos.blockToSectionCoord(offset.getX()), SectionPos.blockToSectionCoord(offset.getZ())); + + if (get_chunk == null) { + full_discovery = false; + continue; + } + + BlockEntity get_entity = get_chunk.getBlockEntity(offset); + + if (get_entity != this && get_entity instanceof IMatterGridCell cell) { + MatterGrid grid = cell.getMatterGrid(); + + if (grid != null && grid != getMatterGrid()) { + if (getMatterGrid() == null) { + grid.track(this); + } else { + grid.mergeWith(getMatterGrid()); + } + } + } + } + + if (getMatterGrid() == null) { + new MatterGrid().track(this); + } + + return full_discovery; + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/MatterGrid.java b/src/main/java/ru/dbotthepony/mc/otm/MatterGrid.java new file mode 100644 index 000000000..093878f61 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/MatterGrid.java @@ -0,0 +1,262 @@ +package ru.dbotthepony.mc.otm; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraftforge.event.TickEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; +import net.minecraftforge.fmlserverevents.FMLServerStoppingEvent; +import ru.dbotthepony.mc.otm.capability.IMatterHandler; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Supplier; + +public class MatterGrid { + public static final Set NETWORKS = new HashSet<>(); + + private final Set cells = new HashSet<>(); + + private static final Set> discovering_neighbours = new HashSet<>(); + + public static void scheduleDiscoverNeighbours(IMatterGridCell cell, BlockPos pos, Level level) { + discovering_neighbours.add(() -> !cell.isValidMatterCell() || cell.connectOrCreateMatterGrid(pos, level, true)); + } + + @SubscribeEvent + public void onServerStarting(FMLServerStartedEvent event) { + discovering_neighbours.clear(); + } + + @SubscribeEvent + public void onServerStopping(FMLServerStoppingEvent event) { + discovering_neighbours.clear(); + } + + @SubscribeEvent + public static void discoverNeighbours(TickEvent.ServerTickEvent event) { + if (event.phase == TickEvent.Phase.END && discovering_neighbours.size() != 0) { + ArrayList> invalid = new ArrayList<>(); + + for (Supplier cell : discovering_neighbours) { + if (cell.get()) { + invalid.add(cell); + } + } + + if (invalid.size() != 0) { + for (Supplier cell : invalid) { + discovering_neighbours.remove(cell); + } + } + } + } + + public MatterGrid() { + NETWORKS.add(this); + } + + public BigDecimal getCapacity() { + BigDecimal summ = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() == IMatterHandler.MatterDirection.BIDIRECTIONAL) { + summ = summ.add(handler.getMaxStoredMatter()); + } + } + + return summ; + } + + public BigDecimal getPotentialCapacity() { + BigDecimal summ = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() != IMatterHandler.MatterDirection.RECEIVE) { + summ = summ.add(handler.getMaxStoredMatter()); + } + } + + return summ; + } + + public BigDecimal getStored() { + BigDecimal summ = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() == IMatterHandler.MatterDirection.BIDIRECTIONAL) { + summ = summ.add(handler.getStoredMatter()); + } + } + + return summ; + } + + public BigDecimal getPotentialStored() { + BigDecimal summ = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() != IMatterHandler.MatterDirection.RECEIVE) { + summ = summ.add(handler.getStoredMatter()); + } + } + + return summ; + } + + public BigDecimal extractMatter(BigDecimal howMuch, boolean simulate) { + if (howMuch.compareTo(BigDecimal.ZERO) <= 0) + return BigDecimal.ZERO; + + BigDecimal extracted = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() != IMatterHandler.MatterDirection.RECEIVE) { + BigDecimal drain = handler.extractMatterOuter(howMuch, simulate); + + if (!drain.equals(BigDecimal.ZERO)) { + extracted = extracted.add(drain); + howMuch = howMuch.subtract(drain); + + if (howMuch.compareTo(BigDecimal.ZERO) <= 0) { + break; + } + } + } + } + + return extracted; + } + + public BigDecimal softPushMatter(BigDecimal howMuch, boolean simulate) { + if (howMuch.compareTo(BigDecimal.ZERO) <= 0) + return BigDecimal.ZERO; + + BigDecimal received = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() == IMatterHandler.MatterDirection.BIDIRECTIONAL) { + BigDecimal receive = handler.receiveMatterOuter(howMuch, simulate); + + if (!receive.equals(BigDecimal.ZERO)) { + received = received.add(receive); + howMuch = howMuch.subtract(receive); + + if (howMuch.compareTo(BigDecimal.ZERO) <= 0) { + break; + } + } + } + } + + return received; + } + + public BigDecimal pushMatter(BigDecimal howMuch, boolean simulate) { + if (howMuch.compareTo(BigDecimal.ZERO) <= 0) + return BigDecimal.ZERO; + + BigDecimal received = BigDecimal.ZERO; + + for (IMatterGridCell cell : cells) { + IMatterHandler handler = cell.getMatterHandler(); + + if (handler != null && handler.getDirection() != IMatterHandler.MatterDirection.EXTRACT) { + BigDecimal receive = handler.receiveMatterOuter(howMuch, simulate); + + if (!receive.equals(BigDecimal.ZERO)) { + received = received.add(receive); + howMuch = howMuch.subtract(receive); + + if (howMuch.compareTo(BigDecimal.ZERO) <= 0) { + break; + } + } + } + } + + return received; + } + + public void track(IMatterGridCell entity) { + if (cells.contains(entity)) + return; + + cells.add(entity); + entity.setMatterGrid(this); + + // OverdriveThatMatters.LOGGER.debug("Tracking {} in {}. Tracking {} in total", entity, this, entities.size()); + } + + public void untrack(IMatterGridCell entity) { + if (!cells.contains(entity)) + return; + + cells.remove(entity); + entity.setMatterGrid(null); + + // OverdriveThatMatters.LOGGER.debug("Untracking {} in {}. Tracking {} in total", entity, this, entities.size()); + } + + public int networkSize() { + return cells.size(); + } + + public void mergeWith(MatterGrid other) { + if (other == this) + return; + + MatterGrid a; + MatterGrid b; + + if (networkSize() > other.networkSize()) { + a = this; + b = other; + } else { + a = other; + b = this; + } + + b.validate(); + + for (IMatterGridCell entity : b.cells) { + a.track(entity); + } + + NETWORKS.remove(b); + } + + public void validate() { + ArrayList invalid = new ArrayList<>(); + + for (IMatterGridCell entity : cells) { + if (!entity.isValidMatterCell()) { + invalid.add(entity); + } + } + + if (invalid.size() != 0) { + for (IMatterGridCell entity : invalid) { + untrack(entity); + } + } + + if (cells.size() == 0) { + NETWORKS.remove(this); + } + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java index d88a5f5cc..22a309d02 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java @@ -48,6 +48,7 @@ public class OverdriveThatMatters { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(AndroidCapabilityPlayer.class); MinecraftForge.EVENT_BUS.register(AndroidCapability.class); + MinecraftForge.EVENT_BUS.register(MatterGrid.class); // LOGGER.info("Registered event handlers"); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/Registry.java b/src/main/java/ru/dbotthepony/mc/otm/Registry.java index 374e47472..7dbdb5132 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/Registry.java +++ b/src/main/java/ru/dbotthepony/mc/otm/Registry.java @@ -17,18 +17,17 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import ru.dbotthepony.mc.otm.block.BlockAndroidStation; import ru.dbotthepony.mc.otm.block.BlockBatteryBank; +import ru.dbotthepony.mc.otm.block.BlockMatterCapacitorBank; import ru.dbotthepony.mc.otm.block.BlockMatterDecomposer; import ru.dbotthepony.mc.otm.block.entity.BlockEntityAndroidStation; import ru.dbotthepony.mc.otm.block.entity.BlockEntityBatteryBank; +import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterCapacitorBank; import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterDecomposer; import ru.dbotthepony.mc.otm.item.ItemBattery; +import ru.dbotthepony.mc.otm.item.ItemMatterCapacitor; import ru.dbotthepony.mc.otm.item.ItemPill; -import ru.dbotthepony.mc.otm.menu.AndroidStationMenu; -import ru.dbotthepony.mc.otm.menu.BatteryBankMenu; -import ru.dbotthepony.mc.otm.menu.MatterDecomposerMenu; -import ru.dbotthepony.mc.otm.screen.AndroidStationScreen; -import ru.dbotthepony.mc.otm.screen.BatteryBankScreen; -import ru.dbotthepony.mc.otm.screen.MatterDecomposerScreen; +import ru.dbotthepony.mc.otm.menu.*; +import ru.dbotthepony.mc.otm.screen.*; import java.math.BigDecimal; @@ -45,6 +44,7 @@ public class Registry { public static final ResourceLocation ANDROID_STATION = new ResourceLocation(OverdriveThatMatters.MOD_ID, "android_station"); public static final ResourceLocation BATTERY_BANK = new ResourceLocation(OverdriveThatMatters.MOD_ID, "battery_bank"); public static final ResourceLocation MATTER_DECOMPOSER = new ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_decomposer"); + public static final ResourceLocation MATTER_CAPACITOR_BANK = new ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_capacitor_bank"); public static final ResourceLocation ANDROID_CAPABILITY = new ResourceLocation(OverdriveThatMatters.MOD_ID, "android_capability"); @@ -57,23 +57,29 @@ public class Registry { public static final ResourceLocation BATTERY_DENSE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "battery_dense"); public static final ResourceLocation BATTERY_CAPACITOR = new ResourceLocation(OverdriveThatMatters.MOD_ID, "battery_capacitor"); public static final ResourceLocation BATTERY_CREATIVE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "battery_creative"); + + public static final ResourceLocation MATTER_CAPACITOR_NORMAL = new ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_capacitor_normal"); + public static final ResourceLocation MATTER_CAPACITOR_CREATIVE = new ResourceLocation(OverdriveThatMatters.MOD_ID, "matter_capacitor_creative"); } public static class Blocks { public static final Block ANDROID_STATION = new BlockAndroidStation(); public static final Block BATTERY_BANK = new BlockBatteryBank(); public static final Block MATTER_DECOMPOSER = new BlockMatterDecomposer(); + public static final Block MATTER_CAPACITOR_BANK = new BlockMatterCapacitorBank(); static { ANDROID_STATION.setRegistryName(Names.ANDROID_STATION); BATTERY_BANK.setRegistryName(Names.BATTERY_BANK); MATTER_DECOMPOSER.setRegistryName(Names.MATTER_DECOMPOSER); + MATTER_CAPACITOR_BANK.setRegistryName(Names.MATTER_CAPACITOR_BANK); } public static void register(final RegistryEvent.Register event) { event.getRegistry().register(ANDROID_STATION); event.getRegistry().register(BATTERY_BANK); event.getRegistry().register(MATTER_DECOMPOSER); + event.getRegistry().register(MATTER_CAPACITOR_BANK); // OverdriveThatMatters.LOGGER.info("Registered blocks"); } @@ -83,6 +89,8 @@ public class Registry { public static final Item ANDROID_STATION = new BlockItem(Blocks.ANDROID_STATION, new Item.Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)); public static final Item BATTERY_BANK = new BlockItem(Blocks.BATTERY_BANK, new Item.Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)); public static final Item MATTER_DECOMPOSER = new BlockItem(Blocks.MATTER_DECOMPOSER, new Item.Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)); + public static final Item MATTER_CAPACITOR_BANK = new BlockItem(Blocks.MATTER_CAPACITOR_BANK, new Item.Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)); + public static final ItemPill PILL_ANDROID = new ItemPill(ItemPill.PillType.BECOME_ANDROID); public static final ItemPill PILL_HUMANE = new ItemPill(ItemPill.PillType.BECOME_HUMANE); @@ -93,10 +101,14 @@ public class Registry { public static final ItemBattery BATTERY_CAPACITOR = new ItemBattery(new BigDecimal(150_000), new BigDecimal(15000), new BigDecimal(15000)); public static final ItemBattery BATTERY_CREATIVE = new ItemBattery(); + public static final ItemMatterCapacitor MATTER_CAPACITOR_NORMAL = new ItemMatterCapacitor(new BigDecimal("10")); + public static final ItemMatterCapacitor MATTER_CAPACITOR_CREATIVE = new ItemMatterCapacitor(); + static { ANDROID_STATION.setRegistryName(Names.ANDROID_STATION); BATTERY_BANK.setRegistryName(Names.BATTERY_BANK); MATTER_DECOMPOSER.setRegistryName(Names.MATTER_DECOMPOSER); + MATTER_CAPACITOR_BANK.setRegistryName(Names.MATTER_CAPACITOR_BANK); PILL_ANDROID.setRegistryName(Names.PILL_ANDROID); PILL_HUMANE.setRegistryName(Names.PILL_HUMANE); @@ -106,12 +118,16 @@ public class Registry { BATTERY_DENSE.setRegistryName(Names.BATTERY_DENSE); BATTERY_CAPACITOR.setRegistryName(Names.BATTERY_CAPACITOR); BATTERY_CREATIVE.setRegistryName(Names.BATTERY_CREATIVE); + + MATTER_CAPACITOR_NORMAL.setRegistryName(Names.MATTER_CAPACITOR_NORMAL); + MATTER_CAPACITOR_CREATIVE.setRegistryName(Names.MATTER_CAPACITOR_CREATIVE); } public static void register(final RegistryEvent.Register event) { event.getRegistry().register(ANDROID_STATION); event.getRegistry().register(BATTERY_BANK); event.getRegistry().register(MATTER_DECOMPOSER); + event.getRegistry().register(MATTER_CAPACITOR_BANK); event.getRegistry().register(PILL_ANDROID); event.getRegistry().register(PILL_HUMANE); @@ -122,6 +138,9 @@ public class Registry { event.getRegistry().register(BATTERY_CAPACITOR); event.getRegistry().register(BATTERY_CREATIVE); + event.getRegistry().register(MATTER_CAPACITOR_NORMAL); + event.getRegistry().register(MATTER_CAPACITOR_CREATIVE); + // OverdriveThatMatters.LOGGER.info("Registered items"); } } @@ -130,17 +149,20 @@ public class Registry { public static BlockEntityType ANDROID_STATION = BlockEntityType.Builder.of(BlockEntityAndroidStation::new, Blocks.ANDROID_STATION).build(null); public static BlockEntityType BATTERY_BANK = BlockEntityType.Builder.of(BlockEntityBatteryBank::new, Blocks.BATTERY_BANK).build(null); public static BlockEntityType MATTER_DECOMPOSER = BlockEntityType.Builder.of(BlockEntityMatterDecomposer::new, Blocks.MATTER_DECOMPOSER).build(null); + public static BlockEntityType MATTER_CAPACITOR_BANK = BlockEntityType.Builder.of(BlockEntityMatterCapacitorBank::new, Blocks.MATTER_CAPACITOR_BANK).build(null); static { ANDROID_STATION.setRegistryName(Names.ANDROID_STATION); BATTERY_BANK.setRegistryName(Names.BATTERY_BANK); MATTER_DECOMPOSER.setRegistryName(Names.MATTER_DECOMPOSER); + MATTER_CAPACITOR_BANK.setRegistryName(Names.MATTER_CAPACITOR_BANK); } public static void register(final RegistryEvent.Register> event) { event.getRegistry().register(ANDROID_STATION); event.getRegistry().register(BATTERY_BANK); event.getRegistry().register(MATTER_DECOMPOSER); + event.getRegistry().register(MATTER_CAPACITOR_BANK); // OverdriveThatMatters.LOGGER.info("Registered block entities"); } @@ -150,17 +172,20 @@ public class Registry { public static final MenuType ANDROID_STATION = new MenuType<>(AndroidStationMenu::new); public static final MenuType BATTERY_BANK = new MenuType<>(BatteryBankMenu::new); public static final MenuType MATTER_DECOMPOSER = new MenuType<>(MatterDecomposerMenu::new); + public static final MenuType MATTER_CAPACITOR_BANK = new MenuType<>(MatterCapacitorBankMenu::new); static { ANDROID_STATION.setRegistryName(Names.ANDROID_STATION); BATTERY_BANK.setRegistryName(Names.BATTERY_BANK); MATTER_DECOMPOSER.setRegistryName(Names.MATTER_DECOMPOSER); + MATTER_CAPACITOR_BANK.setRegistryName(Names.MATTER_CAPACITOR_BANK); } public static void register(final RegistryEvent.Register> event) { event.getRegistry().register(ANDROID_STATION); event.getRegistry().register(BATTERY_BANK); event.getRegistry().register(MATTER_DECOMPOSER); + event.getRegistry().register(MATTER_CAPACITOR_BANK); // OverdriveThatMatters.LOGGER.info("Registered menus"); } @@ -169,6 +194,7 @@ public class Registry { MenuScreens.register(ANDROID_STATION, AndroidStationScreen::new); MenuScreens.register(BATTERY_BANK, BatteryBankScreen::new); MenuScreens.register(MATTER_DECOMPOSER, MatterDecomposerScreen::new); + MenuScreens.register(MATTER_CAPACITOR_BANK, MatterCapacitorBankScreen::new); // OverdriveThatMatters.LOGGER.info("Registered screens"); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/BlockAndroidStation.java b/src/main/java/ru/dbotthepony/mc/otm/block/BlockAndroidStation.java index f4b3ecc2a..b461e0b36 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/BlockAndroidStation.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/BlockAndroidStation.java @@ -23,7 +23,7 @@ import ru.dbotthepony.mc.otm.capability.MatteryCapability; import javax.annotation.Nullable; -public class BlockAndroidStation extends BlockMatteryMachineBase implements EntityBlock { +public class BlockAndroidStation extends BlockMattery implements EntityBlock { private final VoxelShape SHAPE = Shapes.box(0, 0, 0, 1, 0.5, 1); public BlockAndroidStation() { diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/BlockBatteryBank.java b/src/main/java/ru/dbotthepony/mc/otm/block/BlockBatteryBank.java index 68910faa6..bb2a23cd9 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/BlockBatteryBank.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/BlockBatteryBank.java @@ -1,23 +1,19 @@ package ru.dbotthepony.mc.otm.block; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; +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.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.block.state.properties.EnumProperty; import ru.dbotthepony.mc.otm.Registry; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityAndroidStation; import ru.dbotthepony.mc.otm.block.entity.BlockEntityBatteryBank; import javax.annotation.Nullable; -public class BlockBatteryBank extends BlockMatteryRotatableMachineBase implements EntityBlock { +public class BlockBatteryBank extends BlockMatteryRotatable implements EntityBlock { @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState p_153213_, BlockEntityType type) { @@ -29,4 +25,9 @@ public class BlockBatteryBank extends BlockMatteryRotatableMachineBase implement public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { return new BlockEntityBatteryBank(blockPos, blockState); } + + @Override + public boolean faceToPlayer(BlockPlaceContext context) { + return false; + } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterCapacitorBank.java b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterCapacitorBank.java new file mode 100644 index 000000000..97dffe3bb --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterCapacitorBank.java @@ -0,0 +1,17 @@ +package ru.dbotthepony.mc.otm.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterCapacitorBank; + +import javax.annotation.Nullable; + +public class BlockMatterCapacitorBank extends BlockMatteryRotatable implements EntityBlock { + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return new BlockEntityMatterCapacitorBank(blockPos, blockState); + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterDecomposer.java b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterDecomposer.java index d05bc29d6..daf736e68 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterDecomposer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatterDecomposer.java @@ -12,7 +12,7 @@ import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterDecomposer; import javax.annotation.Nullable; -public class BlockMatterDecomposer extends BlockMatteryRotatableMachineBase implements EntityBlock { +public class BlockMatterDecomposer extends BlockMatteryRotatable implements EntityBlock { @Nullable @Override public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryMachineBase.java b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMattery.java similarity index 84% rename from src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryMachineBase.java rename to src/main/java/ru/dbotthepony/mc/otm/block/BlockMattery.java index 699e788ec..41c97dd78 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryMachineBase.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMattery.java @@ -15,23 +15,22 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.phys.BlockHitResult; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityAndroidStation; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatteryMachine; +import ru.dbotthepony.mc.otm.block.entity.BlockEntityMattery; import javax.annotation.Nullable; -public abstract class BlockMatteryMachineBase extends Block { - public BlockMatteryMachineBase(Properties p_49795_) { +public abstract class BlockMattery extends Block { + public BlockMattery(Properties p_49795_) { super(p_49795_); } - public BlockMatteryMachineBase() { + public BlockMattery() { this(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.STONE).requiresCorrectToolForDrops().strength(1.5F, 6.0F)); } @Override public void setPlacedBy(Level p_49847_, BlockPos p_49848_, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack p_49851_) { - if (this instanceof EntityBlock && p_49851_.hasCustomHoverName() && !p_49847_.isClientSide && p_49847_.getBlockEntity(p_49848_) instanceof BlockEntityMatteryMachine tile) { + if (this instanceof EntityBlock && p_49851_.hasCustomHoverName() && !p_49847_.isClientSide && p_49847_.getBlockEntity(p_49848_) instanceof BlockEntityMattery tile) { tile.setDisplayName(p_49851_.getDisplayName()); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryRotatableMachineBase.java b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryRotatable.java similarity index 68% rename from src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryRotatableMachineBase.java rename to src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryRotatable.java index f94fe365f..ddb8cecf1 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryRotatableMachineBase.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/BlockMatteryRotatable.java @@ -1,11 +1,7 @@ package ru.dbotthepony.mc.otm.block; -import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; 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.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; @@ -13,10 +9,10 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; import javax.annotation.Nullable; -public abstract class BlockMatteryRotatableMachineBase extends BlockMatteryMachineBase { +public abstract class BlockMatteryRotatable extends BlockMattery { public static final EnumProperty FACING = EnumProperty.create("facing", Direction.class); - public BlockMatteryRotatableMachineBase() { + public BlockMatteryRotatable() { super(); registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.SOUTH)); @@ -30,6 +26,10 @@ public abstract class BlockMatteryRotatableMachineBase extends BlockMatteryMachi @Nullable @Override public BlockState getStateForPlacement(BlockPlaceContext context) { - return this.defaultBlockState().setValue(FACING, context.getNearestLookingDirection()); + return this.defaultBlockState().setValue(FACING, faceToPlayer(context) ? context.getNearestLookingDirection().getOpposite() : context.getNearestLookingDirection()); + } + + public boolean faceToPlayer(BlockPlaceContext context) { + return true; } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityAndroidStation.java b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityAndroidStation.java index 21bc6509d..cbefb5cda 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityAndroidStation.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityAndroidStation.java @@ -12,7 +12,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; -import net.minecraftforge.common.util.LazyOptional; import ru.dbotthepony.mc.otm.Registry; import ru.dbotthepony.mc.otm.capability.IAndroidCapability; import ru.dbotthepony.mc.otm.capability.MatteryCapability; @@ -24,16 +23,18 @@ import java.math.BigDecimal; import java.util.List; import java.util.Optional; -public class BlockEntityAndroidStation extends BlockEntityMatteryPoweredMachine implements MenuProvider { +public class BlockEntityAndroidStation extends BlockEntityMatteryPowered implements MenuProvider { @Nullable @Override public AbstractContainerMenu createMenu(int containerID, Inventory inventory, Player ply) { return new AndroidStationMenu(containerID, inventory, this); } + private final TranslatableComponent MACHINE_NAME = new TranslatableComponent("block.overdrive_that_matters.android_station"); + @Override protected Component getDefaultDisplayName() { - return new TranslatableComponent("container.otm.android_station"); + return MACHINE_NAME; } public BlockEntityAndroidStation(BlockPos p_155229_, BlockState p_155230_) { diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityBatteryBank.java b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityBatteryBank.java index 37867959c..05281af18 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityBatteryBank.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityBatteryBank.java @@ -11,19 +11,15 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.entity.TickingBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; -import ru.dbotthepony.mc.otm.OverdriveThatMatters; import ru.dbotthepony.mc.otm.Registry; -import ru.dbotthepony.mc.otm.block.BlockMatteryRotatableMachineBase; +import ru.dbotthepony.mc.otm.block.BlockMatteryRotatable; import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage; import ru.dbotthepony.mc.otm.capability.MatteryCapability; -import ru.dbotthepony.mc.otm.capability.MatteryMachineEnergyStorage; import ru.dbotthepony.mc.otm.container.SimpleSerializableContainer; import ru.dbotthepony.mc.otm.menu.BatteryBankMenu; @@ -32,7 +28,7 @@ import javax.annotation.Nullable; import java.math.BigDecimal; import java.util.Optional; -public class BlockEntityBatteryBank extends BlockEntityMatteryMachine { +public class BlockEntityBatteryBank extends BlockEntityMattery { // 5 на 3 public SimpleSerializableContainer battery_container = new SimpleSerializableContainer(this::setChanged, 5 * 3); @@ -262,9 +258,11 @@ public class BlockEntityBatteryBank extends BlockEntityMatteryMachine { super.load(nbt); } + private final TranslatableComponent MACHINE_NAME = new TranslatableComponent("block.overdrive_that_matters.battery_bank"); + @Override protected Component getDefaultDisplayName() { - return new TranslatableComponent("container.otm.battery_bank"); + return MACHINE_NAME; } @Nullable @@ -291,7 +289,7 @@ public class BlockEntityBatteryBank extends BlockEntityMatteryMachine { if (side == null) return energy_resolver.cast(); - if (side == getBlockState().getValue(BlockMatteryRotatableMachineBase.FACING)) + if (side == getBlockState().getValue(BlockMatteryRotatable.FACING)) return energy_extractor_resolver.cast(); return energy_receiver_resolver.cast(); @@ -302,7 +300,7 @@ public class BlockEntityBatteryBank extends BlockEntityMatteryMachine { public static void tick(Level level, BlockPos blockPos, BlockState blockState, T t) { if (t instanceof BlockEntityBatteryBank tile) { - BlockEntity get_entity = level.getBlockEntity(blockPos.offset(tile.getBlockState().getValue(BlockMatteryRotatableMachineBase.FACING).getNormal())); + BlockEntity get_entity = level.getBlockEntity(blockPos.offset(tile.getBlockState().getValue(BlockMatteryRotatable.FACING).getNormal())); if (get_entity != null) { Optional cap = get_entity.getCapability(MatteryCapability.ENERGY).resolve(); diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterCapacitorBank.java b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterCapacitorBank.java new file mode 100644 index 000000000..e301ac3c0 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterCapacitorBank.java @@ -0,0 +1,239 @@ +package ru.dbotthepony.mc.otm.block.entity; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +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.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import ru.dbotthepony.mc.otm.IMatterGridCell; +import ru.dbotthepony.mc.otm.MatterGrid; +import ru.dbotthepony.mc.otm.Registry; +import ru.dbotthepony.mc.otm.capability.IMatterHandler; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.container.SimpleSerializableContainer; +import ru.dbotthepony.mc.otm.menu.MatterCapacitorBankMenu; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.math.BigDecimal; +import java.util.Optional; + +public class BlockEntityMatterCapacitorBank extends BlockEntityMattery implements IMatterGridCell { + public final IMatterHandler matter = new IMatterHandler() { + @Nonnull + @Override + public BigDecimal getStoredMatter() { + BigDecimal summ = BigDecimal.ZERO; + + for (int i = 0; i < matter_container.getContainerSize(); i++) { + ItemStack stack = matter_container.getItem(i); + + if (!stack.isEmpty()) { + Optional handler = stack.getCapability(MatteryCapability.MATTER).resolve(); + + if (handler.isPresent()) { + summ = summ.add(handler.get().getStoredMatter()); + } + } + } + + return summ; + } + + @Nonnull + @Override + public BigDecimal getMaxStoredMatter() { + BigDecimal summ = BigDecimal.ZERO; + + for (int i = 0; i < matter_container.getContainerSize(); i++) { + ItemStack stack = matter_container.getItem(i); + + if (!stack.isEmpty()) { + Optional handler = stack.getCapability(MatteryCapability.MATTER).resolve(); + + if (handler.isPresent()) { + summ = summ.add(handler.get().getMaxStoredMatter()); + } + } + } + + return summ; + } + + @Nonnull + @Override + public BigDecimal receiveMatterOuter(BigDecimal howMuch, boolean simulate) { + return receiveMatterInner(howMuch, simulate); + } + + @Nonnull + @Override + public BigDecimal receiveMatterInner(BigDecimal howMuch, boolean simulate) { + BigDecimal summ = BigDecimal.ZERO; + + for (int i = 0; i < matter_container.getContainerSize(); i++) { + ItemStack stack = matter_container.getItem(i); + + if (!stack.isEmpty()) { + Optional handler = stack.getCapability(MatteryCapability.MATTER).resolve(); + + if (handler.isPresent()) { + BigDecimal diff = handler.get().receiveMatterOuter(howMuch, simulate); + summ = summ.add(diff); + howMuch = howMuch.subtract(diff); + + if (howMuch.compareTo(BigDecimal.ZERO) == 0) { + break; + } + } + } + } + + return summ; + } + + @Nonnull + @Override + public BigDecimal extractMatterOuter(BigDecimal howMuch, boolean simulate) { + return extractMatterInner(howMuch, simulate); + } + + @Nonnull + @Override + public BigDecimal extractMatterInner(BigDecimal howMuch, boolean simulate) { + BigDecimal summ = BigDecimal.ZERO; + + for (int i = 0; i < matter_container.getContainerSize(); i++) { + ItemStack stack = matter_container.getItem(i); + + if (!stack.isEmpty()) { + Optional handler = stack.getCapability(MatteryCapability.MATTER).resolve(); + + if (handler.isPresent()) { + BigDecimal diff = handler.get().extractMatterOuter(howMuch, simulate); + summ = summ.add(diff); + howMuch = howMuch.subtract(diff); + + if (howMuch.compareTo(BigDecimal.ZERO) == 0) { + break; + } + } + } + } + + return summ; + } + + @Nonnull + @Override + public MatterDirection getDirection() { + return MatterDirection.BIDIRECTIONAL; + } + }; + + private final LazyOptional resolver = LazyOptional.of(() -> matter); + + public SimpleSerializableContainer matter_container = new SimpleSerializableContainer(this::setChanged, 5 * 3); + + public BlockEntityMatterCapacitorBank(BlockPos p_155229_, BlockState p_155230_) { + super(Registry.BlockEntities.MATTER_CAPACITOR_BANK, p_155229_, p_155230_); + } + + private final TranslatableComponent MACHINE_NAME = new TranslatableComponent("block.overdrive_that_matters.matter_capacitor_bank"); + + @Override + protected Component getDefaultDisplayName() { + return MACHINE_NAME; + } + + @Override + public CompoundTag save(CompoundTag nbt) { + nbt.put("matter_container", matter_container.serializeNBT()); + return super.save(nbt); + } + + @Override + public void load(CompoundTag nbt) { + if (nbt.contains("matter_container") && nbt.get("matter_container") instanceof CompoundTag tag) + matter_container = SimpleSerializableContainer.of(this::setChanged, tag, matter_container.getContainerSize()); + + super.load(nbt); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(int containerID, Inventory inventory, Player ply) { + return new MatterCapacitorBankMenu(containerID, inventory, this); + } + + private boolean valid = true; + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + valid = false; + } + + @Override + public void reviveCaps() { + super.reviveCaps(); + valid = true; + } + + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { + if (valid && cap == MatteryCapability.MATTER) + return resolver.cast(); + + return super.getCapability(cap, side); + } + + private MatterGrid grid; + + @Nullable + @Override + public MatterGrid getMatterGrid() { + return grid; + } + + @Override + public void setRemoved() { + super.setRemoved(); + + if (grid != null) + grid.untrack(this); + } + + @Override + public void setLevel(Level p_155231_) { + super.setLevel(p_155231_); + + if (!p_155231_.isClientSide) + MatterGrid.scheduleDiscoverNeighbours(this, getBlockPos(), p_155231_); + } + + @Nullable + @Override + public IMatterHandler getMatterHandler() { + return valid ? matter : null; + } + + @Override + public boolean isValidMatterCell() { + return valid; + } + + @Override + public void setMatterGrid(MatterGrid grid) { + this.grid = grid; + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterDecomposer.java b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterDecomposer.java index d59bf07a4..89730c83c 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterDecomposer.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatterDecomposer.java @@ -16,9 +16,7 @@ import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import ru.dbotthepony.mc.otm.MatterRegistry; -import ru.dbotthepony.mc.otm.OverdriveThatMatters; -import ru.dbotthepony.mc.otm.Registry; +import ru.dbotthepony.mc.otm.*; import ru.dbotthepony.mc.otm.capability.IMatterHandler; import ru.dbotthepony.mc.otm.capability.MatterHandlerCapability; import ru.dbotthepony.mc.otm.capability.MatteryCapability; @@ -30,7 +28,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.math.BigDecimal; -public class BlockEntityMatterDecomposer extends BlockEntityMatteryPoweredMachine implements IItemHandler { +public class BlockEntityMatterDecomposer extends BlockEntityMatteryPowered implements IItemHandler, IMatterGridCell { private static final TranslatableComponent MACHINE_NAME = new TranslatableComponent("block.overdrive_that_matters.matter_decomposer"); private boolean valid = true; public final MatterHandlerCapability matter = new MatterHandlerCapability(this::setChanged, IMatterHandler.MatterDirection.EXTRACT, new BigDecimal("20")); @@ -238,6 +236,54 @@ public class BlockEntityMatterDecomposer extends BlockEntityMatteryPoweredMachin tile.work_progress = 0; tile.work_item = ItemStack.EMPTY; } + + if (tile.matter.getStoredMatter().compareTo(BigDecimal.ZERO) > 0 && tile.grid != null) { + BigDecimal diff = tile.matter.extractMatterInner(tile.matter.getStoredMatter(), true); + BigDecimal diff2 = tile.grid.softPushMatter(diff, true); + + tile.matter.extractMatterInner(diff2, false); + tile.grid.softPushMatter(diff2, false); + } } } + + private MatterGrid grid; + + @Override + public void setRemoved() { + super.setRemoved(); + + if (level != null && !level.isClientSide && grid != null) + grid.untrack(this); + } + + @Override + public void setLevel(Level p_155231_) { + super.setLevel(p_155231_); + + if (!p_155231_.isClientSide) + MatterGrid.scheduleDiscoverNeighbours(this, getBlockPos(), p_155231_); + } + + @Nullable + @Override + public MatterGrid getMatterGrid() { + return grid; + } + + @Nullable + @Override + public IMatterHandler getMatterHandler() { + return valid ? matter : null; + } + + @Override + public boolean isValidMatterCell() { + return valid; + } + + @Override + public void setMatterGrid(MatterGrid grid) { + this.grid = grid; + } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryMachine.java b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMattery.java similarity index 82% rename from src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryMachine.java rename to src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMattery.java index 8b344605d..d161290fc 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryMachine.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMattery.java @@ -9,16 +9,18 @@ import net.minecraft.world.MenuProvider; 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.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunk; import javax.annotation.Nullable; -public abstract class BlockEntityMatteryMachine extends BlockEntity implements MenuProvider { +public abstract class BlockEntityMattery extends BlockEntity implements MenuProvider { protected Component display_name; - public BlockEntityMatteryMachine(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { + public BlockEntityMattery(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { super(p_155228_, p_155229_, p_155230_); } @@ -26,9 +28,7 @@ public abstract class BlockEntityMatteryMachine extends BlockEntity implements M display_name = text; } - protected Component getDefaultDisplayName() { - return new TranslatableComponent("container.otm.unknown"); - } + abstract protected Component getDefaultDisplayName(); @Override public Component getDisplayName() { diff --git a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryPoweredMachine.java b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryPowered.java similarity index 92% rename from src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryPoweredMachine.java rename to src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryPowered.java index d1aaa01f7..cbc8ecc34 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryPoweredMachine.java +++ b/src/main/java/ru/dbotthepony/mc/otm/block/entity/BlockEntityMatteryPowered.java @@ -3,10 +3,6 @@ package ru.dbotthepony.mc.otm.block.entity; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.StringTag; -import net.minecraft.network.chat.Component; -import net.minecraft.world.Container; -import net.minecraft.world.SimpleContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -24,7 +20,7 @@ import javax.annotation.Nullable; import java.math.BigDecimal; import java.util.Optional; -abstract public class BlockEntityMatteryPoweredMachine extends BlockEntityMatteryMachine { +abstract public class BlockEntityMatteryPowered extends BlockEntityMattery { protected MatteryMachineEnergyStorage energy = null; protected final LazyOptional energy_resolver = LazyOptional.of(() -> energy);; private boolean valid = true; @@ -91,7 +87,7 @@ abstract public class BlockEntityMatteryPoweredMachine extends BlockEntityMatter } } - public BlockEntityMatteryPoweredMachine(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { + public BlockEntityMatteryPowered(BlockEntityType p_155228_, BlockPos p_155229_, BlockState p_155230_) { super(p_155228_, p_155229_, p_155230_); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/capability/IMatterHandler.java b/src/main/java/ru/dbotthepony/mc/otm/capability/IMatterHandler.java index eb71a869b..51a5134b5 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/capability/IMatterHandler.java +++ b/src/main/java/ru/dbotthepony/mc/otm/capability/IMatterHandler.java @@ -27,4 +27,9 @@ public interface IMatterHandler { @Nonnull MatterDirection getDirection(); + + @Nonnull + default BigDecimal getMissingMatter() { + return getMaxStoredMatter().subtract(getStoredMatter()); + } } diff --git a/src/main/java/ru/dbotthepony/mc/otm/item/ItemBattery.java b/src/main/java/ru/dbotthepony/mc/otm/item/ItemBattery.java index d6d00f342..9b60d2a8a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/item/ItemBattery.java +++ b/src/main/java/ru/dbotthepony/mc/otm/item/ItemBattery.java @@ -58,7 +58,7 @@ public class ItemBattery extends Item { stack.getOrCreateTag().putString("otm_energy", value.toString()); } - BatteryMatteryCapability(ItemStack stack, BigDecimal storage, BigDecimal max_input, BigDecimal max_output) { + public BatteryMatteryCapability(ItemStack stack, BigDecimal storage, BigDecimal max_input, BigDecimal max_output) { this.stack = stack; is_creative = false; this.storage = storage; @@ -66,7 +66,7 @@ public class ItemBattery extends Item { this.max_output = max_output; } - BatteryMatteryCapability(ItemStack stack) { + public BatteryMatteryCapability(ItemStack stack) { this.stack = stack; is_creative = true; storage = MatteryCapability.LONG_MAX_VALUE; diff --git a/src/main/java/ru/dbotthepony/mc/otm/item/ItemMatterCapacitor.java b/src/main/java/ru/dbotthepony/mc/otm/item/ItemMatterCapacitor.java new file mode 100644 index 000000000..696b4499c --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/item/ItemMatterCapacitor.java @@ -0,0 +1,211 @@ +package ru.dbotthepony.mc.otm.item; + +import net.minecraft.ChatFormatting; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.item.*; +import net.minecraft.world.level.Level; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; +import ru.dbotthepony.mc.otm.capability.IMatterHandler; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; +import ru.dbotthepony.mc.otm.menu.FormattingHelper; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.math.BigDecimal; +import java.util.List; +import java.util.Objects; + +public class ItemMatterCapacitor extends Item { + public static class ItemMatterCapacitorCapability implements ICapabilityProvider, IMatterHandler { + private final LazyOptional resolver = LazyOptional.of(() -> this); + + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side) { + if (cap == MatteryCapability.MATTER) + return resolver.cast(); + + return LazyOptional.empty(); + } + private final BigDecimal storage; + private final BigDecimal max_input; + private final BigDecimal max_output; + private final boolean is_creative; + private BigDecimal energy; + private String _energy; + + private final ItemStack stack; + + private BigDecimal matter() { + CompoundTag tag = stack.getOrCreateTag(); + + if (tag.contains("otm_matter")) { + String get_energy = tag.getString("otm_matter"); + + if (Objects.equals(_energy, get_energy)) { + return energy; + } + + energy = new BigDecimal(tag.getString("otm_matter")); + _energy = get_energy; + + return energy; + } + + return BigDecimal.ZERO; + } + + private void matter(BigDecimal value) { + energy = value; + stack.getOrCreateTag().putString("otm_matter", value.toString()); + } + + public ItemMatterCapacitorCapability(ItemStack stack, BigDecimal storage, BigDecimal max_input, BigDecimal max_output) { + this.stack = stack; + is_creative = false; + this.storage = storage; + this.max_input = max_input; + this.max_output = max_output; + } + + public ItemMatterCapacitorCapability(ItemStack stack) { + this.stack = stack; + is_creative = true; + storage = MatteryCapability.LONG_MAX_VALUE; + max_input = MatteryCapability.LONG_MAX_VALUE; + max_output = MatteryCapability.LONG_MAX_VALUE; + } + + public ItemMatterCapacitorCapability(ItemStack stack, BigDecimal storage) { + this.stack = stack; + is_creative = false; + this.storage = storage; + max_input = MatteryCapability.LONG_MAX_VALUE; + max_output = MatteryCapability.LONG_MAX_VALUE; + } + + @Nonnull + @Override + public BigDecimal getStoredMatter() { + if (is_creative) + return MatteryCapability.LONG_MAX_VALUE; + + return matter(); + } + + @Nonnull + @Override + public BigDecimal getMaxStoredMatter() { + if (is_creative) + return MatteryCapability.LONG_MAX_VALUE; + + return storage; + } + + @Nonnull + @Override + public BigDecimal getMissingMatter() { + if (is_creative) + return MatteryCapability.LONG_MAX_VALUE; + + return IMatterHandler.super.getMissingMatter(); + } + + @Nonnull + @Override + public BigDecimal receiveMatterOuter(BigDecimal howMuch, boolean simulate) { + return receiveMatterInner(howMuch, simulate); + } + + @Nonnull + @Override + public BigDecimal receiveMatterInner(BigDecimal howMuch, boolean simulate) { + if (is_creative) + return howMuch; + + BigDecimal new_matter = matter().add(howMuch.min(max_input), MatteryCapability.ROUND_RULES).min(storage); + BigDecimal diff = new_matter.subtract(matter()); + + if (!simulate) { + matter(new_matter); + } + + return diff; + } + + @Nonnull + @Override + public BigDecimal extractMatterOuter(BigDecimal howMuch, boolean simulate) { + return extractMatterInner(howMuch, simulate); + } + + @Nonnull + @Override + public BigDecimal extractMatterInner(BigDecimal howMuch, boolean simulate) { + if (is_creative) + return howMuch; + + + BigDecimal new_matter = matter().subtract(howMuch.min(max_output), MatteryCapability.ROUND_RULES).max(BigDecimal.ZERO); + BigDecimal diff = matter().subtract(new_matter); + + if (!simulate) { + matter(new_matter); + } + + return diff; + } + + @Nonnull + @Override + public MatterDirection getDirection() { + return MatterDirection.BIDIRECTIONAL; + } + } + + public final BigDecimal storage; + + private static final Component INFINITE_STORAGE = new TranslatableComponent("otm.item.matter.infinite").withStyle(ChatFormatting.GRAY); + + private final boolean is_creative; + + public ItemMatterCapacitor(BigDecimal storage) { + super(new Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)); + is_creative = false; + this.storage = storage; + } + + public ItemMatterCapacitor() { + super(new Properties().stacksTo(64).tab(CreativeModeTab.TAB_MISC)); + is_creative = true; + storage = MatteryCapability.LONG_MAX_VALUE; + } + + @Override + public void appendHoverText(ItemStack stack, @Nullable Level p_41422_, List p_41423_, TooltipFlag p_41424_) { + super.appendHoverText(stack, p_41422_, p_41423_, p_41424_); + + if (is_creative) { + p_41423_.add(INFINITE_STORAGE); + } else { + if (stack.getCapability(MatteryCapability.MATTER).resolve().get() instanceof ItemMatterCapacitorCapability cap) + p_41423_.add(new TranslatableComponent("otm.item.matter.normal", FormattingHelper.formatMatterValuePlain(cap.getStoredMatter()), FormattingHelper.formatMatterValuePlain(storage)).withStyle(ChatFormatting.GRAY)); + else + p_41423_.add(new TranslatableComponent("otm.item.matter.normal", "???", FormattingHelper.formatMatterValuePlain(storage)).withStyle(ChatFormatting.GRAY)); + } + } + + @Nullable + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) { + if (is_creative) + return new ItemMatterCapacitorCapability(stack); + + return new ItemMatterCapacitorCapability(stack, storage); + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.java b/src/main/java/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.java index f5d71d25f..06ac7d162 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.java +++ b/src/main/java/ru/dbotthepony/mc/otm/menu/BatteryBankMenu.java @@ -37,7 +37,7 @@ public class BatteryBankMenu extends MatteryMenu { for (int row = 0; row < 3; row++) for (int column = 0; column < 5; column++) - this.addSlot(new BatterySlot(batteries, row * 5 + column, 62 + column * 18, 24 + row * 18)); + this.addSlot(new BatterySlot(batteries, row * 5 + column, 64 + column * 18, 24 + row * 18)); addInventorySlots(); } diff --git a/src/main/java/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.java b/src/main/java/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.java new file mode 100644 index 000000000..4b131e401 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/menu/MatterCapacitorBankMenu.java @@ -0,0 +1,51 @@ +package ru.dbotthepony.mc.otm.menu; + +import net.minecraft.world.Container; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.level.block.entity.BlockEntity; +import ru.dbotthepony.mc.otm.Registry; +import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterCapacitorBank; +import ru.dbotthepony.mc.otm.capability.IMatterHandler; +import ru.dbotthepony.mc.otm.menu.slot.MachineInputSlot; +import ru.dbotthepony.mc.otm.menu.slot.MatterContainerInputSlot; +import ru.dbotthepony.mc.otm.menu.widget.MatterLevelWidget; + +import javax.annotation.Nullable; + +public class MatterCapacitorBankMenu extends MatteryMenu { + public MatterCapacitorBankMenu(int p_38852_, Inventory inventory) { + this(p_38852_, inventory, null); + } + + public MatterLevelWidget matter; + + public MatterCapacitorBankMenu(int p_38852_, Inventory inventory, BlockEntityMatterCapacitorBank tile) { + super(Registry.Menus.MATTER_CAPACITOR_BANK, p_38852_, inventory, tile); + + if (tile == null) { + matter = new MatterLevelWidget<>(this, 14, 20); + } else { + matter = new MatterLevelWidget<>(this, 14, 20, tile.matter); + } + + Container container = tile != null ? tile.matter_container : new SimpleContainer(5 * 3); + + for (int row = 0; row < 3; row++) + for (int column = 0; column < 5; column++) + this.addSlot(new MatterContainerInputSlot(container, row * 5 + column, 64 + column * 18, 20 + row * 18, true, IMatterHandler.MatterDirection.BIDIRECTIONAL)); + + addInventorySlots(); + } + + @Override + protected int getWorkingSlotStart() { + return 0; + } + + @Override + protected int getWorkingSlotEnd() { + return 16; + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.java b/src/main/java/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.java index 79154f847..257944aa1 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.java +++ b/src/main/java/ru/dbotthepony/mc/otm/menu/MatterDecomposerMenu.java @@ -3,19 +3,13 @@ package ru.dbotthepony.mc.otm.menu; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.inventory.ContainerData; -import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import ru.dbotthepony.mc.otm.MatterRegistry; import ru.dbotthepony.mc.otm.Registry; import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatterDecomposer; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatteryPoweredMachine; import ru.dbotthepony.mc.otm.capability.MatteryCapability; -import ru.dbotthepony.mc.otm.menu.data.BigDecimalDataContainer; import ru.dbotthepony.mc.otm.menu.slot.MachineInputSlot; import ru.dbotthepony.mc.otm.menu.slot.MachineOutputSlot; -import ru.dbotthepony.mc.otm.menu.widget.BatteryLevelWidget; import ru.dbotthepony.mc.otm.menu.widget.MatterLevelWidget; import ru.dbotthepony.mc.otm.menu.widget.ProgressGaugeWidget; diff --git a/src/main/java/ru/dbotthepony/mc/otm/menu/MatteryMenu.java b/src/main/java/ru/dbotthepony/mc/otm/menu/MatteryMenu.java index 22d09a11a..6a5059f3e 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/menu/MatteryMenu.java +++ b/src/main/java/ru/dbotthepony/mc/otm/menu/MatteryMenu.java @@ -9,7 +9,6 @@ import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatteryMachine; import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget; import javax.annotation.Nullable; diff --git a/src/main/java/ru/dbotthepony/mc/otm/menu/PoweredMatteryMenu.java b/src/main/java/ru/dbotthepony/mc/otm/menu/PoweredMatteryMenu.java index d2b35e226..b110e7f7c 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/menu/PoweredMatteryMenu.java +++ b/src/main/java/ru/dbotthepony/mc/otm/menu/PoweredMatteryMenu.java @@ -4,20 +4,15 @@ import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.MenuType; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.common.util.LazyOptional; -import ru.dbotthepony.mc.otm.OverdriveThatMatters; -import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatteryPoweredMachine; -import ru.dbotthepony.mc.otm.capability.IMatteryEnergyStorage; +import ru.dbotthepony.mc.otm.block.entity.BlockEntityMatteryPowered; import ru.dbotthepony.mc.otm.capability.MatteryCapability; -import ru.dbotthepony.mc.otm.menu.data.BigDecimalDataContainer; import ru.dbotthepony.mc.otm.menu.slot.BatterySlot; import ru.dbotthepony.mc.otm.menu.widget.BatteryLevelWidget; import javax.annotation.Nullable; abstract public class PoweredMatteryMenu extends MatteryMenu { - protected BlockEntityMatteryPoweredMachine tile; + protected BlockEntityMatteryPowered tile; public BatteryLevelWidget battery_widget; @@ -25,7 +20,7 @@ abstract public class PoweredMatteryMenu extends MatteryMenu { @Nullable MenuType menuType, int containerID, Inventory inventory, - @Nullable BlockEntityMatteryPoweredMachine tile + @Nullable BlockEntityMatteryPowered tile ) { super(menuType, containerID, inventory, tile); this.tile = tile; diff --git a/src/main/java/ru/dbotthepony/mc/otm/menu/slot/MatterContainerInputSlot.java b/src/main/java/ru/dbotthepony/mc/otm/menu/slot/MatterContainerInputSlot.java new file mode 100644 index 000000000..b3723668b --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/menu/slot/MatterContainerInputSlot.java @@ -0,0 +1,32 @@ +package ru.dbotthepony.mc.otm.menu.slot; + +import net.minecraft.world.Container; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import ru.dbotthepony.mc.otm.capability.IMatterHandler; +import ru.dbotthepony.mc.otm.capability.MatteryCapability; + +import java.util.Optional; + +public class MatterContainerInputSlot extends Slot { + public boolean auto_bg; + public IMatterHandler.MatterDirection desired_direction; + + public MatterContainerInputSlot(Container p_40223_, int p_40224_, int p_40225_, int p_40226_, boolean auto_bg, IMatterHandler.MatterDirection desired_direction) { + super(p_40223_, p_40224_, p_40225_, p_40226_); + this.auto_bg = auto_bg; + this.desired_direction = desired_direction; + } + + @Override + public boolean mayPlace(ItemStack p_40231_) { + Optional handler = p_40231_.getCapability(MatteryCapability.MATTER).resolve(); + + if (handler.isEmpty()) + return false; + + IMatterHandler.MatterDirection direction = handler.get().getDirection(); + + return direction == IMatterHandler.MatterDirection.BIDIRECTIONAL || desired_direction == direction; + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/network/AndroidCapabilityChangePacket.java b/src/main/java/ru/dbotthepony/mc/otm/network/AndroidCapabilityChangePacket.java index ba3bfe749..77a9a75d6 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/network/AndroidCapabilityChangePacket.java +++ b/src/main/java/ru/dbotthepony/mc/otm/network/AndroidCapabilityChangePacket.java @@ -23,14 +23,6 @@ public class AndroidCapabilityChangePacket { IS_ANDROID, } - public static ChangeType[] CHANGE_MAP = new ChangeType[] { - ChangeType.TERMINATION, - ChangeType.ENERGY_CHANGED, - ChangeType.MAX_ENERGY_CHANGED, - ChangeType.BATTERY_STACK_CHANGED, - ChangeType.IS_ANDROID, - }; - public BigDecimal energy; public BigDecimal max_energy; public ItemStack battery; @@ -95,7 +87,7 @@ public class AndroidCapabilityChangePacket { public static AndroidCapabilityChangePacket decodeNetwork(FriendlyByteBuf buffer) { AndroidCapabilityChangePacket packet = new AndroidCapabilityChangePacket(); - ChangeType read = CHANGE_MAP[buffer.readByte()]; + ChangeType read = ChangeType.values()[buffer.readByte()]; while (read != ChangeType.TERMINATION) { switch (read) { @@ -105,7 +97,7 @@ public class AndroidCapabilityChangePacket { case IS_ANDROID -> packet.is_android = buffer.readByte() > 0; } - read = CHANGE_MAP[buffer.readByte()]; + read = ChangeType.values()[buffer.readByte()]; } return packet; diff --git a/src/main/java/ru/dbotthepony/mc/otm/screen/MatterCapacitorBankScreen.java b/src/main/java/ru/dbotthepony/mc/otm/screen/MatterCapacitorBankScreen.java new file mode 100644 index 000000000..6e669f269 --- /dev/null +++ b/src/main/java/ru/dbotthepony/mc/otm/screen/MatterCapacitorBankScreen.java @@ -0,0 +1,11 @@ +package ru.dbotthepony.mc.otm.screen; + +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Inventory; +import ru.dbotthepony.mc.otm.menu.MatterCapacitorBankMenu; + +public class MatterCapacitorBankScreen extends MatteryScreen { + public MatterCapacitorBankScreen(MatterCapacitorBankMenu p_97741_, Inventory p_97742_, Component p_97743_) { + super(p_97741_, p_97742_, p_97743_); + } +} diff --git a/src/main/java/ru/dbotthepony/mc/otm/screen/MatteryScreen.java b/src/main/java/ru/dbotthepony/mc/otm/screen/MatteryScreen.java index 630714365..908bb0b5a 100644 --- a/src/main/java/ru/dbotthepony/mc/otm/screen/MatteryScreen.java +++ b/src/main/java/ru/dbotthepony/mc/otm/screen/MatteryScreen.java @@ -17,6 +17,7 @@ import ru.dbotthepony.mc.otm.menu.MatteryMenu; import ru.dbotthepony.mc.otm.menu.slot.BatterySlot; import ru.dbotthepony.mc.otm.menu.slot.MachineInputSlot; import ru.dbotthepony.mc.otm.menu.slot.MachineOutputSlot; +import ru.dbotthepony.mc.otm.menu.slot.MatterContainerInputSlot; import ru.dbotthepony.mc.otm.menu.widget.AbstractWidget; import java.math.BigDecimal; @@ -107,6 +108,8 @@ public class MatteryScreen extends AbstractContainerScree } } else if (slot instanceof MachineInputSlot slot1 && slot1.auto_bg) { renderRegularSlot(pose, slot1.x, slot1.y); + } else if (slot instanceof MatterContainerInputSlot slot1 && slot1.auto_bg) { + renderRegularSlot(pose, slot1.x, slot1.y); } } diff --git a/src/main/resources/assets/overdrive_that_matters/blockstates/battery_bank.json b/src/main/resources/assets/overdrive_that_matters/blockstates/battery_bank.json new file mode 100644 index 000000000..d3754dddd --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/blockstates/battery_bank.json @@ -0,0 +1,19 @@ +{ + "variants": { + "facing=south": { + "model": "overdrive_that_matters:block/battery_bank" + }, + "facing=west": { + "model": "overdrive_that_matters:block/battery_bank", + "y": 90 + }, + "facing=north": { + "model": "overdrive_that_matters:block/battery_bank", + "y": 180 + }, + "facing=east": { + "model": "overdrive_that_matters:block/battery_bank", + "y": 270 + } + } +} diff --git a/src/main/resources/assets/overdrive_that_matters/lang/en_us.json b/src/main/resources/assets/overdrive_that_matters/lang/en_us.json index d24a2755a..0bfbc7a43 100644 --- a/src/main/resources/assets/overdrive_that_matters/lang/en_us.json +++ b/src/main/resources/assets/overdrive_that_matters/lang/en_us.json @@ -18,6 +18,9 @@ "otm.item.power.normal.storage": "Stored energy: %s / %s", "otm.item.power.normal.throughput": "Max I/O %s / %s", + "otm.item.matter.infinite": "Stored matter: Infinity / Infinity", + "otm.item.matter.normal": "Stored matter: %s / %s", + "otm.suffix.merge": "%s %s", "otm.suffix.kilo": "%s k%s", @@ -40,12 +43,10 @@ "otm.suffix.zepto": "%s z%s", "otm.suffix.yocto": "%s y%s", - "container.otm.android_station": "Android station", - "container.otm.battery_bank": "Battery bank", - "block.overdrive_that_matters.android_station": "Android station", "block.overdrive_that_matters.battery_bank": "Battery bank", "block.overdrive_that_matters.matter_decomposer": "Matter decomposer", + "block.overdrive_that_matters.matter_capacitor_bank": "Matter capacitor bank", "item.overdrive_that_matters.pill_android": "Android pill", "item.overdrive_that_matters.pill_humane": "Humane pill", @@ -55,5 +56,8 @@ "item.overdrive_that_matters.battery_normal": "Ordinary Battery", "item.overdrive_that_matters.battery_dense": "Dense Battery", "item.overdrive_that_matters.battery_capacitor": "Capacitor Battery", - "item.overdrive_that_matters.battery_creative": "Creative Battery" + "item.overdrive_that_matters.battery_creative": "Creative Battery", + + "item.overdrive_that_matters.matter_capacitor_normal": "Matter capacitor", + "item.overdrive_that_matters.matter_capacitor_creative": "Creative matter capacitor" } \ No newline at end of file diff --git a/src/main/resources/assets/overdrive_that_matters/models/block/battery_bank.json b/src/main/resources/assets/overdrive_that_matters/models/block/battery_bank.json new file mode 100644 index 000000000..075eaedef --- /dev/null +++ b/src/main/resources/assets/overdrive_that_matters/models/block/battery_bank.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "overdrive_that_matters:block/debug/side", + "south": "overdrive_that_matters:block/debug/front" + } +} diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/debug/front.png b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/front.png new file mode 100644 index 000000000..e5fb3f51c Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/front.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/debug/front.xcf b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/front.xcf new file mode 100644 index 000000000..d45befcbe Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/front.xcf differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/debug/side.png b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/side.png new file mode 100644 index 000000000..7b6bd5d8a Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/side.png differ diff --git a/src/main/resources/assets/overdrive_that_matters/textures/block/debug/side.xcf b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/side.xcf new file mode 100644 index 000000000..c232994a6 Binary files /dev/null and b/src/main/resources/assets/overdrive_that_matters/textures/block/debug/side.xcf differ