Skip to content

Commit

Permalink
Initial Work at the gooPattern Block
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Feb 25, 2024
1 parent eb422b9 commit 246a641
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -11,18 +12,25 @@
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;
import net.minecraft.client.resources.model.BakedModel;
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<T extends GooBlockBE_Base> implements BlockEntityRenderer<T> {
public static final ResourceLocation[] patterns = {
new ResourceLocation(JustDireThings.MODID, "textures/misc/goorender1.png"),
Expand All @@ -45,15 +53,15 @@ 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();
ModelBlockRenderer modelBlockRenderer = new ModelBlockRenderer(blockColors);
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");
Expand All @@ -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];
Expand All @@ -113,15 +123,39 @@ public void renderTexturePattern(Direction direction, Level level, BlockPos pos,

List<BakedQuad> 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<BakedQuad> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}*/
}
Original file line number Diff line number Diff line change
@@ -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<Block, BlockState> builder) {
builder.add(BlockStateProperties.FACING);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,6 +61,8 @@ public static void init(IEventBus eventBus) {
public static final DeferredHolder<Block, GooBlock_Tier1> GooBlock_Tier1 = BLOCKS.register("gooblock_tier1", GooBlock_Tier1::new);
public static final DeferredHolder<Item, BlockItem> GooBlock_Tier1_ITEM = ITEMS.register("gooblock_tier1", () -> new BlockItem(GooBlock_Tier1.get(), new Item.Properties()));

public static final DeferredHolder<Block, GooPatternBlock> GooPatternBlock = BLOCKS.register("goopatternblock", GooPatternBlock::new);

//Blocks - Resources
public static final DeferredHolder<Block, DireIronBlock> DireIronBlock = BLOCKS.register("dire_iron_block", DireIronBlock::new);
public static final DeferredHolder<Item, BlockItem> DireIronBlock_ITEM = ITEMS.register("dire_iron_block", () -> new BlockItem(DireIronBlock.get(), new Item.Properties()));
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 246a641

Please sign in to comment.