Compare commits
4
Commits
3f68f23e13
...
1.21.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcc9472b81
|
||
|
|
b80f430157
|
||
|
|
7c003642c5
|
||
|
|
3b115a1781
|
No files matched your search
@@ -1,3 +1,14 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
|
||||||
|
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
@@ -5,6 +16,7 @@ plugins {
|
|||||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
|
||||||
group = mod_group_id
|
group = mod_group_id
|
||||||
version = mod_version
|
version = mod_version
|
||||||
@@ -107,6 +119,12 @@ minecraft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mixin {
|
||||||
|
add sourceSets.main, "${mod_id}.refmap.json"
|
||||||
|
|
||||||
|
config "${mod_id}.mixins.json"
|
||||||
|
}
|
||||||
|
|
||||||
// Include resources generated by data generators.
|
// Include resources generated by data generators.
|
||||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||||
|
|
||||||
@@ -129,6 +147,7 @@ dependencies {
|
|||||||
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||||
|
|
||||||
|
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||||
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
|
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
|
||||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
|
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
|
||||||
|
|||||||
+7
-7
@@ -1,17 +1,17 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
org.gradle.daemon=false
|
org.gradle.daemon=false
|
||||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||||
minecraft_version=1.21.4
|
minecraft_version=1.21.3
|
||||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||||
# as they do not follow standard versioning conventions.
|
# as they do not follow standard versioning conventions.
|
||||||
minecraft_version_range=[1.21.4,1.22)
|
minecraft_version_range=[1.21.3]
|
||||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||||
forge_version=54.1.0
|
forge_version=53.0.55
|
||||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||||
forge_version_range=[54,)
|
forge_version_range=[53,)
|
||||||
# The loader version range can only use the major version of Forge/FML as bounds
|
# The loader version range can only use the major version of Forge/FML as bounds
|
||||||
loader_version_range=[54,)
|
loader_version_range=[53,)
|
||||||
# The mapping channel to use for mappings.
|
# The mapping channel to use for mappings.
|
||||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||||
@@ -29,7 +29,7 @@ loader_version_range=[54,)
|
|||||||
mapping_channel=official
|
mapping_channel=official
|
||||||
# The mapping version to query from the mapping channel.
|
# The mapping version to query from the mapping channel.
|
||||||
# This must match the format required by the mapping channel.
|
# This must match the format required by the mapping channel.
|
||||||
mapping_version=1.21.4
|
mapping_version=1.21.3
|
||||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||||
mod_id=xp2items
|
mod_id=xp2items
|
||||||
@@ -38,7 +38,7 @@ mod_name=XP -> items
|
|||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=All Rights Reserved
|
mod_license=All Rights Reserved
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.0.1
|
mod_version=0.2.0
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|||||||
+1
-1
@@ -13,4 +13,4 @@ plugins {
|
|||||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = 'jonasmod'
|
rootProject.name = 'xp2items'
|
||||||
@@ -22,6 +22,5 @@ public class Xp2Items {
|
|||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ServerConfig.SPEC, "xp2items.toml");
|
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ServerConfig.SPEC, "xp2items.toml");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,10 +12,12 @@ public class ServerConfig {
|
|||||||
|
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> C_XP_AMOUNT;
|
public static final ForgeConfigSpec.ConfigValue<Integer> C_XP_AMOUNT;
|
||||||
public static final ForgeConfigSpec.ConfigValue<Integer> C_ITEM_AMOUNT;
|
public static final ForgeConfigSpec.ConfigValue<Integer> C_ITEM_AMOUNT;
|
||||||
|
public static final ForgeConfigSpec.ConfigValue<Boolean> C_DISABLE_LOOT_TABLES;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
C_XP_AMOUNT = BUILDER.comment("xp needed per loot drop, 0=per level").define("xp_amount", 25);
|
C_XP_AMOUNT = BUILDER.comment("xp needed per loot drop, 0=per level").define("xp_amount", 25);
|
||||||
C_ITEM_AMOUNT = BUILDER.comment("items per loot drop").define("item_amount", 1);
|
C_ITEM_AMOUNT = BUILDER.comment("items per loot drop").define("item_amount", 1);
|
||||||
|
C_DISABLE_LOOT_TABLES = BUILDER.comment("disable all loot tables").define("disable_loot_tables", false);
|
||||||
|
|
||||||
SPEC = BUILDER.build();
|
SPEC = BUILDER.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.jenny.xp2items.items;
|
package com.jenny.xp2items.items;
|
||||||
|
|
||||||
import com.jenny.xp2items.config.ServerConfig;
|
import com.jenny.xp2items.config.ServerConfig;
|
||||||
import net.minecraft.server.commands.ExperienceCommand;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundEvents;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
@@ -12,7 +14,6 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.apache.logging.log4j.core.jmx.Server;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,22 +23,13 @@ public class xpTalisman extends Item {
|
|||||||
super(properties);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static int getPlayerXP(@NotNull ServerPlayer player) {
|
||||||
public @NotNull InteractionResult use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand interactionHand) {
|
return Mth.floor(player.experienceProgress * (float) player.getXpNeededForNextLevel());
|
||||||
if (!level.isClientSide) {
|
|
||||||
if (ServerConfig.C_XP_AMOUNT.get() > 0) { // xp amount mode
|
|
||||||
spawnItem(level, (ServerPlayer) player);
|
|
||||||
} else { // xp level mode
|
|
||||||
spawnItemLevels(level, (ServerPlayer) player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return InteractionResult.SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void spawnItem(Level level, ServerPlayer player) {
|
private static void spawnItem(Level level, ServerPlayer player) {
|
||||||
List<Item> itemList = ForgeRegistries.ITEMS.getValues().stream().toList();
|
List<Item> itemList = ForgeRegistries.ITEMS.getValues().stream().toList();
|
||||||
int xpNeeded = ServerConfig.C_XP_AMOUNT.get();
|
int xpNeeded = ServerConfig.C_XP_AMOUNT.get();
|
||||||
System.out.println(getPlayerXP(player));
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int expLevelBefore = player.experienceLevel;
|
int expLevelBefore = player.experienceLevel;
|
||||||
float expProgressBefore = player.experienceProgress;
|
float expProgressBefore = player.experienceProgress;
|
||||||
@@ -53,8 +45,11 @@ public class xpTalisman extends Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPlayerXP(ServerPlayer player) {
|
private static void effects(@NotNull Level level, Player player) {
|
||||||
return Mth.floor(player.experienceProgress * (float) player.getXpNeededForNextLevel());
|
level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.PLAYERS, 1.0F, 1.0F);
|
||||||
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
level.addParticle(ParticleTypes.PORTAL, player.getRandomX(0.5F), player.getRandomY() - (double) 0.25F, player.getRandomZ(0.5F), (player.getRandom().nextDouble() - (double) 0.5F) * (double) 2.0F, -player.getRandom().nextDouble(), (player.getRandom().nextDouble() - (double) 0.5F) * (double) 2.0F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void spawnItemLevels(Level level, ServerPlayer player) {
|
private static void spawnItemLevels(Level level, ServerPlayer player) {
|
||||||
@@ -71,4 +66,18 @@ public class xpTalisman extends Item {
|
|||||||
player.setExperiencePoints(0);
|
player.setExperiencePoints(0);
|
||||||
player.giveExperiencePoints(xpPoints);
|
player.giveExperiencePoints(xpPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull InteractionResult use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand interactionHand) {
|
||||||
|
if (!level.isClientSide) {
|
||||||
|
if (ServerConfig.C_XP_AMOUNT.get() > 0) { // xp amount mode
|
||||||
|
spawnItem(level, (ServerPlayer) player);
|
||||||
|
} else { // xp level mode
|
||||||
|
spawnItemLevels(level, (ServerPlayer) player);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
effects(level, player);
|
||||||
|
}
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.jenny.xp2items.mixins;
|
||||||
|
|
||||||
|
import com.jenny.xp2items.config.ServerConfig;
|
||||||
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.storage.loot.LootContext;
|
||||||
|
import net.minecraft.world.level.storage.loot.LootTable;
|
||||||
|
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.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(LootTable.class)
|
||||||
|
public class LootTableMixin {
|
||||||
|
@Inject(method = "getRandomItems(Lnet/minecraft/world/level/storage/loot/LootContext;)Lit/unimi/dsi/fastutil/objects/ObjectArrayList;", at = @At("RETURN"), cancellable = true)
|
||||||
|
private void getRandomItems(LootContext p_230923_, CallbackInfoReturnable<ObjectArrayList<ItemStack>> cir) {
|
||||||
|
if (ServerConfig.C_DISABLE_LOOT_TABLES.get()) {
|
||||||
|
cir.setReturnValue(new ObjectArrayList<>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.8",
|
||||||
|
"package": "com.jenny.xp2items.mixins",
|
||||||
|
"compatibilityLevel": "JAVA_21",
|
||||||
|
"refmap": "xp2items.refmap.json",
|
||||||
|
"client": [
|
||||||
|
],
|
||||||
|
"injectors": {
|
||||||
|
"defaultRequire": 1
|
||||||
|
},
|
||||||
|
"mixins": [
|
||||||
|
"LootTableMixin"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user