1.18-pre -> 1.18.2

This commit is contained in:
Sollace 2022-03-26 21:34:15 +02:00
parent ddbf75a44f
commit 9f46fe9270
37 changed files with 187 additions and 121 deletions

View file

@ -2,11 +2,11 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://fabricmc.net/develop
minecraft_version=1.18-pre8 minecraft_version=1.18.2
yarn_mappings=1.18-pre8+build.2 yarn_mappings=1.18.2+build.1
loader_version=0.12.5 loader_version=0.13.3
fabric_version=0.43.0+1.18 fabric_version=0.47.8+1.18.2
# Mod Properties # Mod Properties
group=com.minelittlepony group=com.minelittlepony
@ -15,6 +15,6 @@ org.gradle.daemon=false
description=Magical Abilities for Mine Little Pony! description=Magical Abilities for Mine Little Pony!
# Dependencies # Dependencies
modmenu_version=2.0.0-beta.7 modmenu_version=3.1.0
minelp_version=4.4.1 minelp_version=4.4.4
kirin_version=1.10.0 kirin_version=1.10.0

View file

@ -2,41 +2,41 @@ package com.minelittlepony.unicopia;
import com.minelittlepony.unicopia.item.toxin.Toxics; import com.minelittlepony.unicopia.item.toxin.Toxics;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.tag.Tag; import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public interface UTags { public interface UTags {
Tag<Item> APPLES = item("apples"); TagKey<Item> APPLES = item("apples");
Tag<Item> FRESH_APPLES = item("fresh_apples"); TagKey<Item> FRESH_APPLES = item("fresh_apples");
Tag<Item> FALLS_SLOWLY = item("falls_slowly"); TagKey<Item> FALLS_SLOWLY = item("falls_slowly");
Tag<Item> MAGIC_FEATHERS = item("magic_feathers"); TagKey<Item> MAGIC_FEATHERS = item("magic_feathers");
Tag<Item> SHADES = item("shades"); TagKey<Item> SHADES = item("shades");
Tag<Block> FRAGILE = block("fragile"); TagKey<Block> FRAGILE = block("fragile");
Tag<Block> INTERESTING = block("interesting"); TagKey<Block> INTERESTING = block("interesting");
Tag<Block> CRYSTAL_HEART_BASE = block("crystal_heart_base"); TagKey<Block> CRYSTAL_HEART_BASE = block("crystal_heart_base");
Tag<Block> CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament"); TagKey<Block> CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament");
Tag<EntityType<?>> TRANSFORMABLE_ENTITIES = entity("transformable"); TagKey<EntityType<?>> TRANSFORMABLE_ENTITIES = entity("transformable");
static Tag<Item> item(String name) { static TagKey<Item> item(String name) {
return TagFactory.ITEM.create(new Identifier("unicopia", name)); return TagKey.of(Registry.ITEM_KEY, new Identifier("unicopia", name));
} }
static Tag<Block> block(String name) { static TagKey<Block> block(String name) {
return TagFactory.BLOCK.create(new Identifier("unicopia", name)); return TagKey.of(Registry.BLOCK_KEY, new Identifier("unicopia", name));
} }
static Tag<EntityType<?>> entity(String name) { static TagKey<EntityType<?>> entity(String name) {
return TagFactory.ENTITY_TYPE.create(new Identifier("unicopia", name)); return TagKey.of(Registry.ENTITY_TYPE_KEY, new Identifier("unicopia", name));
} }
static void bootstrap() { static void bootstrap() {

View file

@ -2,6 +2,7 @@ package com.minelittlepony.unicopia;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.PersistentState; import net.minecraft.world.PersistentState;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
@ -29,12 +30,14 @@ public class WorldTribeManager extends PersistentState {
return tag; return tag;
} }
@SuppressWarnings("deprecation") public static String nameFor(RegistryEntry<DimensionType> dimension) {
public static String nameFor(DimensionType dimension) { if (dimension.matchesKey(DimensionType.THE_END_REGISTRY_KEY)) {
return "unicopia:tribes" + dimension.getSuffix(); return "unicopia:tribes_end";
}
return "unicopia:tribes";
} }
public static WorldTribeManager forWorld(ServerWorld world) { public static WorldTribeManager forWorld(ServerWorld world) {
return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimension())); return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.method_40134()));
} }
} }

View file

