New sounds, registry rename

This commit is contained in:
paulevsGitch 2020-10-27 03:16:55 +03:00
parent c609f98ec2
commit 1c03ecb5e3
105 changed files with 1449 additions and 1447 deletions

View file

@ -22,7 +22,7 @@ import net.minecraft.util.math.Vec3i;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.interfaces.IColorProvider;
import ru.betterend.registry.ItemRegistry;
import ru.betterend.registry.EndItems;
import ru.betterend.util.MHelper;
public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTypeable, IColorProvider {
@ -88,13 +88,13 @@ public class AuroraCrystalBlock extends AbstractGlassBlock implements IRenderTyp
int min = MathHelper.clamp(MIN_DROP + enchant, MIN_DROP, MAX_DROP);
int max = MAX_DROP + (enchant / Enchantments.FORTUNE.getMaxLevel());
if (min == max) {
return Lists.newArrayList(new ItemStack(ItemRegistry.CRYSTAL_SHARDS, max));
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, max));
}
count = MHelper.randRange(min, max, MHelper.RANDOM);
} else {
count = MHelper.randRange(MIN_DROP, MAX_DROP, MHelper.RANDOM);
}
return Lists.newArrayList(new ItemStack(ItemRegistry.CRYSTAL_SHARDS, count));
return Lists.newArrayList(new ItemStack(EndItems.CRYSTAL_SHARDS, count));
}
return Lists.newArrayList();
}

View file

@ -6,7 +6,7 @@ import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUpDownPlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class BlockBlueVine extends BlockUpDownPlant {
public static final EnumProperty<TripleShape> SHAPE = BlockProperties.TRIPLE_SHAPE;
@ -18,6 +18,6 @@ public class BlockBlueVine extends BlockUpDownPlant {
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
}
}

View file

@ -14,7 +14,7 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class BlockBlueVineLantern extends BlockBase {
public static final BooleanProperty NATURAL = BooleanProperty.of("natural");
@ -26,7 +26,7 @@ public class BlockBlueVineLantern extends BlockBase {
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == BlockRegistry.BLUE_VINE : true;
return state.get(NATURAL) ? world.getBlockState(pos.down()).getBlock() == EndBlocks.BLUE_VINE : true;
}
@Override

View file

@ -9,7 +9,7 @@ import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockGlowingFur;
import ru.betterend.blocks.basis.BlockPlantWithAge;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -21,29 +21,29 @@ public class BlockBlueVineSeed extends BlockPlantWithAge {
if (h < height + 1) {
return;
}
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM));
for (int i = 1; i < height; i++) {
BlocksHelper.setWithoutUpdate(world, pos.up(i), BlockRegistry.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, pos.up(i), EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE));
}
BlocksHelper.setWithoutUpdate(world, pos.up(height), BlockRegistry.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, pos.up(height), EndBlocks.BLUE_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP));
placeLantern(world, pos.up(height + 1));
}
private void placeLantern(StructureWorldAccess world, BlockPos pos) {
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.BLUE_VINE_LANTERN.getDefaultState().with(BlockBlueVineLantern.NATURAL, true));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BLUE_VINE_LANTERN.getDefaultState().with(BlockBlueVineLantern.NATURAL, true));
for (Direction dir: BlocksHelper.HORIZONTAL) {
BlockPos p = pos.offset(dir);
if (world.isAir(p)) {
BlocksHelper.setWithoutUpdate(world, p, BlockRegistry.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, dir));
BlocksHelper.setWithoutUpdate(world, p, EndBlocks.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, dir));
}
}
if (world.isAir(pos.up())) {
BlocksHelper.setWithoutUpdate(world, pos.up(), BlockRegistry.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, Direction.UP));
BlocksHelper.setWithoutUpdate(world, pos.up(), EndBlocks.BLUE_VINE_FUR.getDefaultState().with(BlockGlowingFur.FACING, Direction.UP));
}
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
}
}

View file

@ -2,7 +2,7 @@ package ru.betterend.blocks;
import net.minecraft.block.BlockState;
import ru.betterend.blocks.basis.BlockPlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class BlockChorusGrass extends BlockPlant {
public BlockChorusGrass() {
@ -11,6 +11,6 @@ public class BlockChorusGrass extends BlockPlant {
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.CHORUS_NYLIUM;
return state.getBlock() == EndBlocks.CHORUS_NYLIUM;
}
}

View file

@ -28,8 +28,8 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUnderwaterPlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.ItemRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import ru.betterend.util.MHelper;
public class BlockEndLily extends BlockUnderwaterPlant {
@ -91,7 +91,7 @@ public class BlockEndLily extends BlockUnderwaterPlant {
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
if (state.get(SHAPE) == TripleShape.TOP) {
return Lists.newArrayList(new ItemStack(ItemRegistry.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), new ItemStack(BlockRegistry.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
return Lists.newArrayList(new ItemStack(EndItems.END_LILY_LEAF, MHelper.randRange(1, 2, MHelper.RANDOM)), new ItemStack(EndBlocks.END_LILY_SEED, MHelper.randRange(1, 2, MHelper.RANDOM)));
}
return Collections.emptyList();
}

View file

@ -7,20 +7,20 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUnderwaterPlantWithAge;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class BlockEndLilySeed extends BlockUnderwaterPlantWithAge {
@Override
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
if (canGrow(world, pos)) {
BlocksHelper.setWithoutUpdate(world, pos, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM));
BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.BOTTOM));
BlockPos up = pos.up();
while (world.getFluidState(up).isStill()) {
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.MIDDLE));
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.MIDDLE));
up = up.up();
}
BlocksHelper.setWithoutUpdate(world, up, BlockRegistry.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
BlocksHelper.setWithoutUpdate(world, up, EndBlocks.END_LILY.getDefaultState().with(BlockEndLily.SHAPE, TripleShape.TOP));
}
}

View file

@ -16,7 +16,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import ru.betterend.blocks.basis.BlockPlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.MHelper;
public class BlockEndLotusFlower extends BlockPlant {
@ -29,7 +29,7 @@ public class BlockEndLotusFlower extends BlockPlant {
@Override
protected boolean isTerrain(BlockState state) {
return state.isOf(BlockRegistry.END_LOTUS_STEM);
return state.isOf(EndBlocks.END_LOTUS_STEM);
}
@Override
@ -50,6 +50,6 @@ public class BlockEndLotusFlower extends BlockPlant {
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
int count = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(BlockRegistry.END_LOTUS_SEED, count));
return Lists.newArrayList(new ItemStack(EndBlocks.END_LOTUS_SEED, count));
}
}

View file

