diff --git a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index c30bd4e4..8c499948 100644 --- a/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,3 +1,4 @@ -// 1.20.4 2024-02-24T15:43:52.02226 Loot Tables +// 1.20.4 2024-02-24T23:19:21.1599424 Loot Tables 9d014f2566cbaceeb72689cf25beee59806d4a11 data/justdirethings/loot_tables/blocks/dire_iron_block.json 9d62cc762313305bbe032473310bafd15bcdb8bd data/justdirethings/loot_tables/blocks/gooblock_tier1.json +fcef2a947be7443c277f0bc8a7ac5379f2084822 data/justdirethings/loot_tables/blocks/goopatternblock.json diff --git a/src/generated/resources/.cache/a1a2ec2da1e0c65903879d2c88015afc97528c8f b/src/generated/resources/.cache/a1a2ec2da1e0c65903879d2c88015afc97528c8f index ea5a00a1..e733f9bc 100644 --- a/src/generated/resources/.cache/a1a2ec2da1e0c65903879d2c88015afc97528c8f +++ b/src/generated/resources/.cache/a1a2ec2da1e0c65903879d2c88015afc97528c8f @@ -1,5 +1,7 @@ -// 1.20.4 2024-02-24T15:43:52.0212591 Block States: justdirethings +// 1.20.4 2024-02-24T23:19:21.1579408 Block States: justdirethings 920cb18580ea999cb4670bf40b25ba5c2a914032 assets/justdirethings/blockstates/dire_iron_block.json 5a4cd222f3bde8915594a1363e2758ee5208517c assets/justdirethings/blockstates/gooblock_tier1.json +c7729d4e41b5ab3c651235a397de2bf7853c6aa9 assets/justdirethings/blockstates/goopatternblock.json cffdbed997636075f20d3cdcd18712085357f847 assets/justdirethings/models/block/dire_iron_block.json 42066c831f2979ed0f605a673e9b7cbdcb5e3f87 assets/justdirethings/models/block/gooblock_tier1.json +ceedc7d14dd60fc6bbce216fa9fca00031083688 assets/justdirethings/models/block/goopatternblock.json diff --git a/src/generated/resources/assets/justdirethings/blockstates/goopatternblock.json b/src/generated/resources/assets/justdirethings/blockstates/goopatternblock.json new file mode 100644 index 00000000..e5fd85e5 --- /dev/null +++ b/src/generated/resources/assets/justdirethings/blockstates/goopatternblock.json @@ -0,0 +1,30 @@ +{ + "variants": { + "facing=down": { + "model": "justdirethings:block/goopatternblock", + "x": 180 + }, + "facing=east": { + "model": "justdirethings:block/goopatternblock", + "x": 90, + "y": 90 + }, + "facing=north": { + "model": "justdirethings:block/goopatternblock", + "x": 90 + }, + "facing=south": { + "model": "justdirethings:block/goopatternblock", + "x": 90, + "y": 180 + }, + "facing=up": { + "model": "justdirethings:block/goopatternblock" + }, + "facing=west": { + "model": "justdirethings:block/goopatternblock", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/justdirethings/models/block/goopatternblock.json b/src/generated/resources/assets/justdirethings/models/block/goopatternblock.json new file mode 100644 index 00000000..0144c01d --- /dev/null +++ b/src/generated/resources/assets/justdirethings/models/block/goopatternblock.json @@ -0,0 +1,9 @@ +{ + "parent": "minecraft:block/orientable_with_bottom", + "textures": { + "bottom": "justdirethings:block/goopatterblock_bottom", + "front": "justdirethings:block/goopatterblock_side", + "side": "justdirethings:block/goopatterblock_side", + "top": "justdirethings:block/goopatterblock_top" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/justdirethings/loot_tables/blocks/goopatternblock.json b/src/generated/resources/data/justdirethings/loot_tables/blocks/goopatternblock.json new file mode 100644 index 00000000..ef777ed7 --- /dev/null +++ b/src/generated/resources/data/justdirethings/loot_tables/blocks/goopatternblock.json @@ -0,0 +1,21 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:air" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "justdirethings:blocks/goopatternblock" +} \ No newline at end of file diff --git a/src/main/java/com/direwolf20/justdirethings/client/blockentityrenders/GooBlockRender_Base.java b/src/main/java/com/direwolf20/justdirethings/client/blockentityrenders/GooBlockRender_Base.java index 01058ac5..4df088b4 100644 --- a/src/main/java/com/direwolf20/justdirethings/client/blockentityrenders/GooBlockRender_Base.java +++ b/src/main/java/com/direwolf20/justdirethings/client/blockentityrenders/GooBlockRender_Base.java @@ -1,6 +1,7 @@ package com.direwolf20.justdirethings.client.blockentityrenders; import com.direwolf20.justdirethings.JustDireThings; +import com.direwolf20.justdirethings.client.renderers.DireVertexConsumer; import com.direwolf20.justdirethings.client.renderers.OurRenderTypes; import com.direwolf20.justdirethings.common.blockentities.gooblocks.GooBlockBE_Base; import com.direwolf20.justdirethings.setup.Registration; @@ -11,6 +12,7 @@ import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; @@ -18,11 +20,17 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.neoforged.neoforge.client.model.data.ModelData; import org.joml.Matrix3f; import org.joml.Matrix4f; +import java.util.BitSet; +import java.util.List; + public class GooBlockRender_Base implements BlockEntityRenderer { public static final ResourceLocation[] patterns = { new ResourceLocation(JustDireThings.MODID, "textures/misc/goorender1.png"), @@ -45,7 +53,7 @@ public GooBlockRender_Base(BlockEntityRendererProvider.Context p_173636_) { public void render(T blockentity, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightsIn, int combinedOverlayIn) { Level level = blockentity.getLevel(); BlockPos pos = blockentity.getBlockPos().above(0); - BlockState renderState = Registration.GooBlock_Tier1.get().defaultBlockState(); + BlockState renderState = Registration.GooPatternBlock.get().defaultBlockState().setValue(BlockStateProperties.FACING, Direction.UP); BlockRenderDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer(); BakedModel ibakedmodel = blockrendererdispatcher.getBlockModel(renderState); BlockColors blockColors = Minecraft.getInstance().getBlockColors(); @@ -53,7 +61,7 @@ public void render(T blockentity, float partialTicks, PoseStack matrixStackIn, M int remainingTicks = blockentity.getRemainingTimeFor(Direction.UP); //Todo All sides if (remainingTicks > 0) { int maxTicks = blockentity.getCraftingDuration(); - renderTextures(Direction.UP, level, pos, matrixStackIn, bufferIn, combinedOverlayIn, renderState, ibakedmodel, modelBlockRenderer, remainingTicks, maxTicks); + //renderTextures(Direction.UP, level, pos, matrixStackIn, bufferIn, combinedOverlayIn, renderState, ibakedmodel, modelBlockRenderer, remainingTicks, maxTicks); } renderTextures(Direction.UP, level, pos, matrixStackIn, bufferIn, combinedOverlayIn, renderState, ibakedmodel, modelBlockRenderer, 535, 1000); //ResourceLocation patternLocation = new ResourceLocation(JustDireThings.MODID, "textures/misc/goorender4.png"); @@ -77,32 +85,34 @@ public void renderTextures(Direction direction, Level level, BlockPos pos, PoseS public void renderTexturePattern(Direction direction, Level level, BlockPos pos, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedOverlayIn, float transparency, ResourceLocation pattern, BlockState renderState, BakedModel ibakedmodel, ModelBlockRenderer modelBlockRenderer) { OurRenderTypes.updateRenders(); + BlockRenderDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer(); matrixStackIn.pushPose(); matrixStackIn.translate(0, 1, 0); //Todo proper sidedness - VertexConsumer vertexconsumer = bufferIn.getBuffer(OurRenderTypes.gooPatternAlpha(pattern)); + + /*VertexConsumer vertexconsumer = bufferIn.getBuffer(OurRenderTypes.gooPatternAlpha(pattern)); matrixStackIn.pushPose(); - matrixStackIn.translate(0, 0, -0.0003f); //Push forward on Z - for the pattern draw TODO variable? + //matrixStackIn.translate(0, 0, -0.0003f); //Push forward on Z - for the pattern draw TODO variable? PoseStack.Pose posestack$pose = matrixStackIn.last(); Matrix4f matrix4f = posestack$pose.pose(); Matrix3f matrix3f = posestack$pose.normal(); - renderQuad(matrix4f, matrix3f, vertexconsumer, 1f, 1f, 1f, 1f, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1); + //renderQuad(matrix4f, matrix3f, vertexconsumer, 1f, 1f, 1f, 1f, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1); matrixStackIn.popPose(); vertexconsumer = bufferIn.getBuffer(OurRenderTypes.gooPatternColor(patterns[8])); matrixStackIn.pushPose(); - matrixStackIn.translate(0, 0, -0.0003f); + //matrixStackIn.translate(0, 0, -0.0003f); PoseStack.Pose posestack$pose2 = matrixStackIn.last(); Matrix4f matrix4f2 = posestack$pose2.pose(); Matrix3f matrix3f2 = posestack$pose2.normal(); - renderQuad(matrix4f2, matrix3f2, vertexconsumer, 1f, 1f, 1f, 1f, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1); + //renderQuad(matrix4f2, matrix3f2, vertexconsumer, 1f, 1f, 1f, 1f, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1);*/ - /*VertexConsumer builder = bufferIn.getBuffer(OurRenderTypes.RenderBlockBackface); + VertexConsumer builder = bufferIn.getBuffer(OurRenderTypes.gooPatternAlpha(pattern)); DireVertexConsumer chunksConsumer = new DireVertexConsumer(builder, transparency); float[] afloat = new float[Direction.values().length * 2]; @@ -113,15 +123,39 @@ public void renderTexturePattern(Direction direction, Level level, BlockPos pos, List list; ModelBlockRenderer.AmbientOcclusionFace modelblockrenderer$ambientocclusionface = new ModelBlockRenderer.AmbientOcclusionFace(); + matrixStackIn.translate(-0.0005f, -0.0005f, -0.0005f); + matrixStackIn.scale(1.001f, 1.001f, 1.001f); + for (Direction renderSide : Direction.values()) { + list = ibakedmodel.getQuads(renderState, renderSide, randomSource, ModelData.EMPTY, null); + if (!list.isEmpty()) { + blockpos$mutableblockpos.setWithOffset(pos, renderSide); + modelBlockRenderer.renderModelFaceAO(level, renderState, pos, matrixStackIn, chunksConsumer, list, afloat, bitset, modelblockrenderer$ambientocclusionface, combinedOverlayIn); + } + } - Direction renderSide = Direction.NORTH; + VertexConsumer builder2 = bufferIn.getBuffer(OurRenderTypes.RenderBlockBackface); + DireVertexConsumer chunksConsumer2 = new DireVertexConsumer(builder2, transparency); - list = ibakedmodel.getQuads(renderState, renderSide, randomSource, ModelData.EMPTY, null); - if (!list.isEmpty()) { - blockpos$mutableblockpos.setWithOffset(pos, renderSide); - modelBlockRenderer.renderModelFaceAO(level, renderState, pos, matrixStackIn, chunksConsumer, list, afloat, bitset, modelblockrenderer$ambientocclusionface, combinedOverlayIn); - }*/ - matrixStackIn.popPose(); + + float[] afloat2 = new float[Direction.values().length * 2]; + BitSet bitset2 = new BitSet(3); + RandomSource randomSource2 = RandomSource.create(); + BlockState renderState2 = Registration.GooBlock_Tier1.get().defaultBlockState(); + BakedModel ibakedmodel2 = blockrendererdispatcher.getBlockModel(renderState2); + randomSource2.setSeed(renderState2.getSeed(pos)); + + BlockPos.MutableBlockPos blockpos$mutableblockpos2 = pos.mutable(); + + List list2; + ModelBlockRenderer.AmbientOcclusionFace modelblockrenderer$ambientocclusionface2 = new ModelBlockRenderer.AmbientOcclusionFace(); + + for (Direction renderSide : Direction.values()) { + list2 = ibakedmodel2.getQuads(renderState2, renderSide, randomSource2, ModelData.EMPTY, null); + if (!list2.isEmpty()) { + blockpos$mutableblockpos2.setWithOffset(pos.relative(direction), renderSide); + modelBlockRenderer.renderModelFaceAO(level, renderState2, pos.relative(direction), matrixStackIn, chunksConsumer2, list2, afloat2, bitset2, modelblockrenderer$ambientocclusionface2, combinedOverlayIn); + } + } matrixStackIn.popPose(); } diff --git a/src/main/java/com/direwolf20/justdirethings/client/renderers/OurRenderTypes.java b/src/main/java/com/direwolf20/justdirethings/client/renderers/OurRenderTypes.java index cf45ff36..697ebe0d 100644 --- a/src/main/java/com/direwolf20/justdirethings/client/renderers/OurRenderTypes.java +++ b/src/main/java/com/direwolf20/justdirethings/client/renderers/OurRenderTypes.java @@ -65,7 +65,7 @@ public static void updateRenders() { //Only used when testing RenderType.CompositeState overlay = RenderType.CompositeState.builder() .setShaderState(RenderStateShard.RENDERTYPE_ENTITY_ALPHA_SHADER) .setLightmapState(LIGHTMAP) - .setTextureState(new RenderStateShard.TextureStateShard(p_286150_, false, false)) + .setTextureState(BLOCK_SHEET) .setCullState(NO_CULL) .setWriteMaskState(RenderStateShard.DEPTH_WRITE) .createCompositeState(true); diff --git a/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooBlock_Base.java b/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooBlock_Base.java index 3ed431b7..f01f8fb0 100644 --- a/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooBlock_Base.java +++ b/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooBlock_Base.java @@ -8,6 +8,29 @@ public GooBlock_Base() { super(Properties.of() .sound(SoundType.FUNGUS) .strength(2.0f) + .dynamicShape() + .noOcclusion() ); } + + /*@Override + public boolean propagatesSkylightDown(BlockState p_48740_, BlockGetter p_48741_, BlockPos p_48742_) { + return true; + } + + @Override + public float getShadeBrightness(BlockState p_48731_, BlockGetter p_48732_, BlockPos p_48733_) { + return 1.0F; + } + + @Override + public VoxelShape getOcclusionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) { + return super.getOcclusionShape(pState, pLevel, pPos); + } + + @Override + @Deprecated + public boolean useShapeForLightOcclusion(BlockState pState) { + return true; + }*/ } diff --git a/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooPatternBlock.java b/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooPatternBlock.java new file mode 100644 index 00000000..87ec60b2 --- /dev/null +++ b/src/main/java/com/direwolf20/justdirethings/common/blocks/gooblocks/GooPatternBlock.java @@ -0,0 +1,27 @@ +package com.direwolf20.justdirethings.common.blocks.gooblocks; + +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +public class GooPatternBlock extends Block { + public GooPatternBlock() { + super(Properties.of() + .sound(SoundType.FUNGUS) + .strength(2.0f) + ); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext context) { + return this.defaultBlockState().setValue(BlockStateProperties.FACING, context.getClickedFace().getOpposite()); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(BlockStateProperties.FACING); + } +} diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/BlockStates.java b/src/main/java/com/direwolf20/justdirethings/datagen/BlockStates.java index b5172a42..a10ada5a 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/BlockStates.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/BlockStates.java @@ -6,6 +6,8 @@ import net.neoforged.neoforge.client.model.generators.BlockStateProvider; import net.neoforged.neoforge.common.data.ExistingFileHelper; +import java.util.Objects; + public class BlockStates extends BlockStateProvider { public BlockStates(PackOutput output, ExistingFileHelper helper) { @@ -16,8 +18,15 @@ public BlockStates(PackOutput output, ExistingFileHelper helper) { protected void registerStatesAndModels() { simpleBlock(Registration.GooBlock_Tier1.get(), models().cubeAll(Registration.GooBlock_Tier1_ITEM.getId().getPath(), blockTexture(Registration.GooBlock_Tier1.get()))); simpleBlock(Registration.DireIronBlock.get(), models().cubeAll(Registration.DireIronBlock_ITEM.getId().getPath(), blockTexture(Registration.DireIronBlock.get()))); - //models().cubeAll(ForgeRegistries.BLOCKS.getKey(Registration.RenderBlock.get()).getPath(), blockTexture(Registration.RenderBlock.get())).renderType("cutout"); - //simpleBlock(Registration.RenderBlock.get(), models().cubeAll(Registration.RenderBlock.getId().getPath(), blockTexture(Registration.RenderBlock.get())).renderType("cutout")); - //simpleBlock(Registration.LaserNode.get(), models().getExistingFile(modLoc("block/laser_node"))); + + + directionalBlock(Registration.GooPatternBlock.get(), models().orientableWithBottom( + Objects.requireNonNull(Registration.GooPatternBlock.getId()).getPath(), + modLoc("block/goopatterblock_side"), + modLoc("block/goopatterblock_side"), + modLoc("block/goopatterblock_bottom"), + modLoc("block/goopatterblock_top") + )); } + } diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/LootTables.java b/src/main/java/com/direwolf20/justdirethings/datagen/LootTables.java index e6fefac8..d906eb23 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/LootTables.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/LootTables.java @@ -13,6 +13,7 @@ public class LootTables extends VanillaBlockLoot { protected void generate() { dropWhenSilkTouch(Registration.GooBlock_Tier1.get()); dropSelf(Registration.DireIronBlock.get()); + dropSelf(Registration.GooPatternBlock.get()); //add(Registration.RenderBlock.get(), noDrop()); //dropSelf(Registration.TemplateManager.get()); } diff --git a/src/main/java/com/direwolf20/justdirethings/setup/Registration.java b/src/main/java/com/direwolf20/justdirethings/setup/Registration.java index 0dca7252..7eed7b14 100644 --- a/src/main/java/com/direwolf20/justdirethings/setup/Registration.java +++ b/src/main/java/com/direwolf20/justdirethings/setup/Registration.java @@ -4,6 +4,7 @@ import com.direwolf20.justdirethings.common.blockentities.gooblocks.GooBlockBE_Tier1; import com.direwolf20.justdirethings.common.blocks.DireIronBlock; import com.direwolf20.justdirethings.common.blocks.gooblocks.GooBlock_Tier1; +import com.direwolf20.justdirethings.common.blocks.gooblocks.GooPatternBlock; import com.direwolf20.justdirethings.common.containers.FuelCanisterContainer; import com.direwolf20.justdirethings.common.containers.PocketGeneratorContainer; import com.direwolf20.justdirethings.common.items.FuelCanister; @@ -60,6 +61,8 @@ public static void init(IEventBus eventBus) { public static final DeferredHolder GooBlock_Tier1 = BLOCKS.register("gooblock_tier1", GooBlock_Tier1::new); public static final DeferredHolder GooBlock_Tier1_ITEM = ITEMS.register("gooblock_tier1", () -> new BlockItem(GooBlock_Tier1.get(), new Item.Properties())); + public static final DeferredHolder GooPatternBlock = BLOCKS.register("goopatternblock", GooPatternBlock::new); + //Blocks - Resources public static final DeferredHolder DireIronBlock = BLOCKS.register("dire_iron_block", DireIronBlock::new); public static final DeferredHolder DireIronBlock_ITEM = ITEMS.register("dire_iron_block", () -> new BlockItem(DireIronBlock.get(), new Item.Properties())); diff --git a/src/main/resources/assets/justdirethings/textures/block/goopatterblock_bottom.png b/src/main/resources/assets/justdirethings/textures/block/goopatterblock_bottom.png new file mode 100644 index 00000000..0be782d1 Binary files /dev/null and b/src/main/resources/assets/justdirethings/textures/block/goopatterblock_bottom.png differ diff --git a/src/main/resources/assets/justdirethings/textures/block/goopatterblock_side.png b/src/main/resources/assets/justdirethings/textures/block/goopatterblock_side.png new file mode 100644 index 00000000..060a9588 Binary files /dev/null and b/src/main/resources/assets/justdirethings/textures/block/goopatterblock_side.png differ diff --git a/src/main/resources/assets/justdirethings/textures/block/goopatterblock_top.png b/src/main/resources/assets/justdirethings/textures/block/goopatterblock_top.png new file mode 100644 index 00000000..2a4c8365 Binary files /dev/null and b/src/main/resources/assets/justdirethings/textures/block/goopatterblock_top.png differ diff --git a/src/main/resources/assets/justdirethings/textures/misc/goorender10.png b/src/main/resources/assets/justdirethings/textures/misc/goorender10.png index 2cf2330c..0be782d1 100644 Binary files a/src/main/resources/assets/justdirethings/textures/misc/goorender10.png and b/src/main/resources/assets/justdirethings/textures/misc/goorender10.png differ diff --git a/src/main/resources/assets/justdirethings/textures/misc/goorender5.png b/src/main/resources/assets/justdirethings/textures/misc/goorender5.png index bdc0211d..060a9588 100644 Binary files a/src/main/resources/assets/justdirethings/textures/misc/goorender5.png and b/src/main/resources/assets/justdirethings/textures/misc/goorender5.png differ