april
This commit is contained in:
@@ -103,6 +103,8 @@ public class Szar implements ModInitializer {
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
public static int april = 4;
|
||||
public static int fools = 1;
|
||||
public static final Identifier APRIL_GAME_BEATEN = new Identifier(MOD_ID, "april_game_beaten");
|
||||
public static final Identifier APRIL_GAME_BEATEN_REVOKED = new Identifier("szar", "april_game_beaten_revoked");
|
||||
public static final Identifier DRUNK_TYPE_PACKET = new Identifier(MOD_ID, "drunk_type");
|
||||
public static final Identifier OPEN_DETONATOR_SCREEN = new Identifier(MOD_ID, "open_coord_screen");
|
||||
public static final Identifier DETONATOR_INPUT = new Identifier(MOD_ID, "coord_input");
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package dev.tggamesyt.szar.mixin;
|
||||
|
||||
import dev.tggamesyt.szar.Szar;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.minecraft.advancement.Advancement;
|
||||
import net.minecraft.advancement.PlayerAdvancementTracker;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Mixin(PlayerAdvancementTracker.class)
|
||||
public class PlayerAdvancementTrackerMixin {
|
||||
|
||||
@Shadow
|
||||
private ServerPlayerEntity owner;
|
||||
|
||||
@Inject(method = "grantCriterion", at = @At("RETURN"))
|
||||
private void onCriterionGranted(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!cir.getReturnValue()) return;
|
||||
if (owner == null) return;
|
||||
|
||||
if (advancement.getId().equals(new Identifier("end", "kill_dragon"))) {
|
||||
if (!owner.getAdvancementTracker().getProgress(advancement).isDone()) return;
|
||||
|
||||
LocalDate today = LocalDate.now();
|
||||
if (today.getMonthValue() != Szar.april || today.getDayOfMonth() != Szar.fools) return;
|
||||
|
||||
Szar.grantAdvancement(owner, "april_game_beaten");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!advancement.getId().equals(new Identifier(Szar.MOD_ID, "april_game_beaten"))) return;
|
||||
if (!owner.getAdvancementTracker().getProgress(advancement).isDone()) return;
|
||||
|
||||
ServerPlayNetworking.send(owner, Szar.APRIL_GAME_BEATEN, PacketByteBufs.empty());
|
||||
}
|
||||
|
||||
@Inject(method = "revokeCriterion", at = @At("RETURN"))
|
||||
private void onCriterionRevoked(Advancement advancement, String criterionName, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!cir.getReturnValue()) return;
|
||||
if (owner == null) return;
|
||||
|
||||
if (!advancement.getId().equals(new Identifier(Szar.MOD_ID, "april_game_beaten"))) return;
|
||||
// If it's no longer done after revoking, send the revoke packet
|
||||
if (owner.getAdvancementTracker().getProgress(advancement).isDone()) return;
|
||||
|
||||
ServerPlayNetworking.send(owner, Szar.APRIL_GAME_BEATEN_REVOKED, PacketByteBufs.empty());
|
||||
}
|
||||
}
|
||||
@@ -206,5 +206,8 @@
|
||||
"block.szar.ender_obsidian": "Ender Obsidian",
|
||||
"block.szar.ender_ore": "Ender Ore",
|
||||
"item.szar.raw_ender": "Raw Ender",
|
||||
"item.szar.ender_ingot": "Ender Ingot"
|
||||
"item.szar.ender_ingot": "Ender Ingot",
|
||||
|
||||
"advancement.szar.april_game_beaten.title": "We are so back",
|
||||
"advancement.szar.april_game_beaten.description": "Beat the game on april 1st to flip the game back."
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"parent": "szar:april",
|
||||
"display": {
|
||||
"icon": {
|
||||
"item": "szar:april"
|
||||
},
|
||||
"title": {"translate": "advancement.szar.april_game_beaten.title"},
|
||||
"description": {"translate": "advancement.szar.april_game_beaten.description"},
|
||||
"show_toast": true,
|
||||
"announce_to_chat": false,
|
||||
"frame": "challenge"
|
||||
},
|
||||
"criteria": {
|
||||
"used_item": {
|
||||
"trigger": "minecraft:impossible"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
"NoClipMixin",
|
||||
"NoiseChunkGeneratorMixin",
|
||||
"PlaneBlockInteractionMixin",
|
||||
"PlayerAdvancementTrackerMixin",
|
||||
"PlayerDropMixin",
|
||||
"PlayerEntityMixin",
|
||||
"PlayerInteractionMixin",
|
||||
|
||||
Reference in New Issue
Block a user