Fixed some machines not keeping energy when broken.

More left todo.
This commit is contained in:
Flanks255 2024-11-05 20:54:40 -06:00
parent 65d660ad08
commit c1e274db4f
15 changed files with 155 additions and 26 deletions

View file

@ -1,3 +1,13 @@
# 1.3.10+mc1.21.1
* Fixed some machines not holding power when broken, The following machines now keep their stored energy when broken:
* Coal Generator
* Oil Generator
* Leaf eating generator
* Crushers
* Display Stand
* Powered Furnace
* Atomic Reconstructor
# 1.3.9+mc1.21.1 # 1.3.9+mc1.21.1
* Change laser rendering to be compatible with Iris * Change laser rendering to be compatible with Iris
* Fix machines in the Engineer House being obtainable when broken * Fix machines in the Engineer House being obtainable when broken

View file

@ -4,7 +4,7 @@ org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true
org.gradle.configuration-cache=false org.gradle.configuration-cache=false
mod_version=1.3.9 mod_version=1.3.10
# Forge # Forge
game_version=1.21.1 game_version=1.21.1

View file

@ -1,4 +1,4 @@
// 1.21.1 2024-10-16T22:24:12.9580535 Loot Tables // 1.21.1 2024-11-05T20:37:45.5911624 Loot Tables
ef11aa79a2f96a47250f46811f8491fd34d627f9 data/actuallyadditions/loot_table/blocks/atomic_reconstructor.json ef11aa79a2f96a47250f46811f8491fd34d627f9 data/actuallyadditions/loot_table/blocks/atomic_reconstructor.json
e15c868b26b669c30365bfb93e7d9274e07df16d data/actuallyadditions/loot_table/blocks/battery_box.json e15c868b26b669c30365bfb93e7d9274e07df16d data/actuallyadditions/loot_table/blocks/battery_box.json
745d64af3b0203a138f9eca7de21ed4988b35c95 data/actuallyadditions/loot_table/blocks/bio_reactor.json 745d64af3b0203a138f9eca7de21ed4988b35c95 data/actuallyadditions/loot_table/blocks/bio_reactor.json
@ -91,7 +91,7 @@ af0cb5ad3473b274da2873d3e08da0f4085e6699 data/actuallyadditions/loot_table/block
04f2ec311197a6e8770d30704448ee6abba70e32 data/actuallyadditions/loot_table/blocks/laser_relay_item_advanced.json 04f2ec311197a6e8770d30704448ee6abba70e32 data/actuallyadditions/loot_table/blocks/laser_relay_item_advanced.json
395d67efbd229f614c51bd96f637797f035cc7e3 data/actuallyadditions/loot_table/blocks/lava_factory_casing.json 395d67efbd229f614c51bd96f637797f035cc7e3 data/actuallyadditions/loot_table/blocks/lava_factory_casing.json
f8a03e56a032e858126f1b1861ea0b759a3e517d data/actuallyadditions/loot_table/blocks/lava_factory_controller.json f8a03e56a032e858126f1b1861ea0b759a3e517d data/actuallyadditions/loot_table/blocks/lava_factory_controller.json
82e3d0039b6702d62c5460953426812d798cdc37 data/actuallyadditions/loot_table/blocks/leaf_generator.json b5acba2bc0fc0ba58b60b1c929bb67a1a8fe96cb data/actuallyadditions/loot_table/blocks/leaf_generator.json
27ba42bb0f2dca72e29393944b61e566d758a2dc data/actuallyadditions/loot_table/blocks/long_range_breaker.json 27ba42bb0f2dca72e29393944b61e566d758a2dc data/actuallyadditions/loot_table/blocks/long_range_breaker.json
43113c67b268280ce09b9c90df83f33c15bf2f06 data/actuallyadditions/loot_table/blocks/oil_generator.json 43113c67b268280ce09b9c90df83f33c15bf2f06 data/actuallyadditions/loot_table/blocks/oil_generator.json
f0905fdc46775bb0d7382375b0a1109d125175e7 data/actuallyadditions/loot_table/blocks/palis_crystal_block.json f0905fdc46775bb0d7382375b0a1109d125175e7 data/actuallyadditions/loot_table/blocks/palis_crystal_block.json

View file

@ -14,6 +14,15 @@
"name": "actuallyadditions:leaf_generator" "name": "actuallyadditions:leaf_generator"
} }
], ],
"functions": [
{
"function": "minecraft:copy_components",
"include": [
"actuallyadditions:energy"
],
"source": "block_entity"
}
],
"rolls": 1.0 "rolls": 1.0
} }
], ],

View file

@ -75,6 +75,7 @@ public class LootTableGenerator extends LootTableProvider {
dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND); dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND);
dropKeepEnergy(ActuallyBlocks.COAL_GENERATOR); dropKeepEnergy(ActuallyBlocks.COAL_GENERATOR);
dropKeepEnergy(ActuallyBlocks.OIL_GENERATOR); dropKeepEnergy(ActuallyBlocks.OIL_GENERATOR);
dropKeepEnergy(ActuallyBlocks.LEAF_GENERATOR);
dropKeepEnergy(ActuallyBlocks.CRUSHER); dropKeepEnergy(ActuallyBlocks.CRUSHER);
dropKeepEnergy(ActuallyBlocks.CRUSHER_DOUBLE); dropKeepEnergy(ActuallyBlocks.CRUSHER_DOUBLE);
dropKeepEnergy(ActuallyBlocks.POWERED_FURNACE); dropKeepEnergy(ActuallyBlocks.POWERED_FURNACE);
@ -114,7 +115,6 @@ public class LootTableGenerator extends LootTableProvider {
this.dropSelf(ActuallyBlocks.PHANTOM_BOOSTER.get()); this.dropSelf(ActuallyBlocks.PHANTOM_BOOSTER.get());
this.dropSelf(ActuallyBlocks.RANGED_COLLECTOR.get()); this.dropSelf(ActuallyBlocks.RANGED_COLLECTOR.get());
this.dropSelf(ActuallyBlocks.LONG_RANGE_BREAKER.get()); this.dropSelf(ActuallyBlocks.LONG_RANGE_BREAKER.get());
this.dropSelf(ActuallyBlocks.LEAF_GENERATOR.get());
this.dropSelf(ActuallyBlocks.XP_SOLIDIFIER.get()); this.dropSelf(ActuallyBlocks.XP_SOLIDIFIER.get());
this.dropSelf(ActuallyBlocks.LASER_RELAY.get()); this.dropSelf(ActuallyBlocks.LASER_RELAY.get());
this.dropSelf(ActuallyBlocks.LASER_RELAY_ADVANCED.get()); this.dropSelf(ActuallyBlocks.LASER_RELAY_ADVANCED.get());

View file

@ -1,12 +1,11 @@
package de.ellpeck.actuallyadditions.mod.blocks; package de.ellpeck.actuallyadditions.mod.blocks;
import net.minecraft.core.component.DataComponents; import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemNameBlockItem; import net.minecraft.world.item.ItemNameBlockItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -38,12 +37,8 @@ public class AABlockItem extends BlockItem {
public void appendHoverText(ItemStack pStack, @Nullable TooltipContext pContext, List<Component> pTooltip, TooltipFlag pFlag) { public void appendHoverText(ItemStack pStack, @Nullable TooltipContext pContext, List<Component> pTooltip, TooltipFlag pFlag) {
super.appendHoverText(pStack, pContext, pTooltip, pFlag); super.appendHoverText(pStack, pContext, pTooltip, pFlag);
if (pStack.has(DataComponents.BLOCK_ENTITY_DATA)) { if (pStack.has(ActuallyComponents.ENERGY_STORAGE)) {
CustomData customData = pStack.get(DataComponents.BLOCK_ENTITY_DATA); int energy = pStack.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0);
int energy = 0;
if (customData.contains("Energy")) {
energy = customData.copyTag().getInt("Energy");
}
NumberFormat format = NumberFormat.getInstance(); NumberFormat format = NumberFormat.getInstance();
pTooltip.add(Component.translatable("misc.actuallyadditions.power_single", format.format(energy))); pTooltip.add(Component.translatable("misc.actuallyadditions.power_single", format.format(energy)));
} }

View file

@ -126,7 +126,7 @@ public final class ActuallyBlocks {
(b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityCoalGenerator::new); (b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityCoalGenerator::new);
public static final AABlockReg<BlockLeafGenerator, AABlockItem, TileEntityLeafGenerator> LEAF_GENERATOR = new AABlockReg<>("leaf_generator", BlockLeafGenerator::new, public static final AABlockReg<BlockLeafGenerator, AABlockItem, TileEntityLeafGenerator> LEAF_GENERATOR = new AABlockReg<>("leaf_generator", BlockLeafGenerator::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties) , TileEntityLeafGenerator::new); (b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties) , TileEntityLeafGenerator::new);
public static final AABlockReg<BlockXPSolidifier, AABlockItem, TileEntityXPSolidifier> XP_SOLIDIFIER = new AABlockReg<>("xp_solidifier", BlockXPSolidifier::new, public static final AABlockReg<BlockXPSolidifier, AABlockItem, TileEntityXPSolidifier> XP_SOLIDIFIER = new AABlockReg<>("xp_solidifier", BlockXPSolidifier::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityXPSolidifier::new); (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityXPSolidifier::new);

View file

@ -14,10 +14,10 @@ import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock; import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud; import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.IBlockHud;
import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.ReconstructorHud; import de.ellpeck.actuallyadditions.mod.blocks.blockhuds.ReconstructorHud;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.component.DataComponents;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
@ -27,7 +27,6 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
@ -154,19 +153,14 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
String base = block.getDescriptionId() + ".info."; String base = block.getDescriptionId() + ".info.";
pTooltip.add(Component.translatable(base + "1." + this.toPick1).append(" ").append(Component.translatable(base + "2." + this.toPick2)).withStyle(s -> s.withColor(ChatFormatting.GRAY))); pTooltip.add(Component.translatable(base + "1." + this.toPick1).append(" ").append(Component.translatable(base + "2." + this.toPick2)).withStyle(s -> s.withColor(ChatFormatting.GRAY)));
if (pStack.has(DataComponents.CUSTOM_DATA) ) { if (pStack.has(ActuallyComponents.ENERGY_STORAGE) ) {
CustomData customData = pStack.get(DataComponents.CUSTOM_DATA); int energy = pStack.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0);
int energy = 0;
if (customData.contains("Energy")) {
energy = customData.copyTag().getInt("Energy");
}
NumberFormat format = NumberFormat.getInstance(); NumberFormat format = NumberFormat.getInstance();
pTooltip.add(Component.translatable("misc.actuallyadditions.power_single", format.format(energy)).withStyle(ChatFormatting.GRAY)); pTooltip.add(Component.translatable("misc.actuallyadditions.power_single", format.format(energy)).withStyle(ChatFormatting.GRAY));
if (customData.contains("IsPulseMode")) {
pTooltip.add(Component.translatable("info.actuallyadditions.redstoneMode").append(": ")
.append(Component.translatable(customData.copyTag().getBoolean("IsPulseMode")?"info.actuallyadditions.redstoneMode.pulse":"info.actuallyadditions.redstoneMode.deactivation").withStyle($ -> $.withColor(ChatFormatting.RED))));
} }
if (pStack.has(ActuallyComponents.PULSE_MODE)) {
pTooltip.add(Component.translatable("info.actuallyadditions.redstoneMode").append(": ")
.append(Component.translatable(pStack.getOrDefault(ActuallyComponents.PULSE_MODE, false)?"info.actuallyadditions.redstoneMode.pulse":"info.actuallyadditions.redstoneMode.deactivation").withStyle($ -> $.withColor(ChatFormatting.RED))));
} }
} }

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.AASounds; import de.ellpeck.actuallyadditions.mod.AASounds;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer; import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
@ -23,6 +24,7 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -33,6 +35,8 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
import javax.annotation.Nonnull;
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor { public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor {
public static final int ENERGY_USE = 1000; public static final int ENERGY_USE = 1000;
@ -222,4 +226,20 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
public IEnergyStorage getEnergyStorage(Direction facing) { public IEnergyStorage getEnergyStorage(Direction facing) {
return this.storage; return this.storage;
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
this.isPulseMode = input.getOrDefault(ActuallyComponents.PULSE_MODE, false);
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
builder.set(ActuallyComponents.PULSE_MODE, isPulseMode);
}
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe; import de.ellpeck.actuallyadditions.mod.crafting.SolidFuelRecipe;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator; import de.ellpeck.actuallyadditions.mod.inventory.ContainerCoalGenerator;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor;
@ -20,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@ -34,6 +36,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class TileEntityCoalGenerator extends TileEntityInventoryBase implements MenuProvider, ISharingEnergyProvider, IEnergyDisplay { public class TileEntityCoalGenerator extends TileEntityInventoryBase implements MenuProvider, ISharingEnergyProvider, IEnergyDisplay {
@ -209,4 +212,18 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
public boolean needsHoldShift() { public boolean needsHoldShift() {
return false; return false;
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
}
} }

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.AASounds; import de.ellpeck.actuallyadditions.mod.AASounds;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe; import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
import de.ellpeck.actuallyadditions.mod.inventory.CrusherContainer; import de.ellpeck.actuallyadditions.mod.inventory.CrusherContainer;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
@ -22,6 +23,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -38,6 +40,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Optional; import java.util.Optional;
@ -289,4 +292,18 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
public AbstractContainerMenu createMenu(int windowId, Inventory playerInventory, Player player) { public AbstractContainerMenu createMenu(int windowId, Inventory playerInventory, Player player) {
return new CrusherContainer(windowId, playerInventory, this); return new CrusherContainer(windowId, playerInventory, this);
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
}
} }

View file

@ -12,9 +12,11 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
@ -25,6 +27,8 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
import javax.annotation.Nonnull;
public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay { public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay {
public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000, 0); public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000, 0);
@ -114,4 +118,18 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
public ItemStack getStack() { public ItemStack getStack() {
return this.inv.getStackInSlot(0); return this.inv.getStackInSlot(0);
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
}
} }

View file

@ -11,11 +11,13 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer; import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
@ -27,6 +29,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.energy.IEnergyStorage; import net.neoforged.neoforge.energy.IEnergyStorage;
import javax.annotation.Nonnull;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -137,4 +140,18 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
public IEnergyStorage getEnergyStorage(Direction facing) { public IEnergyStorage getEnergyStorage(Direction facing) {
return this.storage; return this.storage;
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
}
} }

View file

@ -12,12 +12,14 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.config.CommonConfig; import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe; import de.ellpeck.actuallyadditions.mod.crafting.LiquidFuelRecipe;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator; import de.ellpeck.actuallyadditions.mod.inventory.ContainerOilGenerator;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider; import net.minecraft.world.MenuProvider;
@ -229,4 +231,18 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
public AbstractContainerMenu createMenu(int windowId, Inventory playerInventory, Player player) { public AbstractContainerMenu createMenu(int windowId, Inventory playerInventory, Player player) {
return new ContainerOilGenerator(windowId, playerInventory, this); return new ContainerOilGenerator(windowId, playerInventory, this);
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
}
} }

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
@ -20,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider; import net.minecraft.world.MenuProvider;
@ -264,4 +266,18 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
public AbstractContainerMenu createMenu(int windowId, @Nonnull Inventory playerInventory, @Nonnull Player player) { public AbstractContainerMenu createMenu(int windowId, @Nonnull Inventory playerInventory, @Nonnull Player player) {
return new ContainerFurnaceDouble(windowId, playerInventory, this); return new ContainerFurnaceDouble(windowId, playerInventory, this);
} }
@Override
protected void applyImplicitComponents(@Nonnull DataComponentInput input) {
super.applyImplicitComponents(input);
storage.setEnergyStored(input.getOrDefault(ActuallyComponents.ENERGY_STORAGE, 0));
}
@Override
protected void collectImplicitComponents(@Nonnull DataComponentMap.Builder builder) {
super.collectImplicitComponents(builder);
builder.set(ActuallyComponents.ENERGY_STORAGE, storage.getEnergyStored());
}
} }