This commit is contained in:
2026-01-07 09:36:07 +01:00
parent 84c354cf7e
commit c1b19343ae
449 changed files with 5277 additions and 2496 deletions

View File

@@ -0,0 +1,33 @@
package dev.tggamesyt.szar.client;
import dev.tggamesyt.szar.items.Joint;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.item.ItemStack;
public class SmokeZoomHandler {
private static float smokeScale = 0.5f; // start scale
private static final float TARGET_SCALE = 1.05f; // max zoom
private static final float LERP_SPEED = 0.5f; // lerp speed
public static void register() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player == null) return;
ItemStack stack = client.player.getActiveItem();
boolean usingSmoke = stack.getItem() instanceof Joint;
float target = usingSmoke ? TARGET_SCALE : 0.5f;
// lerp smokeScale toward target like spyglass
smokeScale = lerp(LERP_SPEED * client.getTickDelta(), smokeScale, target);
});
}
private static float lerp(float delta, float start, float end) {
return start + delta * (end - start);
}
public static float getSmokeScale() {
return smokeScale;
}
}

View File

@@ -8,14 +8,19 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.*;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.EntityModelLayers;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
public class SzarClient implements ClientModInitializer {
@@ -42,44 +47,75 @@ public class SzarClient implements ClientModInitializer {
Szar.CANNABIS_BLOCK,
RenderLayer.getCutout()
);
WorldRenderEvents.AFTER_TRANSLUCENT.register(context -> {
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.player.hasStatusEffect(Szar.DROG_EFFECT)) {
float time = client.player.age + client.getTickDelta();
float hue = (time * 0.01f) % 1f;
int rgb = MathHelper.hsvToRgb(hue, 1f, 1f);
if (client.player == null) return;
if (!client.player.hasStatusEffect(Szar.DROG_EFFECT)) return;
float alpha = 0.25f;
float r = ((rgb >> 16) & 0xFF) / 255f;
float g = ((rgb >> 8) & 0xFF) / 255f;
float b = (rgb & 0xFF) / 255f;
var effect = client.player.getStatusEffect(Szar.DROG_EFFECT);
int amplifier = effect.getAmplifier(); // 0 = level I
int width = client.getWindow().getFramebufferWidth();
int height = client.getWindow().getFramebufferHeight();
float level = amplifier + 1f;
float time = client.player.age + tickDelta;
RenderSystem.disableDepthTest();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
/* ───── Color speed (gentle ramp) ───── */
float speed = 0.015f + amplifier * 0.012f;
float hue = (time * speed) % 1.0f;
// ✅ Correct shader for 1.20.1 colored quads
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
int rgb = MathHelper.hsvToRgb(hue, 0.95f, 1f);
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
/* ───── Alpha (mostly stable) ───── */
float pulse =
(MathHelper.sin(time * (0.04f + amplifier * 0.015f)) + 1f) * 0.5f;
buffer.vertex(0, height, 0).color(r, g, b, alpha).next();
buffer.vertex(width, height, 0).color(r, g, b, alpha).next();
buffer.vertex(width, 0, 0).color(r, g, b, alpha).next();
buffer.vertex(0, 0, 0).color(r, g, b, alpha).next();
float alpha = MathHelper.clamp(
0.20f + amplifier * 0.10f + pulse * 0.10f,
0.20f,
0.70f
);
Tessellator.getInstance().draw();
/* ───── Very subtle jitter ───── */
float jitter = 0.15f * amplifier;
float jitterX = (client.world.random.nextFloat() - 0.5f) * jitter;
float jitterY = (client.world.random.nextFloat() - 0.5f) * jitter;
RenderSystem.disableBlend();
RenderSystem.enableDepthTest();
int width = client.getWindow().getScaledWidth();
int height = client.getWindow().getScaledHeight();
int color =
((int)(alpha * 255) << 24)
| (rgb & 0x00FFFFFF);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
drawContext.getMatrices().push();
drawContext.getMatrices().translate(jitterX, jitterY, 0);
drawContext.fill(0, 0, width, height, color);
drawContext.getMatrices().pop();
RenderSystem.disableBlend();
});
HudRenderCallback.EVENT.register((drawContext, tickDelta) -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null) return;
float scale = SmokeZoomHandler.getSmokeScale();
if (scale > 0.51f) { // only when smoking
client.inGameHud.spyglassScale = scale;
}
});
SmokeZoomHandler.register();
// In your mod initialization code
FabricModelPredicateProviderRegistry.register(Szar.WEED_JOINT_ITEM, new Identifier("held"),
(stack, world, entity, seed) -> {
return entity != null && entity.getMainHandStack() == stack ? 1.0f : 0.0f;
});
}
}

View File

@@ -0,0 +1,67 @@
package dev.tggamesyt.szar.items;
import dev.tggamesyt.szar.Szar;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SpyglassItem;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.world.World;
public class Joint extends SpyglassItem {
public Joint(Settings settings) {
super(settings.maxDamage(64)); // max durability
}
@Override
public UseAction getUseAction(ItemStack stack) {
return UseAction.SPYGLASS; // keeps spyglass hold animation
}
@Override
public int getMaxUseTime(ItemStack stack) {
return 40; // shorter “smoking” duration
}
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
// play custom smoke sound
user.playSound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK, 1.0F, 1.0F);
user.incrementStat(Stats.USED.getOrCreateStat(this));
user.setCurrentHand(hand); // start using
return TypedActionResult.consume(user.getStackInHand(hand));
}
@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
// Only do server/client side durability and effect
if (!world.isClient) return;
// Consume 1 durability
stack.damage(1, user, p -> p.sendToolBreakStatus(user.getActiveHand()));
// Increase drug effect
int amplifier = 0;
if (user.hasStatusEffect(Szar.DROG_EFFECT)) {
amplifier = Math.min(user.getStatusEffect(Szar.DROG_EFFECT).getAmplifier() + 1, 9); // max 10 levels
}
// Apply the effect (10 seconds, invisible particles)
user.addStatusEffect(new net.minecraft.entity.effect.StatusEffectInstance(
Szar.DROG_EFFECT,
6000,
amplifier,
false, // ambient
false, // show particles
true // show icon
));
// Optional: play inhale / stop sound
user.playSound(SoundEvents.ITEM_HONEY_BOTTLE_DRINK, 1.0F, 1.0F);
}
}

View File

@@ -1,5 +1,6 @@
package dev.tggamesyt.szar;
import dev.tggamesyt.szar.items.Joint;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
@@ -38,7 +39,7 @@ public class Szar implements ModInitializer {
new Identifier(MOD_ID, "nwordpacket");
public static final ItemGroup SZAR_GROUP = Registry.register(
Registries.ITEM_GROUP,
new Identifier("modid", "szar_group"),
new Identifier(MOD_ID, "szar_group"),
FabricItemGroup.builder()
.displayName(Text.translatable("itemgroup.szar_group"))
.icon(() -> new ItemStack(Szar.CIGANYBLOCK)) // icon item
@@ -49,6 +50,7 @@ public class Szar implements ModInitializer {
entries.add(Szar.NIGGER_SPAWNEGG);
entries.add(Szar.CANNABIS_ITEM);
entries.add(Szar.WEED_ITEM);
entries.add(Szar.WEED_JOINT_ITEM);
})
.build()
);
@@ -103,6 +105,11 @@ public class Szar implements ModInitializer {
new Identifier(MOD_ID, "weed"),
new Item(new Item.Settings())
);
public static final Item WEED_JOINT_ITEM = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "weed_joint"),
new Joint(new Item.Settings())
);
public static final Item CIGANYBLOCK = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "cigany"),

View File

@@ -7,5 +7,6 @@
"itemgroup.szar_group": "Szar",
"block.szar.cannabis": "Cannabis",
"item.szar.weed": "Weed",
"effect.szar.drog": "Drog"
"effect.szar.drog": "Drog",
"item.szar.weed_joint": "Weed Joint"
}

View File

@@ -0,0 +1,29 @@
{
"format_version": "1.9.0",
"credit": "Made with Blockbench",
"textures": {
"0": "szar:item/joint3d",
"particle": "szar:item/joint3d"
},
"elements": [
{
"from": [7, 0, 7],
"to": [9, 12, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
"faces": {
"north": {"uv": [0, 0, 2, 12], "texture": "#0"},
"east": {"uv": [2, 0, 4, 12], "texture": "#0"},
"south": {"uv": [4, 0, 6, 12], "texture": "#0"},
"west": {"uv": [6, 0, 8, 12], "texture": "#0"},
"up": {"uv": [10, 2, 8, 0], "texture": "#0"},
"down": {"uv": [10, 2, 8, 4], "texture": "#0"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [90, 0, 0],
"translation": [-6, -1.5, 0]
}
}
}

View File

@@ -0,0 +1,16 @@
{
"parent": "item/generated",
"textures": {
"layer0": "szar:item/weed_joint"
},
"overrides": [
{
"predicate": { "held": 1 },
"model": "szar:item/weed_join_3d"
},
{
"predicate": { "using": 1 },
"model": "szar:item/weed_joint_held"
}
]
}

View File

@@ -0,0 +1,32 @@
{
"format_version": "1.9.0",
"credit": "Made with Blockbench",
"textures": {
"0": "szar:item/joint3d",
"particle": "szar:item/joint3d"
},
"elements": [
{
"from": [7, 0, 7],
"to": [9, 12, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
"faces": {
"north": {"uv": [0, 0, 2, 12], "texture": "#0"},
"east": {"uv": [2, 0, 4, 12], "texture": "#0"},
"south": {"uv": [4, 0, 6, 12], "texture": "#0"},
"west": {"uv": [6, 0, 8, 12], "texture": "#0"},
"up": {"uv": [10, 2, 8, 0], "texture": "#0"},
"down": {"uv": [10, 2, 8, 4], "texture": "#0"}
}
}
],
"overrides": [
{
"predicate": {
"using": 1
},
"model": "szar:item/weed_joint_held"
}
],
"display": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

View File

@@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"WP ",
"PWP",
" PW"
],
"key": {
"W": {
"item": "szar:weed"
},
"P": {
"item": "minecraft:paper"
}
},
"result": {
"item": "szar:weed_joint",
"count": 1
}
}

View File

@@ -9,6 +9,7 @@
"license": "All-Rights-Reserved",
"icon": "assets/szar/icon.png",
"environment": "*",
"accessWidener" : "szar.accesswidener",
"entrypoints": {
"fabric-datagen": [
"dev.tggamesyt.szar.client.SzarDataGenerator"

View File

@@ -0,0 +1,3 @@
accessWidener v2 named
accessible field net/minecraft/client/gui/hud/InGameHud spyglassScale F