Skip to content
Merged

Dev #38

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.caching=true
org.gradle.configuration-cache=true
minecraft_version=26.1.2
minecraft_version_range=[26.1,26.2]
neo_version=26.1.2.99
neo_version=26.1.2.109

## Mod Properties

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.devdyna.cakesticklib.api.aspect.logic;

import com.devdyna.cakesticklib.api.templates.SynchedBlockEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand Down Expand Up @@ -29,6 +31,10 @@ default InteractionResult executeWhenNotBucket(ItemStack stack, BlockState state
default InteractionResult bucketAction(ItemStack item, BlockState blockState, Level level,
BlockPos blockPos, Player player, InteractionHand hand, BlockHitResult blockHitResult) {

if (level.getBlockEntity(blockPos) != null)
if (level.getBlockEntity(blockPos) instanceof SynchedBlockEntity be)
be.update();

if (item.isEmpty())
return executeWhenEmpty(item, blockState, level, blockPos, player, hand, blockHitResult);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.devdyna.cakesticklib.api.aspect.logic;

import com.devdyna.cakesticklib.api.templates.SynchedBlockEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand All @@ -17,6 +19,9 @@ default InteractionResult useItemToClear(BlockState blockState, Level level,
// if (!player.isCrouching())
// return InteractionResult.FAIL;

if (level.getBlockEntity(blockPos) instanceof SynchedBlockEntity be)
be.update();

if (level.isClientSide())
return InteractionResult.SUCCESS;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.devdyna.cakesticklib.api.aspect.logic;


import static com.devdyna.cakesticklib.CakeStickLib.MODULE_ID;

import com.devdyna.cakesticklib.api.templates.SynchedBlockEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
Expand All @@ -17,7 +18,9 @@

/**
* Warning :
* <br/><br/> This only support atm SINGLE FLUID TANKS!
* <br/>
* <br/>
* This only support atm SINGLE FLUID TANKS!
*/
public interface FluidTooltipWhenEmpty {

Expand All @@ -31,6 +34,9 @@ default boolean showWhen(BlockEntity be) {
default InteractionResult sendFluidTooltip(ItemStack stack, BlockState state, Level level, BlockPos pos,
Player player, InteractionHand hand, BlockHitResult hitResult) {

if (level.getBlockEntity(pos) instanceof SynchedBlockEntity be)
be.update();

if (level.isClientSide())
return InteractionResult.SUCCESS;

Expand All @@ -42,7 +48,8 @@ default InteractionResult sendFluidTooltip(ItemStack stack, BlockState state, Le
else
player.sendOverlayMessage(
Component.literal(
fluid.getFluidType().getDescription().getString() + " : " + tank.getAmountAsInt(0) + "mb"));
fluid.getFluidType().getDescription().getString() + " : " + tank.getAmountAsInt(0)
+ "mb"));

return InteractionResult.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;

import com.devdyna.cakesticklib.api.templates.SynchedBlockEntity;
import com.devdyna.cakesticklib.api.utils.x;

import net.minecraft.core.BlockPos;
Expand All @@ -28,6 +29,9 @@ default InteractionResult itemUseOn(Player player, Level level, BlockPos pos, In

if (be instanceof NoGuiStorage storage) {

if (be instanceof SynchedBlockEntity sync)
sync.update();

// If holding item -> try insert
if (!stack.isEmpty() && !extractOnly() && insertFilter(stack) && requiredToInsert(stack)) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.devdyna.cakesticklib.api.aspect.logic;

// RIP TickingBE 2025-2026

public interface Tickable {

/**
* Server only ticking
* <br/>
* <br/>
* Level-null SAFE
* <br/>
* <br/>
* Useful for block events
* <br/>
* <br/>
* Dont require super!
*/
default void tickServer() {
}

/**
* Client only ticking
* <br/>
* <br/>
* Level-null SAFE
* <br/>
* <br/>
* Useful for player events
* <br/>
* <br/>
* Dont require super!
*/
default void tickClient() {
}

/**
* Client and Server ticking
* <br/>
* <br/>
* Level-null SAFE
* <br/>
* <br/>
* Usefull for particles
* <br/>
* <br/>
* Dont require super!
*/
default void tickBoth() {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.devdyna.cakesticklib.api.client;
package com.devdyna.cakesticklib.api.client.hud;

import com.devdyna.cakesticklib.api.client.hud.HudInfoRenderHandler;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphicsExtractor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
package com.devdyna.cakesticklib.api.client.utils;

import java.util.function.Consumer;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;
import net.neoforged.neoforge.fluids.FluidStack;

public class FluidRenderHelper {

private TextureAtlasSprite texture;
private int color = 0xFFFFFF;
private float x = 0;
private float y = 0;
private float z = 0;
private float amount = 1000;
private float height = 1.0f;
private float width = 1.0f;
private float scale = 1.0f;
private Consumer<PoseStack> modified = p -> {
p.scale(scale, scale, scale);
p.translate(x, y, z);
};

public FluidRenderHelper() {
}

public static FluidRenderHelper of() {
return new FluidRenderHelper();
}

// /**
// * define the texture of the render<br/>
// * <br/>
// * REQUIRED
// */
// public FluidRenderHelper texture(Identifier rl) {
// return texture(Minecraft.getInstance().getAtlasManager().get(new
// SpriteId(AtlasIds.BLOCKS, rl)));
// }

/**
* define the texture of the render<br/>
* <br/>
* REQUIRED
*/
public FluidRenderHelper texture(FluidStack fluid) {
return texture(Minecraft.getInstance()
.getModelManager()
.getFluidStateModelSet()
.get(fluid.getFluid().defaultFluidState()).stillMaterial().sprite());
}

/**
* define the texture of the render<br/>
* <br/>
* REQUIRED
*/
public FluidRenderHelper textureAndColor(FluidStack f) {
color(f);
return texture(f);
}

/**
* define the texture of the render<br/>
* <br/>
* REQUIRED
*/
public FluidRenderHelper texture(TextureAtlasSprite sp) {
texture = sp;
return this;
}

/**
* define the color of the render<br/>
* <br/>
* REQUIRED
*/
public FluidRenderHelper color(int c) {
color = c;
return this;
}

/**
* define the color of the render<br/>
* <br/>
* use the default fluid color<br/>
* <br/>
* REQUIRED
*/
public FluidRenderHelper color(FluidStack f) {

var fluidModel = Minecraft.getInstance()
.getModelManager()
.getFluidStateModelSet()
.get(f.getFluid().defaultFluidState());

return color((fluidModel.fluidTintSource() != null
? fluidModel.fluidTintSource().colorAsStack(
com.devdyna.cakesticklib.api.utils.x.fluid(f.getFluid()))
: -1) | 0xFF000000);
}

/**
* define the fluid amount<br/>
* <br/>
* REQUIRED
*/
public FluidRenderHelper amount(float a) {
amount = a;
return this;
}

/**
* define the offset of the entire render<br/>
* <br/>
* Default = 0
*/
public FluidRenderHelper offset(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}

/**
* multiply the scale<br/>
* <br/>
* Default = x1.0f
*/
@Deprecated
public FluidRenderHelper scaleMultiplier(float h, float w) {
this.height = h;
this.width = w;
return this;
}

/**
* multiply the scale using the same scale factor<br/>
* <br/>
* Default = x1.0f
*/
public FluidRenderHelper scaleMultiplier(float v) {
this.scale = v;
return this;
}

/**
* multiply the scale using the same scale factor<br/>
* <br/>
* Default = x1.0f
*/
public FluidRenderHelper modify(Consumer<PoseStack> m) {
this.modified = m;
return this;
}

public void build(PoseStack stack, SubmitNodeCollector node, int packedLight) {

if (this.texture == null)
throw new NullPointerException(
"FluidRenderHelper/Texture: You need to set the texture sprite BEFORE build it!");

stack.pushPose();

modified.accept(stack);

float faceSize = 14 / 16f;
float fluidHeight = amount * faceSize;
float inset = 1 / 16f;

TextureRenderUtil.renderDirectionalFace(Direction.NORTH, stack, node, texture,
inset, inset, inset,
width * faceSize, height * fluidHeight,
color, packedLight);

TextureRenderUtil.renderDirectionalFace(Direction.SOUTH, stack, node, texture,
inset, inset, inset,
width * faceSize, height * fluidHeight,
color, packedLight);

TextureRenderUtil.renderDirectionalFace(Direction.EAST, stack, node, texture,
inset, inset, inset,
width * faceSize, height * fluidHeight,
color, packedLight);

TextureRenderUtil.renderDirectionalFace(Direction.WEST, stack, node, texture,
inset, inset, inset,
width * faceSize, height * fluidHeight,
color, packedLight);

TextureRenderUtil.renderDirectionalFace(Direction.UP, stack, node, texture,
inset, inset, inset + fluidHeight,
width * faceSize, height * faceSize,
color, packedLight);

TextureRenderUtil.renderDirectionalFace(Direction.DOWN, stack, node, texture,
inset, inset, 1 - inset,
width * faceSize, height * faceSize,
color, packedLight);

stack.popPose();
}

}
Loading
Loading