-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated dependencies, renamed StaticRegistries to RegistryAccessConta…
…iner, replaced Context with RAC in some wrappers. Added RecipeViewerEvents (WIP), new fluid registry (WIP)
- Loading branch information
1 parent
4797b4d
commit f0efecb
Showing
56 changed files
with
655 additions
and
317 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
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
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
11 changes: 5 additions & 6 deletions
11
src/main/java/dev/latvian/mods/kubejs/bindings/DamageSourceWrapper.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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
package dev.latvian.mods.kubejs.bindings; | ||
|
||
import dev.latvian.mods.kubejs.script.KubeJSContext; | ||
import dev.latvian.mods.kubejs.util.ID; | ||
import dev.latvian.mods.rhino.Context; | ||
import dev.latvian.mods.kubejs.util.RegistryAccessContainer; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
public class DamageSourceWrapper { | ||
public static DamageSource of(Context cx, Object from) { | ||
public static DamageSource of(RegistryAccessContainer registries, Object from) { | ||
return switch (from) { | ||
case DamageSource source -> source; | ||
case Player player -> ((KubeJSContext) cx).getRegistries().damageSources().get().playerAttack(player); | ||
case LivingEntity livingEntity -> ((KubeJSContext) cx).getRegistries().damageSources().get().mobAttack(livingEntity); | ||
case null, default -> ((KubeJSContext) cx).getRegistries().damageSources().get().source(ResourceKey.create(Registries.DAMAGE_TYPE, ID.mc(from))); | ||
case Player player -> registries.damageSources().get().playerAttack(player); | ||
case LivingEntity livingEntity -> registries.damageSources().get().mobAttack(livingEntity); | ||
case null, default -> registries.damageSources().get().source(ResourceKey.create(Registries.DAMAGE_TYPE, ID.mc(from))); | ||
}; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/main/java/dev/latvian/mods/kubejs/bindings/ParticleOptionsWrapper.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,32 @@ | ||
package dev.latvian.mods.kubejs.bindings; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.mojang.brigadier.StringReader; | ||
import dev.latvian.mods.kubejs.util.RegistryAccessContainer; | ||
import net.minecraft.commands.arguments.ParticleArgument; | ||
import net.minecraft.core.particles.DustParticleOptions; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import org.joml.Vector3f; | ||
|
||
public interface ParticleOptionsWrapper { | ||
DustParticleOptions ERROR = new DustParticleOptions(new Vector3f(0F, 0F, 0F), 1F); | ||
|
||
static ParticleOptions wrap(RegistryAccessContainer registries, Object o) { | ||
if (o instanceof ParticleOptions po) { | ||
return po; | ||
} else if (o != null) { | ||
try { | ||
var reader = new StringReader(o instanceof JsonElement j ? j.getAsString() : o.toString()); | ||
return ParticleArgument.readParticle(reader, registries.access()); | ||
} catch (Exception ex) { | ||
throw new RuntimeException("Failed to parse ParticleOptions from " + o, ex); | ||
} | ||
} | ||
|
||
return ERROR; | ||
} | ||
|
||
static ParticleOptions create(ParticleOptions options) { | ||
return options; | ||
} | ||
} |
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
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
Oops, something went wrong.