@ -10,10 +10,10 @@ import com.minelittlepony.unicopia.ability.magic.spell.AbstractDisguiseSpell;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance; import com.minelittlepony.unicopia.entity.behaviour.EntityAppearance;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
import com.minelittlepony.unicopia.particle.UParticles; import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.RayTraceHelper; import com.minelittlepony.unicopia.util.RayTraceHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.decoration.AbstractDecorationEntity; import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -53,7 +53,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
.orElse(e) : e; .orElse(e) : e;
}).orElseGet(() -> trace.getBlockPos().map(pos -> { }).orElseGet(() -> trace.getBlockPos().map(pos -> {
if (!iplayer.getWorld().isAir(pos)) { if (!iplayer.getWorld().isAir(pos)) {
return new FallingBlockEntity(player.getEntityWorld(), 0, 0, 0, iplayer.getWorld().getBlockState(pos)); return MixinFallingBlockEntity.createInstance(player.getEntityWorld(), 0, 0, 0, iplayer.getWorld().getBlockState(pos));
} }
return null; return null;
}).orElse(null)); }).orElse(null));

View file

@ -154,7 +154,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
public static void spawnEffectAround(Entity source, BlockPos center, double radius, double range) { public static void spawnEffectAround(Entity source, BlockPos center, double radius, double range) {
BlockPos.iterate(center.add(-radius, -radius, -radius), center.add(radius, radius, radius)).forEach(i -> { BlockPos.iterate(center.add(-radius, -radius, -radius), center.add(radius, radius, radius)).forEach(i -> {
double dist = Math.sqrt(i.getSquaredDistance(source.getX(), source.getY(), source.getZ(), true)); double dist = Math.sqrt(i.getSquaredDistance(source.getX(), source.getY(), source.getZ()));
if (dist <= radius) { if (dist <= radius) {
spawnEffect(source.world, i, dist, range); spawnEffect(source.world, i, dist, range);

View file

@ -10,6 +10,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.ProjectileSpell;
import com.minelittlepony.unicopia.ability.magic.spell.Situation; import com.minelittlepony.unicopia.ability.magic.spell.Situation;
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits; import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait; import com.minelittlepony.unicopia.ability.magic.spell.trait.Trait;
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.util.RayTraceHelper; import com.minelittlepony.unicopia.util.RayTraceHelper;
@ -105,7 +106,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
} }
Vec3d pos = Vec3d.ofBottomCenter(bpos); Vec3d pos = Vec3d.ofBottomCenter(bpos);
FallingBlockEntity e = new FallingBlockEntity(world, pos.x, pos.y, pos.z, world.getBlockState(bpos)); FallingBlockEntity e = MixinFallingBlockEntity.createInstance(world, pos.x, pos.y, pos.z, world.getBlockState(bpos));
world.removeBlock(bpos, true); world.removeBlock(bpos, true);
e.setOnGround(false); e.setOnGround(false);
e.timeFalling = Integer.MIN_VALUE; e.timeFalling = Integer.MIN_VALUE;
@ -115,5 +116,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
apply.accept(e); apply.accept(e);
} }
world.spawnEntity(e); world.spawnEntity(e);
e.updateVelocity(HORIZONTAL_VARIANCE, pos);
} }
} }

View file

