diff --git a/common/src/main/java/biomesoplenty/block/AnomalyBlock.java b/common/src/main/java/biomesoplenty/block/AnomalyBlock.java index a1a070302..ea9fd93e3 100644 --- a/common/src/main/java/biomesoplenty/block/AnomalyBlock.java +++ b/common/src/main/java/biomesoplenty/block/AnomalyBlock.java @@ -8,6 +8,7 @@ import com.mojang.serialization.MapCodec; import net.minecraft.core.BlockPos; import net.minecraft.util.StringRepresentable; +import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.Block; @@ -18,7 +19,8 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import org.jetbrains.annotations.Nullable; + +import javax.annotation.Nullable; public class AnomalyBlock extends BaseEntityBlock { @@ -37,6 +39,45 @@ protected MapCodec codec() return CODEC; } + @Nullable + @Override + public BlockState getStateForPlacement(BlockPlaceContext p_49479_) + { + AnomalyType type; + switch (p_49479_.getLevel().random.nextInt(4)) + { + default: + case 0: + type = AnomalyBlock.AnomalyType.VOLATILE; + break; + + case 1: + type = AnomalyBlock.AnomalyType.QUIRKY; + break; + + case 2: + type = AnomalyBlock.AnomalyType.UNSTABLE; + break; + + case 3: + type = AnomalyBlock.AnomalyType.STABLE; + break; + } + return this.defaultBlockState().setValue(ANOMALY_TYPE, type); + } + + @Override + public boolean propagatesSkylightDown(BlockState state, BlockGetter getter, BlockPos pos) + { + return state.getValue(ANOMALY_TYPE) != AnomalyType.STABLE; + } + + @Override + public float getShadeBrightness(BlockState state, BlockGetter getter, BlockPos pos) + { + return 1.0F; + } + @Override public RenderShape getRenderShape(BlockState state) { @@ -47,13 +88,6 @@ public RenderShape getRenderShape(BlockState state) public VoxelShape getOcclusionShape(BlockState state, BlockGetter getter, BlockPos pos) { if (state.getValue(ANOMALY_TYPE) == AnomalyType.STABLE) return Shapes.block(); - - AnomalyBlockEntity blockEntity = (AnomalyBlockEntity)getter.getBlockEntity(pos); - - if (blockEntity != null) - { - return blockEntity.getRenderState().getOcclusionShape(getter, pos); - } else return Shapes.empty(); } diff --git a/common/src/main/java/biomesoplenty/block/NullBlock.java b/common/src/main/java/biomesoplenty/block/NullBlock.java new file mode 100644 index 000000000..4591a68ea --- /dev/null +++ b/common/src/main/java/biomesoplenty/block/NullBlock.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright 2022, the Glitchfiend Team. + * All rights reserved. + ******************************************************************************/ +package biomesoplenty.block; + +import biomesoplenty.init.ModParticles; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + +public class NullBlock extends Block +{ + public NullBlock(Properties properties) + { + super(properties); + } + + @Override + public void animateTick(BlockState p_221253_, Level p_221254_, BlockPos p_221255_, RandomSource p_221256_) + { + if (p_221256_.nextInt(5) == 0) + { + Direction direction = Direction.getRandom(p_221256_); + Direction.Axis direction$axis = direction.getAxis(); + BlockPos blockpos = p_221255_.relative(direction); + BlockState blockstate = p_221254_.getBlockState(blockpos); + + if (!isFaceFull(blockstate.getCollisionShape(p_221254_, blockpos), direction)) + { + double d0 = (double)p_221255_.getX() + 0.5D; + double d1 = (double)p_221255_.getY() + 0.5D; + double d2 = (double)p_221255_.getZ() + 0.5D; + + double d3 = (p_221256_.nextDouble() * 0.5D) - (p_221256_.nextDouble() * 0.5D); + double d4 = direction$axis == Direction.Axis.X ? (double)direction.getStepX() * 0.55D : d3; + double d5 = direction$axis == Direction.Axis.Y ? (double)direction.getStepY() * 0.55D : d3; + double d6 = direction$axis == Direction.Axis.Z ? (double)direction.getStepZ() * 0.55D : d3; + + double ymove = 0.1D; + if (direction == Direction.DOWN) + { + ymove = -0.1D; + } + + p_221254_.addParticle(ModParticles.NULL, d0 + d4, d1 + d5, d2 + d6, 0.0D, ymove, 0.0D); + } + } + } +} diff --git a/common/src/main/java/biomesoplenty/client/renderer/AnomalyRenderer.java b/common/src/main/java/biomesoplenty/client/renderer/AnomalyRenderer.java index 6968201f1..a8e68c47c 100644 --- a/common/src/main/java/biomesoplenty/client/renderer/AnomalyRenderer.java +++ b/common/src/main/java/biomesoplenty/client/renderer/AnomalyRenderer.java @@ -6,8 +6,6 @@ import biomesoplenty.block.AnomalyBlock; import biomesoplenty.block.entity.AnomalyBlockEntity; -import biomesoplenty.core.BiomesOPlenty; -import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.MultiBufferSource; @@ -16,18 +14,10 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.state.BlockState; -import java.util.Map; - public class AnomalyRenderer implements BlockEntityRenderer { private final BlockRenderDispatcher dispatcher; @@ -35,6 +25,11 @@ public AnomalyRenderer(BlockEntityRendererProvider.Context context) { this.dispatcher = context.getBlockRenderDispatcher(); } + @Override + public int getViewDistance() { + return 32; + } + @Override public void render(AnomalyBlockEntity blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource buffer, int packedLight, int packedOverlay) { // Do regular model rendering for stable anomalies diff --git a/common/src/main/java/biomesoplenty/init/ModBlocks.java b/common/src/main/java/biomesoplenty/init/ModBlocks.java index 93cab849d..f60dd3ba0 100644 --- a/common/src/main/java/biomesoplenty/init/ModBlocks.java +++ b/common/src/main/java/biomesoplenty/init/ModBlocks.java @@ -129,7 +129,7 @@ private static void registerBlocks(BiConsumer func) ALGAL_END_STONE = register(func, new AlgalEndStoneBlock(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).mapColor(MapColor.TERRACOTTA_YELLOW).randomTicks().requiresCorrectToolForDrops().strength(3.0F, 9.0F)), "algal_end_stone"); BARNACLES = register(func, new BarnaclesBlock(BlockBehaviour.Properties.of().mapColor(MapColor.CLAY).pushReaction(PushReaction.DESTROY).replaceable().noCollission().sound(SoundType.CORAL_BLOCK)), "barnacles"); NULL_END_STONE = register(func, new Block(BlockBehaviour.Properties.of().instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(1.5F, 4.5F)), "null_end_stone"); - NULL_BLOCK = register(func, new Block(BlockBehaviour.Properties.of()), "null_block"); + NULL_BLOCK = register(func, new NullBlock(BlockBehaviour.Properties.of()), "null_block"); ANOMALY = register(func, new AnomalyBlock(BlockBehaviour.Properties.of()), "anomaly"); TOADSTOOL = register(func, new MushroomBlockBOP(BlockBehaviour.Properties.of().pushReaction(PushReaction.DESTROY).mapColor(MapColor.COLOR_ORANGE).noCollission().instabreak().sound(SoundType.GRASS)), "toadstool"); diff --git a/common/src/main/java/biomesoplenty/init/ModClient.java b/common/src/main/java/biomesoplenty/init/ModClient.java index e8314397d..669f37474 100644 --- a/common/src/main/java/biomesoplenty/init/ModClient.java +++ b/common/src/main/java/biomesoplenty/init/ModClient.java @@ -315,6 +315,7 @@ public static void registerParticleSprites(RegisterParticleSpritesEvent event) event.registerSpriteSet(ModParticles.PUS, PusParticle.Provider::new); event.registerSpriteSet(ModParticles.GLOWWORM, GlowwormParticle.Provider::new); event.registerSpriteSet(ModParticles.STEAM, SteamParticle.Provider::new); + event.registerSpriteSet(ModParticles.NULL, NullParticle.Provider::new); event.registerSpriteSet(ModParticles.JACARANDA_LEAVES, (p_277215_) -> { return (p_277217_, p_277218_, p_277219_, p_277220_, p_277221_, p_277222_, p_277223_, p_277224_) -> { return new LeafParticle(p_277218_, p_277219_, p_277220_, p_277221_, p_277215_); diff --git a/common/src/main/java/biomesoplenty/init/ModParticles.java b/common/src/main/java/biomesoplenty/init/ModParticles.java index 278a96324..9d3164c4a 100644 --- a/common/src/main/java/biomesoplenty/init/ModParticles.java +++ b/common/src/main/java/biomesoplenty/init/ModParticles.java @@ -26,6 +26,7 @@ public class ModParticles public static SimpleParticleType RED_MAPLE_LEAVES; public static SimpleParticleType ORANGE_MAPLE_LEAVES; public static SimpleParticleType YELLOW_MAPLE_LEAVES; + public static SimpleParticleType NULL; public static void registerParticles(BiConsumer> func) { @@ -40,6 +41,7 @@ public static void registerParticles(BiConsumer> T register(BiConsumer> func, String name, T particle) diff --git a/common/src/main/java/biomesoplenty/particle/NullParticle.java b/common/src/main/java/biomesoplenty/particle/NullParticle.java new file mode 100644 index 000000000..bf061ef69 --- /dev/null +++ b/common/src/main/java/biomesoplenty/particle/NullParticle.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright 2022, the Glitchfiend Team. + * All rights reserved. + ******************************************************************************/ +package biomesoplenty.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.core.particles.SimpleParticleType; + +public class NullParticle extends TextureSheetParticle +{ + NullParticle(ClientLevel p_105856_, double p_105857_, double p_105858_, double p_105859_, double p_105860_, double p_105861_, double p_105862_) + { + super(p_105856_, p_105857_, p_105858_, p_105859_); + this.setSize(0.02F, 0.02F); + this.lifetime = this.random.nextInt(24) + 8; + this.xd = p_105860_; + this.yd = p_105861_; + this.zd = p_105862_; + } + + @Override + public void tick() + { + this.xo = this.x; + this.yo = this.y; + this.zo = this.z; + if (this.age++ < this.lifetime) + { + this.move(this.xd, this.yd, this.zd); + } + else + { + this.remove(); + } + } + + @Override + public ParticleRenderType getRenderType() { + return ParticleRenderType.PARTICLE_SHEET_OPAQUE; + } + + public static class Provider implements ParticleProvider + { + private final SpriteSet sprites; + + public Provider(SpriteSet p_105899_) { + this.sprites = p_105899_; + } + + public Particle createParticle(SimpleParticleType p_105910_, ClientLevel p_105911_, double p_105912_, double p_105913_, double p_105914_, double p_105915_, double p_105916_, double p_105917_) + { + NullParticle particle = new NullParticle(p_105911_, p_105912_, p_105913_, p_105914_, p_105915_, p_105916_, p_105917_); + particle.pickSprite(this.sprites); + return particle; + } + } +} \ No newline at end of file diff --git a/common/src/main/java/biomesoplenty/worldgen/feature/misc/AnomalyFeature.java b/common/src/main/java/biomesoplenty/worldgen/feature/misc/AnomalyFeature.java index 71dcb84d4..45cbe4926 100644 --- a/common/src/main/java/biomesoplenty/worldgen/feature/misc/AnomalyFeature.java +++ b/common/src/main/java/biomesoplenty/worldgen/feature/misc/AnomalyFeature.java @@ -46,8 +46,8 @@ public boolean place(FeaturePlaceContext featurePlaceC return false; } - int radius = rand.nextInt(3); - int anomalyHeight = (radius*2)+4; + int radius = rand.nextInt(4); + int anomalyHeight = radius+4; if (!this.checkSpace(world, startPos, radius, anomalyHeight)) { diff --git a/common/src/main/resources/assets/biomesoplenty/particles/null.json b/common/src/main/resources/assets/biomesoplenty/particles/null.json new file mode 100644 index 000000000..b84da90ea --- /dev/null +++ b/common/src/main/resources/assets/biomesoplenty/particles/null.json @@ -0,0 +1,7 @@ +{ + "textures": [ + "biomesoplenty:null_0", + "biomesoplenty:null_1", + "biomesoplenty:null_2" + ] +} diff --git a/common/src/main/resources/assets/biomesoplenty/textures/particle/null_0.png b/common/src/main/resources/assets/biomesoplenty/textures/particle/null_0.png new file mode 100644 index 000000000..21b37845d Binary files /dev/null and b/common/src/main/resources/assets/biomesoplenty/textures/particle/null_0.png differ diff --git a/common/src/main/resources/assets/biomesoplenty/textures/particle/null_1.png b/common/src/main/resources/assets/biomesoplenty/textures/particle/null_1.png new file mode 100644 index 000000000..7c718a913 Binary files /dev/null and b/common/src/main/resources/assets/biomesoplenty/textures/particle/null_1.png differ diff --git a/common/src/main/resources/assets/biomesoplenty/textures/particle/null_2.png b/common/src/main/resources/assets/biomesoplenty/textures/particle/null_2.png new file mode 100644 index 000000000..d35f41b75 Binary files /dev/null and b/common/src/main/resources/assets/biomesoplenty/textures/particle/null_2.png differ