Atomic Reconstructor fixes, saves energy when mined, also saves redstone mode, and restores on placement, more to come.

This commit is contained in:
Flanks255 2022-10-12 17:49:01 -05:00
parent c15fbab60b
commit 6825fa3d4a
8 changed files with 55 additions and 11 deletions

View file

@ -454,7 +454,7 @@ f657eabc7321de0b05cf92d9ebdd6f5215a685b5 assets/actuallyadditions/models/item/wo
7f8e5e703d9244222706c52d7b24b299e07cb2db assets/actuallyadditions/models/item/worm.json
0b1ab8963077c90a5104b516eab36e56c8a07057 assets/actuallyadditions/models/item/xp_solidifier.json
ecf1cc8efe1f425334e8e07a6c747641c714c92c assets/actuallyadditions/sounds.json
9a7897ef54a7b27d06db0cbb412465fd1e71b9fe data/actuallyadditions/loot_tables/blocks/atomic_reconstructor.json
cfe30d630abb33959f24b3296a31a6dfe1e8fd49 data/actuallyadditions/loot_tables/blocks/atomic_reconstructor.json
de3c64d6a363f8e27078d7f7df1a67e4931fd81c data/actuallyadditions/loot_tables/blocks/battery_box.json
fb968dc63f2d0a467eff504f3f6ff386080e2433 data/actuallyadditions/loot_tables/blocks/bio_reactor.json
a1b62291e361451916e45a97bb499ecb1b6eb595 data/actuallyadditions/loot_tables/blocks/black_quartz_block.json

View file

@ -6,6 +6,34 @@
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_name",
"source": "block_entity"
},
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "Energy",
"target": "BlockEntityTag.Energy",
"op": "replace"
}
]
},
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "IsPulseMode",
"target": "BlockEntityTag.IsPulseMode",
"op": "replace"
}
]
}
],
"name": "actuallyadditions:atomic_reconstructor"
}
],

View file

@ -17,6 +17,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.loot.*;
import net.minecraft.loot.conditions.BlockStateProperty;
import net.minecraft.loot.functions.CopyName;
import net.minecraft.loot.functions.CopyNbt;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject;
@ -59,7 +61,15 @@ public class LootTableGenerator extends LootTableProvider {
this.dropSelf(ActuallyBlocks.ITEM_INTERFACE.get());
this.dropSelf(ActuallyBlocks.FIREWORK_BOX.get());
this.dropSelf(ActuallyBlocks.VERTICAL_DIGGER.get());
this.dropSelf(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get());
//this.dropSelf(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get());
this.add(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get(), LootTable.lootTable()
.withPool(applyExplosionCondition(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get(), LootPool.lootPool().setRolls(ConstantRange.exactly(1)))
.add(ItemLootEntry.lootTableItem(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get())
.apply(CopyName.copyName(CopyName.Source.BLOCK_ENTITY)).apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY).copy("Energy", "BlockEntityTag.Energy"))
.apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY).copy("IsPulseMode", "BlockEntityTag.IsPulseMode")))));
this.dropSelf(ActuallyBlocks.ENERGIZER.get());
this.dropSelf(ActuallyBlocks.ENERVATOR.get());
this.dropSelf(ActuallyBlocks.LAVA_FACTORY_CONTROLLER.get());

View file

@ -65,7 +65,7 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
ItemStack heldItem = player.getItemInHand(hand);
if (this.tryToggleRedstone(world, pos, player)) {
return ActionResultType.PASS;
return ActionResultType.CONSUME;
}
if (!world.isClientSide) {
TileEntityAtomicReconstructor reconstructor = (TileEntityAtomicReconstructor) world.getBlockEntity(pos);
@ -159,6 +159,15 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
String base = block.getDescriptionId() + ".info.";
pTooltip.add(new TranslationTextComponent(base + "1." + this.toPick1).append(" ").append(new TranslationTextComponent(base + "2." + this.toPick2)).withStyle(s -> s.withColor(TextFormatting.GRAY)));
}
@Override
protected boolean updateCustomBlockEntityTag(BlockPos pPos, World pLevel, @Nullable PlayerEntity pPlayer, ItemStack pStack, BlockState pState) {
boolean ret = super.updateCustomBlockEntityTag(pPos, pLevel, pPlayer, pStack, pState);
return ret;
}
}
@Override

View file

@ -193,6 +193,7 @@ public abstract class BlockContainerBase extends Block {
@Override
public void playerWillDestroy(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, PlayerEntity player) {
super.playerWillDestroy(world, pos, state, player);
if (!player.isCreative()) {
TileEntity tile = world.getBlockEntity(pos);
if (tile instanceof TileEntityBase && ((TileEntityBase) tile).stopFromDropping) {
@ -256,11 +257,6 @@ public abstract class BlockContainerBase extends Block {
// }
@Override
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid) {
return willHarvest || super.removedByPlayer(state, world, pos, player, false, fluid);
}
// TODO: [port]: eval
// @Override

View file

@ -70,6 +70,6 @@ public class CustomEnergyStorage extends EnergyStorage {
public void setEnergyStored(int energy) {
this.energy = energy;
this.dirty = false;
this.dirty = true;
}
}

View file

@ -121,6 +121,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
this.currentTime = compound.getInt("CurrentTime");
this.counter = compound.getInt("Counter");
}
if (compound.contains("Energy"))
this.storage.readFromNBT(compound);
}

View file

@ -147,7 +147,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickableTile
this.stopFromDropping = compound.getBoolean("StopDrop");
}
if (this.isRedstoneToggle()) {
if (this.isRedstoneToggle() && compound.contains("IsPulseMode")) {
this.isPulseMode = compound.getBoolean("IsPulseMode");
}
}