@ -1,10 +1,9 @@
package com.minelittlepony.unicopia.ability.magic.spell.effect; package com.minelittlepony.unicopia.ability.magic.spell.effect;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Optional; import java.util.Optional;
import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.UTags;
@ -15,12 +14,15 @@ import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
import com.minelittlepony.unicopia.entity.UEntities; import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity; import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup; import net.minecraft.entity.SpawnGroup;
import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.MobEntity;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraft.world.World;
/** /**
* Transforms whatever entity it strikes into a random other entity. * Transforms whatever entity it strikes into a random other entity.
@ -40,7 +42,7 @@ public class TransformationSpell extends AbstractSpell implements ProjectileSpel
if (projectile.world.isClient) { if (projectile.world.isClient) {
return; return;
} }
pickType(entity.getType(), entity.world.random).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> { pickType(entity.getType(), entity.world).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> {
entity.playSound(USounds.SPELL_TRANSFORM_TRANSMUTE_ENTITY, 1, 1); entity.playSound(USounds.SPELL_TRANSFORM_TRANSMUTE_ENTITY, 1, 1);
}, () -> { }, () -> {
ParticleUtils.spawnParticles(ParticleTypes.SMOKE, entity, 20); ParticleUtils.spawnParticles(ParticleTypes.SMOKE, entity, 20);
@ -62,8 +64,8 @@ public class TransformationSpell extends AbstractSpell implements ProjectileSpel
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T extends MobEntity> Optional<EntityType<T>> pickType(EntityType<?> except, Random random) { private <T extends MobEntity> Optional<EntityType<T>> pickType(EntityType<?> except, World world) {
Set<EntityType<?>> options = new HashSet<>(UTags.TRANSFORMABLE_ENTITIES.values()); Set<EntityType<?>> options = Registries.valuesForTag(world, UTags.TRANSFORMABLE_ENTITIES).collect(Collectors.toSet());
if (except.getSpawnGroup() == SpawnGroup.MONSTER) { if (except.getSpawnGroup() == SpawnGroup.MONSTER) {
options.removeIf(t -> t.getSpawnGroup() == SpawnGroup.MONSTER); options.removeIf(t -> t.getSpawnGroup() == SpawnGroup.MONSTER);
} else { } else {
@ -72,6 +74,6 @@ public class TransformationSpell extends AbstractSpell implements ProjectileSpel
if (options.size() <= 1) { if (options.size() <= 1) {
return options.stream().findFirst().map(t -> (EntityType<T>)t); return options.stream().findFirst().map(t -> (EntityType<T>)t);
} }
return Optional.ofNullable((EntityType<T>)Util.getRandom(new ArrayList<>(options), random)); return Optional.ofNullable((EntityType<T>)Util.getRandom(new ArrayList<>(options), world.random));
} }
} }

View file

@ -11,7 +11,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.tag.Tag; import net.minecraft.tag.TagKey;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
@ -66,7 +66,7 @@ class BlockStateMap implements BlockStateConverter {
return add(StateMapping.replaceBlock(from, to)); return add(StateMapping.replaceBlock(from, to));
} }
public Builder replaceBlock(Tag<Block> from, Block to) { public Builder replaceBlock(TagKey<Block> from, Block to) {
return add(StateMapping.replaceBlock(from, to)); return add(StateMapping.replaceBlock(from, to));
} }

View file

@ -6,13 +6,15 @@ import java.util.function.Predicate;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Property; import net.minecraft.state.property.Property;
import net.minecraft.tag.Tag; import net.minecraft.tag.TagKey;
import net.minecraft.world.World; import net.minecraft.world.World;
interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockState, BlockState> { interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockState, BlockState> {
@ -49,13 +51,13 @@ interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockSta
(w, s) -> Blocks.AIR.getDefaultState()); (w, s) -> Blocks.AIR.getDefaultState());
} }
static StateMapping replaceBlock(Tag<Block> tag, Block to) { static StateMapping replaceBlock(TagKey<Block> tag, Block to) {
return build( return build(
s -> s.isIn(tag), s -> s.isIn(tag),
(w, s) -> to.getDefaultState(), (w, s) -> to.getDefaultState(),
s -> build( s -> build(
p -> p.isOf(to), p -> p.isOf(to),
(w, p) -> tag.getRandom(w.random).getDefaultState() (w, p) -> Registries.entriesForTag(w, tag).getRandom(w.random).get().value().getDefaultState()
) )
); );
} }

View file

@ -78,7 +78,7 @@ public class KeyBindingsHandler {
} else { } else {
for (Binding i : keys.keySet()) { for (Binding i : keys.keySet()) {
AbilitySlot slot = keys.get(i); AbilitySlot slot = keys.get(i);
if (slot == AbilitySlot.PRIMARY && client.options.keySneak.isPressed() && abilities.isFilled(AbilitySlot.PASSIVE)) { if (slot == AbilitySlot.PRIMARY && client.options.sneakKey.isPressed() && abilities.isFilled(AbilitySlot.PASSIVE)) {
slot = AbilitySlot.PASSIVE; slot = AbilitySlot.PASSIVE;
} }
if (slot == AbilitySlot.PRIMARY && !abilities.isFilled(slot)) { if (slot == AbilitySlot.PRIMARY && !abilities.isFilled(slot)) {

View file

@ -78,7 +78,7 @@ public class DismissSpellScreen extends GameGui {
} }
@Override @Override
public boolean isPauseScreen() { public boolean shouldPause() {
return false; return false;
} }

View file

@ -96,7 +96,7 @@ public class TribeSelectionScreen extends GameGui implements HidesHud {
@Override @Override
public void finish() { public void finish() {
finished = true; finished = true;
onClose(); close();
} }
@Override @Override

View file

@ -113,7 +113,7 @@ public class UHud extends DrawableHelper {
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.setShaderTexture(0, HUD_TEXTURE); RenderSystem.setShaderTexture(0, HUD_TEXTURE);
boolean swap = client.options.keySneak.isPressed(); boolean swap = client.options.sneakKey.isPressed();
slots.forEach(slot -> slot.renderBackground(matrices, abilities, swap, tickDelta)); slots.forEach(slot -> slot.renderBackground(matrices, abilities, swap, tickDelta));
slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta)); slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta));
@ -271,7 +271,7 @@ public class UHud extends DrawableHelper {
void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) {
stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> { stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> {
RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.keySneak.isPressed())); RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.sneakKey.isPressed()));
drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v);
RenderSystem.setShaderTexture(0, HUD_TEXTURE); RenderSystem.setShaderTexture(0, HUD_TEXTURE);
}); });

View file

@ -27,10 +27,10 @@ public abstract class AbstractGeometryBasedParticle extends Particle {
int light = getBrightness(tickDelta); int light = getBrightness(tickDelta);
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT);
buffer.vertex(corners[0].getX(), corners[0].getY(), corners[0].getZ()).texture(0, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corners[0].getX(), corners[0].getY(), corners[0].getZ()).texture(0, 0).color(red, green, blue, alpha).light(light).next();
buffer.vertex(corners[1].getX(), corners[1].getY(), corners[1].getZ()).texture(1, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corners[1].getX(), corners[1].getY(), corners[1].getZ()).texture(1, 0).color(red, green, blue, alpha).light(light).next();
buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(red, green, blue, alpha).light(light).next();
buffer.vertex(corners[3].getX(), corners[3].getY(), corners[3].getZ()).texture(0, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corners[3].getX(), corners[3].getY(), corners[3].getZ()).texture(0, 1).color(red, green, blue, alpha).light(light).next();
te.draw(); te.draw();
} }
@ -39,7 +39,7 @@ public abstract class AbstractGeometryBasedParticle extends Particle {
int light = getBrightness(tickDelta); int light = getBrightness(tickDelta);
for (Vec3f corner : corners) { for (Vec3f corner : corners) {
buffer.vertex(corner.getX(), corner.getY(), corner.getZ()).color(colorRed, colorGreen, colorBlue, alpha).light(light).next(); buffer.vertex(corner.getX(), corner.getY(), corner.getZ()).color(red, green, blue, alpha).light(light).next();
} }
} }

View file

@ -27,10 +27,10 @@ public class MagicParticle extends SpriteBillboardParticle {
scale = random.nextFloat() * 0.12F; scale = random.nextFloat() * 0.12F;
maxAge = (int)(Math.random() * 10) + 20; maxAge = (int)(Math.random() * 10) + 20;
colorRed = color.getX(); red = color.getX();
colorGreen = color.getY(); green = color.getY();
colorBlue = color.getZ(); blue = color.getZ();
colorAlpha = alpha; this.alpha = alpha;
} }
public MagicParticle(MagicParticleEffect effect, SpriteProvider provider, ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) { public MagicParticle(MagicParticleEffect effect, SpriteProvider provider, ClientWorld w, double x, double y, double z, double vX, double vY, double vZ) {

View file

@ -50,7 +50,7 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl
corner.add(x, y, z); corner.add(x, y, z);
} }
float alpha = colorAlpha * (1 - ((float)age / maxAge)); float alpha = this.alpha * (1 - ((float)age / maxAge));
renderQuad(te, buffer, corners, alpha, tickDelta); renderQuad(te, buffer, corners, alpha, tickDelta);
} }

View file

@ -120,7 +120,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
} }
float getAlpha() { float getAlpha() {
return colorAlpha * (1 - ((float)age / maxAge)); return alpha * (1 - ((float)age / maxAge));
} }
boolean tick() { boolean tick() {

View file

@ -43,9 +43,9 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
super(effect, world, x, y, z, velocityX, velocityY, velocityZ); super(effect, world, x, y, z, velocityX, velocityY, velocityZ);
setMaxAge(70); setMaxAge(70);
colorRed = world.random.nextFloat(); red = world.random.nextFloat();
colorGreen = world.random.nextFloat(); green = world.random.nextFloat();
colorBlue = world.random.nextFloat(); blue = world.random.nextFloat();
} }
@Override @Override
@ -72,9 +72,9 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
public void setAttribute(int key, Object value) { public void setAttribute(int key, Object value) {
if (key == 1) { if (key == 1) {
int tint = (int)value; int tint = (int)value;
colorRed = Color.r(tint); red = Color.r(tint);
colorGreen = Color.g(tint); green = Color.g(tint);
colorBlue = Color.b(tint); blue = Color.b(tint);
} }
} }
@Override @Override
@ -100,13 +100,13 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
@Override @Override
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) { protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
float alpha = colorAlpha * getAlphaScale(); float alpha = this.alpha * getAlphaScale();
float angle = MathHelper.lerp(tickDelta, prevRotationAngle, rotationAngle); float angle = MathHelper.lerp(tickDelta, prevRotationAngle, rotationAngle);
for (int i = 0; i < TEXTURES.length; i++) { for (int i = 0; i < TEXTURES.length; i++) {
RenderSystem.setShaderTexture(0, TEXTURES[i]); RenderSystem.setShaderTexture(0, TEXTURES[i]);
RenderSystem.setShaderColor(colorRed, colorGreen, colorBlue, alpha); RenderSystem.setShaderColor(red, green, blue, alpha);
Vec3f[] corners = new Vec3f[]{ Vec3f[] corners = new Vec3f[]{
new Vec3f(-1, -1, 0), new Vec3f(-1, -1, 0),

View file

@ -49,10 +49,10 @@ public class SphereParticle extends Particle implements Attachment {
super(w, x, y, z); super(w, x, y, z);
this.parameters = parameters; this.parameters = parameters;
this.radius = parameters.getRadius(); this.radius = parameters.getRadius();
this.colorRed = parameters.getColor().getX() / 255F; this.red = parameters.getColor().getX() / 255F;
this.colorGreen = parameters.getColor().getY() / 255F; this.green = parameters.getColor().getY() / 255F;
this.colorBlue = parameters.getColor().getZ() / 255F; this.blue = parameters.getColor().getZ() / 255F;
this.colorAlpha = parameters.getAlpha(); this.alpha = parameters.getAlpha();
setMaxAge(10); setMaxAge(10);
} }
@ -82,12 +82,12 @@ public class SphereParticle extends Particle implements Attachment {
} }
if (key == 1) { if (key == 1) {
int tint = (int)value; int tint = (int)value;
colorRed = Color.r(tint); red = Color.r(tint);
colorGreen = Color.g(tint); green = Color.g(tint);
colorBlue = Color.b(tint); blue = Color.b(tint);
} }
if (key == 2) { if (key == 2) {
colorAlpha = (float)value; alpha = (float)value;
} }
} }
@ -121,12 +121,12 @@ public class SphereParticle extends Particle implements Attachment {
@Override @Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) { public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
if (colorAlpha <= 0 || radius <= 0) { if (alpha <= 0 || radius <= 0) {
return; return;
} }
float[] color = ColorHelper.changeSaturation(colorRed, colorGreen, colorBlue, 4); float[] color = ColorHelper.changeSaturation(red, green, blue, 4);
RenderSystem.setShaderColor(color[0], color[1], color[2], colorAlpha / 3F); RenderSystem.setShaderColor(color[0], color[1], color[2], alpha / 3F);
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
VertexConsumer buffer = immediate.getBuffer(RenderLayers.getMagicNoColor()); VertexConsumer buffer = immediate.getBuffer(RenderLayers.getMagicNoColor());

View file

@ -26,7 +26,7 @@ import net.minecraft.world.World;
public class CastSpellEntity extends LightEmittingEntity implements Caster<LivingEntity>, WeaklyOwned<LivingEntity> { public class CastSpellEntity extends LightEmittingEntity implements Caster<LivingEntity>, WeaklyOwned<LivingEntity> {
private static final TrackedData<Float> GRAVITY = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData<Float> GRAVITY = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(CastSpellEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private static final LevelStore LEVELS = Levelled.fixed(0); private static final LevelStore LEVELS = Levelled.fixed(0);

View file

@ -38,8 +38,8 @@ import net.minecraft.nbt.NbtElement;
import net.minecraft.world.World; import net.minecraft.world.World;
public class Creature extends Living<LivingEntity> implements WeaklyOwned<LivingEntity> { public class Creature extends Living<LivingEntity> implements WeaklyOwned<LivingEntity> {
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private static final TrackedData<NbtCompound> MASTER = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private static final TrackedData<NbtCompound> MASTER = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
public static final TrackedData<Float> GRAVITY = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT); public static final TrackedData<Float> GRAVITY = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final LevelStore LEVELS = Levelled.fixed(0); private static final LevelStore LEVELS = Levelled.fixed(0);

View file

@ -6,7 +6,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
public interface DynamicLightSource { public interface DynamicLightSource {
int getLightLevel(); default int getLightLevel() {
return 0;
}
static final class LightEmitter<T extends Entity & DynamicLightSource> { static final class LightEmitter<T extends Entity & DynamicLightSource> {
@Nullable @Nullable

View file

@ -209,12 +209,6 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource,
return false; return false;
} }
@Override
public void setRemoved(RemovalReason reason) {
super.setRemoved(reason);
emitter.remove();
}
@Override @Override
public void onRemoved() { public void onRemoved() {
super.onRemoved(); super.onRemoved();

View file

@ -17,12 +17,6 @@ public abstract class LightEmittingEntity extends Entity implements DynamicLight
emitter.tick(); emitter.tick();
} }
@Override
public void setRemoved(RemovalReason reason) {
super.setRemoved(reason);
emitter.remove();
}
@Override @Override
public void onRemoved() { public void onRemoved() {
super.onRemoved(); super.onRemoved();

View file

@ -8,13 +8,15 @@ import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.item.GemstoneItem; import com.minelittlepony.unicopia.item.GemstoneItem;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.util.Registries;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.tag.ItemTags; import net.minecraft.tag.ItemTags;
import net.minecraft.tag.Tag; import net.minecraft.tag.TagKey;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraft.village.TradeOffer; import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers; import net.minecraft.village.TradeOffers;
@ -36,7 +38,7 @@ public interface UTradeOffers {
TradeOfferHelper.registerWanderingTraderOffers(1, factories -> { TradeOfferHelper.registerWanderingTraderOffers(1, factories -> {
factories.add(buyTiered(UItems.GEMSTONE, 30, UItems.GOLDEN_FEATHER, 1, UItems.GOLDEN_WING, 1, 30, 2, 0.05F)); factories.add(buyTiered(UItems.GEMSTONE, 30, UItems.GOLDEN_FEATHER, 1, UItems.GOLDEN_WING, 1, 30, 2, 0.05F));
factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 3), GemstoneItem.enchant(UItems.GEMSTONE.getDefaultStack(), SpellType.REGISTRY.getRandom(rng)), 20, 1, 0.05F)); factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 3), GemstoneItem.enchant(UItems.GEMSTONE.getDefaultStack(), SpellType.REGISTRY.getRandom(rng).get().value()), 20, 1, 0.05F));
factories.add(buy(UItems.GEMSTONE, 20, UItems.HAY_FRIES, 5, 50, 3, 0.06F)); factories.add(buy(UItems.GEMSTONE, 20, UItems.HAY_FRIES, 5, 50, 3, 0.06F));
factories.add(buy(Items.WHEAT, 17, UItems.HAY_BURGER, 1, 10, 6, 0.08F)); factories.add(buy(Items.WHEAT, 17, UItems.HAY_BURGER, 1, 10, 6, 0.08F));
factories.add(buy(ItemTags.SMALL_FLOWERS, 2, UItems.DAFFODIL_DAISY_SANDWICH, 1, 10, 6, 0.08F)); factories.add(buy(ItemTags.SMALL_FLOWERS, 2, UItems.DAFFODIL_DAISY_SANDWICH, 1, 10, 6, 0.08F));
@ -64,17 +66,21 @@ public interface UTradeOffers {
return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(intermediate, intermediatCount), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange); return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(intermediate, intermediatCount), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange);
} }
private static TradeOffers.Factory buy(Tag<Item> item, int count, Item returnItem, int returnCount, int maxUses, int experience, float priceChange) { private static TradeOffers.Factory buy(TagKey<Item> item, int count, Item returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange); return (e, rng) -> new TradeOffer(new ItemStack(random(e, item, rng), count), new ItemStack(returnItem, returnCount), maxUses, experience, priceChange);
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static TradeOffers.Factory buy(Tag<Item> item, int count, Tag<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) { private static TradeOffers.Factory buy(TagKey<Item> item, int count, TagKey<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item.getRandom(rng), count), new ItemStack(returnItem.getRandom(rng), returnCount), maxUses, experience, priceChange); return (e, rng) -> new TradeOffer(new ItemStack(random(e, item, rng), count), new ItemStack(random(e, returnItem, rng), returnCount), maxUses, experience, priceChange);
} }
private static TradeOffers.Factory buy(Item item, int count, Tag<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) { private static TradeOffers.Factory buy(Item item, int count, TagKey<Item> returnItem, int returnCount, int maxUses, int experience, float priceChange) {
return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(returnItem.getRandom(rng), returnCount), maxUses, experience, priceChange); return (e, rng) -> new TradeOffer(new ItemStack(item, count), new ItemStack(random(e, returnItem, rng), returnCount), maxUses, experience, priceChange);
}
private static Item random(Entity e, TagKey<Item> item, Random rng) {
return Registries.entriesForTag(e.world, item).getRandom(rng).get().value();
} }
static class JarredItemTradeOfferFactory implements TradeOffers.Factory { static class JarredItemTradeOfferFactory implements TradeOffers.Factory {

View file

@ -6,6 +6,7 @@ import java.util.Optional;
import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinFallingBlock; import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
import com.minelittlepony.unicopia.mixin.MixinFallingBlockEntity;
import com.minelittlepony.unicopia.util.Tickable; import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -71,9 +72,9 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
BlockState lowerState = state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER); BlockState lowerState = state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER);
BlockState upperState = state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER); BlockState upperState = state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER);
context.attachExtraEntity(configure(new FallingBlockEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), upperState), block)); context.attachExtraEntity(configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), upperState), block));
return configure(new FallingBlockEntity(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block); return configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block);
} }
if (block instanceof BlockEntityProvider) { if (block instanceof BlockEntityProvider) {
@ -91,7 +92,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
boolean logged = entity.world.isWater(entity.getBlockPos()); boolean logged = entity.world.isWater(entity.getBlockPos());
if (state.get(Properties.WATERLOGGED) != logged) { if (state.get(Properties.WATERLOGGED) != logged) {
entity = new FallingBlockEntity(entity.world, entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged)); entity = MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged));
spell.getDisguise().setAppearance(entity); spell.getDisguise().setAppearance(entity);
return; return;
} }

View file

@ -78,7 +78,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
static final TrackedData<Float> MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT); static final TrackedData<Float> MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT); static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private final AbilityDispatcher powers = new AbilityDispatcher(this); private final AbilityDispatcher powers = new AbilityDispatcher(this);
private final PlayerPhysics gravity = new PlayerPhysics(this); private final PlayerPhysics gravity = new PlayerPhysics(this);
@ -323,7 +323,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
public boolean canHangAt(BlockPos pos) { public boolean canHangAt(BlockPos pos) {
BlockState state = getWorld().getBlockState(pos); BlockState state = getWorld().getBlockState(pos);
return state.hasSolidTopSurface(getWorld(), pos, getEntity(), Direction.DOWN); return state.isSolidSurface(getWorld(), pos, getEntity(), Direction.DOWN);
} }
private BlockPos getHangingPos() { private BlockPos getHangingPos() {

View file

@ -3,12 +3,16 @@ package com.minelittlepony.unicopia.item;
import java.util.Optional; import java.util.Optional;
import com.minelittlepony.unicopia.UTags; import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.advancement.UCriteria; import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.toxin.Toxicity; import com.minelittlepony.unicopia.item.toxin.Toxicity;
import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.particle.UParticles; import com.minelittlepony.unicopia.particle.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.RayTraceHelper; import com.minelittlepony.unicopia.util.RayTraceHelper;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity; import net.minecraft.entity.LightningEntity;
@ -107,12 +111,13 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> items) { public void appendStacks(ItemGroup tab, DefaultedList<ItemStack> items) {
super.appendStacks(tab, items); super.appendStacks(tab, items);
if (isIn(tab)) { if (isIn(tab)) {
UTags.APPLES.values().forEach(item -> { Unicopia.SIDE.getPony().map(Pony::getWorld)
if (item != this) { .stream()
.flatMap(world -> Registries.valuesForTag(world, UTags.APPLES))
.filter(a -> a != this).forEach(item -> {
ItemStack stack = new ItemStack(this); ItemStack stack = new ItemStack(this);
stack.getOrCreateNbt().putString("appearance", Registry.ITEM.getId(item).toString()); stack.getOrCreateNbt().putString("appearance", Registry.ITEM.getId(item).toString());
items.add(stack); items.add(stack);
}
}); });
} }
} }

View file

@ -13,7 +13,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent; import net.minecraft.item.FoodComponent;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tag.Tag; import net.minecraft.tag.TagKey;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction; import net.minecraft.util.UseAction;
@ -27,9 +27,9 @@ public class Toxic {
private final Ailment defaultAilment; private final Ailment defaultAilment;
private final Map<Race, Ailment> ailments; private final Map<Race, Ailment> ailments;
private final Tag<Item> tag; private final TagKey<Item> tag;
Toxic(UseAction action, Optional<FoodComponent> component, Tag<Item> tag, Ailment defaultAilment, Map<Race, Ailment> ailments) { Toxic(UseAction action, Optional<FoodComponent> component, TagKey<Item> tag, Ailment defaultAilment, Map<Race, Ailment> ailments) {
this.action = action; this.action = action;
this.component = component; this.component = component;
this.tag = tag; this.tag = tag;
@ -37,8 +37,9 @@ public class Toxic {
this.ailments = ailments; this.ailments = ailments;
} }
@SuppressWarnings("deprecation")
public boolean matches(Item item) { public boolean matches(Item item) {
return tag.contains(item); return item.getRegistryEntry().isIn(tag);
} }
public Optional<FoodComponent> getFoodComponent() { public Optional<FoodComponent> getFoodComponent() {

View file

@ -14,7 +14,7 @@ import net.minecraft.world.World;
@Mixin(BlockItem.class) @Mixin(BlockItem.class)
abstract class MixinBlockItem extends Item implements ToxicHolder { abstract class MixinBlockItem extends Item implements ToxicHolder {
public MixinBlockItem() {super(null); } MixinBlockItem() {super(null); }
@Override @Override
public UseAction getUseAction(ItemStack stack) { public UseAction getUseAction(ItemStack stack) {

View file

@ -0,0 +1,16 @@
package com.minelittlepony.unicopia.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.block.BlockState;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.world.World;
@Mixin(FallingBlockEntity.class)
public interface MixinFallingBlockEntity {
@Invoker("<init>")
static FallingBlockEntity createInstance(World world, double x, double y, double z, BlockState state) {
return null;
}
}

View file

@ -1,6 +1,11 @@
package com.minelittlepony.unicopia.mixin; package com.minelittlepony.unicopia.mixin;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringWriter;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -10,6 +15,7 @@ import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.unicopia.item.toxin.Toxic; import com.minelittlepony.unicopia.item.toxin.Toxic;

View file

@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.item.VanillaOverrides;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
@Mixin(Items.class) @Mixin(Items.class)
abstract class MixinItems { abstract class MixinItems {
@ -18,8 +19,10 @@ abstract class MixinItems {
argsOnly = true) argsOnly = true)
private static Item modifyItem(Item item, Identifier id, Item itemAlso) { private static Item modifyItem(Item item, Identifier id, Item itemAlso) {
// Registry#containsId is client-only :thonkjang: // Registry#containsId is client-only :thonkjang:
// TODO: Move onGroundTick() event to MixinItem and make it a registerable event so we don't have to do this
Item replacement = VanillaOverrides.REGISTRY.get(id); Item replacement = VanillaOverrides.REGISTRY.get(id);
if (replacement != null) { if (replacement != null) {
Registry.register(Registry.ITEM, new Identifier("unicopia_overriden", id.getPath()), item);
return replacement; return replacement;
} }
return item; return item;

View file

@ -54,7 +54,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Li
private static final TrackedData<Float> DAMAGE = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData<Float> DAMAGE = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<Float> GRAVITY = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT); private static final TrackedData<Float> GRAVITY = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<Boolean> HYDROPHOBIC = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN); private static final TrackedData<Boolean> HYDROPHOBIC = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND); private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(MagicProjectileEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
private static final LevelStore LEVELS = Levelled.fixed(1); private static final LevelStore LEVELS = Levelled.fixed(1);
public static final byte PROJECTILE_COLLISSION = 3; public static final byte PROJECTILE_COLLISSION = 3;

View file

@ -0,0 +1,13 @@
package com.minelittlepony.unicopia.util;
import java.util.HashSet;
import java.util.Set;
public final class ItemTrace {
private static final Set<Class<?>> noticedClasses = new HashSet<>();
public static void traceItem(Class<?> c) {
if (noticedClasses.add(c)) {
System.out.println(c.getCanonicalName());
}
}
}

View file

@ -1,15 +1,29 @@
package com.minelittlepony.unicopia.util; package com.minelittlepony.unicopia.util;
import java.util.stream.Stream;
import com.mojang.serialization.Lifecycle; import com.mojang.serialization.Lifecycle;
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryEntryList;
import net.minecraft.util.registry.RegistryKey; import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.registry.SimpleRegistry; import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.world.World;
public interface Registries { public interface Registries {
static <T> Registry<T> createSimple(Identifier id) { static <T> Registry<T> createSimple(Identifier id) {
return FabricRegistryBuilder.from(new SimpleRegistry<T>(RegistryKey.ofRegistry(id), Lifecycle.stable())).buildAndRegister(); return FabricRegistryBuilder.from(new SimpleRegistry<T>(RegistryKey.ofRegistry(id), Lifecycle.stable(), null)).buildAndRegister();
}
static <T> RegistryEntryList<T> entriesForTag(World world, TagKey<T> key) {
return world.getRegistryManager().get(key.registry()).getOrCreateEntryList(key);
}
static <T> Stream<T> valuesForTag(World world, TagKey<T> key) {
return entriesForTag(world, key).stream().map(RegistryEntry::value);
} }
} }

View file

@ -13,6 +13,7 @@
"MixinDamageSource", "MixinDamageSource",
"MixinEntity", "MixinEntity",
"MixinFallingBlock", "MixinFallingBlock",
"MixinFallingBlockEntity",
"MixinItem", "MixinItem",
"MixinItemEntity", "MixinItemEntity",
"MixinItems", "MixinItems",