mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 16:38:33 +01:00
Compare commits
3 commits
773d723ce0
...
ffb11ca5f3
Author | SHA1 | Date | |
---|---|---|---|
|
ffb11ca5f3 | ||
|
6825fa3d4a | ||
|
c15fbab60b |
9 changed files with 101 additions and 39 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
|
||||
9a7897ef54a7b27d06db0cbb412465fd1e71b9fe data/actuallyadditions/loot_tables/blocks/atomic_reconstructor.json
|
||||
214cf5b268cb34e55c2232cc7c694e81f388dc1f 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
|
||||
|
|
|
@ -13,6 +13,34 @@
|
|||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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,12 @@ 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());
|
||||
|
||||
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());
|
||||
|
@ -192,6 +199,15 @@ 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)));
|
||||
}
|
||||
|
||||
/* // This isn't quite right :cry: fortune doesn't change it
|
||||
private void registerCrystal(RegistryObject<Block> crystalCluster, RegistryObject<Item> crystalShard) {
|
||||
this.registerLootTable(crystalCluster.get(), (crystal) ->
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class ActuallyBlocks {
|
|||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ActuallyAdditions.MODID);
|
||||
public static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, ActuallyAdditions.MODID);
|
||||
|
||||
private static final Item.Properties defaultBlockItemProperties = new Item.Properties().tab(ActuallyAdditions.GROUP).stacksTo(64);
|
||||
public static final Item.Properties defaultBlockItemProperties = new Item.Properties().tab(ActuallyAdditions.GROUP).stacksTo(64);
|
||||
|
||||
public static final AbstractBlock.Properties miscBlockProperties = AbstractBlock.Properties.of(Material.STONE).harvestLevel(1).harvestTool(ToolType.PICKAXE).strength(1.5f, 10f);
|
||||
|
||||
|
@ -99,7 +99,7 @@ public final class ActuallyBlocks {
|
|||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityVerticalDigger::new);
|
||||
|
||||
public static final AABlockReg<BlockAtomicReconstructor, AABlockItem, TileEntityAtomicReconstructor> ATOMIC_RECONSTRUCTOR = new AABlockReg<>("atomic_reconstructor", BlockAtomicReconstructor::new,
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityAtomicReconstructor::new);
|
||||
BlockAtomicReconstructor.TheItemBlock::new, TileEntityAtomicReconstructor::new);
|
||||
public static final AABlockReg<BlockRangedCollector, AABlockItem, TileEntityRangedCollector> RANGED_COLLECTOR = new AABlockReg<>("ranged_collector", BlockRangedCollector::new,
|
||||
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityRangedCollector::new);
|
||||
public static final AABlockReg<BlockLongRangeBreaker, AABlockItem, TileEntityLongRangeBreaker> LONG_RANGE_BREAKER = new AABlockReg<>("long_range_breaker", BlockLongRangeBreaker::new,
|
||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.blocks;
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||
|
@ -19,9 +20,11 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
|||
import de.ellpeck.actuallyadditions.mod.util.Lang;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -43,7 +46,10 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container implements IHudDisplay {
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
|
@ -59,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);
|
||||
|
@ -122,32 +128,47 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
|||
}
|
||||
}
|
||||
|
||||
// public static class TheItemBlock extends ItemBlockBase {
|
||||
//
|
||||
// private long lastSysTime;
|
||||
// private int toPick1;
|
||||
// private int toPick2;
|
||||
//
|
||||
// public TheItemBlock(Block block) {
|
||||
// super(block, new Item.Properties().group(ActuallyAdditions.GROUP).setNoRepair());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addInformation(ItemStack stack, @Nullable World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
// long sysTime = System.currentTimeMillis();
|
||||
//
|
||||
// if (this.lastSysTime + 3000 < sysTime) {
|
||||
// this.lastSysTime = sysTime;
|
||||
// if (Minecraft.getInstance().world != null) {
|
||||
// this.toPick1 = Minecraft.getInstance().world.rand.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
|
||||
// this.toPick2 = Minecraft.getInstance().world.rand.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String base = "tile." + ActuallyAdditions.MODID + "." + ((BlockAtomicReconstructor) this.block).getBaseName() + ".info.";
|
||||
// tooltip.add(StringUtil.localize(base + "1." + this.toPick1) + " " + StringUtil.localize(base + "2." + this.toPick2));
|
||||
// }
|
||||
// }
|
||||
public static class TheItemBlock extends AABlockItem {
|
||||
|
||||
private long lastSysTime;
|
||||
private int toPick1;
|
||||
private int toPick2;
|
||||
private final Block block;
|
||||
|
||||
public TheItemBlock(Block blockIn) {
|
||||
super(blockIn, ActuallyBlocks.defaultBlockItemProperties);
|
||||
block = blockIn;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Override
|
||||
public void appendHoverText(@Nonnull ItemStack pStack, @Nullable World pLevel, @Nonnull List<ITextComponent> pTooltip, @Nonnull ITooltipFlag pFlag) {
|
||||
super.appendHoverText(pStack, pLevel, pTooltip, pFlag);
|
||||
|
||||
long sysTime = System.currentTimeMillis();
|
||||
|
||||
if (this.lastSysTime + 3000 < sysTime) {
|
||||
this.lastSysTime = sysTime;
|
||||
if (Minecraft.getInstance().level != null) {
|
||||
Random random = Minecraft.getInstance().level.random;
|
||||
this.toPick1 = random.nextInt(NAME_FLAVOR_AMOUNTS_1) + 1;
|
||||
this.toPick2 = random.nextInt(NAME_FLAVOR_AMOUNTS_2) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -70,6 +70,6 @@ public class CustomEnergyStorage extends EnergyStorage {
|
|||
|
||||
public void setEnergyStored(int energy) {
|
||||
this.energy = energy;
|
||||
this.dirty = false;
|
||||
this.dirty = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
|||
this.currentTime = compound.getInt("CurrentTime");
|
||||
this.counter = compound.getInt("Counter");
|
||||
}
|
||||
this.storage.readFromNBT(compound);
|
||||
if (compound.contains("Energy"))
|
||||
this.storage.readFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue