-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
107 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.teacon.gimmeman; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.fml.common.Mod; | ||
|
||
@Mod(GiveMeMan.MOD_ID) | ||
public final class GiveMeMan { | ||
public static final String MOD_ID = "gimmeman"; | ||
|
||
public GiveMeMan(IEventBus eventBus) { | ||
|
||
} | ||
|
||
public static ResourceLocation id(String path) { | ||
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/org/teacon/gimmeman/mixin/AdvancementManagerMixin.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
src/main/java/org/teacon/gimmeman/mixin/AdvancementRewardsMixin.java
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
src/main/java/org/teacon/gimmeman/mixin/DisplayInfoMixin.java
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
src/main/java/org/teacon/gimmeman/mixin/L2BackpackMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.teacon.gimmeman.mixin; | ||
|
||
import dev.xkmc.l2backpack.events.StartUpGiveItemEvents; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.level.storage.loot.LootParams; | ||
import net.minecraft.world.level.storage.loot.LootTable; | ||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet; | ||
import net.neoforged.neoforge.event.tick.PlayerTickEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.teacon.gimmeman.GiveMeMan; | ||
|
||
@Mixin(StartUpGiveItemEvents.class) | ||
public class L2BackpackMixin { | ||
|
||
@Inject(method = "onPlayerTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;placeItemBackInInventory(Lnet/minecraft/world/item/ItemStack;)V", shift = At.Shift.AFTER)) | ||
private static void afterBackpackGiven(PlayerTickEvent.Post event, CallbackInfo ci) { | ||
if (!(event.getEntity() instanceof ServerPlayer player)) return; | ||
LootTable lootTable = player.server.reloadableRegistries().getLootTable( | ||
ResourceKey.create(Registries.LOOT_TABLE, GiveMeMan.id("startup_items"))); | ||
LootParams lootParams = (new LootParams.Builder(player.serverLevel())) | ||
.withLuck(player.getLuck()) | ||
.create(LootContextParamSet.builder().build()); | ||
lootTable.getRandomItems(lootParams).forEach(itemStack -> { | ||
if (!player.getInventory().add(itemStack)) { | ||
player.drop(itemStack, false); | ||
} | ||
}); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/org/teacon/gimmeman/mixin/MixinClientAdvancements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.teacon.gimmeman.mixin; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.components.toasts.Toast; | ||
import net.minecraft.client.gui.components.toasts.ToastComponent; | ||
import net.minecraft.client.multiplayer.ClientAdvancements; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ClientAdvancements.class) | ||
public class MixinClientAdvancements { | ||
|
||
@Redirect(method = "update",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/toasts/ToastComponent;addToast(Lnet/minecraft/client/gui/components/toasts/Toast;)V")) | ||
public void onAddToast(ToastComponent instance, Toast arg){ | ||
assert Minecraft.getInstance().player != null; | ||
if (Minecraft.getInstance().player.tickCount < 100) return; | ||
instance.addToast(arg); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/teacon/gimmeman/mixin/MixinPlayerAdvancements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.teacon.gimmeman.mixin; | ||
|
||
import net.minecraft.advancements.DisplayInfo; | ||
import net.minecraft.server.PlayerAdvancements; | ||
import net.minecraft.server.level.ServerPlayer; | ||
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.Redirect; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Consumer; | ||
|
||
@Mixin(PlayerAdvancements.class) | ||
public class MixinPlayerAdvancements { | ||
|
||
@Shadow private ServerPlayer player; | ||
|
||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType") | ||
@Redirect(method = "award", at = @At(value = "INVOKE", target = "Ljava/util/Optional;ifPresent(Ljava/util/function/Consumer;)V")) | ||
public void onBoardCastMessage(Optional<DisplayInfo> instance, Consumer<DisplayInfo> action){ | ||
if (player.tickCount < 100) return; | ||
instance.ifPresent(action); | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
src/main/resources/data/gimmeman/advancement/give_startup_items.json
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters