Skip to content

Commit

Permalink
Code and recipe cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian-Wuest committed Sep 20, 2024
1 parent 7e1c60e commit 77afb08
Show file tree
Hide file tree
Showing 49 changed files with 67 additions and 80 deletions.
11 changes: 0 additions & 11 deletions src/main/java/com/wuest/prefab/blocks/BlockBoundary.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ public BlockBoundary() {
this.registerDefaultState(this.getStateDefinition().any().setValue(Powered, false));
}

/**
* Queries if this block should render in a given layer.
*/
public static boolean canRenderInLayer(RenderType layer) {
// NOTE: This code is in a partial state. Need to find out how to get block state to determine if the block should be rendered this pass.
boolean powered = false;// state.get(Powered);

// first part is translucent, second is for solid.
return (layer == RenderType.translucent() && !powered) || (layer == RenderType.solid() && powered);
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(BlockBoundary.Powered);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/wuest/prefab/blocks/BlockCustomWall.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ public String getSerializedName() {
return this.name;
}

// public Material getMaterial() {
// return this.material;
// }


public BlockBehaviour getBlockBehaviour() {
return blockBehaviour;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/wuest/prefab/blocks/BlockDirtStairs.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.StairBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;

/**
Expand All @@ -20,7 +19,8 @@ public class BlockDirtStairs extends StairBlock implements IGrassSpreadable {
* Initializes a new instance of the BlockDirtStairs class.
*/
public BlockDirtStairs() {
super(Blocks.DIRT.defaultBlockState(), FabricBlockSettings.ofFullCopy(Blocks.DIRT));
super(Blocks.DIRT.defaultBlockState(),
FabricBlockSettings.ofFullCopy(Blocks.DIRT));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/wuest/prefab/blocks/BlockGrassStairs.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public class BlockGrassStairs extends StairBlock {

public BlockGrassStairs() {
super(Blocks.GRASS_BLOCK.defaultBlockState(), FabricBlockSettings.ofFullCopy(Blocks.GRASS_BLOCK));
super(Blocks.GRASS_BLOCK.defaultBlockState(),
FabricBlockSettings.ofFullCopy(Blocks.GRASS_BLOCK));
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/wuest/prefab/blocks/BlockLightSwitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public class BlockLightSwitch extends TileBlockBase<LightSwitchBlockEntity> {
public static final EnumProperty<AttachFace> FACE;

public static final BooleanProperty POWERED;
// public static final MapCodec<BlockLightSwitch> CODEC = ()->{
// return RecordCodecBuilder.mapCodec((instance -> instance.group(propertiesCodec()).apply(instance,BlockLightSwitch::new)));
// };

public static final MapCodec<BlockLightSwitch> CODEC = simpleCodec(BlockLightSwitch::new);

static {
Expand Down Expand Up @@ -96,7 +94,10 @@ public BlockLightSwitch() {
.mapColor(MapColor.TERRACOTTA_RED)
.pushReaction(PushReaction.DESTROY)
.noOcclusion()
.strength(1.5F, 10.0F).noCollission().strength(0.5F).sound(SoundType.WOOD));
.strength(1.5F, 10.0F)
.noCollission()
.strength(0.5F).
sound(SoundType.WOOD));

this.registerDefaultState(this.defaultBlockState()
.setValue(BlockLightSwitch.FACING, Direction.NORTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class BlockPaperLantern extends Block {
* Initializes a new instance of the BlockPaperLantern class.
*/
public BlockPaperLantern() {
// The "func_226896_b_" function causes the "isSolid" field on the block to be set to false.
super(Prefab.SeeThroughImmovable.get()
.sound(SoundType.SNOW)
.strength(0.6f)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/wuest/prefab/blocks/BlockPhasic.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state,
// Set this block and all neighbor Phasic Blocks to base. This will cascade to tall touching Phasic blocks.
this.updateNeighborPhasicBlocks(false, world, pos, state, false, false);
}

return state;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/wuest/prefab/gui/GuiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ protected Tuple<Integer, Integer> getAdjustedXYValue() {
* @return Some integer value.
*/
public int drawString(GuiGraphics guiGraphics, String text, float x, float y, int color) {
// return this.getFontRenderer().wordWrapHeight(text,Integer.parseInt(String.valueOf(y)));
guiGraphics.drawWordWrap(font, Utils.createTextComponent(text), (int) x, (int) y, 9999, color);
return 0;
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/wuest/prefab/mixins/ClientWorldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
import com.wuest.prefab.structures.render.StructureRenderHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GameRenderer.class)
public class ClientWorldMixin {
public abstract class ClientWorldMixin {
@Shadow public abstract void checkEntityPostEffect(@Nullable Entity entity);

@Inject(method = "renderLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/GameRenderer;renderHand:Z"))
public void renderWorldLast(float tickDelta, long limitTime, PoseStack matrix, CallbackInfo ci) {
Minecraft prefabMinecraft = Minecraft.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public static class Serializer implements RecipeSerializer<ConditionedShapelessR
}
}, DataResult::success).forGetter((shapelessRecipe) -> {
return shapelessRecipe.ingredients;
}), ExtraCodecs.strictOptionalField(Codec.STRING, "config", "").forGetter((shapelessRecipe) -> {
return shapelessRecipe.group;
}), ExtraCodecs.strictOptionalField(Codec.STRING, "configName", "").forGetter((shapelessRecipe) -> {
return shapelessRecipe.configName;
})).apply(instance, ConditionedShapelessRecipe::new);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static class Serializer implements RecipeSerializer<ConditionedSmeltingRe
ItemStack.CODEC.fieldOf("result").forGetter((o) -> o.result),
ExtraCodecs.strictOptionalField(Codec.FLOAT, "experience", 0.1f).forGetter((o) -> o.experience),
ExtraCodecs.strictOptionalField(Codec.INT, "cookingtime", 200).forGetter((o) -> o.cookingTime),
ExtraCodecs.strictOptionalField(Codec.STRING, "config", "").forGetter((o) -> o.configName)
ExtraCodecs.strictOptionalField(Codec.STRING, "configName", "").forGetter((o) -> o.configName)

).apply(instance, ConditionedSmeltingRecipe::new)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

Expand Down Expand Up @@ -88,10 +89,16 @@ public static void renderPlayerLook(Player player, HitResult src, PoseStack matr

MultiBufferSource.BufferSource entityVertexConsumer = Minecraft.getInstance().renderBuffers().bufferSource();

Frustum frustum = new Frustum(matrixStack.last().pose(), RenderSystem.getProjectionMatrix());
// Preparing cull frustum
Vec3 playerEyePosition = player.getEyePosition(1.0F);
Matrix4f matrix4f = matrixStack.last().pose();
Frustum frustum = new Frustum(matrix4f, RenderSystem.getProjectionMatrix());
frustum.prepare(playerEyePosition.x, playerEyePosition.y, playerEyePosition.z);

/*Frustum frustum = new Frustum(matrixStack.last().pose(), RenderSystem.getProjectionMatrix());
Vec3i vec = new Vec3i((int) player.getEyePosition(1.0F).x, (int) player.getEyePosition(1.0F).y, (int) player.getEyePosition(1.0F).z);
BlockPos cameraPos = new BlockPos(vec);
frustum.prepare(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ());
frustum.prepare(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ());*/

for (BuildBlock buildBlock : StructureRenderHandler.currentStructure.getBlocks()) {
Block foundBlock = BuiltInRegistries.BLOCK.get(buildBlock.getResourceLocation());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shapeless",
"config": "Bundle of Timber",
"configName": "Bundle of Timber",
"group": "Bundle of Timber",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shapeless",
"config": "Paper Lantern",
"configName": "Paper Lantern",
"group": "Paper Lantern",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Compressed dirt to normal dirt"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Dirt",
"configName": "Compressed Dirt",
"group": "Compressed Dirt",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Compressed Glowstone to glowstone"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Glowstone",
"configName": "Compressed Glowstone",
"group": "Compressed Glowstone",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Obsidian",
"configName": "Compressed Obsidian",
"group": "Compressed Obsidian",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Obsidian",
"configName": "Compressed Obsidian",
"group": "Compressed Obsidian",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Compressed dirt to normal dirt"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Quartz-Crete",
"configName": "Quartz-Crete",
"group": "Quartz-Crete",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Compressed Stone to normal stone"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Stone",
"configName": "Compressed Stone",
"group": "Compressed Stone",
"ingredients": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/dirt_slab.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"###"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"#",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/dirt_stairs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"# ",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"#",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/dirt_wall.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Double compressed dirt to compressed dirt"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Dirt",
"configName": "Compressed Dirt",
"group": "Compressed Dirt",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Double compressed glowstone to compressed glowstone"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Glowstone",
"configName": "Compressed Glowstone",
"group": "Compressed Glowstone",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Compressed dirt to normal dirt"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Quartz-Crete",
"configName": "Quartz-Crete",
"group": "Quartz-Crete",
"ingredients": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Double compressed Stone to compressed stone"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Compressed Stone",
"configName": "Compressed Stone",
"group": "Compressed Stone",
"ingredients": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/grass_slab.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"###"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"#",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/grass_stairs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"# ",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"#",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/grass_wall.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"###",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shaped",
"config": "Dirt Recipes",
"configName": "Dirt Recipes",
"group": "Dirt Recipes",
"pattern": [
"#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Heap of timber to bundle of timber"
],
"type": "prefab:condition_crafting_shapeless",
"config": "Heap of Timber",
"configName": "Heap of Timber",
"group": "Heap of Timber",
"ingredients": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/house_advanced.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shapeless",
"config": "Advanced House",
"configName": "Advanced House",
"group": "Advanced House",
"ingredients": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/prefab/recipes/house_improved.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "prefab:condition_crafting_shapeless",
"config": "Improved House",
"configName": "Improved House",
"group": "Improved House",
"ingredients": [
{
Expand Down
Loading

0 comments on commit 77afb08

Please sign in to comment.