@ -10,17 +10,17 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.BlockUnderwaterPlantWithAge;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge {
@Override
public void grow(StructureWorldAccess world, Random random, BlockPos pos) {
if (canGrow(world, pos)) {
BlockState startLeaf = BlockRegistry.END_LOTUS_STEM.getDefaultState().with(BlockEndLotusStem.LEAF, true);
BlockState roots = BlockRegistry.END_LOTUS_STEM.getDefaultState().with(BlockEndLotusStem.SHAPE, TripleShape.BOTTOM).with(BlockEndLotusStem.WATERLOGGED, true);
BlockState stem = BlockRegistry.END_LOTUS_STEM.getDefaultState();
BlockState flower = BlockRegistry.END_LOTUS_FLOWER.getDefaultState();
BlockState startLeaf = EndBlocks.END_LOTUS_STEM.getDefaultState().with(BlockEndLotusStem.LEAF, true);
BlockState roots = EndBlocks.END_LOTUS_STEM.getDefaultState().with(BlockEndLotusStem.SHAPE, TripleShape.BOTTOM).with(BlockEndLotusStem.WATERLOGGED, true);
BlockState stem = EndBlocks.END_LOTUS_STEM.getDefaultState();
BlockState flower = EndBlocks.END_LOTUS_FLOWER.getDefaultState();
BlocksHelper.setWithoutUpdate(world, pos, roots);
Mutable bpos = new Mutable().set(pos);
@ -63,14 +63,14 @@ public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge {
BlocksHelper.setWithoutUpdate(world, bpos, flower);
bpos.setY(bpos.getY() - 1);
stem = world.getBlockState(bpos);
if (!stem.isOf(BlockRegistry.END_LOTUS_STEM)) {
stem = BlockRegistry.END_LOTUS_STEM.getDefaultState();
if (!stem.isOf(EndBlocks.END_LOTUS_STEM)) {
stem = EndBlocks.END_LOTUS_STEM.getDefaultState();
if (!world.getBlockState(bpos.north()).getFluidState().isEmpty()) {
stem = stem.with(BlockEndLotusStem.WATERLOGGED, true);
}
}
if (world.getBlockState(bpos.offset(dir)).isOf(BlockRegistry.END_LOTUS_LEAF)) {
if (world.getBlockState(bpos.offset(dir)).isOf(EndBlocks.END_LOTUS_LEAF)) {
stem = stem.with(BlockEndLotusStem.LEAF, true).with(BlockEndLotusStem.FACING, dir);
}
@ -89,7 +89,7 @@ public class BlockEndLotusSeed extends BlockUnderwaterPlantWithAge {
private void generateLeaf(StructureWorldAccess world, BlockPos pos) {
Mutable p = new Mutable();
BlockState leaf = BlockRegistry.END_LOTUS_LEAF.getDefaultState();
BlockState leaf = EndBlocks.END_LOTUS_LEAF.getDefaultState();
BlocksHelper.setWithoutUpdate(world, pos, leaf.with(BlockEndLotusLeaf.SHAPE, TripleShape.BOTTOM));
for (Direction move: BlocksHelper.HORIZONTAL) {
BlocksHelper.setWithoutUpdate(world, p.set(pos).move(move), leaf.with(BlockEndLotusLeaf.HORIZONTAL_FACING, move).with(BlockEndLotusLeaf.SHAPE, TripleShape.MIDDLE));

View file

@ -6,7 +6,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import ru.betterend.blocks.basis.BlockPlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class BlockGlowingMoss extends BlockPlant {
public BlockGlowingMoss(int light) {
@ -15,7 +15,7 @@ public class BlockGlowingMoss extends BlockPlant {
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
}
@Environment(EnvType.CLIENT)

View file

@ -9,7 +9,7 @@ import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class BlockMossyGlowshroomCap extends Block {
public static final BooleanProperty TRANSITION = BooleanProperty.of("transition");
@ -20,7 +20,7 @@ public class BlockMossyGlowshroomCap extends Block {
}
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.getDefaultState().with(TRANSITION, BlockRegistry.MOSSY_GLOWSHROOM.isTreeLog(ctx.getWorld().getBlockState(ctx.getBlockPos().down())));
return this.getDefaultState().with(TRANSITION, EndBlocks.MOSSY_GLOWSHROOM.isTreeLog(ctx.getWorld().getBlockState(ctx.getBlockPos().down())));
}
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {

View file

@ -2,7 +2,7 @@ package ru.betterend.blocks;
import net.minecraft.world.gen.feature.Feature;
import ru.betterend.blocks.basis.BlockFeatureSapling;
import ru.betterend.registry.FeatureRegistry;
import ru.betterend.registry.EndFeatures;
public class BlockMossyGlowshroomSapling extends BlockFeatureSapling {
public BlockMossyGlowshroomSapling() {
@ -11,6 +11,6 @@ public class BlockMossyGlowshroomSapling extends BlockFeatureSapling {
@Override
protected Feature<?> getFeature() {
return FeatureRegistry.MOSSY_GLOWSHROOM.getFeature();
return EndFeatures.MOSSY_GLOWSHROOM.getFeature();
}
}

View file

@ -2,7 +2,7 @@ package ru.betterend.blocks;
import net.minecraft.world.gen.feature.Feature;
import ru.betterend.blocks.basis.BlockFeatureSapling;
import ru.betterend.registry.FeatureRegistry;
import ru.betterend.registry.EndFeatures;
public class BlockMossyPythadendronSapling extends BlockFeatureSapling {
public BlockMossyPythadendronSapling() {
@ -11,6 +11,6 @@ public class BlockMossyPythadendronSapling extends BlockFeatureSapling {
@Override
protected Feature<?> getFeature() {
return FeatureRegistry.PYTHADENDRON_TREE.getFeature();
return EndFeatures.PYTHADENDRON_TREE.getFeature();
}
}

View file

@ -11,7 +11,7 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.BlockDoublePlant;
import ru.betterend.blocks.basis.BlockPlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
public class BlockUmbrellaMoss extends BlockPlant {
@ -21,7 +21,7 @@ public class BlockUmbrellaMoss extends BlockPlant {
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
}
@Environment(EnvType.CLIENT)
@ -42,7 +42,7 @@ public class BlockUmbrellaMoss extends BlockPlant {
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
int rot = world.random.nextInt(4);
BlockState bs = BlockRegistry.UMBRELLA_MOSS_TALL.getDefaultState().with(BlockDoublePlant.ROTATION, rot);
BlockState bs = EndBlocks.UMBRELLA_MOSS_TALL.getDefaultState().with(BlockDoublePlant.ROTATION, rot);
BlocksHelper.setWithoutUpdate(world, pos, bs);
BlocksHelper.setWithoutUpdate(world, pos.up(), bs.with(BlockDoublePlant.TOP, true));
}

View file

@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import ru.betterend.blocks.basis.BlockDoublePlant;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class BlockUmbrellaMossTall extends BlockDoublePlant {
public BlockUmbrellaMossTall() {
@ -17,12 +17,12 @@ public class BlockUmbrellaMossTall extends BlockDoublePlant {
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(BlockRegistry.UMBRELLA_MOSS));
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, new ItemStack(EndBlocks.UMBRELLA_MOSS));
world.spawnEntity(item);
}
@Override
protected boolean isTerrain(BlockState state) {
return state.getBlock() == BlockRegistry.END_MOSS || state.getBlock() == BlockRegistry.END_MYCELIUM;
return state.getBlock() == EndBlocks.END_MOSS || state.getBlock() == EndBlocks.END_MYCELIUM;
}
}

View file

@ -26,8 +26,8 @@ import net.minecraft.world.gen.feature.ConfiguredFeatures;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.interfaces.TeleportingEntity;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.registry.ParticleRegistry;
import ru.betterend.registry.EndParticles;
import ru.betterend.registry.EndTags;
import ru.betterend.util.PortalFrameHelper;
public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable {
@ -54,7 +54,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
z = pos.getZ() + 0.5D + 0.25D * k;
}
world.addParticle(ParticleRegistry.PORTAL_SPHERE, x, y, z, 0, 0, 0);
world.addParticle(EndParticles.PORTAL_SPHERE, x, y, z, 0, 0, 0);
}
@Override
@ -164,7 +164,7 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
BlockState state = world.getBlockState(position);
if (state.isAir()) airBlocks++;
if (world.getRegistryKey().equals(World.END)) {
free &= state.isAir() || BlockTagRegistry.validGenBlock(state);
free &= state.isAir() || EndTags.validGenBlock(state);
} else {
BlockState surfaceBlock = world.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
free &= this.validBlock(state, surfaceBlock.getBlock());

View file

@ -16,14 +16,14 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.explosion.Explosion;
import ru.betterend.blocks.basis.BlockSlab;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
public class EternalPedestal extends BlockSlab {
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
public static final BooleanProperty HAS_ITEM = BooleanProperty.of("has_item");
public EternalPedestal() {
super(BlockRegistry.FLAVOLITE_RUNED_ETERNAL);
super(EndBlocks.FLAVOLITE_RUNED_ETERNAL);
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false).with(HAS_ITEM, false));
}

View file

@ -10,7 +10,7 @@ import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.BlockBase;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.PortalFrameHelper;
@ -18,7 +18,7 @@ public class RunedFlavolite extends BlockBase {
public static final BooleanProperty ACTIVATED = BooleanProperty.of("active");
public RunedFlavolite() {
super(FabricBlockSettings.copyOf(BlockRegistry.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> {
super(FabricBlockSettings.copyOf(EndBlocks.FLAVOLITE.polished).resistance(Blocks.OBSIDIAN.getBlastResistance()).luminance(state -> {
return state.get(ACTIVATED) ? 8 : 0;
}));
this.setDefaultState(stateManager.getDefaultState().with(ACTIVATED, false));
@ -40,7 +40,7 @@ public class RunedFlavolite extends BlockBase {
BlockState posState = world.getBlockState(position);
if (posState.getBlock() instanceof RunedFlavolite && posState.get(ACTIVATED)) {
BlocksHelper.setWithoutUpdate(world, position, posState.with(ACTIVATED, false));
} else if (posState.isOf(BlockRegistry.END_PORTAL_BLOCK)) {
} else if (posState.isOf(EndBlocks.END_PORTAL_BLOCK)) {
world.removeBlock(position, false);
}
}

View file

@ -27,7 +27,7 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import ru.betterend.blocks.entities.EBarrelBlockEntity;
import ru.betterend.interfaces.Patterned;
import ru.betterend.registry.BlockEntityRegistry;
import ru.betterend.registry.EndBlockEntities;
public class BlockBarrel extends BarrelBlock implements Patterned {
public BlockBarrel(Block source) {
@ -36,7 +36,7 @@ public class BlockBarrel extends BarrelBlock implements Patterned {
@Override
public BlockEntity createBlockEntity(BlockView world) {
return BlockEntityRegistry.BARREL.instantiate();
return EndBlockEntities.BARREL.instantiate();
}
@Override

View file

@ -14,7 +14,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import ru.betterend.interfaces.Patterned;
import ru.betterend.registry.BlockEntityRegistry;
import ru.betterend.registry.EndBlockEntities;
public class BlockChest extends ChestBlock implements Patterned {
@ -22,7 +22,7 @@ public class BlockChest extends ChestBlock implements Patterned {
public BlockChest(Block source) {
super(FabricBlockSettings.copyOf(source).nonOpaque(), () -> {
return BlockEntityRegistry.CHEST;
return EndBlockEntities.CHEST;
});
this.parent = source;
}
@ -30,7 +30,7 @@ public class BlockChest extends ChestBlock implements Patterned {
@Override
public BlockEntity createBlockEntity(BlockView world)
{
return BlockEntityRegistry.CHEST.instantiate();
return EndBlockEntities.CHEST.instantiate();
}
@Override

View file

@ -36,7 +36,7 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
@ -93,7 +93,7 @@ public class BlockDoublePlant extends BlockBaseNotFull implements IRenderTypeabl
}
protected boolean isTerrain(BlockState state) {
return state.isIn(BlockTagRegistry.END_GROUND);
return state.isIn(EndTags.END_GROUND);
}
@Override

View file

@ -25,7 +25,7 @@ import net.minecraft.world.gen.feature.Feature;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.interfaces.Patterned;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fertilizable, IRenderTypeable {
@ -59,7 +59,7 @@ public abstract class BlockFeatureSapling extends BlockBaseNotFull implements Fe
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND);
return world.getBlockState(pos.down()).isIn(EndTags.END_GROUND);
}
@Override

View file

@ -32,7 +32,7 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.registry.EndTags;
public class BlockPlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
@ -84,7 +84,7 @@ public class BlockPlant extends BlockBaseNotFull implements IRenderTypeable, Fer
}
protected boolean isTerrain(BlockState state) {
return state.isIn(BlockTagRegistry.END_GROUND);
return state.isIn(EndTags.END_GROUND);
}
@Override

View file

@ -36,8 +36,8 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
public class BlockUnderwaterPlant extends BlockBaseNotFull implements IRenderTypeable, Fertilizable, FluidFillable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 14, 12);
@ -82,7 +82,7 @@ public class BlockUnderwaterPlant extends BlockBaseNotFull implements IRenderTyp
}
protected boolean isTerrain(BlockState state) {
return state.isIn(BlockTagRegistry.END_GROUND) || state.getBlock() == BlockRegistry.ENDSTONE_DUST;
return state.isIn(EndTags.END_GROUND) || state.getBlock() == EndBlocks.ENDSTONE_DUST;
}
@Override

View file

@ -28,7 +28,7 @@ import net.minecraft.world.WorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.client.ERenderLayer;
import ru.betterend.client.IRenderTypeable;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.registry.EndTags;
public class BlockUpDownPlant extends BlockBaseNotFull implements IRenderTypeable {
private static final VoxelShape SHAPE = Block.createCuboidShape(4, 0, 4, 12, 16, 12);
@ -54,7 +54,7 @@ public class BlockUpDownPlant extends BlockBaseNotFull implements IRenderTypeabl
}
protected boolean isTerrain(BlockState state) {
return state.isIn(BlockTagRegistry.END_GROUND);
return state.isIn(EndTags.END_GROUND);
}
protected boolean isSupport(BlockState state, WorldView world, BlockPos pos) {

View file

@ -14,7 +14,7 @@ import ru.betterend.blocks.basis.BlockStoneButton;
import ru.betterend.blocks.basis.BlockStonePressurePlate;
import ru.betterend.blocks.basis.BlockWall;
import ru.betterend.recipe.builders.RecipeBuilder;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.TagHelper;
public class StoneMaterial {
@ -37,20 +37,20 @@ public class StoneMaterial {
public StoneMaterial(String name, MaterialColor color) {
FabricBlockSettings material = FabricBlockSettings.copyOf(Blocks.END_STONE).materialColor(color);
stone = BlockRegistry.registerBlock(name, new BlockBase(material));
polished = BlockRegistry.registerBlock(name + "_polished", new BlockBase(material));
tiles = BlockRegistry.registerBlock(name + "_tiles", new BlockBase(material));
pillar = BlockRegistry.registerBlock(name + "_pillar", new BlockPillar(material));
stairs = BlockRegistry.registerBlock(name + "_stairs", new BlockStairs(stone));
slab = BlockRegistry.registerBlock(name + "_slab", new BlockSlab(stone));
wall = BlockRegistry.registerBlock(name + "_wall", new BlockWall(stone));
button = BlockRegistry.registerBlock(name + "_button", new BlockStoneButton(stone));
pressure_plate = BlockRegistry.registerBlock(name + "_plate", new BlockStonePressurePlate(stone));
stone = EndBlocks.registerBlock(name, new BlockBase(material));
polished = EndBlocks.registerBlock(name + "_polished", new BlockBase(material));
tiles = EndBlocks.registerBlock(name + "_tiles", new BlockBase(material));
pillar = EndBlocks.registerBlock(name + "_pillar", new BlockPillar(material));
stairs = EndBlocks.registerBlock(name + "_stairs", new BlockStairs(stone));
slab = EndBlocks.registerBlock(name + "_slab", new BlockSlab(stone));
wall = EndBlocks.registerBlock(name + "_wall", new BlockWall(stone));
button = EndBlocks.registerBlock(name + "_button", new BlockStoneButton(stone));
pressure_plate = EndBlocks.registerBlock(name + "_plate", new BlockStonePressurePlate(stone));
bricks = BlockRegistry.registerBlock(name + "_bricks", new BlockBase(material));
brick_stairs = BlockRegistry.registerBlock(name + "_bricks_stairs", new BlockStairs(bricks));
brick_slab = BlockRegistry.registerBlock(name + "_bricks_slab", new BlockSlab(bricks));
brick_wall = BlockRegistry.registerBlock(name + "_bricks_wall", new BlockWall(bricks));
bricks = EndBlocks.registerBlock(name + "_bricks", new BlockBase(material));
brick_stairs = EndBlocks.registerBlock(name + "_bricks_stairs", new BlockStairs(bricks));
brick_slab = EndBlocks.registerBlock(name + "_bricks_slab", new BlockSlab(bricks));
brick_wall = EndBlocks.registerBlock(name + "_bricks_wall", new BlockWall(bricks));
// Recipes //
RecipeBuilder.make(name + "_bricks", bricks).setOutputCount(4).setShape("##", "##").addMaterial('#', stone).setGroup("end_bricks").build();

View file

@ -27,7 +27,7 @@ import ru.betterend.blocks.basis.BlockStairs;
import ru.betterend.blocks.basis.BlockTrapdoor;
import ru.betterend.blocks.basis.BlockWoodenButton;
import ru.betterend.recipe.builders.RecipeBuilder;
import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.TagHelper;
public class WoodenMaterial {
@ -58,28 +58,28 @@ public class WoodenMaterial {
public WoodenMaterial(String name, MaterialColor woodColor, MaterialColor planksColor) {
FabricBlockSettings materialPlanks = FabricBlockSettings.copyOf(Blocks.OAK_PLANKS).materialColor(planksColor);
log_stripped = BlockRegistry.registerBlock(name + "_stripped_log", new BlockPillar(materialPlanks));
bark_stripped = BlockRegistry.registerBlock(name + "_stripped_bark", new BlockBark(materialPlanks));
log_stripped = EndBlocks.registerBlock(name + "_stripped_log", new BlockPillar(materialPlanks));
bark_stripped = EndBlocks.registerBlock(name + "_stripped_bark", new BlockBark(materialPlanks));
log = BlockRegistry.registerBlock(name + "_log", new BlockLogStripable(woodColor, log_stripped));
bark = BlockRegistry.registerBlock(name + "_bark", new BlockBarkStripable(woodColor, bark_stripped));
log = EndBlocks.registerBlock(name + "_log", new BlockLogStripable(woodColor, log_stripped));
bark = EndBlocks.registerBlock(name + "_bark", new BlockBarkStripable(woodColor, bark_stripped));
planks = BlockRegistry.registerBlock(name + "_planks", new BlockBase(materialPlanks));
stairs = BlockRegistry.registerBlock(name + "_stairs", new BlockStairs(planks));
slab = BlockRegistry.registerBlock(name + "_slab", new BlockSlab(planks));
fence = BlockRegistry.registerBlock(name + "_fence", new BlockFence(planks));
gate = BlockRegistry.registerBlock(name + "_gate", new BlockGate(planks));
button = BlockRegistry.registerBlock(name + "_button", new BlockWoodenButton(planks));
pressure_plate = BlockRegistry.registerBlock(name + "_plate", new BlockPressurePlate(planks));
trapdoor = BlockRegistry.registerBlock(name + "_trapdoor", new BlockTrapdoor(planks));
door = BlockRegistry.registerBlock(name + "_door", new BlockDoor(planks));
planks = EndBlocks.registerBlock(name + "_planks", new BlockBase(materialPlanks));
stairs = EndBlocks.registerBlock(name + "_stairs", new BlockStairs(planks));
slab = EndBlocks.registerBlock(name + "_slab", new BlockSlab(planks));
fence = EndBlocks.registerBlock(name + "_fence", new BlockFence(planks));
gate = EndBlocks.registerBlock(name + "_gate", new BlockGate(planks));
button = EndBlocks.registerBlock(name + "_button", new BlockWoodenButton(planks));
pressure_plate = EndBlocks.registerBlock(name + "_plate", new BlockPressurePlate(planks));
trapdoor = EndBlocks.registerBlock(name + "_trapdoor", new BlockTrapdoor(planks));
door = EndBlocks.registerBlock(name + "_door", new BlockDoor(planks));
crafting_table = BlockRegistry.registerBlock(name + "_crafting_table", new BlockCraftingTable(planks));
ladder = BlockRegistry.registerBlock(name + "_ladder", new BlockLadder(planks));
sign = BlockRegistry.registerBlock(name + "_sign", new BlockSign(planks));
crafting_table = EndBlocks.registerBlock(name + "_crafting_table", new BlockCraftingTable(planks));
ladder = EndBlocks.registerBlock(name + "_ladder", new BlockLadder(planks));
sign = EndBlocks.registerBlock(name + "_sign", new BlockSign(planks));
chest = BlockRegistry.registerBlock(name + "_chest", new BlockChest(planks));
barrel = BlockRegistry.registerBlock(name + "_barrel", new BlockBarrel(planks));
chest = EndBlocks.registerBlock(name + "_chest", new BlockChest(planks));
barrel = EndBlocks.registerBlock(name + "_barrel", new BlockBarrel(planks));
// Recipes //
RecipeBuilder.make(name + "_planks", planks).setOutputCount(4).setList("#").addMaterial('#', log, bark, log_stripped, bark_stripped).setGroup("end_planks").build();

View file

@ -21,7 +21,7 @@ import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import ru.betterend.blocks.basis.BlockBarrel;
import ru.betterend.registry.BlockEntityRegistry;
import ru.betterend.registry.EndBlockEntities;
public class EBarrelBlockEntity extends LootableContainerBlockEntity {
private DefaultedList<ItemStack> inventory;
@ -33,7 +33,7 @@ public class EBarrelBlockEntity extends LootableContainerBlockEntity {
}
public EBarrelBlockEntity() {
this(BlockEntityRegistry.BARREL);
this(EndBlockEntities.BARREL);
}
public CompoundTag toTag(CompoundTag tag) {

View file

@ -1,10 +1,10 @@
package ru.betterend.blocks.entities;
import net.minecraft.block.entity.ChestBlockEntity;
import ru.betterend.registry.BlockEntityRegistry;
import ru.betterend.registry.EndBlockEntities;
public class EChestBlockEntity extends ChestBlockEntity {
public EChestBlockEntity() {
super(BlockEntityRegistry.CHEST);
super(EndBlockEntities.CHEST);
}
}

View file

@ -25,7 +25,7 @@ import net.minecraft.text.Texts;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import ru.betterend.registry.BlockEntityRegistry;
import ru.betterend.registry.EndBlockEntities;
public class ESignBlockEntity extends BlockEntity {
private final Text[] text;
@ -35,7 +35,7 @@ public class ESignBlockEntity extends BlockEntity {
private DyeColor textColor;
public ESignBlockEntity() {
super(BlockEntityRegistry.SIGN);
super(EndBlockEntities.SIGN);
this.text = new Text[] { LiteralText.EMPTY, LiteralText.EMPTY, LiteralText.EMPTY, LiteralText.EMPTY };
this.editable = true;
this.textBeingEdited = new OrderedText[4];

View file

@ -1,481 +1,481 @@
package ru.betterend.blocks.entities;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.LockableContainerBlockEntity;
import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.recipe.BlastingRecipe;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeFinder;
import net.minecraft.recipe.RecipeInputProvider;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.RecipeUnlocker;
import net.minecraft.screen.PropertyDelegate;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.tag.Tag;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.Tickable;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.EndStoneSmelter;
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.registry.BlockEntityRegistry;
public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider, Tickable {
private static final int[] TOP_SLOTS = new int[] { 0, 1 };
private static final int[] BOTTOM_SLOTS = new int[] { 2, 3 };
private static final int[] SIDE_SLOTS = new int[] { 3 };
private static final Map<Item, Integer> availableFuels = Maps.newHashMap();
private final Object2IntOpenHashMap<Identifier> recipesUsed;
protected DefaultedList<ItemStack> inventory;
protected final PropertyDelegate propertyDelegate;
private Recipe<?> lastRecipe;
private int smeltTimeTotal;
private int smeltTime;
private int burnTime;
private int fuelTime;
public EndStoneSmelterBlockEntity() {
super(BlockEntityRegistry.END_STONE_SMELTER);
this.inventory = DefaultedList.ofSize(4, ItemStack.EMPTY);
this.recipesUsed = new Object2IntOpenHashMap<Identifier>();
this.propertyDelegate = new PropertyDelegate() {
public int get(int index) {
switch(index) {
case 0:
return EndStoneSmelterBlockEntity.this.burnTime;
case 1:
return EndStoneSmelterBlockEntity.this.fuelTime;
case 2:
return EndStoneSmelterBlockEntity.this.smeltTime;
case 3:
return EndStoneSmelterBlockEntity.this.smeltTimeTotal;
default:
return 0;
}
}
public void set(int index, int value) {
switch(index) {
case 0:
EndStoneSmelterBlockEntity.this.burnTime = value;
break;
case 1:
EndStoneSmelterBlockEntity.this.fuelTime = value;
break;
case 2:
EndStoneSmelterBlockEntity.this.smeltTime = value;
break;
case 3:
EndStoneSmelterBlockEntity.this.smeltTimeTotal = value;
}
}
public int size() {
return 4;
}
};
this.registerFuels();
}
private void registerFuels() {
registerFuel(Items.LAVA_BUCKET, 16000);
registerFuel(Blocks.COAL_BLOCK, 12000);
registerFuel(Items.BLAZE_ROD, 2000);
}
private boolean isBurning() {
return this.burnTime > 0;
}
@Override
public int size() {
return this.inventory.size();
}
@Override
public boolean isEmpty() {
Iterator<ItemStack> iterator = this.inventory.iterator();
ItemStack itemStack;
do {
if (!iterator.hasNext()) {
return true;
}
itemStack = iterator.next();
} while (itemStack.isEmpty());
return false;
}
@Override
public ItemStack getStack(int slot) {
return this.inventory.get(slot);
}
@Override
public ItemStack removeStack(int slot, int amount) {
return Inventories.splitStack(this.inventory, slot, amount);
}
@Override
public ItemStack removeStack(int slot) {
return Inventories.removeStack(this.inventory, slot);
}
@Override
public void setStack(int slot, ItemStack stack) {
ItemStack itemStack = this.inventory.get(slot);
boolean stackValid = !stack.isEmpty() && stack.isItemEqualIgnoreDamage(itemStack) && ItemStack.areTagsEqual(stack, itemStack);
this.inventory.set(slot, stack);
if (stack.getCount() > getMaxCountPerStack()) {
stack.setCount(getMaxCountPerStack());
}
if ((slot == 0 || slot == 1) && !stackValid) {
this.smeltTimeTotal = this.getSmeltTime();
this.smeltTime = 0;
this.markDirty();
}
}
protected int getSmeltTime() {
int smeltTime = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world)
.map(AlloyingRecipe::getSmeltTime).orElse(0);
if (smeltTime == 0) {
smeltTime = this.world.getRecipeManager().getFirstMatch(RecipeType.BLASTING, this, world)
.map(BlastingRecipe::getCookTime).orElse(200);
smeltTime /= 1.5;
}
return smeltTime;
}
public void dropExperience(PlayerEntity player) {
List<Recipe<?>> list = Lists.newArrayList();
ObjectIterator<Entry<Identifier>> usedRecipes = this.recipesUsed.object2IntEntrySet().iterator();
while(usedRecipes.hasNext()) {
Entry<Identifier> entry = usedRecipes.next();
world.getRecipeManager().get(entry.getKey()).ifPresent((recipe) -> {
list.add(recipe);
if (recipe instanceof AlloyingRecipe) {
AlloyingRecipe alloying = (AlloyingRecipe) recipe;
this.dropExperience(player.world, player.getPos(), entry.getIntValue(), alloying.getExperience());
} else {
BlastingRecipe blasting = (BlastingRecipe) recipe;
this.dropExperience(player.world, player.getPos(), entry.getIntValue(), blasting.getExperience());
}
});
}
player.unlockRecipes(list);
this.recipesUsed.clear();
}
private void dropExperience(World world, Vec3d vec3d, int i, float f) {
int j = MathHelper.floor(i * f);
float g = MathHelper.fractionalPart(i * f);
if (g != 0.0F && Math.random() < g) {
j++;
}
while(j > 0) {
int k = ExperienceOrbEntity.roundToOrbSize(j);
j -= k;
world.spawnEntity(new ExperienceOrbEntity(world, vec3d.x, vec3d.y, vec3d.z, k));
}
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
if (this.world.getBlockEntity(this.pos) != this) {
return false;
} else {
return player.squaredDistanceTo(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64.0D;
}
}
@Override
public void clear() {
this.inventory.clear();
}
@Override
protected Text getContainerName() {
return new TranslatableText(String.format("block.%s.%s", BetterEnd.MOD_ID, EndStoneSmelter.ID));
}
@Override
protected ScreenHandler createScreenHandler(int syncId, PlayerInventory playerInventory) {
return new EndStoneSmelterScreenHandler(syncId, playerInventory, this, propertyDelegate);
}
@Override
public void tick() {
boolean initialBurning = this.isBurning();
boolean smelting = false;
if (initialBurning) {
this.burnTime--;
}
boolean burning = this.isBurning();
if (!this.world.isClient) {
ItemStack fuel = this.inventory.get(2);
if (!burning && (fuel.isEmpty() || inventory.get(0).isEmpty() && inventory.get(1).isEmpty())) {
if (!burning && smeltTime > 0) {
this.smeltTime = MathHelper.clamp(smeltTime - 2, 0, smeltTimeTotal);
}
} else {
Recipe<?> recipe = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world).orElse(null);
if (recipe == null) {
recipe = this.world.getRecipeManager().getFirstMatch(RecipeType.BLASTING, this, world).orElse(null);
}
boolean accepted = this.canAcceptRecipeOutput(recipe);
if (!burning && accepted) {
this.burnTime = this.getFuelTime(fuel);
this.fuelTime = this.burnTime;
burning = this.isBurning();
if (burning) {
smelting = true;
if (!fuel.isEmpty()) {
Item item = fuel.getItem();
fuel.decrement(1);
if (fuel.isEmpty()) {
Item remainFuel = item.getRecipeRemainder();
this.inventory.set(2, remainFuel == null ? ItemStack.EMPTY : new ItemStack(remainFuel));
}
}
}
}
if (burning && accepted) {
this.smeltTime++;
if (smeltTime == smeltTimeTotal) {
this.smeltTime = 0;
this.smeltTimeTotal = this.getSmeltTime();
this.craftRecipe(recipe);
smelting = true;
}
} else {
this.smeltTime = 0;
}
}
if (initialBurning != burning) {
smelting = true;
this.world.setBlockState(pos, world.getBlockState(pos).with(EndStoneSmelter.LIT, burning), 3);
}
}
if (smelting) {
this.markDirty();
}
}
protected boolean canAcceptRecipeOutput(Recipe<?> recipe) {
if (recipe == null) return false;
boolean validInput = false;
if (recipe instanceof AlloyingRecipe) {
validInput = !inventory.get(0).isEmpty() &&
!inventory.get(1).isEmpty();
} else {
validInput = !inventory.get(0).isEmpty() ||
!inventory.get(1).isEmpty();
}
if (validInput) {
ItemStack result = recipe.getOutput();
if (result.isEmpty()) {
return false;
} else {
ItemStack output = this.inventory.get(3);
int outCount = output.getCount();
int total = outCount + result.getCount();
if (output.isEmpty()) {
return true;
} else if (!output.isItemEqualIgnoreDamage(result)) {
return false;
} else if (outCount < this.getMaxCountPerStack() && outCount < output.getMaxCount()) {
return this.getMaxCountPerStack() >= total;
} else {
return output.getCount() < result.getMaxCount();
}
}
}
return false;
}
private void craftRecipe(Recipe<?> recipe) {
if (recipe == null || !canAcceptRecipeOutput(recipe)) return;
ItemStack result = recipe.getOutput();
ItemStack output = this.inventory.get(3);
if (output.isEmpty()) {
this.inventory.set(3, result.copy());
} else if (output.getItem() == result.getItem()) {
output.increment(result.getCount());
}
if (!this.world.isClient) {
this.setLastRecipe(recipe);
}
if (recipe instanceof AlloyingRecipe) {
this.inventory.get(0).decrement(1);
this.inventory.get(1).decrement(1);
} else {
if (!this.inventory.get(0).isEmpty()) {
this.inventory.get(0).decrement(1);
} else {
this.inventory.get(1).decrement(1);
}
}
}
@Override
public void provideRecipeInputs(RecipeFinder finder) {
Iterator<ItemStack> inventory = this.inventory.iterator();
while(inventory.hasNext()) {
ItemStack itemStack = inventory.next();
finder.addItem(itemStack);
}
}
@Override
public void setLastRecipe(Recipe<?> recipe) {
if (recipe != null) {
Identifier recipeId = recipe.getId();
this.recipesUsed.addTo(recipeId, 1);
this.lastRecipe = recipe;
}
}
@Override
public Recipe<?> getLastRecipe() {
return this.lastRecipe;
}
@Override
public int[] getAvailableSlots(Direction side) {
if (side == Direction.DOWN) {
return BOTTOM_SLOTS;
} else {
return side == Direction.UP ? TOP_SLOTS : SIDE_SLOTS;
}
}
@Override
public boolean canInsert(int slot, ItemStack stack, Direction dir) {
return this.isValid(slot, stack);
}
@Override
public boolean canExtract(int slot, ItemStack stack, Direction dir) {
if (dir == Direction.DOWN && slot == 2) {
if (stack.getItem() != Items.BUCKET) {
return false;
}
}
return true;
}
protected int getFuelTime(ItemStack fuel) {
if (fuel.isEmpty()) {
return 0;
} else {
Item item = fuel.getItem();
return availableFuels.getOrDefault(item, 0);
}
}
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
this.inventory = DefaultedList.ofSize(size(), ItemStack.EMPTY);
Inventories.fromTag(tag, inventory);
this.burnTime = tag.getShort("BurnTime");
this.fuelTime = tag.getShort("FuelTime");
this.smeltTime = tag.getShort("SmeltTime");
this.smeltTimeTotal = tag.getShort("SmeltTimeTotal");
CompoundTag compoundTag = tag.getCompound("RecipesUsed");
Iterator<String> recipes = compoundTag.getKeys().iterator();
while(recipes.hasNext()) {
String id = recipes.next();
this.recipesUsed.put(new Identifier(id), compoundTag.getInt(id));
}
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
tag.putShort("BurnTime", (short) burnTime);
tag.putShort("FuelTime", (short) fuelTime);
tag.putShort("SmeltTime", (short) smeltTime);
tag.putShort("SmeltTimeTotal", (short) smeltTimeTotal);
Inventories.toTag(tag, inventory);
CompoundTag usedRecipes = new CompoundTag();
this.recipesUsed.forEach((identifier, integer) -> {
usedRecipes.putInt(identifier.toString(), integer);
});
tag.put("RecipesUsed", usedRecipes);
return tag;
}
public boolean isValid(int slot, ItemStack stack) {
if (slot == 3) {
return false;
} else if (slot != 0 || slot != 1) {
return true;
} else {
ItemStack itemStack = this.inventory.get(2);
return canUseAsFuel(stack) || stack.getItem() == Items.BUCKET && itemStack.getItem() != Items.BUCKET;
}
}
public static boolean canUseAsFuel(ItemStack stack) {
return availableFuels.containsKey(stack.getItem());
}
public static void registerFuel(ItemConvertible fuel, int time) {
if (availableFuels.containsKey(fuel)) {
availableFuels.replace(fuel.asItem(), time);
} else {
availableFuels.put(fuel.asItem(), time);
}
}
public static void registerFuel(Tag<Item> tag, int time) {
Iterator<Item> tagItems = tag.values().iterator();
tagItems.forEachRemaining(item -> registerFuel(item, time));
}
public static Map<Item, Integer> availableFuels() {
return availableFuels;
}
}
package ru.betterend.blocks.entities;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.LockableContainerBlockEntity;
import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.recipe.BlastingRecipe;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeFinder;
import net.minecraft.recipe.RecipeInputProvider;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.RecipeUnlocker;
import net.minecraft.screen.PropertyDelegate;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.tag.Tag;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.Tickable;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.EndStoneSmelter;
import ru.betterend.client.gui.EndStoneSmelterScreenHandler;
import ru.betterend.recipe.builders.AlloyingRecipe;
import ru.betterend.registry.EndBlockEntities;
public class EndStoneSmelterBlockEntity extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider, Tickable {
private static final int[] TOP_SLOTS = new int[] { 0, 1 };
private static final int[] BOTTOM_SLOTS = new int[] { 2, 3 };
private static final int[] SIDE_SLOTS = new int[] { 3 };
private static final Map<Item, Integer> availableFuels = Maps.newHashMap();
private final Object2IntOpenHashMap<Identifier> recipesUsed;
protected DefaultedList<ItemStack> inventory;
protected final PropertyDelegate propertyDelegate;
private Recipe<?> lastRecipe;
private int smeltTimeTotal;
private int smeltTime;
private int burnTime;
private int fuelTime;
public EndStoneSmelterBlockEntity() {
super(EndBlockEntities.END_STONE_SMELTER);
this.inventory = DefaultedList.ofSize(4, ItemStack.EMPTY);
this.recipesUsed = new Object2IntOpenHashMap<Identifier>();
this.propertyDelegate = new PropertyDelegate() {
public int get(int index) {
switch(index) {
case 0:
return EndStoneSmelterBlockEntity.this.burnTime;
case 1:
return EndStoneSmelterBlockEntity.this.fuelTime;
case 2:
return EndStoneSmelterBlockEntity.this.smeltTime;
case 3:
return EndStoneSmelterBlockEntity.this.smeltTimeTotal;
default:
return 0;
}
}
public void set(int index, int value) {
switch(index) {
case 0:
EndStoneSmelterBlockEntity.this.burnTime = value;
break;
case 1:
EndStoneSmelterBlockEntity.this.fuelTime = value;
break;
case 2:
EndStoneSmelterBlockEntity.this.smeltTime = value;
break;
case 3:
EndStoneSmelterBlockEntity.this.smeltTimeTotal = value;
}
}
public int size() {
return 4;
}
};
this.registerFuels();
}
private void registerFuels() {
registerFuel(Items.LAVA_BUCKET, 16000);
registerFuel(Blocks.COAL_BLOCK, 12000);
registerFuel(Items.BLAZE_ROD, 2000);
}
private boolean isBurning() {
return this.burnTime > 0;
}
@Override
public int size() {
return this.inventory.size();
}
@Override
public boolean isEmpty() {
Iterator<ItemStack> iterator = this.inventory.iterator();
ItemStack itemStack;
do {
if (!iterator.hasNext()) {
return true;
}
itemStack = iterator.next();
} while (itemStack.isEmpty());
return false;
}
@Override
public ItemStack getStack(int slot) {
return this.inventory.get(slot);
}
@Override
public ItemStack removeStack(int slot, int amount) {
return Inventories.splitStack(this.inventory, slot, amount);
}
@Override
public ItemStack removeStack(int slot) {
return Inventories.removeStack(this.inventory, slot);
}
@Override
public void setStack(int slot, ItemStack stack) {
ItemStack itemStack = this.inventory.get(slot);
boolean stackValid = !stack.isEmpty() && stack.isItemEqualIgnoreDamage(itemStack) && ItemStack.areTagsEqual(stack, itemStack);
this.inventory.set(slot, stack);
if (stack.getCount() > getMaxCountPerStack()) {
stack.setCount(getMaxCountPerStack());
}
if ((slot == 0 || slot == 1) && !stackValid) {
this.smeltTimeTotal = this.getSmeltTime();
this.smeltTime = 0;
this.markDirty();
}
}
protected int getSmeltTime() {
int smeltTime = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world)
.map(AlloyingRecipe::getSmeltTime).orElse(0);
if (smeltTime == 0) {
smeltTime = this.world.getRecipeManager().getFirstMatch(RecipeType.BLASTING, this, world)
.map(BlastingRecipe::getCookTime).orElse(200);
smeltTime /= 1.5;
}
return smeltTime;
}
public void dropExperience(PlayerEntity player) {
List<Recipe<?>> list = Lists.newArrayList();
ObjectIterator<Entry<Identifier>> usedRecipes = this.recipesUsed.object2IntEntrySet().iterator();
while(usedRecipes.hasNext()) {
Entry<Identifier> entry = usedRecipes.next();
world.getRecipeManager().get(entry.getKey()).ifPresent((recipe) -> {
list.add(recipe);
if (recipe instanceof AlloyingRecipe) {
AlloyingRecipe alloying = (AlloyingRecipe) recipe;
this.dropExperience(player.world, player.getPos(), entry.getIntValue(), alloying.getExperience());
} else {
BlastingRecipe blasting = (BlastingRecipe) recipe;
this.dropExperience(player.world, player.getPos(), entry.getIntValue(), blasting.getExperience());
}
});
}
player.unlockRecipes(list);
this.recipesUsed.clear();
}
private void dropExperience(World world, Vec3d vec3d, int i, float f) {
int j = MathHelper.floor(i * f);
float g = MathHelper.fractionalPart(i * f);
if (g != 0.0F && Math.random() < g) {
j++;
}
while(j > 0) {
int k = ExperienceOrbEntity.roundToOrbSize(j);
j -= k;
world.spawnEntity(new ExperienceOrbEntity(world, vec3d.x, vec3d.y, vec3d.z, k));
}
}
@Override
public boolean canPlayerUse(PlayerEntity player) {
if (this.world.getBlockEntity(this.pos) != this) {
return false;
} else {
return player.squaredDistanceTo(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64.0D;
}
}
@Override
public void clear() {
this.inventory.clear();
}
@Override
protected Text getContainerName() {
return new TranslatableText(String.format("block.%s.%s", BetterEnd.MOD_ID, EndStoneSmelter.ID));
}
@Override
protected ScreenHandler createScreenHandler(int syncId, PlayerInventory playerInventory) {
return new EndStoneSmelterScreenHandler(syncId, playerInventory, this, propertyDelegate);
}
@Override
public void tick() {
boolean initialBurning = this.isBurning();
boolean smelting = false;
if (initialBurning) {
this.burnTime--;
}
boolean burning = this.isBurning();
if (!this.world.isClient) {
ItemStack fuel = this.inventory.get(2);
if (!burning && (fuel.isEmpty() || inventory.get(0).isEmpty() && inventory.get(1).isEmpty())) {
if (!burning && smeltTime > 0) {
this.smeltTime = MathHelper.clamp(smeltTime - 2, 0, smeltTimeTotal);
}
} else {
Recipe<?> recipe = this.world.getRecipeManager().getFirstMatch(AlloyingRecipe.TYPE, this, world).orElse(null);
if (recipe == null) {
recipe = this.world.getRecipeManager().getFirstMatch(RecipeType.BLASTING, this, world).orElse(null);
}
boolean accepted = this.canAcceptRecipeOutput(recipe);
if (!burning && accepted) {
this.burnTime = this.getFuelTime(fuel);
this.fuelTime = this.burnTime;
burning = this.isBurning();
if (burning) {
smelting = true;
if (!fuel.isEmpty()) {
Item item = fuel.getItem();
fuel.decrement(1);
if (fuel.isEmpty()) {
Item remainFuel = item.getRecipeRemainder();
this.inventory.set(2, remainFuel == null ? ItemStack.EMPTY : new ItemStack(remainFuel));
}
}
}
}
if (burning && accepted) {
this.smeltTime++;
if (smeltTime == smeltTimeTotal) {
this.smeltTime = 0;
this.smeltTimeTotal = this.getSmeltTime();
this.craftRecipe(recipe);
smelting = true;
}
} else {
this.smeltTime = 0;
}
}
if (initialBurning != burning) {
smelting = true;
this.world.setBlockState(pos, world.getBlockState(pos).with(EndStoneSmelter.LIT, burning), 3);
}
}
if (smelting) {
this.markDirty();
}
}
protected boolean canAcceptRecipeOutput(Recipe<?> recipe) {
if (recipe == null) return false;
boolean validInput = false;
if (recipe instanceof AlloyingRecipe) {
validInput = !inventory.get(0).isEmpty() &&
!inventory.get(1).isEmpty();
} else {
validInput = !inventory.get(0).isEmpty() ||
!inventory.get(1).isEmpty();
}
if (validInput) {
ItemStack result = recipe.getOutput();
if (result.isEmpty()) {
return false;
} else {
ItemStack output = this.inventory.get(3);
int outCount = output.getCount();
int total = outCount + result.getCount();
if (output.isEmpty()) {
return true;
} else if (!output.isItemEqualIgnoreDamage(result)) {
return false;
} else if (outCount < this.getMaxCountPerStack() && outCount < output.getMaxCount()) {
return this.getMaxCountPerStack() >= total;
} else {
return output.getCount() < result.getMaxCount();
}
}
}
return false;
}
private void craftRecipe(Recipe<?> recipe) {
if (recipe == null || !canAcceptRecipeOutput(recipe)) return;
ItemStack result = recipe.getOutput();
ItemStack output = this.inventory.get(3);
if (output.isEmpty()) {
this.inventory.set(3, result.copy());
} else if (output.getItem() == result.getItem()) {
output.increment(result.getCount());
}
if (!this.world.isClient) {
this.setLastRecipe(recipe);
}
if (recipe instanceof AlloyingRecipe) {
this.inventory.get(0).decrement(1);
this.inventory.get(1).decrement(1);
} else {
if (!this.inventory.get(0).isEmpty()) {
this.inventory.get(0).decrement(1);
} else {
this.inventory.get(1).decrement(1);
}
}
}
@Override
public void provideRecipeInputs(RecipeFinder finder) {
Iterator<ItemStack> inventory = this.inventory.iterator();
while(inventory.hasNext()) {
ItemStack itemStack = inventory.next();
finder.addItem(itemStack);
}
}
@Override
public void setLastRecipe(Recipe<?> recipe) {
if (recipe != null) {
Identifier recipeId = recipe.getId();
this.recipesUsed.addTo(recipeId, 1);
this.lastRecipe = recipe;
}
}
@Override
public Recipe<?> getLastRecipe() {
return this.lastRecipe;
}
@Override
public int[] getAvailableSlots(Direction side) {
if (side == Direction.DOWN) {
return BOTTOM_SLOTS;
} else {
return side == Direction.UP ? TOP_SLOTS : SIDE_SLOTS;
}
}
@Override
public boolean canInsert(int slot, ItemStack stack, Direction dir) {
return this.isValid(slot, stack);
}
@Override
public boolean canExtract(int slot, ItemStack stack, Direction dir) {
if (dir == Direction.DOWN && slot == 2) {
if (stack.getItem() != Items.BUCKET) {
return false;
}
}
return true;
}
protected int getFuelTime(ItemStack fuel) {
if (fuel.isEmpty()) {
return 0;
} else {
Item item = fuel.getItem();
return availableFuels.getOrDefault(item, 0);
}
}
@Override
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
this.inventory = DefaultedList.ofSize(size(), ItemStack.EMPTY);
Inventories.fromTag(tag, inventory);
this.burnTime = tag.getShort("BurnTime");
this.fuelTime = tag.getShort("FuelTime");
this.smeltTime = tag.getShort("SmeltTime");
this.smeltTimeTotal = tag.getShort("SmeltTimeTotal");
CompoundTag compoundTag = tag.getCompound("RecipesUsed");
Iterator<String> recipes = compoundTag.getKeys().iterator();
while(recipes.hasNext()) {
String id = recipes.next();
this.recipesUsed.put(new Identifier(id), compoundTag.getInt(id));
}
}
@Override
public CompoundTag toTag(CompoundTag tag) {
super.toTag(tag);
tag.putShort("BurnTime", (short) burnTime);
tag.putShort("FuelTime", (short) fuelTime);
tag.putShort("SmeltTime", (short) smeltTime);
tag.putShort("SmeltTimeTotal", (short) smeltTimeTotal);
Inventories.toTag(tag, inventory);
CompoundTag usedRecipes = new CompoundTag();
this.recipesUsed.forEach((identifier, integer) -> {
usedRecipes.putInt(identifier.toString(), integer);
});
tag.put("RecipesUsed", usedRecipes);
return tag;
}
public boolean isValid(int slot, ItemStack stack) {
if (slot == 3) {
return false;
} else if (slot != 0 || slot != 1) {
return true;
} else {
ItemStack itemStack = this.inventory.get(2);
return canUseAsFuel(stack) || stack.getItem() == Items.BUCKET && itemStack.getItem() != Items.BUCKET;
}
}
public static boolean canUseAsFuel(ItemStack stack) {
return availableFuels.containsKey(stack.getItem());
}
public static void registerFuel(ItemConvertible fuel, int time) {
if (availableFuels.containsKey(fuel)) {
availableFuels.replace(fuel.asItem(), time);
} else {
availableFuels.put(fuel.asItem(), time);
}
}
public static void registerFuel(Tag<Item> tag, int time) {
Iterator<Item> tagItems = tag.values().iterator();
tagItems.forEachRemaining(item -> registerFuel(item, time));
}
public static Map<Item, Integer> availableFuels() {
return availableFuels;
}
}

View file

@ -33,7 +33,7 @@ import net.minecraft.world.World;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.BlockChest;
import ru.betterend.blocks.entities.EChestBlockEntity;
import ru.betterend.registry.ItemRegistry;
import ru.betterend.registry.EndItems;
public class EChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlockEntity> {
private static final HashMap<Integer, RenderLayer[]> LAYERS = Maps.newHashMap();
@ -162,7 +162,7 @@ public class EChestBlockEntityRenderer extends BlockEntityRenderer<EChestBlockEn
RenderLayer.getEntitySolid(new Identifier("textures/entity/chest/normal_right.png"))
};
ItemRegistry.getModBlocks().forEach((item) -> {
EndItems.getModBlocks().forEach((item) -> {
if (item instanceof BlockItem) {
Block block = ((BlockItem) item).getBlock();
if (block instanceof BlockChest) {

View file

@ -30,7 +30,7 @@ import net.minecraft.util.registry.Registry;
import ru.betterend.BetterEnd;
import ru.betterend.blocks.basis.BlockSign;
import ru.betterend.blocks.entities.ESignBlockEntity;
import ru.betterend.registry.ItemRegistry;
import ru.betterend.registry.EndItems;
public class ESignBlockEntityRenderer extends BlockEntityRenderer<ESignBlockEntity> {
private static final HashMap<Integer, RenderLayer> LAYERS = Maps.newHashMap();
@ -106,7 +106,7 @@ public class ESignBlockEntityRenderer extends BlockEntityRenderer<ESignBlockEnti
static {
defaultLayer = RenderLayer.getEntitySolid(new Identifier("textures/entity/sign/oak.png"));
ItemRegistry.getModBlocks().forEach((item) -> {
EndItems.getModBlocks().forEach((item) -> {
if (item instanceof BlockItem) {
Block block = ((BlockItem) item).getBlock();
if (block instanceof BlockSign) {