Skip to content

Commit

Permalink
1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JustS-js committed Jan 10, 2025
1 parent 6906e52 commit 876269f
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 40 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.16.3
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10

# Fabric API
fabric_version=0.102.0+1.21
fabric_version=0.114.2+1.21.4

# Mod Properties
mod_version = 1.0.5_1.21
mod_version = 1.0.5_1.21.4
maven_group = net.just_s.sframes
archives_base_name = seamless-itemframes
19 changes: 13 additions & 6 deletions src/main/java/net/just_s/sframes/SFramesMod.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
package net.just_s.sframes;

import com.google.common.collect.Lists;
import io.netty.buffer.Unpooled;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.just_s.sframes.mixin.AccessDataTrackerEntries;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.EntityTrackerUpdateS2CPacket;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SFramesMod implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("sframes");
public static final Config CONFIG = new Config();
public static final String TEAM_NAME = "SeamlessFrames";

@Override
public void onInitialize() {
LOGGER.info("Seamless Frames loaded successfully!");
CONFIG.load();
CommandRegistrationCallback.EVENT.register(FrameCommand::register);
ServerLifecycleEvents.SERVER_STARTED.register(
server -> {
Team team = server.getScoreboard().getTeam(TEAM_NAME);
if (team == null) {
team = server.getScoreboard().addTeam(TEAM_NAME);
}
team.setColor(Formatting.byName(SFramesMod.CONFIG.outlineColor));
}
);
}

public static void sendPackets(List<ServerPlayerEntity> players, Packet<?> packet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package net.just_s.sframes.mixin;

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.entity.data.DataTracker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.concurrent.locks.ReadWriteLock;

@Mixin(DataTracker.class)
public interface AccessDataTrackerEntries {
@Accessor
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/net/just_s/sframes/mixin/CustomColorMixin.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.just_s.sframes.mixin;

import io.netty.buffer.Unpooled;
import net.just_s.sframes.SFramesMod;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.TeamS2CPacket;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void inject(ItemUsageContext context, CallbackInfoReturnable<ActionResul
}

itemStack.decrement(1);
cir.setReturnValue(ActionResult.success(world.isClient));
cir.setReturnValue(ActionResult.SUCCESS);
} else {
cir.setReturnValue(ActionResult.CONSUME);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
package net.just_s.sframes.mixin;

import net.just_s.sframes.SFramesMod;
import net.minecraft.component.ComponentHolder;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.EnchantmentEffectComponentTypes;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.decoration.GlowItemFrameEntity;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.item.ItemStack;
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/net/just_s/sframes/mixin/GlowingTickMixin.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package net.just_s.sframes.mixin;

import io.netty.buffer.Unpooled;
import net.just_s.sframes.SFramesMod;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.decoration.BlockAttachedEntity;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket;
import net.minecraft.network.packet.s2c.play.RemoveEntityStatusEffectS2CPacket;
import net.minecraft.network.packet.s2c.play.TeamS2CPacket;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/just_s/sframes/mixin/ItemFrameMixin.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
package net.just_s.sframes.mixin;

import net.just_s.sframes.SFramesMod;
import net.minecraft.component.ComponentType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
import net.minecraft.network.packet.s2c.play.RemoveEntityStatusEffectS2CPacket;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.scoreboard.Team;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -32,13 +28,14 @@

import java.util.List;

import static net.just_s.sframes.SFramesMod.LOGGER;
import static net.just_s.sframes.SFramesMod.generateGlowPacket;


@Mixin(ItemFrameEntity.class)
public class ItemFrameMixin {
@Inject(at = @At("HEAD"), method = "damage", cancellable = true)
private void injectDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
private void injectDamage(ServerWorld world, DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
try {
if (source.getAttacker().isPlayer()) {
PlayerEntity player = (PlayerEntity) source.getAttacker();
Expand Down Expand Up @@ -66,6 +63,7 @@ private void injectDamage(DamageSource source, float amount, CallbackInfoReturna
SFramesMod.sendPackets((ServerPlayerEntity) player, new ParticleS2CPacket(
ParticleTypes.CLOUD,
false,
false,
frame.getX(),
frame.getY(),
frame.getZ(),
Expand All @@ -88,6 +86,7 @@ private void injectDamage(DamageSource source, float amount, CallbackInfoReturna
cir.setReturnValue(true);
cir.cancel();
}
LOGGER.info(itemStackInHand.getItem().getTranslationKey().equals("item.minecraft.leather") + " | " + frame.isInvisible() + " | " + SFramesMod.shouldGlow(frame) + " | " + SFramesMod.CONFIG.fixWithLeather);
if (itemStackInHand.getItem().getTranslationKey().equals("item.minecraft.leather") && (frame.isInvisible() || SFramesMod.shouldGlow(frame)) && SFramesMod.CONFIG.fixWithLeather) {
if (!player.isCreative()) {itemStackInHand.decrement(1);}
frame.getWorld().playSound(
Expand All @@ -111,6 +110,7 @@ private void injectDamage(DamageSource source, float amount, CallbackInfoReturna
SFramesMod.sendPackets((ServerPlayerEntity) player, new ParticleS2CPacket(
ParticleTypes.CRIT,
false,
false,
frame.getX(),
frame.getY(),
frame.getZ(),
Expand Down Expand Up @@ -151,7 +151,7 @@ private void injectInteract(PlayerEntity player, Hand hand, CallbackInfoReturnab
}

@Inject(at = @At("RETURN"), method = "dropHeldStack")
private void injectDropItem(Entity entity, boolean alwaysDrop, CallbackInfo ci) {
private void injectDropItem(ServerWorld world, Entity entity, boolean dropSelf, CallbackInfo ci) {
updateState();
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/net/just_s/sframes/mixin/ServerStartMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand All @@ -15,19 +19,24 @@

@Mixin(MinecraftDedicatedServer.class)
public class ServerStartMixin {
@Shadow @Final private static Logger LOGGER;

@Inject(at = @At("TAIL"), method = "setupServer")
private void inject(CallbackInfoReturnable<Boolean> cir) {
MinecraftDedicatedServer server = ((MinecraftDedicatedServer)(Object)this);
World world = server.getWorlds().iterator().next();

try {
teamSettings(Objects.requireNonNull(world.getScoreboard().getTeam("SeamlessFrames")));
LOGGER.info("SeamlessFrames scoreboard loaded successfully");
} catch (NullPointerException e) {
LOGGER.info("SeamlessFrames does not exist, setting up...");
Team team = world.getScoreboard().addTeam("SeamlessFrames");
teamSettings(team);
}
}

@Unique
private void teamSettings(Team team) {
team.setColor(Formatting.byName(SFramesMod.CONFIG.outlineColor));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"depends": {
"fabricloader": ">=0.14.8",
"fabric": "*",
"minecraft": ">=1.21",
"minecraft": ">=1.21.4",
"java": ">=21"
}
}
3 changes: 1 addition & 2 deletions src/main/resources/sframes.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"DecorationItemMixin",
"GlowingItemFrameMixin",
"GlowingTickMixin",
"ItemFrameMixin",
"ServerStartMixin"
"ItemFrameMixin"
],
"client": [
],
Expand Down

0 comments on commit 876269f

Please sign in to comment.