mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
More tiles storing energy...
This commit is contained in:
parent
ffb11ca5f3
commit
e8fee61c91
10 changed files with 110 additions and 22 deletions
|
@ -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
|
||||
214cf5b268cb34e55c2232cc7c694e81f388dc1f data/actuallyadditions/loot_tables/blocks/atomic_reconstructor.json
|
||||
b679296118ae905d4a15b6bc658cfa7b8048e57f 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
|
||||
|
@ -477,14 +477,14 @@ f3df22f203e8c00ee7ee004bb9b4edfd522f069a data/actuallyadditions/loot_tables/bloc
|
|||
7b10afffb30390977f1729356e0b4959ccb4cf1c data/actuallyadditions/loot_tables/blocks/chiseled_black_quartz_slab.json
|
||||
6df5538ba7cf057d19728f8e615862a84b9d4bb1 data/actuallyadditions/loot_tables/blocks/chiseled_black_quartz_stair.json
|
||||
092e8773d46f16d80d0c489c4a2d2f8bd5a78799 data/actuallyadditions/loot_tables/blocks/chiseled_black_quartz_wall.json
|
||||
d1f6498ad95f87ca8ad0aa78f356bf4a76f78842 data/actuallyadditions/loot_tables/blocks/coal_generator.json
|
||||
bf7743c27757cf5b0dbab9b3e15d1d5ca1ece818 data/actuallyadditions/loot_tables/blocks/coal_generator.json
|
||||
66ee33930c8392b29710ce2bc117f99907e336df data/actuallyadditions/loot_tables/blocks/coffee.json
|
||||
3285202e3f840d091b8d85dc2c721199fcc96240 data/actuallyadditions/loot_tables/blocks/coffee_machine.json
|
||||
98c2198bf7df995a8c43f08101eb2021a62e1dec data/actuallyadditions/loot_tables/blocks/crusher.json
|
||||
93c16ed7d46e44ceafdc32c2a440f98b8c805723 data/actuallyadditions/loot_tables/blocks/crusher_double.json
|
||||
6336ca572b8d81f6e06b43bb925b48bb915b6574 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_block.json
|
||||
b9ed4007fec7a382a02b08b231f072df6aa40049 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_cluster.json
|
||||
6097f74352ae6f7ad59736cd6cf4bc545aa8a39d data/actuallyadditions/loot_tables/blocks/display_stand.json
|
||||
7476dbc0cbb3c1a8ce5a3c1562f73fcfb4adcd10 data/actuallyadditions/loot_tables/blocks/display_stand.json
|
||||
162331b9fbc67309820a20377575336e63ed3e74 data/actuallyadditions/loot_tables/blocks/dropper.json
|
||||
3b93e666ae7c49a182e771063901b27da8dcfb3f data/actuallyadditions/loot_tables/blocks/emeradic_crystal_block.json
|
||||
9fec34737374133601990074c4156334ab3841ad data/actuallyadditions/loot_tables/blocks/emeradic_crystal_cluster.json
|
||||
|
@ -547,7 +547,7 @@ d97afdaa98f4202a2fc767599a4e5e34ffbefa71 data/actuallyadditions/loot_tables/bloc
|
|||
a26c16e8bf499948ef947d5e7e2e6691e0c7e1a8 data/actuallyadditions/loot_tables/blocks/lava_factory_controller.json
|
||||
d2cfb9e1d68cfabcf21f2847cf66760b514bb510 data/actuallyadditions/loot_tables/blocks/leaf_generator.json
|
||||
644aab55582d80b4b1fb9857b1b136b3f50bbe79 data/actuallyadditions/loot_tables/blocks/long_range_breaker.json
|
||||
c21bd06177fdd1d367bfb58dd241cdfd2134f0d8 data/actuallyadditions/loot_tables/blocks/oil_generator.json
|
||||
0317d1a12de12767cac13a5a2c9d173198b7e600 data/actuallyadditions/loot_tables/blocks/oil_generator.json
|
||||
8a49a3773ea9ac5f56b68373671fbf535a33ae0b data/actuallyadditions/loot_tables/blocks/palis_crystal_block.json
|
||||
101ae500268810b6ec90bfcbbecc6ddfdd843e74 data/actuallyadditions/loot_tables/blocks/palis_crystal_cluster.json
|
||||
84e7d1632faf9762a0112e3d7ba7e83f49a8707a data/actuallyadditions/loot_tables/blocks/phantom_booster.json
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_name",
|
||||
"source": "block_entity"
|
||||
},
|
||||
{
|
||||
"function": "minecraft:copy_nbt",
|
||||
"source": "block_entity",
|
||||
|
|
|
@ -13,6 +13,19 @@
|
|||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_nbt",
|
||||
"source": "block_entity",
|
||||
"ops": [
|
||||
{
|
||||
"source": "Energy",
|
||||
"target": "BlockEntityTag.Energy",
|
||||
"op": "replace"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -13,6 +13,19 @@
|
|||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_nbt",
|
||||
"source": "block_entity",
|
||||
"ops": [
|
||||
{
|
||||
"source": "Energy",
|
||||
"target": "BlockEntityTag.Energy",
|
||||
"op": "replace"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -13,6 +13,19 @@
|
|||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:copy_nbt",
|
||||
"source": "block_entity",
|
||||
"ops": [
|
||||
{
|
||||
"source": "Energy",
|
||||
"target": "BlockEntityTag.Energy",
|
||||
"op": "replace"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -49,6 +49,15 @@ public class LootTableGenerator extends LootTableProvider {
|
|||
public static class Blocks extends BlockLootTables {
|
||||
@Override
|
||||
protected void addTables() {
|
||||
CopyNbt.Builder copyEnergy = CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY).copy("Energy", "BlockEntityTag.Energy");
|
||||
CopyNbt.Builder copyPulseMode = CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY).copy("IsPulseMode", "BlockEntityTag.IsPulseMode");
|
||||
|
||||
//Special Drops
|
||||
dropNBT(ActuallyBlocks.ATOMIC_RECONSTRUCTOR, $ -> $.apply(copyEnergy).apply(copyPulseMode));
|
||||
dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND);
|
||||
dropKeepEnergy(ActuallyBlocks.COAL_GENERATOR);
|
||||
dropKeepEnergy(ActuallyBlocks.OIL_GENERATOR);
|
||||
|
||||
this.dropSelf(ActuallyBlocks.BATTERY_BOX.get());
|
||||
this.dropSelf(ActuallyBlocks.ITEM_INTERFACE_HOPPING.get());
|
||||
this.dropSelf(ActuallyBlocks.FARMER.get());
|
||||
|
@ -56,17 +65,10 @@ public class LootTableGenerator extends LootTableProvider {
|
|||
this.dropSelf(ActuallyBlocks.EMPOWERER.get());
|
||||
this.dropSelf(ActuallyBlocks.TINY_TORCH.get());
|
||||
this.dropSelf(ActuallyBlocks.SHOCK_SUPPRESSOR.get());
|
||||
this.dropSelf(ActuallyBlocks.DISPLAY_STAND.get());
|
||||
this.dropSelf(ActuallyBlocks.PLAYER_INTERFACE.get());
|
||||
this.dropSelf(ActuallyBlocks.ITEM_INTERFACE.get());
|
||||
this.dropSelf(ActuallyBlocks.FIREWORK_BOX.get());
|
||||
this.dropSelf(ActuallyBlocks.VERTICAL_DIGGER.get());
|
||||
|
||||
dropNBT(ActuallyBlocks.ATOMIC_RECONSTRUCTOR, a ->
|
||||
a.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());
|
||||
|
@ -77,8 +79,6 @@ public class LootTableGenerator extends LootTableProvider {
|
|||
this.dropSelf(ActuallyBlocks.PHANTOM_ENERGYFACE.get());
|
||||
this.dropSelf(ActuallyBlocks.PHANTOM_REDSTONEFACE.get());
|
||||
this.dropSelf(ActuallyBlocks.PHANTOM_BREAKER.get());
|
||||
this.dropSelf(ActuallyBlocks.COAL_GENERATOR.get());
|
||||
this.dropSelf(ActuallyBlocks.OIL_GENERATOR.get());
|
||||
this.dropSelf(ActuallyBlocks.FERMENTING_BARREL.get());
|
||||
this.dropSelf(ActuallyBlocks.FEEDER.get());
|
||||
this.dropSelf(ActuallyBlocks.CRUSHER.get());
|
||||
|
@ -201,12 +201,14 @@ public class LootTableGenerator extends LootTableProvider {
|
|||
|
||||
private void dropNBT(Supplier<Block> blockSupplier, Consumer<LootPool.Builder> lootFunctionProvider) {
|
||||
LootPool.Builder lootpool = LootPool.lootPool().setRolls(ConstantRange.exactly(1)).add(ItemLootEntry.lootTableItem(blockSupplier.get()));
|
||||
lootpool.apply(CopyName.copyName(CopyName.Source.BLOCK_ENTITY));
|
||||
|
||||
lootFunctionProvider.accept(lootpool);
|
||||
|
||||
add(blockSupplier.get(), LootTable.lootTable().withPool(applyExplosionCondition(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get(), lootpool)));
|
||||
}
|
||||
private void dropKeepEnergy(Supplier<Block> blockSupplier) {
|
||||
dropNBT(blockSupplier, $ -> $.apply(CopyNbt.copyData(CopyNbt.Source.BLOCK_ENTITY).copy("Energy", "BlockEntityTag.Energy")));
|
||||
}
|
||||
|
||||
/* // This isn't quite right :cry: fortune doesn't change it
|
||||
private void registerCrystal(RegistryObject<Block> crystalCluster, RegistryObject<Item> crystalShard) {
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.BlockNamedItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
public class AABlockItem extends BlockItem {
|
||||
public AABlockItem(Block blockIn, Properties builder) {
|
||||
|
@ -19,4 +30,25 @@ public class AABlockItem extends BlockItem {
|
|||
return this.getOrCreateDescriptionId();
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockEntityEnergyItem extends AABlockItem {
|
||||
public BlockEntityEnergyItem(Block blockIn, Properties builder) {
|
||||
super(blockIn, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack pStack, @Nullable World pLevel, List<ITextComponent> pTooltip, ITooltipFlag pFlag) {
|
||||
super.appendHoverText(pStack, pLevel, pTooltip, pFlag);
|
||||
|
||||
if (pStack.hasTag() && pStack.getTag().contains("BlockEntityTag")) {
|
||||
CompoundNBT BET = pStack.getTag().getCompound("BlockEntityTag");
|
||||
int energy = 0;
|
||||
if (BET.contains("Energy")) {
|
||||
energy = BET.getInt("Energy");
|
||||
}
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
pTooltip.add(new TranslationTextComponent("misc.actuallyadditions.power_single", format.format(energy)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,10 +67,10 @@ public final class ActuallyBlocks {
|
|||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityFermentingBarrel::new);
|
||||
|
||||
public static final AABlockReg<BlockOilGenerator, AABlockItem, TileEntityOilGenerator> OIL_GENERATOR = new AABlockReg<>("oil_generator", BlockOilGenerator::new,
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityOilGenerator::new);
|
||||
(b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityOilGenerator::new);
|
||||
|
||||
public static final AABlockReg<BlockCoalGenerator, AABlockItem, TileEntityCoalGenerator> COAL_GENERATOR = new AABlockReg<>("coal_generator", BlockCoalGenerator::new,
|
||||
(b) -> new AABlockItem(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,
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties) , TileEntityLeafGenerator::new);
|
||||
|
@ -155,7 +155,7 @@ public final class ActuallyBlocks {
|
|||
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityEmpowerer> EMPOWERER = new AABlockReg<>("empowerer", () -> new BlockDisplayStand(true),
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityEmpowerer::new);
|
||||
public static final AABlockReg<BlockDisplayStand, AABlockItem, TileEntityDisplayStand> DISPLAY_STAND = new AABlockReg<>("display_stand", () -> new BlockDisplayStand(false),
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityDisplayStand::new);
|
||||
(b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityDisplayStand::new);
|
||||
|
||||
// Interface Blocks
|
||||
public static final AABlockReg<BlockPlayerInterface, AABlockItem, TileEntityPlayerInterface> PLAYER_INTERFACE = new AABlockReg<>("player_interface", BlockPlayerInterface::new,
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -39,6 +40,7 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
|
@ -48,6 +50,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -158,6 +161,21 @@ 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)));
|
||||
|
||||
if (pStack.hasTag() && pStack.getTag().contains("BlockEntityTag")) {
|
||||
CompoundNBT BET = pStack.getTag().getCompound("BlockEntityTag");
|
||||
int energy = 0;
|
||||
if (BET.contains("Energy")) {
|
||||
energy = BET.getInt("Energy");
|
||||
}
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
pTooltip.add(new TranslationTextComponent("misc.actuallyadditions.power_single", format.format(energy)));
|
||||
|
||||
if (BET.contains("IsPulseMode")) {
|
||||
pTooltip.add(new TranslationTextComponent("info.actuallyadditions.redstoneMode").append(": ")
|
||||
.append(new TranslationTextComponent(BET.getBoolean("IsPulseMode")?"info.actuallyadditions.redstoneMode.pulse":"info.actuallyadditions.redstoneMode.deactivation").withStyle($ -> $.withColor(TextFormatting.RED))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,7 +61,8 @@ public class CustomEnergyStorage extends EnergyStorage {
|
|||
}
|
||||
|
||||
public void readFromNBT(CompoundNBT compound) {
|
||||
this.setEnergyStored(compound.getInt("Energy"));
|
||||
if (compound.contains("Energy"))
|
||||
this.setEnergyStored(compound.getInt("Energy"));
|
||||
}
|
||||
|
||||
public void writeToNBT(CompoundNBT compound) {
|
||||
|
|
Loading…
Reference in a new issue