diff --git a/gradle.properties b/gradle.properties index e60405fa..2c9cc03f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.19.4 - yarn_mappings=1.19.4+build.1 - loader_version=0.14.17 - fabric_version=0.76.0+1.19.4 + minecraft_version=1.20-pre6 + yarn_mappings=1.20-pre6+build.2 + loader_version=0.14.21 + fabric_version=0.82.1+1.20 # Mod Properties group=com.minelittlepony @@ -15,19 +15,19 @@ org.gradle.daemon=false description=Magical Abilities for Mine Little Pony! # Publishing - minecraft_version_range=>=1.19.4 + minecraft_version_range=>=1.20.0 modrinth_loader_type=fabric - modrinth_project_id= + modrinth_project_id=9K7RJlvM # Dependencies - fabwork_version=1.1.9 - modmenu_version=6.1.0-rc.4 - minelp_version=4.8.7 - kirin_version=1.14.0 - reach_attributes_version=2.3.2 + fabwork_version=1.2.0 + modmenu_version=7.0.0-beta.2 + minelp_version=4.9.0-beta.2 + kirin_version=1.15.0 + reach_attributes_version=2.3.3 trinkets_version=3.6.0 - terraformer_api_version=6.1.0 + terraformer_api_version=7.0.0-beta.1 # TMI Testing - tmi_type=emi - emi_version=1.0.0+1.19.4 + tmi_type=none + emi_version=1.0.0+1.19.3 diff --git a/lib/reach-entity-attributes-2.3.3.jar b/lib/reach-entity-attributes-2.3.3.jar new file mode 100644 index 00000000..40ddce21 Binary files /dev/null and b/lib/reach-entity-attributes-2.3.3.jar differ diff --git a/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java b/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java index ab37c15c..d21ac152 100644 --- a/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java +++ b/src/main/java/com/minelittlepony/unicopia/EntityConvertable.java @@ -30,6 +30,6 @@ public interface EntityConvertable extends WorldConvertable { @Override default World asWorld() { - return asEntity().world; + return asEntity().getWorld(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java index 7578967b..609aede2 100644 --- a/src/main/java/com/minelittlepony/unicopia/InteractionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/InteractionManager.java @@ -79,7 +79,7 @@ public class InteractionManager { */ @NotNull public final PlayerEntity createPlayer(Entity observer, GameProfile profile) { - return createPlayer(observer.world, profile); + return createPlayer(observer.getWorld(), profile); } /** diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 956e1c4b..660ad410 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -127,7 +127,7 @@ public class ChangelingFeedAbility implements Ability { if (!canFeed(iplayer)) { - iplayer.playSound(SoundEvents.ENTITY_PLAYER_BURP, 1, (float)player.world.random.nextTriangular(1F, 0.2F)); + iplayer.playSound(SoundEvents.ENTITY_PLAYER_BURP, 1, (float)player.getWorld().random.nextTriangular(1F, 0.2F)); } else { iplayer.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.1F, iplayer.getRandomPitch()); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java index 3d5341f8..3cb12abc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyKickAbility.java @@ -164,9 +164,9 @@ public class EarthPonyKickAbility implements Ability { PlayerEntity player = iplayer.asEntity(); - if (BlockDestructionManager.of(player.world).getBlockDestruction(pos) + 4 >= BlockDestructionManager.MAX_DAMAGE) { - if (player.world.random.nextInt(30) == 0) { - tree.traverse(player.world, pos, (w, state, p, recurseLevel) -> { + if (BlockDestructionManager.of(player.getWorld()).getBlockDestruction(pos) + 4 >= BlockDestructionManager.MAX_DAMAGE) { + if (player.getWorld().random.nextInt(30) == 0) { + tree.traverse(player.getWorld(), pos, (w, state, p, recurseLevel) -> { if (recurseLevel < 5) { w.breakBlock(p, true); } else { @@ -196,12 +196,12 @@ public class EarthPonyKickAbility implements Ability { } private int dropApples(PlayerEntity player, BlockPos pos) { - TreeType tree = TreeType.at(pos, player.world); + TreeType tree = TreeType.at(pos, player.getWorld()); - if (tree.countBlocks(player.world, pos) > 0) { + if (tree.countBlocks(player.getWorld(), pos) > 0) { List capturedDrops = new ArrayList<>(); - tree.traverse(player.world, pos, (world, state, position, recurse) -> { + tree.traverse(player.getWorld(), pos, (world, state, position, recurse) -> { affectBlockChange(player, position); }, (world, state, position, recurse) -> { affectBlockChange(player, position); @@ -215,7 +215,7 @@ public class EarthPonyKickAbility implements Ability { } }); - capturedDrops.forEach(player.world::spawnEntity); + capturedDrops.forEach(player.getWorld()::spawnEntity); return capturedDrops.size() / 3; } @@ -255,28 +255,28 @@ public class EarthPonyKickAbility implements Ability { } private void affectBlockChange(PlayerEntity player, BlockPos position) { - BlockDestructionManager.of(player.world).damageBlock(position, 4); + BlockDestructionManager.of(player.getWorld()).damageBlock(position, 4); PosHelper.all(position, p -> { - BlockState s = player.world.getBlockState(p); + BlockState s = player.getWorld().getBlockState(p); if (s.getBlock() instanceof BeehiveBlock) { - if (player.world.getBlockEntity(p) instanceof BeehiveBlockEntity hive) { + if (player.getWorld().getBlockEntity(p) instanceof BeehiveBlockEntity hive) { hive.angerBees(player, s, BeehiveBlockEntity.BeeState.EMERGENCY); } - player.world.updateComparators(position, s.getBlock()); + player.getWorld().updateComparators(position, s.getBlock()); Box area = new Box(position).expand(8, 6, 8); - List nearbyBees = player.world.getNonSpectatingEntities(BeeEntity.class, area); + List nearbyBees = player.getWorld().getNonSpectatingEntities(BeeEntity.class, area); if (!nearbyBees.isEmpty()) { - List nearbyPlayers = player.world.getNonSpectatingEntities(PlayerEntity.class, area); + List nearbyPlayers = player.getWorld().getNonSpectatingEntities(PlayerEntity.class, area); int i = nearbyPlayers.size(); for (BeeEntity bee : nearbyBees) { if (bee.getTarget() == null) { - bee.setTarget(nearbyPlayers.get(player.world.random.nextInt(i))); + bee.setTarget(nearbyPlayers.get(player.getWorld().random.nextInt(i))); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 1db144e3..57e56059 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -17,13 +17,13 @@ import com.minelittlepony.unicopia.util.PosHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.Material; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; @@ -148,7 +148,7 @@ public class EarthPonyStompAbility implements Ability { spawnEffectAround(player, center, radius, rad); - ParticleUtils.spawnParticle(player.world, UParticles.GROUND_POUND, player.getX(), player.getY() - 1, player.getZ(), 0, 0, 0); + ParticleUtils.spawnParticle(player.getWorld(), UParticles.GROUND_POUND, player.getX(), player.getY() - 1, player.getZ(), 0, 0, 0); iplayer.subtractEnergyCost(rad); }); @@ -159,7 +159,7 @@ public class EarthPonyStompAbility implements Ability { double dist = Math.sqrt(i.getSquaredDistance(source.getX(), source.getY(), source.getZ())); if (dist <= radius) { - spawnEffect(source.world, i, dist, range); + spawnEffect(source.getWorld(), i, dist, range); } }); } @@ -187,7 +187,7 @@ public class EarthPonyStompAbility implements Ability { w.breakBlock(pos, true); if (w instanceof ServerWorld) { - if (state.getMaterial() == Material.STONE && w.getRandom().nextInt(4) == 0) { + if (state.isIn(BlockTags.BASE_STONE_OVERWORLD) && w.getRandom().nextInt(4) == 0) { ItemStack stack = UItems.PEBBLES.getDefaultStack(); stack.setCount(1 + w.getRandom().nextInt(2)); Block.dropStack(w, pos, stack); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index 3903d8e9..f8cc8cb1 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -168,7 +168,7 @@ public class UnicornTeleportAbility implements Ability { participant.fallDistance /= distance; - participant.world.playSound(null, destination.pos(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1); + participant.getWorld().playSound(null, destination.pos(), USounds.ENTITY_PLAYER_UNICORN_TELEPORT, SoundCategory.PLAYERS, 1, 1); } private boolean enterable(World w, BlockPos pos) { @@ -186,7 +186,7 @@ public class UnicornTeleportAbility implements Ability { Block c = state.getBlock(); return state.hasSolidTopSurface(w, pos, player) - || state.getMaterial().isLiquid() + || state.isLiquid() || (c instanceof WallBlock) || (c instanceof FenceBlock) || (c instanceof LeavesBlock); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java index ea6f89da..6f23df66 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/PlaceableSpell.java @@ -131,8 +131,8 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS } entity.getSpellSlot().put(copy); entity.setCaster(source); - entity.world.spawnEntity(entity); - Ether.get(entity.world).put(getType(), entity); + entity.getWorld().spawnEntity(entity); + Ether.get(entity.getWorld()).put(getType(), entity); castEntity.set(entity); setDirty(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java index 65791079..cc0dcc0f 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/crafting/SpellShapedCraftingRecipe.java @@ -5,7 +5,7 @@ import com.minelittlepony.unicopia.item.EnchantableItem; import com.minelittlepony.unicopia.item.URecipes; import com.minelittlepony.unicopia.util.InventoryUtil; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.recipe.RecipeSerializer; @@ -20,7 +20,7 @@ public class SpellShapedCraftingRecipe extends ShapedRecipe { } @Override - public ItemStack craft(CraftingInventory inventory, DynamicRegistryManager registries) { + public ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registries) { return InventoryUtil.stream(inventory) .filter(stack -> stack.getItem() instanceof EnchantableItem) .filter(EnchantableItem::isEnchanted) diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java index 7e824d70..2336c4bd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/AttractiveSpell.java @@ -75,8 +75,8 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp @Override protected boolean isValidTarget(Caster source, Entity entity) { - if (target.isPresent(entity.world)) { - return target.get(entity.world) == entity; + if (target.referenceEquals(entity)) { + return true; } return getTraits().get(Trait.KNOWLEDGE) > 10 ? entity instanceof ItemEntity : super.isValidTarget(source, entity); } @@ -114,7 +114,7 @@ public class AttractiveSpell extends ShieldSpell implements HomingSpell, TimedSp z = 0; } - if (this.target.get(target.world) == target) { + if (this.target.referenceEquals(target)) { target.fallDistance = 0; if (target.isOnGround()) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java index c6426c6d..092218cd 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/CatapultSpell.java @@ -41,7 +41,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileDelegate.B @Override public void onImpact(MagicProjectileEntity projectile, BlockHitResult hit) { if (!projectile.isClient() && projectile.canModifyAt(hit.getBlockPos())) { - createBlockEntity(projectile.world, hit.getBlockPos(), e -> apply(projectile, e)); + createBlockEntity(projectile.getWorld(), hit.getBlockPos(), e -> apply(projectile, e)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java index e10b03a4..bfd2123a 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/DarkVortexSpell.java @@ -60,7 +60,7 @@ public class DarkVortexSpell extends AttractiveSpell implements ProjectileDelega public void onImpact(MagicProjectileEntity projectile, BlockHitResult hit) { if (!projectile.isClient()) { BlockPos pos = hit.getBlockPos(); - projectile.world.createExplosion(projectile, pos.getX(), pos.getY(), pos.getZ(), 3, ExplosionSourceType.NONE); + projectile.getWorld().createExplosion(projectile, pos.getX(), pos.getY(), pos.getZ(), 3, ExplosionSourceType.NONE); toPlaceable().tick(projectile, Situation.BODY); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java index 428d183e..f5065ff2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/IceSpell.java @@ -110,7 +110,7 @@ public class IceSpell extends AbstractSpell { return true; } - if (state.getMaterial() == Material.ICE + if (state.isIn(BlockTags.ICE) && world.random.nextInt(10) == 0 && isSurroundedByIce(world, pos)) { world.setBlockState(pos, Blocks.PACKED_ICE.getDefaultState()); @@ -122,7 +122,7 @@ public class IceSpell extends AbstractSpell { private static boolean isSurroundedByIce(World w, BlockPos pos) { return PosHelper.adjacentNeighbours(pos).allMatch(i -> - w.getBlockState(i).getMaterial() == Material.ICE + w.getBlockState(i).isIn(BlockTags.ICE) ); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java index 0dd8fa74..afa33e74 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/LightSpell.java @@ -71,7 +71,7 @@ public class LightSpell extends AbstractSpell implements TimedSpell, ProjectileD return caster.getOriginVector().add(VecHelper.supply(() -> caster.asWorld().random.nextInt(3) - 1)); })); entity.setMaster(caster); - entity.world.spawnEntity(entity); + entity.getWorld().spawnEntity(entity); ref.set(entity); setDirty(); @@ -94,7 +94,7 @@ public class LightSpell extends AbstractSpell implements TimedSpell, ProjectileD } lights.forEach(ref -> { ref.ifPresent(caster.asWorld(), e -> { - e.world.sendEntityStatus(e, (byte)60); + e.getWorld().sendEntityStatus(e, (byte)60); e.discard(); }); }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java index 4e7a9882..ddd8f605 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/NecromancySpell.java @@ -99,7 +99,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell implements Projecti summonedEntities.removeIf(ref -> ref.getOrEmpty(source.asWorld()).filter(e -> { if (e.getPos().distanceTo(source.getOriginVector()) > radius * 2) { - e.world.sendEntityStatus(e, (byte)60); + e.getWorld().sendEntityStatus(e, (byte)60); e.discard(); return false; } @@ -146,7 +146,7 @@ public class NecromancySpell extends AbstractAreaEffectSpell implements Projecti if (master != null) { master.applyDamageEffects(master, e); } - e.world.sendEntityStatus(e, (byte)60); + e.getWorld().sendEntityStatus(e, (byte)60); e.discard(); }); }); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java index 5ba08dfb..dc0fd4b0 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/PortalSpell.java @@ -122,9 +122,9 @@ public class PortalSpell extends AbstractSpell implements PlaceableSpell.Placeme entity.setYaw(entity.getYaw() + yawDifference); entity.setVelocity(entity.getVelocity().rotateY(yawDifference * MathHelper.RADIANS_PER_DEGREE)); - entity.world.playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); + entity.getWorld().playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); entity.teleport(dest.x, dest.y, dest.z); - entity.world.playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); + entity.getWorld().playSoundFromEntity(null, entity, USounds.ENTITY_PLAYER_UNICORN_TELEPORT, entity.getSoundCategory(), 1, 1); setDirty(); if (!source.subtractEnergyCost(Math.sqrt(entity.getPos().subtract(dest).length()))) { diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java index 7b6552f3..705533c6 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/SiphoningSpell.java @@ -106,7 +106,7 @@ public class SiphoningSpell extends AbstractAreaEffectSpell { } } else { e.heal((float)Math.min(source.getLevel().getScaled(e.getHealth()) / 2F, maxHealthGain * 0.6)); - ParticleUtils.spawnParticle(e.world, new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.getPos(), Vec3d.ZERO); + ParticleUtils.spawnParticle(e.getWorld(), new FollowingParticleEffect(UParticles.HEALTH_DRAIN, e, 0.2F), e.getPos(), Vec3d.ZERO); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java index 237d2f79..b88763c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/magic/spell/effect/TransformationSpell.java @@ -39,11 +39,11 @@ public class TransformationSpell extends AbstractSpell implements ProjectileDele @Override public void onImpact(MagicProjectileEntity projectile, EntityHitResult hit) { - if (projectile.world.isClient) { + if (projectile.getWorld().isClient) { return; } Entity entity = hit.getEntity(); - pickType(entity.getType(), entity.world).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> { + pickType(entity.getType(), entity.getWorld()).flatMap(type -> convert(entity, type)).ifPresentOrElse(e -> { entity.playSound(USounds.SPELL_TRANSFORM_TRANSMUTE_ENTITY, 1, 1); }, () -> { ParticleUtils.spawnParticles(ParticleTypes.SMOKE, entity, 20); diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java b/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java index 3ba1ba75..b183cbad 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/CustomEventCriterion.java @@ -16,7 +16,7 @@ import net.minecraft.advancement.criterion.AbstractCriterionConditions; import net.minecraft.entity.Entity; import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer; -import net.minecraft.predicate.entity.EntityPredicate.Extended; +import net.minecraft.predicate.entity.LootContextPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; @@ -31,7 +31,7 @@ public class CustomEventCriterion extends AbstractCriterion races = new HashSet<>(); @@ -73,7 +73,7 @@ public class CustomEventCriterion extends AbstractCriterion races, Boolean flying, int repeatCount) { + public Conditions(LootContextPredicate playerPredicate, String event, Set races, Boolean flying, int repeatCount) { super(ID, playerPredicate); this.event = event; this.races = races; diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java b/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java index 3852453f..42b5dedd 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/RaceChangeCriterion.java @@ -10,7 +10,7 @@ import net.minecraft.advancement.criterion.AbstractCriterionConditions; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer; import net.minecraft.predicate.entity.AdvancementEntityPredicateSerializer; -import net.minecraft.predicate.entity.EntityPredicate.Extended; +import net.minecraft.predicate.entity.LootContextPredicate; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; @@ -25,7 +25,7 @@ public class RaceChangeCriterion extends AbstractCriterion type) { @@ -32,15 +33,15 @@ interface BlockConstructionUtils { } static PillarBlock createLogBlock(MapColor topMapColor, MapColor sideMapColor) { - return new PillarBlock(AbstractBlock.Settings.of(Material.WOOD, state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor).strength(2).sounds(BlockSoundGroup.WOOD)); + return new PillarBlock(AbstractBlock.Settings.create().mapColor(state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor).instrument(Instrument.BASS).strength(2.0f).sounds(BlockSoundGroup.WOOD).burnable()); } static PillarBlock createWoodBlock(MapColor mapColor) { - return new PillarBlock(AbstractBlock.Settings.of(Material.WOOD, mapColor).strength(2).sounds(BlockSoundGroup.WOOD)); + return new PillarBlock(AbstractBlock.Settings.create().mapColor(mapColor).instrument(Instrument.BASS).strength(2.0f).sounds(BlockSoundGroup.WOOD).burnable()); } static LeavesBlock createLeavesBlock(BlockSoundGroup soundGroup) { - return new LeavesBlock(AbstractBlock.Settings.of(Material.LEAVES).strength(0.2F).ticksRandomly().sounds(soundGroup).nonOpaque().allowsSpawning(BlockConstructionUtils::canSpawnOnLeaves).suffocates(BlockConstructionUtils::never).blockVision(BlockConstructionUtils::never)); + return new LeavesBlock(AbstractBlock.Settings.create().mapColor(MapColor.DARK_GREEN).strength(0.2f).ticksRandomly().sounds(soundGroup).nonOpaque().allowsSpawning(BlockConstructionUtils::canSpawnOnLeaves).suffocates(BlockConstructionUtils::never).blockVision(BlockConstructionUtils::never).burnable().pistonBehavior(PistonBehavior.DESTROY).solidBlock(BlockConstructionUtils::never)); } static Boolean canSpawnOnLeaves(BlockState state, BlockView world, BlockPos pos, EntityType type) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java index 4cc23ee9..07bebabc 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FrostedObsidianBlock.java @@ -7,7 +7,6 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.FrostedIceBlock; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.piston.PistonBehavior; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.stat.Stats; @@ -35,9 +34,4 @@ public class FrostedObsidianBlock extends FrostedIceBlock { world.setBlockState(pos, Blocks.LAVA.getDefaultState()); world.updateNeighbor(pos, Blocks.LAVA, pos); } - - @Override - public PistonBehavior getPistonBehavior(BlockState state) { - return PistonBehavior.BLOCK; - } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java index 2b3be10c..8313bcf7 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FruitBlock.java @@ -6,8 +6,10 @@ import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.minecraft.block.*; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; +import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.math.*; import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; @@ -30,7 +32,7 @@ public class FruitBlock extends Block implements Buckable { } public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape) { - this(settings, attachmentFace, stem, shape, true); + this(settings.sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), attachmentFace, stem, shape, true); } public FruitBlock(Settings settings, Direction attachmentFace, Block stem, VoxelShape shape, boolean flammable) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java b/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java index ca934c01..ab2eebcf 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/SproutBlock.java @@ -5,6 +5,7 @@ import java.util.function.Supplier; import org.jetbrains.annotations.Nullable; import net.minecraft.block.*; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; @@ -34,7 +35,12 @@ public class SproutBlock extends CropBlock implements TintedBlock { private final int overlay; public SproutBlock(int overlay, ItemConvertible seeds, Supplier matureState) { - super(Settings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.STEM)); + super(Settings.create() + .noCollision() + .ticksRandomly() + .breakInstantly() + .sounds(BlockSoundGroup.STEM) + .pistonBehavior(PistonBehavior.DESTROY)); this.seeds = seeds; this.matureState = matureState; this.overlay = overlay; diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index 0fbe52e9..02e927e4 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -9,25 +9,27 @@ import com.minelittlepony.unicopia.item.group.ItemGroupRegistry; import com.minelittlepony.unicopia.server.world.UTreeGen; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricMaterialBuilder; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; import net.minecraft.block.*; import net.minecraft.block.AbstractBlock.Settings; +import net.minecraft.block.piston.PistonBehavior; import net.minecraft.item.*; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.Registries; public interface UBlocks { List TRANSLUCENT_BLOCKS = new ArrayList<>(); - Block ROCKS = register("rocks", new RockCropBlock(FabricBlockSettings.of( - new FabricMaterialBuilder(MapColor.STONE_GRAY).allowsMovement().lightPassesThrough().notSolid().destroyedByPiston().build() - ) + Block ROCKS = register("rocks", new RockCropBlock(Settings.create() + .mapColor(MapColor.STONE_GRAY) + .nonOpaque() + .pistonBehavior(PistonBehavior.DESTROY) .requiresTool() .ticksRandomly() .strength(2) @@ -44,22 +46,22 @@ public interface UBlocks { Block ZAP_LEAVES = register("zap_leaves", new ZapAppleLeavesBlock(), ItemGroups.NATURAL); Block FLOWERING_ZAP_LEAVES = register("flowering_zap_leaves", new BaseZapAppleLeavesBlock(), ItemGroups.NATURAL); Block ZAP_LEAVES_PLACEHOLDER = register("zap_leaves_placeholder", new ZapAppleLeavesPlaceholderBlock()); - Block ZAP_BULB = register("zap_bulb", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).strength(500, 1200).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); - Block ZAP_APPLE = register("zap_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GRAY).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); + Block ZAP_BULB = register("zap_bulb", new FruitBlock(Settings.create().mapColor(MapColor.GRAY).strength(500, 1200).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); + Block ZAP_APPLE = register("zap_apple", new FruitBlock(Settings.create().mapColor(MapColor.GRAY).sounds(BlockSoundGroup.AZALEA_LEAVES), Direction.DOWN, ZAP_LEAVES, FruitBlock.DEFAULT_SHAPE, false)); Block PALM_LOG = register("palm_log", BlockConstructionUtils.createLogBlock(MapColor.OFF_WHITE, MapColor.SPRUCE_BROWN), ItemGroups.BUILDING_BLOCKS); Block PALM_WOOD = register("palm_wood", BlockConstructionUtils.createWoodBlock(MapColor.OFF_WHITE), ItemGroups.BUILDING_BLOCKS); Block STRIPPED_PALM_LOG = register("stripped_palm_log", BlockConstructionUtils.createLogBlock(MapColor.OFF_WHITE, MapColor.OFF_WHITE), ItemGroups.BUILDING_BLOCKS); Block STRIPPED_PALM_WOOD = register("stripped_palm_wood", BlockConstructionUtils.createWoodBlock(MapColor.OFF_WHITE), ItemGroups.BUILDING_BLOCKS); - Block PALM_PLANKS = register("palm_planks", new Block(Settings.of(Material.WOOD, MapColor.OFF_WHITE).strength(2, 3).sounds(BlockSoundGroup.WOOD)), ItemGroups.BUILDING_BLOCKS); - Block PALM_STAIRS = register("palm_stairs", new StairsBlock(PALM_PLANKS.getDefaultState(), Settings.copy(PALM_PLANKS)), ItemGroups.BUILDING_BLOCKS); - Block PALM_SLAB = register("palm_slab", new SlabBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD)), ItemGroups.BUILDING_BLOCKS); - Block PALM_FENCE = register("palm_fence", new FenceBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD)), ItemGroups.BUILDING_BLOCKS); - Block PALM_FENCE_GATE = register("palm_fence_gate", new FenceGateBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD), WoodType.OAK), ItemGroups.BUILDING_BLOCKS); + Block PALM_PLANKS = register("palm_planks", new Block(Settings.create().mapColor(MapColor.OFF_WHITE).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_STAIRS = register("palm_stairs", new StairsBlock(PALM_PLANKS.getDefaultState(), Settings.copy(PALM_PLANKS).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_SLAB = register("palm_slab", new SlabBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_FENCE = register("palm_fence", new FenceBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL)), ItemGroups.BUILDING_BLOCKS); + Block PALM_FENCE_GATE = register("palm_fence_gate", new FenceGateBlock(Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).strength(2, 3).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.NORMAL), WoodType.OAK), ItemGroups.BUILDING_BLOCKS); // Block PALM_DOOR = register("palm_door", new DoorBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(3.0f).sounds(BlockSoundGroup.WOOD).nonOpaque(), SoundEvents.BLOCK_WOODEN_DOOR_CLOSE, SoundEvents.BLOCK_WOODEN_DOOR_OPEN), ItemGroups.BUILDING_BLOCKS); // Block PALM_TRAPDOOR = register("palm_trapdoor", new TrapdoorBlock(Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).strength(3.0f).sounds(BlockSoundGroup.WOOD).nonOpaque().allowsSpawning(UBlocks::never), SoundEvents.BLOCK_WOODEN_TRAPDOOR_CLOSE, SoundEvents.BLOCK_WOODEN_TRAPDOOR_OPEN), ItemGroups.BUILDING_BLOCKS); - Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, Settings.of(Material.WOOD, PALM_PLANKS.getDefaultMapColor()).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD), BlockSetType.OAK), ItemGroups.BUILDING_BLOCKS); + Block PALM_PRESSURE_PLATE = register("palm_pressure_plate", new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, Settings.create().mapColor(PALM_PLANKS.getDefaultMapColor()).noCollision().strength(0.5f).sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), BlockSetType.OAK), ItemGroups.BUILDING_BLOCKS); Block PALM_BUTTON = register("palm_button", BlockConstructionUtils.woodenButton(), ItemGroups.BUILDING_BLOCKS); // Block PALM_SIGN = register("palm_sign", new SignBlock(Settings.of(Material.WOOD).noCollision().strength(1.0f).sounds(BlockSoundGroup.WOOD), PALM_SIGN_TYPE), ItemGroups.BUILDING_BLOCKS); // @@ -69,16 +71,16 @@ public interface UBlocks { Block PALM_LEAVES = register("palm_leaves", BlockConstructionUtils.createLeavesBlock(BlockSoundGroup.GRASS), ItemGroups.BUILDING_BLOCKS); - Block BANANAS = register("bananas", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.YELLOW).sounds(BlockSoundGroup.WOOD).hardness(3), Direction.DOWN, PALM_LEAVES, VoxelShapes.fullCube())); + Block BANANAS = register("bananas", new FruitBlock(Settings.create().mapColor(MapColor.YELLOW).sounds(BlockSoundGroup.WOOD).hardness(3).pistonBehavior(PistonBehavior.DESTROY), Direction.DOWN, PALM_LEAVES, VoxelShapes.fullCube())); - Block WEATHER_VANE = register("weather_vane", new WeatherVaneBlock(FabricBlockSettings.of(Material.METAL, MapColor.BLACK).requiresTool().strength(3.0f, 6.0f).sounds(BlockSoundGroup.METAL).nonOpaque()), ItemGroups.TOOLS); + Block WEATHER_VANE = register("weather_vane", new WeatherVaneBlock(Settings.create().mapColor(MapColor.BLACK).requiresTool().strength(3.0f, 6.0f).sounds(BlockSoundGroup.METAL).nonOpaque().pistonBehavior(PistonBehavior.BLOCK)), ItemGroups.TOOLS); Block GREEN_APPLE_LEAVES = register("green_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES), 0xE5FFFF88, () -> UBlocks.GREEN_APPLE, () -> UItems.GREEN_APPLE.getDefaultStack() ), ItemGroups.NATURAL); - Block GREEN_APPLE = register("green_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, GREEN_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); + Block GREEN_APPLE = register("green_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), Direction.DOWN, GREEN_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block GREEN_APPLE_SPROUT = register("green_apple_sprout", new SproutBlock(0xE5FFFF88, () -> UItems.GREEN_APPLE_SEEDS, () -> UTreeGen.GREEN_APPLE_TREE.sapling().map(Block::getDefaultState).get())); Block SWEET_APPLE_LEAVES = register("sweet_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES), @@ -86,7 +88,7 @@ public interface UBlocks { () -> UBlocks.SWEET_APPLE, () -> UItems.SWEET_APPLE.getDefaultStack() ), ItemGroups.NATURAL); - Block SWEET_APPLE = register("sweet_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SWEET_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); + Block SWEET_APPLE = register("sweet_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), Direction.DOWN, SWEET_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block SWEET_APPLE_SPROUT = register("sweet_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SWEET_APPLE_SEEDS, () -> UTreeGen.SWEET_APPLE_TREE.sapling().map(Block::getDefaultState).get())); Block SOUR_APPLE_LEAVES = register("sour_apple_leaves", new FruitBearingBlock(FabricBlockSettings.copy(Blocks.OAK_LEAVES), @@ -94,10 +96,10 @@ public interface UBlocks { () -> UBlocks.SOUR_APPLE, () -> UItems.SOUR_APPLE.getDefaultStack() ), ItemGroups.NATURAL); - Block SOUR_APPLE = register("sour_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SOUR_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); + Block SOUR_APPLE = register("sour_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), Direction.DOWN, SOUR_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE)); Block SOUR_APPLE_SPROUT = register("sour_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SOUR_APPLE_SEEDS, () -> UTreeGen.SOUR_APPLE_TREE.sapling().map(Block::getDefaultState).get())); - Block APPLE_PIE = register("apple_pie", new PieBlock(FabricBlockSettings.of(Material.CAKE, MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS), () -> UItems.APPLE_PIE_SLICE)); + Block APPLE_PIE = register("apple_pie", new PieBlock(Settings.create().solid().mapColor(MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS).pistonBehavior(PistonBehavior.DESTROY), () -> UItems.APPLE_PIE_SLICE)); SegmentedCropBlock OATS = register("oats", SegmentedCropBlock.create(11, 5, AbstractBlock.Settings.copy(Blocks.WHEAT), () -> UItems.OAT_SEEDS, null, () -> UBlocks.OATS_STEM)); SegmentedCropBlock OATS_STEM = register("oats_stem", OATS.createNext(5)); @@ -107,11 +109,11 @@ public interface UBlocks { return register(Unicopia.id(name), item); } - static T register(String name, T block, ItemGroup group) { + static T register(String name, T block, RegistryKey group) { return register(Unicopia.id(name), block, group); } - static T register(Identifier id, T block, ItemGroup group) { + static T register(Identifier id, T block, RegistryKey group) { UItems.register(id, ItemGroupRegistry.register(new BlockItem(block, new Item.Settings()), group)); return register(id, block); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java index 5b23dcde..124ab202 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLeavesPlaceholderBlock.java @@ -10,7 +10,7 @@ import net.minecraft.util.math.random.Random; public class ZapAppleLeavesPlaceholderBlock extends AirBlock { ZapAppleLeavesPlaceholderBlock() { - super(AbstractBlock.Settings.of(Material.AIR).noCollision().dropsNothing().air()); + super(Settings.create().replaceable().noCollision().dropsNothing().air()); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java index 94d2b1c4..69a6eacd 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/ZapAppleLogBlock.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.block; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.block.*; +import net.minecraft.block.enums.Instrument; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; import net.minecraft.sound.BlockSoundGroup; @@ -18,11 +19,13 @@ public class ZapAppleLogBlock extends PillarBlock { private final Block artifialModelBlock; ZapAppleLogBlock(Block artifialModelBlock, MapColor topMapColor, MapColor sideMapColor) { - super(AbstractBlock.Settings.of(Material.WOOD, + super(AbstractBlock.Settings.create().mapColor( state -> state.get(PillarBlock.AXIS) == Direction.Axis.Y ? topMapColor : sideMapColor ) + .instrument(Instrument.BASS) + .strength(2.0f) .sounds(BlockSoundGroup.WOOD) - .strength(500, 1200)); + .burnable()); setDefaultState(getDefaultState().with(NATURAL, true)); this.artifialModelBlock = artifialModelBlock; } diff --git a/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java b/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java index 5a6ded9f..2743c01e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/block/state/StatePredicate.java @@ -20,6 +20,7 @@ import net.minecraft.util.JsonHelper; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.tag.FluidTags; import net.minecraft.registry.tag.TagKey; import net.minecraft.world.World; @@ -123,11 +124,11 @@ public abstract class StatePredicate implements Predicate { } static boolean isWater(BlockState s) { - return s.getMaterial() == Material.WATER; + return s.isLiquid() && s.getFluidState().isIn(FluidTags.WATER); } static boolean isLava(BlockState s) { - return s.getMaterial() == Material.LAVA; + return s.isLiquid() && s.getFluidState().isIn(FluidTags.LAVA); } public static Predicate ofState(String state) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java index 99c6e7e4..51eeb451 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java +++ b/src/main/java/com/minelittlepony/unicopia/client/DiscoveryToast.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; import org.spongepowered.include.com.google.common.base.Objects; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.toast.Toast; import net.minecraft.client.toast.ToastManager; @@ -26,7 +26,7 @@ public class DiscoveryToast implements Toast { private boolean justUpdated; @Override - public Toast.Visibility draw(MatrixStack matrices, ToastManager manager, long startTime) { + public Toast.Visibility draw(DrawContext context, ToastManager manager, long startTime) { if (justUpdated) { this.startTime = startTime; justUpdated = false; @@ -37,26 +37,21 @@ public class DiscoveryToast implements Toast { } RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderTexture(0, TEXTURE); RenderSystem.setShaderColor(1.0F, 1, 1, 1); - ToastManager.drawTexture(matrices, 0, 0, 0, 32, getWidth(), getHeight()); - manager.getClient().textRenderer.draw(matrices, TITLE, 30, 7, -11534256); - manager.getClient().textRenderer.draw(matrices, DESCRIPTION, 30, 18, -16777216); + + context.drawTexture(TEXTURE, 0, 0, 0, 32, getWidth(), getHeight()); + context.drawText(manager.getClient().textRenderer, TITLE, 30, 7, -11534256, false); + context.drawText(manager.getClient().textRenderer, DESCRIPTION, 30, 18, -16777216, false); Identifier icon = discoveries.get((int)(startTime / Math.max(1L, MAX_AGE / discoveries.size()) % discoveries.size())); - MatrixStack matrixStack = RenderSystem.getModelViewStack(); - matrixStack.push(); - matrixStack.scale(0.6F, 0.6F, 1); - RenderSystem.applyModelViewMatrix(); - manager.getClient().getItemRenderer().renderInGui(matrixStack, UItems.SPELLBOOK.getDefaultStack(), 3, 3); - matrixStack.pop(); - RenderSystem.applyModelViewMatrix(); + MatrixStack matrices = context.getMatrices(); + matrices.push(); + matrices.scale(0.6F, 0.6F, 1); + context.drawItem(UItems.SPELLBOOK.getDefaultStack(), 3, 3); + matrices.pop(); - RenderSystem.setShaderTexture(0, icon); - DrawableHelper.drawTexture(matrices, 8, 8, 1, 0, 0, 16, 16, 16, 16); - - // manager.getClient().getItemRenderer().renderInGui(recipe.getOutput(), 8, 8); + context.drawTexture(icon, 8, 8, 1, 0, 0, 16, 16, 16, 16); return startTime - this.startTime >= MAX_AGE ? Toast.Visibility.HIDE : Toast.Visibility.SHOW; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java index a5cfb6e3..1de38b4a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DismissSpellScreen.java @@ -72,21 +72,22 @@ public class DismissSpellScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - fillGradient(matrices, 0, 0, width, height / 2, 0xF0101010, 0x80101010); - fillGradient(matrices, 0, height / 2, width, height, 0x80101010, 0xF0101010); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + context.fillGradient(0, 0, width, height / 2, 0xF0101010, 0x80101010); + context.fillGradient(0, height / 2, width, height, 0x80101010, 0xF0101010); relativeMouseX = -width + mouseX * 2; relativeMouseY = -height + mouseY * 2; + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(width - mouseX, height - mouseY, 0); DrawableUtil.drawLine(matrices, 0, 0, relativeMouseX, relativeMouseY, 0xFFFFFF88); DrawableUtil.drawArc(matrices, 40, 80, 0, DrawableUtil.TAU, 0x00000010, false); DrawableUtil.drawArc(matrices, 160, 1600, 0, DrawableUtil.TAU, 0x00000020, false); - super.render(matrices, mouseX, mouseY, delta); - DrawableUtil.renderRaceIcon(matrices, pony.getObservedSpecies(), 0, 0, 16); + super.render(context, mouseX, mouseY, delta); + DrawableUtil.renderRaceIcon(context, pony.getObservedSpecies(), 0, 0, 16); matrices.pop(); DrawableUtil.drawLine(matrices, mouseX, mouseY - 4, mouseX, mouseY + 4, 0xFFAAFF99); @@ -95,7 +96,7 @@ public class DismissSpellScreen extends GameGui { matrices.push(); matrices.translate(0, 0, 300); Text cancel = Text.literal("Press ESC to cancel"); - getFont().drawWithShadow(matrices, cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF); + context.drawText(getFont(), cancel, (width - getFont().getWidth(cancel)) / 2, height - 30, 0xFFFFFFFF, true); matrices.pop(); } @@ -159,14 +160,15 @@ public class DismissSpellScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + MatrixStack matrices = context.getMatrices(); copy.set(x, y, z, w); copy.mul(matrices.peek().getPositionMatrix()); var type = actualSpell.getType().withTraits(actualSpell.getTraits()); DrawableUtil.drawLine(matrices, 0, 0, (int)x, (int)y, 0xFFAAFF99); - DrawableUtil.renderItemIcon(actualSpell.isDead() ? UItems.BOTCHED_GEM.getDefaultStack() : type.getDefaultStack(), + DrawableUtil.renderItemIcon(context, actualSpell.isDead() ? UItems.BOTCHED_GEM.getDefaultStack() : type.getDefaultStack(), copy.x - 8 + copy.z / 20F, copy.y - 8 + copy.z / 20F, 1 @@ -199,7 +201,7 @@ public class DismissSpellScreen extends GameGui { } tooltip.add(ScreenTexts.EMPTY); tooltip.add(Text.translatable("[Click to Discard]")); - renderTooltip(matrices, tooltip, 0, 0); + context.drawTooltip(getFont(), tooltip, 0, 0); if (!lastMouseOver) { lastMouseOver = true; diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java index 19afcc3b..82cd1958 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/DrawableUtil.java @@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Race; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.BufferRenderer; import net.minecraft.client.render.GameRenderer; @@ -24,32 +24,29 @@ public interface DrawableUtil { double NUM_RINGS = 300; double INCREMENT = TAU / NUM_RINGS; - static void drawScaledText(MatrixStack matrices, Text text, int x, int y, float size, int color) { + static void drawScaledText(DrawContext context, Text text, int x, int y, float size, int color) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 0); matrices.scale(size, size, 1); - MinecraftClient.getInstance().textRenderer.draw(matrices, text, 0, 0, color); + context.drawText(MinecraftClient.getInstance().textRenderer, text, 0, 0, color, false); matrices.pop(); } - static void renderItemIcon(ItemStack stack, double x, double y, float scale) { - MatrixStack modelStack = RenderSystem.getModelViewStack(); + static void renderItemIcon(DrawContext context ,ItemStack stack, double x, double y, float scale) { + MatrixStack modelStack = context.getMatrices(); modelStack.push(); modelStack.translate(x, y, 0); if (scale != 1) { modelStack.scale(scale, scale, 1); } - RenderSystem.applyModelViewMatrix(); - - MinecraftClient.getInstance().getItemRenderer().renderGuiItemIcon(modelStack, stack, 0, 0); + context.drawItem(stack, 0, 0); modelStack.pop(); - RenderSystem.applyModelViewMatrix(); } - static void renderRaceIcon(MatrixStack matrices, Race race, int x, int y, int size) { - RenderSystem.setShaderTexture(0, race.getIcon()); - DrawableHelper.drawTexture(matrices, x - size / 2, y - size / 2, 0, 0, 0, size, size, size, size); + static void renderRaceIcon(DrawContext context, Race race, int x, int y, int size) { + context.drawTexture(race.getIcon(), x - size / 2, y - size / 2, 0, 0, 0, size, size, size, size); } static void drawLine(MatrixStack matrices, int x1, int y1, int x2, int y2, int color) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java index 637f4247..e4e304f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ItemTraitsTooltipRenderer.java @@ -6,16 +6,14 @@ import java.util.List; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.magic.spell.trait.*; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.font.TextRenderer.TextLayerType; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.text.*; @@ -54,12 +52,12 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp } @Override - public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer) { + public void drawItems(TextRenderer textRenderer, int x, int y, DrawContext context) { int columns = getColumns(); int i = 0; for (var entry : traits) { - renderTraitIcon(entry.getKey(), entry.getValue(), matrices, + renderTraitIcon(entry.getKey(), entry.getValue(), context, x + (i % columns) * 17, y + (i / columns) * 17 ); @@ -82,11 +80,11 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp return Text.empty(); } - public static void renderStackTraits(ItemStack stack, MatrixStack matrices, float x, float y, float weight, float delta, int seed) { - renderStackTraits(SpellTraits.of(stack), matrices, x, y, weight, delta, seed, false); + public static void renderStackTraits(ItemStack stack, DrawContext context, float x, float y, float weight, float delta, int seed) { + renderStackTraits(SpellTraits.of(stack), context, x, y, weight, delta, seed, false); } - public static void renderStackTraits(SpellTraits traits, MatrixStack matrices, float x, float y, float weight, float delta, int seed, boolean revealAll) { + public static void renderStackTraits(SpellTraits traits, DrawContext context, float x, float y, float weight, float delta, int seed, boolean revealAll) { float time = MathHelper.cos((MinecraftClient.getInstance().player.age + delta + seed) / 2F) * 0.7F; float angle = 0.7F + (time / 30F) % MathHelper.TAU; @@ -95,7 +93,7 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp for (var entry : traits) { if (revealAll || isKnown(entry.getKey())) { - ItemTraitsTooltipRenderer.renderTraitIcon(entry.getKey(), entry.getValue() * weight, matrices, + ItemTraitsTooltipRenderer.renderTraitIcon(entry.getKey(), entry.getValue() * weight, context, x + r * MathHelper.sin(angle), y + r * MathHelper.cos(angle), revealAll || isKnown(entry.getKey()) @@ -110,21 +108,20 @@ public class ItemTraitsTooltipRenderer implements Text, OrderedText, TooltipComp || Pony.of(MinecraftClient.getInstance().player).getDiscoveries().isKnown(trait); } - public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, float xx, float yy) { - renderTraitIcon(trait, value, matrices, xx, yy, isKnown(trait)); + public static void renderTraitIcon(Trait trait, float value, DrawContext context, float xx, float yy) { + renderTraitIcon(trait, value, context, xx, yy, isKnown(trait)); } - public static void renderTraitIcon(Trait trait, float value, MatrixStack matrices, float xx, float yy, boolean reveal) { + public static void renderTraitIcon(Trait trait, float value, DrawContext context, float xx, float yy, boolean reveal) { TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; int size = 12; - RenderSystem.setShaderTexture(0, reveal ? trait.getSprite() : UNKNOWN); - + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(xx, yy, 300F); - DrawableHelper.drawTexture(matrices, 2, 1, 0, 0, 0, size, size, size, size); + context.drawTexture(reveal ? trait.getSprite() : UNKNOWN, 2, 1, 0, 0, 0, size, size, size, size); matrices.translate(9, 3 + size / 2, 0); matrices.scale(0.5F, 0.5F, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java index b9a0fac4..866ba85f 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/LanSettingsScreen.java @@ -15,8 +15,8 @@ import com.minelittlepony.unicopia.Config; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Unicopia; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -135,10 +135,10 @@ public class LanSettingsScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { - renderBackground(matrices); - super.render(matrices, mouseX, mouseY, tickDelta); - content.render(matrices, mouseX, mouseY, tickDelta); + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + renderBackground(context); + super.render(context, mouseX, mouseY, tickDelta); + content.render(context, mouseX, mouseY, tickDelta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java index 1b60d28e..2412bb63 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ManaRingSlot.java @@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.entity.player.MagicReserves; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; class ManaRingSlot extends Slot { @@ -18,7 +19,8 @@ class ManaRingSlot extends Slot { } @Override - protected void renderContents(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(24.5, 25.5, 0); @@ -58,7 +60,7 @@ class ManaRingSlot extends Slot { matrices.pop(); - super.renderContents(matrices, abilities, bSwap, tickDelta); + super.renderContents(context, abilities, bSwap, tickDelta); } private double renderRing(MatrixStack matrices, double outerRadius, double innerRadius, double offsetAngle, Bar bar, int color, float tickDelta) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java index 39c6775b..15ffad4b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/SettingsScreen.java @@ -13,8 +13,8 @@ import com.minelittlepony.unicopia.util.RegistryIndexer; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.Text; @@ -81,7 +81,7 @@ public class SettingsScreen extends GameGui { row += 20; content.addButton(new Label(LEFT, row)).getStyle().setText("unicopia.options.world"); - WorldTribeManager tribes = WorldTribeManager.forWorld((ServerWorld)server.getPlayerManager().getPlayer(MinecraftClient.getInstance().player.getUuid()).world); + WorldTribeManager tribes = WorldTribeManager.forWorld((ServerWorld)server.getPlayerManager().getPlayer(MinecraftClient.getInstance().player.getUuid()).getWorld()); content.addButton(new Slider(LEFT, row += 20, 0, races.size(), races.indexOf(tribes.getDefaultRace()))) .onChange(races.createSetter(tribes::setDefaultRace)) @@ -105,10 +105,10 @@ public class SettingsScreen extends GameGui { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { - renderBackground(matrices); - super.render(matrices, mouseX, mouseY, tickDelta); - content.render(matrices, mouseX, mouseY, tickDelta); + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { + renderBackground(context); + super.render(context, mouseX, mouseY, tickDelta); + content.render(context, mouseX, mouseY, tickDelta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java index cc05d25a..e337ddf3 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/Slot.java @@ -5,6 +5,7 @@ import com.minelittlepony.unicopia.ability.AbilitySlot; import com.minelittlepony.unicopia.client.KeyBindingsHandler; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.math.MathHelper; @@ -74,7 +75,7 @@ class Slot { return y; } - void renderBackground(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + void renderBackground(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { if (aSlot != bSlot) { bSwap |= !abilities.isFilled(aSlot); @@ -83,17 +84,17 @@ class Slot { RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.enableBlend(); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(getX(), getY(), 0); // background - UHud.drawTexture(matrices, 0, 0, backgroundU, backgroundV, size, size, 128, 128); + context.drawTexture(UHud.HUD_TEXTURE, 0, 0, backgroundU, backgroundV, size, size, 128, 128); AbilityDispatcher.Stat stat = abilities.getStat(bSwap ? bSlot : aSlot); - int sz = iconSize - slotPadding; - uHud.renderAbilityIcon(matrices, stat, slotPadding, slotPadding, sz, sz, sz, sz); + uHud.renderAbilityIcon(context, stat, slotPadding, slotPadding, sz, sz, sz, sz); float cooldown = stat.getFillProgress(); @@ -107,21 +108,22 @@ class Slot { int progressTop = progressBottom - (int)(progressMax * cooldown); // progress - UHud.fill(matrices, slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF); + context.fill(slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF); } - renderContents(matrices, abilities, bSwap, tickDelta); + renderContents(context, abilities, bSwap, tickDelta); matrices.pop(); } - protected void renderContents(MatrixStack matrices, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { + protected void renderContents(DrawContext context, AbilityDispatcher abilities, boolean bSwap, float tickDelta) { // contents - UHud.drawTexture(matrices, 0, 0, foregroundU, foregroundV, size, size, 128, 128); + context.drawTexture(UHud.HUD_TEXTURE, 0, 0, foregroundU, foregroundV, size, size, 128, 128); } - void renderLabel(MatrixStack matrices, AbilityDispatcher abilities, float tickDelta) { + void renderLabel(DrawContext context, AbilityDispatcher abilities, float tickDelta) { Text label = KeyBindingsHandler.INSTANCE.getBinding(aSlot).getLabel(); + MatrixStack matrices = context.getMatrices(); matrices.push(); int x = getX(); @@ -135,7 +137,7 @@ class Slot { matrices.translate(x, getY() + labelY, 0); matrices.scale(0.5F, 0.5F, 0.5F); - UHud.drawTextWithShadow(matrices, uHud.font, label, 0, 0, 0xFFFFFF); + context.drawText(uHud.font, label, 0, 0, 0xFFFFFF, true); matrices.pop(); } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java index a47fff2e..8943da6e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TextBlock.java @@ -4,7 +4,7 @@ import com.minelittlepony.common.client.gui.dimension.Bounds; import com.minelittlepony.common.client.gui.element.Label; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.OrderedText; public class TextBlock extends Label { @@ -24,11 +24,11 @@ public class TextBlock extends Label { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { int textY = (int)(getY() + MinecraftClient.getInstance().textRenderer.fontHeight/1.5F); for (OrderedText line : getFont().wrapLines(getStyle().getText(), maxWidth)) { - getFont().drawWithShadow(matrices, line, getX(), textY, getStyle().getColor()); + context.drawText(getFont(), line, getX(), textY, getStyle().getColor(), true); textY += getFont().fontHeight; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java index 220366ed..4d6c9204 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeButton.java @@ -8,8 +8,8 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -28,9 +28,8 @@ public class TribeButton extends Button { } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float partialTicks) { RenderSystem.setShader(GameRenderer::getPositionTexProgram); - RenderSystem.setShaderTexture(0, TribeSelectionScreen.TEXTURE); RenderSystem.setShaderColor(1, 1, 1, alpha); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -41,18 +40,18 @@ public class TribeButton extends Button { MinecraftClient mc = MinecraftClient.getInstance(); - drawTexture(matrices, getX() - 3, getY() - 13, 0, 0, 76, 69); + context.drawTexture(TribeSelectionScreen.TEXTURE, getX() - 3, getY() - 13, 0, 0, 76, 69); if (isHovered()) { - drawTexture(matrices, getX() - 4, getY() - 14, 76, 0, 78, 71); + context.drawTexture(TribeSelectionScreen.TEXTURE, getX() - 4, getY() - 14, 76, 0, 78, 71); if (hovered && screenWidth > 0) { Identifier id = Race.REGISTRY.getId(race); - drawCenteredTextWithShadow(matrices, getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, getY() + height, 0xFFFFFFFF); + context.drawCenteredTextWithShadow(getFont(), Text.translatable("gui.unicopia.tribe_selection.describe." + id.getNamespace() + "." + id.getPath()), screenWidth / 2, getY() + height, 0xFFFFFFFF); } } if (getStyle().hasIcon()) { - getStyle().getIcon().render(matrices, getX(), getY(), mouseX, mouseY, partialTicks); + getStyle().getIcon().render(context, getX(), getY(), mouseX, mouseY, partialTicks); } int foreColor = getStyle().getColor(); @@ -65,7 +64,7 @@ public class TribeButton extends Button { setMessage(getStyle().getText()); - renderForground(matrices, mc, mouseX, mouseY, foreColor | MathHelper.ceil(alpha * 255.0F) << 24); + renderForground(context, mc, mouseX, mouseY, foreColor | MathHelper.ceil(alpha * 255.0F) << 24); } public static ISprite createSprite(Race race, int x, int y, int size) { diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java index 75cd0629..44d98451 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeConfirmationScreen.java @@ -6,10 +6,9 @@ import com.minelittlepony.common.client.gui.GameGui; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.client.gui.element.Label; import com.minelittlepony.unicopia.Race; -import com.mojang.blaze3d.systems.RenderSystem; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import net.minecraft.util.*; @@ -82,10 +81,8 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - renderBackground(matrices); - - RenderSystem.setShaderTexture(0, TribeSelectionScreen.TEXTURE); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + renderBackground(context); final int columnHeight = 180; final int columnWidth = 310; @@ -98,23 +95,23 @@ public class TribeConfirmationScreen extends GameGui implements HidesHud { final int zOffset = 0; - drawTexture(matrices, left + zOffset, top, 0, 70, 123, columnHeight); + context.drawTexture(TribeSelectionScreen.TEXTURE, left + zOffset, top, 0, 70, 123, columnHeight); - drawTexture(matrices, left + segmentWidth + zOffset, top, 20, 70, 123, columnHeight); + context.drawTexture(TribeSelectionScreen.TEXTURE, left + segmentWidth + zOffset, top, 20, 70, 123, columnHeight); - drawTexture(matrices, width - left - segmentWidth + zOffset, top, 10, 70, 123, columnHeight); + context.drawTexture(TribeSelectionScreen.TEXTURE, width - left - segmentWidth + zOffset, top, 10, 70, 123, columnHeight); top -= 31; left = width / 2; - drawTexture(matrices, left - 55, top, 140, 70, 21, 50); + context.drawTexture(TribeSelectionScreen.TEXTURE, left - 55, top, 140, 70, 21, 50); - drawTexture(matrices, left - 35, top, 10, 70, 69, 50); + context.drawTexture(TribeSelectionScreen.TEXTURE, left - 35, top, 10, 70, 69, 50); - drawTexture(matrices, left + 35, top, 148, 70, 21, 50); + context.drawTexture(TribeSelectionScreen.TEXTURE, left + 35, top, 148, 70, 21, 50); - super.render(matrices, mouseX, mouseY, delta); + super.render(context, mouseX, mouseY, delta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java index 55c44635..302c546d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/TribeSelectionScreen.java @@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.network.Channel; import com.minelittlepony.unicopia.network.MsgRequestSpeciesChange; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; @@ -93,9 +93,9 @@ public class TribeSelectionScreen extends GameGui implements HidesHud { } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { - renderBackground(matrices); - super.render(matrices, mouseX, mouseY, delta); + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + renderBackground(context); + super.render(context, mouseX, mouseY, delta); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java index d2d9848d..15b61f42 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/UHud.java @@ -22,7 +22,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.client.gui.screen.ingame.InventoryScreen; import net.minecraft.client.util.math.MatrixStack; @@ -35,7 +35,7 @@ import net.minecraft.util.*; import net.minecraft.util.math.*; import net.minecraft.util.math.random.Random; -public class UHud extends DrawableHelper { +public class UHud { public static final UHud INSTANCE = new UHud(); @@ -70,7 +70,7 @@ public class UHud extends DrawableHelper { private boolean prevReplacing; private SpellType focusedType = SpellType.empty(); - public void render(InGameHud hud, MatrixStack matrices, float tickDelta) { + public void render(InGameHud hud, DrawContext context, float tickDelta) { if (client.player == null) { return; @@ -81,7 +81,7 @@ public class UHud extends DrawableHelper { Pony pony = Pony.of(client.player); - renderViewEffects(pony, matrices, scaledWidth, scaledHeight, tickDelta); + renderViewEffects(pony, context, scaledWidth, scaledHeight, tickDelta); if (client.currentScreen instanceof HidesHud || client.player.isSpectator() || client.options.hudHidden) { return; @@ -90,6 +90,7 @@ public class UHud extends DrawableHelper { font = client.textRenderer; xDirection = client.player.getMainArm() == Arm.LEFT ? -1 : 1; + MatrixStack matrices = context.getMatrices(); matrices.push(); int hudX = ((scaledWidth - 50) / 2) + (104 * xDirection); @@ -111,7 +112,7 @@ public class UHud extends DrawableHelper { AbilityDispatcher abilities = pony.getAbilities(); if (message != null && messageTime > 0) { - renderMessage(matrices, tickDelta); + renderMessage(context, tickDelta); } RenderSystem.setShaderColor(1, 1, 1,1); @@ -120,7 +121,7 @@ public class UHud extends DrawableHelper { boolean swap = client.options.sneakKey.isPressed(); - slots.forEach(slot -> slot.renderBackground(matrices, abilities, swap, tickDelta)); + slots.forEach(slot -> slot.renderBackground(context, abilities, swap, tickDelta)); if (pony.getObservedSpecies().canCast()) { AbilitySlot slot = swap ? AbilitySlot.PASSIVE : AbilitySlot.PRIMARY; @@ -145,18 +146,18 @@ public class UHud extends DrawableHelper { matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(-26)); matrices.scale(0.8F, 0.8F, 1); int u = replacing ? 16 : 3; - UHud.drawTexture(matrices, 0, 0, u, 120, 13, 7, 128, 128); + context.drawTexture(HUD_TEXTURE, 0, 0, u, 120, 13, 7, 128, 128); matrices.pop(); } } - slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta)); + slots.forEach(slot -> slot.renderLabel(context, abilities, tickDelta)); matrices.pop(); if (pony.getObservedSpecies().canCast()) { - renderSpell(pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 10 - xDirection * 13, hudY + 2); - renderSpell(pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 8 - xDirection * 2, hudY - 6); + renderSpell(context, pony.getCharms().getEquippedSpell(Hand.MAIN_HAND), hudX + 10 - xDirection * 13, hudY + 2); + renderSpell(context, pony.getCharms().getEquippedSpell(Hand.OFF_HAND), hudX + 8 - xDirection * 2, hudY - 6); } RenderSystem.disableBlend(); @@ -176,19 +177,16 @@ public class UHud extends DrawableHelper { int x = scaledWidth / 2 + xDirection * 67; int y = (int)(scaledHeight - 18 - dims.height/2F); - MatrixStack view = RenderSystem.getModelViewStack(); - - view.push(); - view.translate(x, y, 0); - view.multiply(RotationAxis.POSITIVE_X.rotationDegrees(xDirection * 45)); - InventoryScreen.drawEntity(view, 0, 0, scale, 0, -20, client.player); - view.pop(); - RenderSystem.applyModelViewMatrix(); + matrices.push(); + matrices.translate(x, y, 0); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(xDirection * 45)); + InventoryScreen.drawEntity(context, 0, 0, scale, 0, -20, client.player); + matrices.pop(); }); } } - public void renderSpell(CustomisedSpellType spell, double x, double y) { + public void renderSpell(DrawContext context, CustomisedSpellType spell, double x, double y) { if (spell.isEmpty()) { return; } @@ -196,7 +194,7 @@ public class UHud extends DrawableHelper { Pony pony = Pony.of(client.player); if (spell.isOn(pony)) { - MatrixStack modelStack = new MatrixStack(); + MatrixStack modelStack = context.getMatrices(); modelStack.push(); modelStack.translate(x + 5.5, y + 5.5, 0); @@ -215,17 +213,17 @@ public class UHud extends DrawableHelper { modelStack.push(); modelStack.translate(1, 1, 900); modelStack.scale(0.8F, 0.8F, 0.8F); - font.drawWithShadow(modelStack, count > 64 ? "64+" : String.valueOf(count), 0, 0, 0xFFFFFFFF); + context.drawText(font, count > 64 ? "64+" : String.valueOf(count), 0, 0, 0xFFFFFFFF, true); modelStack.pop(); } modelStack.pop(); } - DrawableUtil.renderItemIcon(spell.getDefaultStack(), x, y, EQUIPPED_GEMSTONE_SCALE); + DrawableUtil.renderItemIcon(context, spell.getDefaultStack(), x, y, EQUIPPED_GEMSTONE_SCALE); } - private void renderMessage(MatrixStack matrices, float tickDelta) { + private void renderMessage(DrawContext context, float tickDelta) { float time = messageTime - tickDelta; int progress = Math.min(255, (int)(time * 255F / 20F)); @@ -235,11 +233,11 @@ public class UHud extends DrawableHelper { color |= alpha; - drawCenteredTextWithShadow(matrices, client.textRenderer, message, 25, -15, color); + context.drawCenteredTextWithShadow(font, message, 25, -15, color); } } - protected void renderViewEffects(Pony pony, MatrixStack matrices, int scaledWidth, int scaledHeight, float tickDelta) { + protected void renderViewEffects(Pony pony, DrawContext context, int scaledWidth, int scaledHeight, float tickDelta) { boolean hasEffect = client.player.hasStatusEffect(UEffects.SUN_BLINDNESS); @@ -258,12 +256,12 @@ public class UHud extends DrawableHelper { int color = 0xFFFFFF; if (hasEffect) { - GradientUtil.fillRadialGradient(matrices, 0, 0, scaledWidth, scaledHeight, + GradientUtil.fillRadialGradient(context.getMatrices(), 0, 0, scaledWidth, scaledHeight, color | (alpha1 << 24), color | (alpha2 << 24), 0, 1); } else { - GradientUtil.fillVerticalGradient(matrices, 0, 0, scaledHeight / 2, scaledWidth, scaledHeight, + GradientUtil.fillVerticalGradient(context.getMatrices(), 0, 0, scaledHeight / 2, scaledWidth, scaledHeight, color | (alpha1 << 24), color | (alpha2 << 24), color | (alpha1 << 24), @@ -277,7 +275,7 @@ public class UHud extends DrawableHelper { final int delay = 7; final int current = client.player.age / delay; final int tint = DyeColor.byId(current % DyeColor.values().length).getSignColor(); - fillGradient(matrices, 0, 0, scaledWidth, scaledHeight, 0x1F000000 | tint, 0x5F000000 | tint); + context.fillGradient(0, 0, scaledWidth, scaledHeight, 0x1F000000 | tint, 0x5F000000 | tint); if (partySound == null || partySound.isDone()) { client.getSoundManager().play( @@ -292,7 +290,7 @@ public class UHud extends DrawableHelper { if (partySound != null) { partySound.setMuted(true); } - fillGradient(matrices, 0, 0, scaledWidth, scaledHeight, 0x0A000088, 0x7E000000); + context.fillGradient(0, 0, scaledWidth, scaledHeight, 0x0A000088, 0x7E000000); } } else { if (partySound != null) { @@ -302,7 +300,7 @@ public class UHud extends DrawableHelper { if (UItems.ALICORN_AMULET.isApplicable(client.player)) { float radius = (float)pony.getArmour().getTicks(UItems.ALICORN_AMULET) / (5 * ItemTracker.DAYS); - renderVignette(matrices, 0x000000, radius, radius, scaledWidth, scaledHeight); + renderVignette(context, 0x000000, radius, radius, scaledWidth, scaledHeight); } float exhaustion = MathHelper.clamp(pony.getMagicalReserves().getExhaustion().getPercentFill(), 0, 0.6F); @@ -319,11 +317,11 @@ public class UHud extends DrawableHelper { float rate = exhaustion > 0.5F ? 2.5F : 7F; float radius = (1 + (float)Math.sin(client.player.age / rate)) / 2F; - renderVignette(matrices, 0x880000, exhaustion * radius, 0.1F + radius * 0.3F, scaledWidth, scaledHeight); + renderVignette(context, 0x880000, exhaustion * radius, 0.1F + radius * 0.3F, scaledWidth, scaledHeight); } } - private void renderVignette(MatrixStack matrices, int color, float alpha, float radius, int scaledWidth, int scaledHeight) { + private void renderVignette(DrawContext context, int color, float alpha, float radius, int scaledWidth, int scaledHeight) { if (radius <= 0) { return; } @@ -331,7 +329,7 @@ public class UHud extends DrawableHelper { color &= 0xFFFFFF; float alpha2 = MathHelper.clamp(radius - 1, 0, 1) * 255; float alpha1 = Math.max(alpha2, MathHelper.clamp(alpha * 2, 0, 1) * 205); - GradientUtil.fillRadialGradient(matrices, 0, 0, scaledWidth, scaledHeight, + GradientUtil.fillRadialGradient(context.getMatrices(), 0, 0, scaledWidth, scaledHeight, color | (int)alpha1 << 24, color | (int)alpha2 << 24, 0, Math.min(1, radius)); @@ -348,11 +346,9 @@ 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(DrawContext context, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) { stat.getAbility(Unicopia.getConfig().hudPage.get()).ifPresent(ability -> { - RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player))); - drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v); - RenderSystem.setShaderTexture(0, HUD_TEXTURE); + context.drawTexture(ability.getIcon(Pony.of(client.player)), x, y, 0, 0, frameWidth, frameHeight, u, v); }); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java index 80657620..3a5cc878 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/DynamicContent.java @@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.container.SpellbookChapterLoader.Flow; import com.minelittlepony.unicopia.container.SpellbookState; import com.minelittlepony.unicopia.entity.player.Pony; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.text.Text; @@ -30,17 +31,17 @@ public class DynamicContent implements Content { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { int pageIndex = state.getOffset() * 2; - getPage(pageIndex).ifPresent(page -> page.draw(matrices, mouseX, mouseY, container)); + getPage(pageIndex).ifPresent(page -> page.draw(context, mouseX, mouseY, container)); - matrices.push(); + context.getMatrices().push(); getPage(pageIndex + 1).ifPresent(page -> { page.bounds.left = bounds.left + bounds.width / 2 + 20; - page.draw(matrices, mouseX, mouseY, container); + page.draw(context, mouseX, mouseY, container); }); - matrices.pop(); + context.getMatrices().pop(); } @Override @@ -123,7 +124,7 @@ public class DynamicContent implements Content { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { if (elements.isEmpty()) { return; @@ -142,8 +143,9 @@ public class DynamicContent implements Content { int headerColor = mouseY % 255; - DrawableUtil.drawScaledText(matrices, needsMoreXp ? UNKNOWN : title, bounds.left, bounds.top - 10, 1.3F, headerColor); - DrawableUtil.drawScaledText(matrices, level < 0 ? UNKNOWN_LEVEL : Text.literal("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor); + MatrixStack matrices = context.getMatrices(); + DrawableUtil.drawScaledText(context, needsMoreXp ? UNKNOWN : title, bounds.left, bounds.top - 10, 1.3F, headerColor); + DrawableUtil.drawScaledText(context, level < 0 ? UNKNOWN_LEVEL : Text.literal("Level: " + (level + 1)).formatted(Formatting.DARK_GREEN), bounds.left, bounds.top - 10 + 12, 0.8F, headerColor); matrices.push(); matrices.translate(bounds.left, bounds.top + 16, 0); @@ -151,13 +153,13 @@ public class DynamicContent implements Content { Bounds bounds = element.bounds(); matrices.push(); bounds.translate(matrices); - element.draw(matrices, mouseX, mouseY, container); + element.draw(context, mouseX, mouseY, container); matrices.pop(); }); matrices.push(); elements.stream().filter(PageElement::isInline).forEach(element -> { - element.draw(matrices, mouseX, mouseY, container); + element.draw(context, mouseX, mouseY, container); matrices.translate(0, element.bounds().height, 0); }); matrices.pop(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java index 7dd29a45..c6d3834e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/EquippedSpellSlot.java @@ -9,11 +9,11 @@ import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellTyp import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.item.TooltipContext; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.sound.SoundManager; -import net.minecraft.client.util.math.MatrixStack; public class EquippedSpellSlot extends Button { @@ -33,34 +33,32 @@ public class EquippedSpellSlot extends Button { } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SpellbookScreen.SLOT); RenderSystem.enableBlend(); - drawTexture(matrices, getX() - 8, getY() - 8, 0, 0, 32, 32, 32, 32); + context.drawTexture(SpellbookScreen.SLOT, getX() - 8, getY() - 8, 0, 0, 32, 32, 32, 32); Vector4f pos = new Vector4f(getX(), getY(), 0, 1); - pos.mul(matrices.peek().getPositionMatrix()); + pos.mul(context.getMatrices().peek().getPositionMatrix()); if (spell.isEmpty()) { RenderSystem.setShaderColor(1, 1, 1, 0.3F); - RenderSystem.setShaderTexture(0, SpellbookScreen.GEM); - drawTexture(matrices, getX(), getY(), 0, 0, 16, 16, 16, 16); + context.drawTexture(SpellbookScreen.GEM, getX(), getY(), 0, 0, 16, 16, 16, 16); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); } else { RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); - drawItem(matrices, (int)pos.x, (int)pos.y); + drawItem(context, (int)pos.x, (int)pos.y); } if (isHovered()) { - HandledScreen.drawSlotHighlight(matrices, getX(), getY(), 0); + HandledScreen.drawSlotHighlight(context, getX(), getY(), 0); } } - protected void drawItem(MatrixStack matrices, int x, int y) { - itemRenderer.renderInGui(matrices, spell.getDefaultStack(), x, y); + protected void drawItem(DrawContext context, int x, int y) { + context.drawItem(spell.getDefaultStack(), x, y); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java index 737dcabd..d54a80e1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/IngredientTree.java @@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.client.render.PassThroughVertexConsumer; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.item.TooltipContext; import net.minecraft.client.render.*; import net.minecraft.client.render.item.ItemRenderer; @@ -133,22 +134,22 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SpellbookScreen.SLOT); RenderSystem.enableBlend(); - drawTexture(matrices, getX() - 8, getY() - 10, 0, 0, 32, 32, 32, 32); + context.drawTexture(SpellbookScreen.SLOT, getX() - 8, getY() - 10, 0, 0, 32, 32, 32, 32); RenderSystem.disableBlend(); RenderSystem.setShaderColor(1, 1, 1, 1); - MinecraftClient.getInstance().textRenderer.draw(matrices, label, + context.drawText(getFont(), label, getX() - MinecraftClient.getInstance().textRenderer.getWidth(label) / 2 - 3, getY() + 4, - 0 + 0, + false ); - entry.render(matrices, getX(), getY(), tickDelta); + entry.render(context, getX(), getY(), tickDelta); } } @@ -162,7 +163,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { return Multiple.of(Arrays.stream(traits).map(t -> new Traits(t, value)).toArray(Entry[]::new)); } - void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta); + void render(DrawContext context, int mouseX, int mouseY, float tickDelta); Tooltip getTooltip(); @@ -177,7 +178,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { static final IngredientTree.Entry EMPTY = new IngredientTree.Entry() { @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) {} + public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) {} @Override public void onClick() { } @@ -203,14 +204,14 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void render(MatrixStack matrices, int x, int y, float tickDelta) { + public void render(DrawContext context, int x, int y, float tickDelta) { y -= 2; if (ticker++ % 30 == 0) { index = (index + 1) % entries.length; } - entries[index].render(matrices, x, y, tickDelta); + entries[index].render(context, x, y, tickDelta); } @Override @@ -235,12 +236,12 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void render(MatrixStack matrices, int x, int y, float tickDelta) { - drawItem(matrices, x, y - 2); + public void render(DrawContext context, int x, int y, float tickDelta) { + drawItem(context, x, y - 2); } - protected void drawItem(MatrixStack matrices, int x, int y) { - itemRenderer.renderInGui(matrices, stack, x, y); + protected void drawItem(DrawContext context, int x, int y) { + context.drawItem(stack, x, y); } @Override @@ -261,7 +262,7 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { static class HiddenStacks extends Stacks { private static final PassThroughVertexConsumer.Parameters FIXTURE = new PassThroughVertexConsumer.Parameters().color((parent, r, g, b, a) -> { - parent.color(0, 0, 0, a); + parent.color(0, 0, 0, 0.6F); }); HiddenStacks(ItemStack stack) { @@ -269,17 +270,18 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - protected void drawItem(MatrixStack matrices, int x, int y) { + protected void drawItem(DrawContext context, int x, int y) { var model = itemRenderer.getModel(stack, null, null, 0); MinecraftClient.getInstance().getTextureManager().getTexture(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE).setFilter(false, false); RenderSystem.setShaderTexture(0, PlayerScreenHandler.BLOCK_ATLAS_TEXTURE); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 100); matrices.translate(8, 8, 0); matrices.scale(1, -1, 1); matrices.scale(8, 8, 8); - VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); + VertexConsumerProvider.Immediate immediate = context.getVertexConsumers(); boolean bl = !model.isSideLit(); if (bl) { DiffuseLighting.disableGuiDepthLighting(); @@ -316,8 +318,8 @@ class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder { } @Override - public void render(MatrixStack matrices, int x, int y, float tickDelta) { - ItemTraitsTooltipRenderer.renderTraitIcon(trait, value, matrices, x, y); + public void render(DrawContext context, int x, int y, float tickDelta) { + ItemTraitsTooltipRenderer.renderTraitIcon(trait, value, context, x, y); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java index 6b7a82fb..b7aea805 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/PageElement.java @@ -11,11 +11,10 @@ import com.minelittlepony.unicopia.client.gui.ParagraphWrappingVisitor; import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookChapterList.Drawable; import com.minelittlepony.unicopia.container.SpellbookChapterLoader.Flow; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.text.Style; @@ -24,7 +23,7 @@ import net.minecraft.util.*; interface PageElement extends Drawable { @Override - default void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + default void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { } @@ -64,10 +63,8 @@ interface PageElement extends Drawable { Bounds bounds, Flow flow) implements PageElement { @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { - RenderSystem.setShaderTexture(0, texture); - DrawableHelper.drawTexture(matrices, 0, 0, 0, 0, 0, bounds().width, bounds().height, bounds().width, bounds().height); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { + context.drawTexture(texture, 0, 0, 0, 0, 0, bounds().width, bounds().height, bounds().width, bounds().height); } } @@ -96,12 +93,13 @@ interface PageElement extends Drawable { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { TextRenderer font = MinecraftClient.getInstance().textRenderer; boolean needsMoreXp = page.getLevel() < 0 || Pony.of(MinecraftClient.getInstance().player).getLevel().get() < page.getLevel(); + MatrixStack matrices = context.getMatrices(); matrices.push(); wrappedText.forEach(line -> { - font.draw(matrices, needsMoreXp ? line.text().copy().formatted(Formatting.OBFUSCATED) : line.text().copy(), line.x(), 0, 0); + context.drawText(font, needsMoreXp ? line.text().copy().formatted(Formatting.OBFUSCATED) : line.text().copy(), line.x(), 0, 0, false); matrices.translate(0, font.fontHeight, 0); }); matrices.pop(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java index cc61d777..72adc98c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookChapterList.java @@ -8,7 +8,7 @@ import com.minelittlepony.common.client.gui.IViewRoot; import com.minelittlepony.unicopia.Debug; import com.minelittlepony.unicopia.Unicopia; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.util.Identifier; public class SpellbookChapterList { @@ -89,14 +89,14 @@ public class SpellbookChapterList { } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { - obj.draw(matrices, mouseX, mouseY, container); + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { + obj.draw(context, mouseX, mouseY, container); } }); } } public interface Drawable { - void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container); + void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java index 3492fb6b..e2be6444 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookCraftingPageContent.java @@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.container.SpellbookState; import com.minelittlepony.unicopia.item.URecipes; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -40,14 +41,14 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { int headerColor = mouseY % 255; - DrawableUtil.drawScaledText(matrices, state.getOffset() == 0 ? INVENTORY_TITLE : RECIPES_TITLE, screen.getFrameBounds().left + screen.getFrameBounds().width / 2 + 20, SpellbookScreen.TITLE_Y, 1.3F, headerColor); + DrawableUtil.drawScaledText(context, state.getOffset() == 0 ? INVENTORY_TITLE : RECIPES_TITLE, screen.getFrameBounds().left + screen.getFrameBounds().width / 2 + 20, SpellbookScreen.TITLE_Y, 1.3F, headerColor); Text pageText = Text.translatable("%s/%s", state.getOffset() + 1, TOTAL_PAGES); - textRenderer.draw(matrices, pageText, 337 - textRenderer.getWidth(pageText) / 2F, 190, headerColor); + context.drawText(textRenderer, pageText, (int)(337 - textRenderer.getWidth(pageText) / 2F), 190, headerColor, false); } @Override @@ -97,35 +98,35 @@ public class SpellbookCraftingPageContent extends ScrollContainer implements Spe } @Override - public void drawOverlays(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void drawOverlays(DrawContext context, int mouseX, int mouseY, float tickDelta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(margin.left, margin.top, 0); matrices.translate(-2, -2, 200); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); int tileSize = 25; final int bottom = height - tileSize + 4; final int right = width - tileSize + 9; - drawTexture(matrices, 0, 0, 405, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, 0, 425, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, 0, 405, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, 0, 425, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, bottom, 425, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, bottom, 425, 72, tileSize, tileSize, 512, 256); for (int i = tileSize; i < right; i += tileSize) { - drawTexture(matrices, i, 0, 415, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, i, bottom, 415, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, 0, 415, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, bottom, 415, 72, tileSize, tileSize, 512, 256); } for (int i = tileSize; i < bottom; i += tileSize) { - drawTexture(matrices, 0, i, 405, 67, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, i, 425, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, i, 405, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, i, 425, 67, tileSize, tileSize, 512, 256); } matrices.pop(); - screen.drawSlots(matrices, mouseX, mouseY, tickDelta); + screen.drawSlots(context, mouseX, mouseY, tickDelta); - super.drawOverlays(matrices, mouseX, mouseY, tickDelta); + super.drawOverlays(context, mouseX, mouseY, tickDelta); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java index b01a9169..1c75f655 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookProfilePageContent.java @@ -9,14 +9,14 @@ import com.sollace.romanizer.api.Romanizer; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.Text; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -public class SpellbookProfilePageContent extends DrawableHelper implements SpellbookChapterList.Content { +public class SpellbookProfilePageContent implements SpellbookChapterList.Content { private final MinecraftClient client = MinecraftClient.getInstance(); private final Pony pony = Pony.of(client.player); private final TextRenderer font = client.textRenderer; @@ -63,7 +63,7 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { int y = SpellbookScreen.TITLE_Y; @@ -72,8 +72,8 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell float currentScaledLevel = pony.getLevel().getScaled(1); float currentCorruption = pony.getCorruption().getScaled(1); - DrawableUtil.drawScaledText(matrices, pony.asEntity().getName(), SpellbookScreen.TITLE_X, y, 1.3F, SpellbookScreen.TITLE_COLOR); - DrawableUtil.drawScaledText(matrices, ExperienceGroup.forLevel( + DrawableUtil.drawScaledText(context, pony.asEntity().getName(), SpellbookScreen.TITLE_X, y, 1.3F, SpellbookScreen.TITLE_COLOR); + DrawableUtil.drawScaledText(context, ExperienceGroup.forLevel( currentScaledLevel, currentCorruption ), SpellbookScreen.TITLE_X, y + 13, 0.8F, @@ -85,10 +85,11 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell MagicReserves reserves = pony.getMagicalReserves(); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(screen.getBackgroundWidth() / 2 + SpellbookScreen.TITLE_X - 10, y, 0); matrices.scale(1.3F, 1.3F, 1); - font.draw(matrices, SpellbookCraftingPageContent.INVENTORY_TITLE, 0, 0, SpellbookScreen.TITLE_COLOR); + context.drawText(font, SpellbookCraftingPageContent.INVENTORY_TITLE, 0, 0, SpellbookScreen.TITLE_COLOR, false); matrices.pop(); Bounds bounds = screen.getFrameBounds(); @@ -139,26 +140,26 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell String manaString = (int)reserves.getMana().get() + "/" + (int)reserves.getMana().getMax(); y = 15; - font.draw(matrices, "Mana", -font.getWidth("Mana") / 2, y, SpellbookScreen.TITLE_COLOR); - font.draw(matrices, manaString, -font.getWidth(manaString) / 2, y += font.fontHeight, SpellbookScreen.TITLE_COLOR); + context.drawText(font, "Mana", -font.getWidth("Mana") / 2, y, SpellbookScreen.TITLE_COLOR, false); + context.drawText(font, manaString, -font.getWidth(manaString) / 2, y += font.fontHeight, SpellbookScreen.TITLE_COLOR, false); Text levelString = Text.literal(Romanizer.romanize(currentLevel + 1)); matrices.translate(-font.getWidth(levelString), -35, 0); matrices.scale(2F, 2F, 1); - font.draw(matrices, levelString, 0, 0, SpellbookScreen.TITLE_COLOR); + context.drawText(font, levelString, 0, 0, SpellbookScreen.TITLE_COLOR, false); matrices.pop(); matrices.push(); matrices.translate(-screen.getX(), -screen.getY(), 0); - screen.drawSlots(matrices, mouseX, mouseY, 0); + screen.drawSlots(context, mouseX, mouseY, 0); matrices.pop(); } - static void drawBar(MatrixStack matrices, int x, int y, float value, int color) { + static void drawBar(DrawContext context, int x, int y, float value, int color) { int barWidth = 40; int midpoint = x + (int)(barWidth * value); - fill(matrices, x, y, midpoint, y + 5, 0xFFAAFFFF); - fill(matrices, midpoint, y, x + barWidth, y + 5, color); + context.fill(x, y, midpoint, y + 5, 0xFFAAFFFF); + context.fill(midpoint, y, x + barWidth, y + 5, color); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java index f45173eb..3419e79b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookScreen.java @@ -19,6 +19,7 @@ import com.minelittlepony.unicopia.network.MsgSpellbookStateChanged; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.Drawable; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider; @@ -27,7 +28,6 @@ import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.screen.slot.Slot; -import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -70,7 +70,7 @@ public class SpellbookScreen extends HandledScreen imple return chapters.getCurrentChapter() == craftingChapter; }); handler.getSpellbookState().setSynchronizer(state -> { - Channel.CLIENT_SPELLBOOK_UPDATE.sendToServer(new MsgSpellbookStateChanged(handler.syncId, state)); + Channel.CLIENT_SPELLBOOK_UPDATE.sendToServer(MsgSpellbookStateChanged.create(handler, state)); }); } @@ -133,21 +133,19 @@ public class SpellbookScreen extends HandledScreen imple } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float partialTicks) { + public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { if (getState().isDirty()) { clearAndInit(); } - super.render(matrices, mouseX, mouseY, partialTicks); - drawMouseoverTooltip(matrices, mouseX, mouseY); + super.render(context, mouseX, mouseY, partialTicks); } @Override - protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) { - renderBackground(matrices); + protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) { + renderBackground(context); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, TEXTURE); - drawTexture(matrices, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256); + context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight, 512, 256); if (Debug.DEBUG_SPELLBOOK_CHAPTERS) { clearAndInit(); @@ -169,43 +167,41 @@ public class SpellbookScreen extends HandledScreen imple boolean isRight = tab.chapter().side() == TabSide.RIGHT; - drawTexture(matrices, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256); + context.drawTexture(TEXTURE, bounds.left, bounds.top, isRight ? 510 - bounds.width : 402, v, bounds.width, bounds.height, 512, 256); RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.setShaderTexture(0, tab.icon().get()); - drawTexture(matrices, isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16); + context.drawTexture(TEXTURE, isRight ? bounds.left + bounds.width - 16 - 10 : bounds.left + 10, bounds.top + (bounds.height - 16) / 2, 0, 0, 16, 16, 16, 16); RenderSystem.setShaderTexture(0, TEXTURE); }); + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 0); - chapters.getCurrentChapter().content().ifPresent(content -> content.draw(matrices, mouseX, mouseY, (IViewRoot)this)); + chapters.getCurrentChapter().content().ifPresent(content -> content.draw(context, mouseX, mouseY, (IViewRoot)this)); matrices.pop(); } - void drawSlots(MatrixStack matrices, int mouseX, int mouseY, float delta) { + void drawSlots(DrawContext context, int mouseX, int mouseY, float delta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(x, y, 0); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SLOT); RenderSystem.enableBlend(); for (Slot slot : handler.slots) { if (slot.isEnabled() && slot instanceof SpellbookSlot p) { - drawTexture(matrices, slot.x - 8, slot.y - 8, 0, 0, 32, 32, 32, 32); + context.drawTexture(SLOT, slot.x - 8, slot.y - 8, 0, 0, 32, 32, 32, 32); if (slot instanceof InputSlot) { RenderSystem.setShaderColor(1, 1, 1, 0.3F); - RenderSystem.setShaderTexture(0, GEM); - drawTexture(matrices, slot.x, slot.y, 0, 0, 16, 16, 16, 16); + context.drawTexture(GEM, slot.x, slot.y, 0, 0, 16, 16, 16, 16); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SLOT); } if (!(p instanceof InventorySlot)) { float weight = p.getWeight(); - ItemTraitsTooltipRenderer.renderStackTraits(slot.getStack(), matrices, slot.x, slot.y, weight == 0 ? 1 : weight, delta, slot.id); - RenderSystem.setShaderTexture(0, SLOT); + ItemTraitsTooltipRenderer.renderStackTraits(slot.getStack(), context, slot.x, slot.y, weight == 0 ? 1 : weight, delta, slot.id); RenderSystem.enableBlend(); } } @@ -216,7 +212,7 @@ public class SpellbookScreen extends HandledScreen imple } @Override - protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) { + protected void drawForeground(DrawContext context, int mouseX, int mouseY) { } @Override @@ -271,7 +267,7 @@ public class SpellbookScreen extends HandledScreen imple } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { if (!active) { return; } @@ -279,7 +275,7 @@ public class SpellbookScreen extends HandledScreen imple int state = hovered ? 1 : 0; sprite.setTextureOffset(23 * state, (int)(479 + 6.5F - (increment * 6.5F))); - super.renderButton(matrices, mouseX, mouseY, tickDelta); + super.renderButton(context, mouseX, mouseY, tickDelta); } } @@ -294,7 +290,7 @@ public class SpellbookScreen extends HandledScreen imple } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(1, 1, 1, alpha); @@ -304,7 +300,7 @@ public class SpellbookScreen extends HandledScreen imple GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); if (getStyle().hasIcon()) { - getStyle().getIcon().render(matrices, getX(), getY(), mouseX, mouseY, tickDelta); + getStyle().getIcon().render(context, getX(), getY(), mouseX, mouseY, tickDelta); } RenderSystem.setShaderColor(1, 1, 1, 1); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java index f3177bc6..8276e4a1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/spellbook/SpellbookTraitDexPageContent.java @@ -16,7 +16,7 @@ import com.minelittlepony.unicopia.item.group.ItemGroupRegistry; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.*; import net.minecraft.sound.SoundEvents; @@ -24,7 +24,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.Util; -public class SpellbookTraitDexPageContent extends DrawableHelper implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener { +public class SpellbookTraitDexPageContent implements SpellbookChapterList.Content, SpellbookScreen.RecipesChangedListener { private final Trait[] traits = Trait.values(); private SpellbookState.PageState state = new SpellbookState.PageState(); @@ -40,7 +40,7 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel } @Override - public void draw(MatrixStack matrices, int mouseX, int mouseY, IViewRoot container) { + public void draw(DrawContext context, int mouseX, int mouseY, IViewRoot container) { } @@ -144,42 +144,42 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel @Override - public void drawOverlays(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void drawOverlays(DrawContext context, int mouseX, int mouseY, float tickDelta) { + MatrixStack matrices = context.getMatrices(); matrices.push(); matrices.translate(margin.left, margin.top, 0); matrices.translate(-2, -2, 200); RenderSystem.enableBlend(); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); int tileSize = 25; final int bottom = height - tileSize + 4; final int right = width - tileSize + 9; - drawTexture(matrices, 0, 0, 405, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, 0, 405, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, bottom, 405, 72, tileSize, tileSize, 512, 256); for (int i = tileSize; i < right; i += tileSize) { - drawTexture(matrices, i, 0, 415, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, i, bottom, 415, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, 0, 415, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, i, bottom, 415, 72, tileSize, tileSize, 512, 256); } for (int i = tileSize; i < bottom; i += tileSize) { - drawTexture(matrices, 0, i, 405, 67, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, i, 425, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, 0, i, 405, 67, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, i, 425, 67, tileSize, tileSize, 512, 256); } - drawTexture(matrices, right, 0, 425, 62, tileSize, tileSize, 512, 256); - drawTexture(matrices, right, bottom, 425, 72, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, 0, 425, 62, tileSize, tileSize, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, right, bottom, 425, 72, tileSize, tileSize, 512, 256); matrices.pop(); if (this == rightPage) { - leftPage.drawDelayed(matrices, mouseX, mouseY, 0); - rightPage.drawDelayed(matrices, mouseX, mouseY, 0); + leftPage.drawDelayed(context, mouseX, mouseY, 0); + rightPage.drawDelayed(context, mouseX, mouseY, 0); } } - public void drawDelayed(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { - super.drawOverlays(matrices, mouseX, mouseY, tickDelta); + public void drawDelayed(DrawContext context, int mouseX, int mouseY, float tickDelta) { + super.drawOverlays(context, mouseX, mouseY, tickDelta); } } @@ -199,24 +199,23 @@ public class SpellbookTraitDexPageContent extends DrawableHelper implements Spel } @Override - public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float tickDelta) { + public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { TraitDiscovery discoveries = Pony.of(MinecraftClient.getInstance().player).getDiscoveries(); setEnabled(discoveries.isKnown(trait)); RenderSystem.setShaderColor(1, 1, 1, 1); - RenderSystem.setShaderTexture(0, SpellbookScreen.TEXTURE); RenderSystem.enableBlend(); - drawTexture(matrices, getX() - 2, getY() - 8, 204, 219, 22, 32, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, getX() - 2, getY() - 8, 204, 219, 22, 32, 512, 256); if (!active) { - drawTexture(matrices, getX() - 2, getY() - 1, 74, 223, 18, 18, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, getX() - 2, getY() - 1, 74, 223, 18, 18, 512, 256); } if (discoveries.isUnread(trait)) { - drawTexture(matrices, getX() - 8, getY() - 8, 225, 219, 35, 32, 512, 256); + context.drawTexture(SpellbookScreen.TEXTURE, getX() - 8, getY() - 8, 225, 219, 35, 32, 512, 256); } - super.renderButton(matrices, mouseX, mouseY, tickDelta); + super.renderButton(context, mouseX, mouseY, tickDelta); hovered &= active; } diff --git a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java index 754b0d1c..7c759bdc 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java +++ b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/WingsGear.java @@ -55,7 +55,7 @@ class WingsGear implements IGear { } if (AmuletSelectors.PEGASUS_AMULET.test(living.asEntity())) { - return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; + return entity.getWorld().getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; } Race race = living instanceof Pony pony ? pony.getObservedSpecies() : living.getSpecies(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java index 839abd30..e69c12e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/FloatingArtefactEntityRenderer.java @@ -34,7 +34,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer extends WingsFea @Override protected Identifier getTexture(E entity) { - return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; + return entity.getWorld().getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS; } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index 0eb9a4ff..5fbcd174 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -87,13 +87,13 @@ public class DisguiseCommand { .setDisguise(entity); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.disguise.success.self", entity.getName()), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.success.self", entity.getName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.disguise.success", entity.getName())); } - source.sendFeedback(Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.success.other", player.getName(), entity.getName()), true); } return 0; @@ -114,13 +114,13 @@ public class DisguiseCommand { iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE, true); if (source.getEntity() == player) { - source.sendFeedback(Text.translatable("commands.disguise.removed.self"), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.removed.self"), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.disguise.removed")); } - source.sendFeedback(Text.translatable("commands.disguise.removed.other", player.getName()), true); + source.sendFeedback(() -> Text.translatable("commands.disguise.removed.other", player.getName()), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java index 61607b62..b0cbeab3 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/GravityCommand.java @@ -60,13 +60,13 @@ class GravityCommand { String translationKey = "commands.gravity." + key; if (source.getEntity() == player) { - source.sendFeedback(Text.translatable(translationKey + ".self", arguments), true); + source.sendFeedback(() -> Text.translatable(translationKey + ".self", arguments), true); } else { if (notifyTarget && source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable(translationKey, arguments)); } - source.sendFeedback(Text.translatable(translationKey + ".other", Streams.concat(Stream.of(player.getDisplayName()), Arrays.stream(arguments)).toArray()), true); + source.sendFeedback(() -> Text.translatable(translationKey + ".other", Streams.concat(Stream.of(player.getDisplayName()), Arrays.stream(arguments)).toArray()), true); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java index fc173e62..6e66b3f6 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/RacelistCommand.java @@ -50,19 +50,20 @@ class RacelistCommand { } static int toggle(ServerCommandSource source, ServerPlayerEntity player, Race race, String action, Function func) { - String translationKey = "commands.racelist." + action; + source.sendFeedback(() -> { + String translationKey = "commands.racelist." + action; - if (!func.apply(race)) { - if (race.isUnset()) { - translationKey = "commands.racelist.illegal"; - } else { - translationKey += ".failed"; + if (!func.apply(race)) { + if (race.isUnset()) { + translationKey = "commands.racelist.illegal"; + } else { + translationKey += ".failed"; + } } - } - Text formattedName = race.getDisplayName().copy().formatted(Formatting.GOLD); - - source.sendFeedback(Text.translatable(translationKey, formattedName).formatted(Formatting.GREEN), false); + Text formattedName = race.getDisplayName().copy().formatted(Formatting.GOLD); + return Text.translatable(translationKey, formattedName).formatted(Formatting.GREEN); + }, false); return 0; } } diff --git a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java index 9b61331f..9c5dae7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/SpeciesCommand.java @@ -72,12 +72,12 @@ class SpeciesCommand { } if (player == source.getPlayer()) { - source.sendFeedback(Text.translatable("commands.race.success.self", race.getDisplayName()), true); + source.sendFeedback(() -> Text.translatable("commands.race.success.self", race.getDisplayName()), true); } else { if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.race.success", race.getDisplayName()), false); } - source.sendFeedback(Text.translatable("commands.race.success.other", player.getName(), race.getDisplayName()), true); + source.sendFeedback(() -> Text.translatable("commands.race.success.other", player.getName(), race.getDisplayName()), true); } } else if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) { player.sendMessage(Text.translatable("commands.race.permission"), false); diff --git a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java index 2c02dc71..dbda7a73 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/TraitCommand.java @@ -86,7 +86,7 @@ class TraitCommand { if (source.getPlayer() == player) { player.sendMessage(Text.translatable(translationKey, gravity), false); } else { - source.sendFeedback(Text.translatable(translationKey + ".other", player.getName(), gravity), true); + source.sendFeedback(() -> Text.translatable(translationKey + ".other", player.getName(), gravity), true); } return 0; diff --git a/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java b/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java index b166abd2..933bc4f4 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/WorldTribeCommand.java @@ -25,8 +25,10 @@ class WorldTribeCommand { } static int get(ServerCommandSource source) throws CommandSyntaxException { - WorldTribeManager manager = WorldTribeManager.forWorld(source.getWorld()); - source.sendFeedback(Text.translatable("commands.worldtribe.success.get", manager.getDefaultRace().getDisplayName()), true); + source.sendFeedback(() -> { + WorldTribeManager manager = WorldTribeManager.forWorld(source.getWorld()); + return Text.translatable("commands.worldtribe.success.get", manager.getDefaultRace().getDisplayName()); + }, true); return 0; } @@ -34,7 +36,7 @@ class WorldTribeCommand { WorldTribeManager manager = WorldTribeManager.forWorld(source.getWorld()); manager.setDefaultRace(race); - source.sendFeedback(Text.translatable("commands.worldtribe.success.set", race.getDisplayName()), true); + source.sendFeedback(() -> Text.translatable("commands.worldtribe.success.set", race.getDisplayName()), true); return 0; } } diff --git a/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java b/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java index 58b10365..66329472 100644 --- a/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/compat/emi/SpellbookEmiRecipe.java @@ -18,7 +18,7 @@ import dev.emi.emi.api.stack.EmiIngredient; import dev.emi.emi.api.stack.EmiStack; import dev.emi.emi.api.widget.TextureWidget; import dev.emi.emi.api.widget.WidgetHolder; -import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; @@ -120,9 +120,9 @@ class SpellbookEmiRecipe implements EmiRecipe, SpellbookRecipe.CraftingTreeBuild } @Override - public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) { + public void render(DrawContext context, int mouseX, int mouseY, float delta) { RenderSystem.enableBlend(); - super.render(matrices, mouseX, mouseY, delta); + context.drawTexture(texture, x, y, 0, u, v, width, height, textureWidth, textureHeight); } } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java b/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java index 62e2de6c..0d8b2d77 100644 --- a/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java +++ b/src/main/java/com/minelittlepony/unicopia/compat/emi/TraitEmiStack.java @@ -14,6 +14,7 @@ import dev.emi.emi.api.render.EmiRender; import dev.emi.emi.api.stack.Comparison; import dev.emi.emi.api.stack.EmiStack; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.Item; @@ -78,25 +79,30 @@ public class TraitEmiStack extends EmiStack { return trait.getName(); } - @Override - public void render(MatrixStack matrices, int x, int y, float delta, int flags) { + //@Override + public void render(DrawContext context, int x, int y, float delta, int flags) { if ((flags & RENDER_ICON) != 0) { List knownItems = trait.getItems(); if (knownItems.isEmpty() || MinecraftClient.getInstance().player == null) { - ItemTraitsTooltipRenderer.renderTraitIcon(trait, amount, matrices, x, y, true); + ItemTraitsTooltipRenderer.renderTraitIcon(trait, amount, context, x, y, true); } else { int tick = (MinecraftClient.getInstance().player.age / 12) % knownItems.size(); ItemStack stack = knownItems.get(tick).getDefaultStack(); - EmiStack.of(stack).render(matrices, x, y, delta, flags); - ItemTraitsTooltipRenderer.renderStackTraits(traits, matrices, x, y, 1, delta, 0, true); + EmiStack.of(stack).render(context.getMatrices(), x, y, delta, flags); + ItemTraitsTooltipRenderer.renderStackTraits(traits, context, x, y, 1, delta, 0, true); } } if ((flags & RENDER_REMAINDER) != 0) { - EmiRender.renderRemainderIcon(this, matrices, x, y); + EmiRender.renderRemainderIcon(this, context.getMatrices(), x, y); } } + //@Override + public void render(MatrixStack matrices, int x, int y, float delta, int flags) { + + } + @Override public EmiStack copy() { return new TraitEmiStack(trait, amount); diff --git a/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java b/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java index 766cbdaa..abf77fad 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/container/inventory/OutputSlot.java @@ -55,7 +55,7 @@ public class OutputSlot extends CraftingResultSlot implements SpellbookSlot { InventoryUtil.stream(input).forEach(s -> { pony.getDiscoveries().unlock(s.getItem()); }); - pony.getMagicalReserves().getXp().add(MathHelper.clamp(player.world.getRandom().nextFloat() / 10F, 0.001F, 0.3F)); + pony.getMagicalReserves().getXp().add(MathHelper.clamp(player.getWorld().getRandom().nextFloat() / 10F, 0.001F, 0.3F)); super.onTakeItem(player, stack); } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java index a5057afb..8e75aa84 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/AirBalloonEntity.java @@ -80,7 +80,7 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C if (isAirworthy()) { setVelocity(getVelocity() - .add(getWind(world, getBlockPos())) + .add(getWind(getWorld(), getBlockPos())) .normalize() .multiply(0.2) .add(0, isBurnerActive() ? 0.00F : isTouchingWater() ? 0.02F : -0.06F, 0)); @@ -112,15 +112,15 @@ public class AirBalloonEntity extends FlyingEntity implements EntityCollisions.C if (velocityBeforeTick.length() > 0.01 && !isSubmergedInWater()) { Box box = getInteriorBoundingBox(); - for (Entity e : world.getOtherEntities(this, box.expand(-0.2, 1, -0.2))) { - updatePassenger(e, box, !onGround); + for (Entity e : getWorld().getOtherEntities(this, box.expand(-0.2, 1, -0.2))) { + updatePassenger(e, box, !isOnGround()); weight++; } if (hasBalloon()) { Box balloonBox = getBalloonBoundingBox(); - for (Entity e : world.getOtherEntities(this, balloonBox.expand(1.0E-7))) { + for (Entity e : getWorld().getOtherEntities(this, balloonBox.expand(1.0E-7))) { updatePassenger(e, balloonBox, false); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java index fbb6dfba..72868273 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java @@ -176,17 +176,17 @@ public class ButterflyEntity extends AmbientEntity { return; } - if (world.getBlockState(below).isAir() - || !world.getOtherEntities(this, getBoundingBox().expand(3), this::isAggressor).isEmpty() - || (ticksResting++ > MAX_REST_TICKS || world.random.nextInt(500) == 0) - || world.hasRain(below)) { + if (getWorld().getBlockState(below).isAir() + || !getWorld().getOtherEntities(this, getBoundingBox().expand(3), this::isAggressor).isEmpty() + || (ticksResting++ > MAX_REST_TICKS || getWorld().random.nextInt(500) == 0) + || getWorld().hasRain(below)) { setResting(false); return; } - if (!world.isClient + if (!getWorld().isClient && age % BREEDING_INTERVAL == 0 - && world.random.nextInt(200) == 0 + && getWorld().random.nextInt(200) == 0 && canBreed()) { breed(); } @@ -205,14 +205,14 @@ public class ButterflyEntity extends AmbientEntity { return flower; }).or(this::findNextHoverPosition).ifPresent(this::moveTowards); - if (random.nextInt(100) == 0 && world.getBlockState(below).isOpaque()) { + if (random.nextInt(100) == 0 && getWorld().getBlockState(below).isOpaque()) { setResting(true); } } } private boolean canBreed() { - return age > BREEDING_INTERVAL && breedingCooldown <= 0 && isResting() && world.getOtherEntities(this, getBoundingBox().expand(2), i -> { + return age > BREEDING_INTERVAL && breedingCooldown <= 0 && isResting() && getWorld().getOtherEntities(this, getBoundingBox().expand(2), i -> { return i instanceof ButterflyEntity && i.getType() == getType() && ((ButterflyEntity)i).isResting(); }).size() == 1; } @@ -220,9 +220,9 @@ public class ButterflyEntity extends AmbientEntity { private boolean breed() { breedingCooldown = MAX_BREEDING_COOLDOWN; - ButterflyEntity copy = (ButterflyEntity)getType().create(world); + ButterflyEntity copy = (ButterflyEntity)getType().create(getWorld()); copy.copyPositionAndRotation(this); - world.spawnEntity(copy); + getWorld().spawnEntity(copy); setResting(false); return true; } @@ -231,7 +231,7 @@ public class ButterflyEntity extends AmbientEntity { // invalidate the hovering position BlockPos pos = getBlockPos(); - return hoveringPosition = hoveringPosition.filter(p -> world.isAir(p) + return hoveringPosition = hoveringPosition.filter(p -> getWorld().isAir(p) && p.getY() >= 1 && random.nextInt(30) != 0 && p.getSquaredDistance(pos) >= 4).or(() -> { @@ -249,9 +249,9 @@ public class ButterflyEntity extends AmbientEntity { return flowerPosition; } - flowerPosition = flowerPosition.filter(p -> world.getBlockState(p).isIn(BlockTags.FLOWERS)).or(() -> { + flowerPosition = flowerPosition.filter(p -> getWorld().getBlockState(p).isIn(BlockTags.FLOWERS)).or(() -> { return BlockPos.streamOutwards(getBlockPos(), FLOWER_DETECTION_RANGE, FLOWER_DETECTION_RANGE, FLOWER_DETECTION_RANGE) - .filter(p -> !visited.containsKey(p) && world.getBlockState(p).isIn(BlockTags.FLOWERS)) + .filter(p -> !visited.containsKey(p) && getWorld().getBlockState(p).isIn(BlockTags.FLOWERS)) .findFirst() .map(p -> { visited.put(p, (long)age - 900); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java index a9364259..63592f7f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CastSpellEntity.java @@ -67,7 +67,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster Operation.ofBoolean(spell.tick(this, Situation.GROUND_ENTITY)), world.isClient)) { + if (!getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.GROUND_ENTITY)), getWorld().isClient)) { discard(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java b/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java index 6ce8ce7e..112a5087 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/DynamicLightSource.java @@ -22,7 +22,7 @@ public interface DynamicLightSource { @SuppressWarnings("deprecation") void tick() { - if (entity.world.isClient) { + if (entity.getWorld().isClient) { if (entity.isRemoved()) { remove(); return; @@ -36,12 +36,13 @@ public interface DynamicLightSource { BlockPos currentPos = entity.getBlockPos(); - if (!currentPos.equals(lastPos) && entity.world.isChunkLoaded(currentPos)) { + if (!currentPos.equals(lastPos) && entity.getWorld().isChunkLoaded(currentPos)) { try { if (lastPos != null) { - entity.world.getLightingProvider().checkBlock(lastPos); + entity.getWorld().getLightingProvider().checkBlock(lastPos); } - entity.world.getLightingProvider().addLightSource(currentPos, light); + // TODO: store this in the ether and inject into Chunk#forEachLightSource + //entity.getWorld().getLightingProvider().addLightSource(currentPos, light); lastPos = currentPos; } catch (Exception ignored) { } } @@ -49,9 +50,9 @@ public interface DynamicLightSource { } void remove() { - if (entity.world.isClient && lastPos != null) { + if (entity.getWorld().isClient && lastPos != null) { try { - entity.world.getLightingProvider().checkBlock(lastPos); + entity.getWorld().getLightingProvider().checkBlock(lastPos); } catch (Exception ignored) {} } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java index 4bc6b8f7..679ea0ef 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityPhysics.java @@ -42,7 +42,7 @@ public class EntityPhysics implements Physics, Copyable entity.world.getHeight() + 64) { + if (entity.getY() > entity.getWorld().getHeight() + 64) { entity.damage(entity.getDamageSources().outOfWorld(), 4.0F); } @@ -60,7 +60,7 @@ public class EntityPhysics implements Physics, Copyable implements Physics, Copyable implements Physics, Copyable 100) { teleport( - target.getX() + world.random.nextFloat() / 2F - 0.5F, + target.getX() + getWorld().random.nextFloat() / 2F - 0.5F, target.getEyeY(), - target.getZ() + world.random.nextFloat() / 2F - 0.5F + target.getZ() + getWorld().random.nextFloat() / 2F - 0.5F ); setVelocity(target.getVelocity()); return; @@ -331,7 +331,7 @@ public class FairyEntity extends PathAwareEntity implements DynamicLightSource, if (distance <= minDistance * minDistance) { - BlockPos pos = FuzzyPositions.localFuzz(FairyEntity.this.world.random, 5, 5); + BlockPos pos = FuzzyPositions.localFuzz(getWorld().random, 5, 5); if (pos != null) { getNavigation().startMovingTo(pos.getX(), pos.getY(), pos.getZ(), speed); } else { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java index 6fdf43b6..d1ea98e4 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/FloatingArtefactEntity.java @@ -98,7 +98,7 @@ public class FloatingArtefactEntity extends Entity implements UDamageSources { setStack(UItems.EMPTY_JAR.getDefaultStack()); } - if (world.isClient) { + if (getWorld().isClient) { float spin = getSpin(); if (Math.abs(spin - targetSpin) > 1.0E-5F) { spinChange = spin - targetSpin; @@ -129,7 +129,7 @@ public class FloatingArtefactEntity extends Entity implements UDamageSources { ((Artifact)stack.getItem()).onArtifactTick(this); } - if (world.getTime() % 80 == 0) { + if (getWorld().getTime() % 80 == 0) { State state = getState(); playSound(USounds.ENTITY_ARTEFACT_AMBIENT, state.getVolume(), state.getPitch()); } @@ -193,7 +193,7 @@ public class FloatingArtefactEntity extends Entity implements UDamageSources { @Override public World asWorld() { - return world; + return getWorld(); } public enum State { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java index 1777d7dc..92fe5549 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemImpl.java @@ -49,7 +49,7 @@ public class ItemImpl implements Equine { @Override public boolean beforeUpdate() { - if (!entity.world.isClient) { + if (!entity.getWorld().isClient) { Race race = getSpecies(); if (race != serverRace) { serverRace = race; @@ -67,9 +67,9 @@ public class ItemImpl implements Equine { ClingyItem clingy = item instanceof ClingyItem ? (ClingyItem)item : ClingyItem.DEFAULT; if (clingy.isClingy(stack)) { - Random rng = entity.world.random; + Random rng = entity.getWorld().random; - entity.world.addParticle(clingy.getParticleEffect((IItemEntity)entity), + entity.getWorld().addParticle(clingy.getParticleEffect((IItemEntity)entity), entity.getX() + rng.nextFloat() - 0.5, entity.getY() + rng.nextFloat() - 0.5, entity.getZ() + rng.nextFloat() - 0.5, @@ -77,7 +77,7 @@ public class ItemImpl implements Equine { ); Vec3d position = entity.getPos(); - VecHelper.findInRange(entity, entity.world, entity.getPos(), clingy.getFollowDistance(i), e -> e instanceof PlayerEntity) + VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), clingy.getFollowDistance(i), e -> e instanceof PlayerEntity) .stream() .sorted((a, b) -> (int)(a.getPos().distanceTo(position) - b.getPos().distanceTo(position))) .findFirst() diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java index 5464dea5..f1675f0d 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ItemPhysics.java @@ -25,7 +25,7 @@ class ItemPhysics extends EntityPhysics { float above = 0.98f; if (entity.verticalCollision) { - above *= entity.world.getBlockState(entity.getBlockPos().up()).getBlock().getSlipperiness(); + above *= entity.getWorld().getBlockState(entity.getBlockPos().up()).getBlock().getSlipperiness(); //above /= 9; } @@ -36,8 +36,8 @@ class ItemPhysics extends EntityPhysics { @Override protected void onGravitychanged() { - if (!entity.world.isClient) { - float gravity = this.getBaseGravityModifier(); + if (!entity.getWorld().isClient) { + float gravity = getBaseGravityModifier(); setBaseGravityModifier(gravity == 0 ? 1 : gravity * 2); setBaseGravityModifier(gravity); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/Living.java b/src/main/java/com/minelittlepony/unicopia/entity/Living.java index 8650adb4..2bf7cbf2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/Living.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/Living.java @@ -170,7 +170,7 @@ public abstract class Living implements Equine, Caste tickers.forEach(Tickable::tick); try { - getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.world.isClient); + getSpellSlot().forEach(spell -> Operation.ofBoolean(spell.tick(this, Situation.BODY)), entity.getWorld().isClient); } catch (Exception e) { Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", entity, e); } @@ -223,12 +223,12 @@ public abstract class Living implements Equine, Caste } private void updateDragonBreath() { - if (!entity.world.isClient && (entity instanceof PlayerEntity || entity.hasCustomName())) { + if (!entity.getWorld().isClient && (entity instanceof PlayerEntity || entity.hasCustomName())) { Vec3d targetPos = entity.getRotationVector().multiply(2).add(entity.getEyePos()); if (entity.getWorld().isAir(BlockPos.ofFloored(targetPos))) { - DragonBreathStore store = DragonBreathStore.get(entity.world); + DragonBreathStore store = DragonBreathStore.get(entity.getWorld()); String name = entity.getDisplayName().getString(); store.popEntries(name).forEach(stack -> { Vec3d randomPos = targetPos.add(VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5))); @@ -238,16 +238,16 @@ public abstract class Living implements Equine, Caste } for (int i = 0; i < 10; i++) { - ParticleUtils.spawnParticle(entity.world, ParticleTypes.FLAME, randomPos.add( + ParticleUtils.spawnParticle(entity.getWorld(), ParticleTypes.FLAME, randomPos.add( VecHelper.supply(() -> entity.getRandom().nextTriangular(0.1, 0.5)) ), Vec3d.ZERO); } - ItemEntity item = EntityType.ITEM.create(entity.world); + ItemEntity item = EntityType.ITEM.create(entity.getWorld()); item.setStack(stack.payload()); item.setPosition(randomPos); - item.world.spawnEntity(item); - entity.world.playSoundFromEntity(null, entity, USounds.ITEM_DRAGON_BREATH_ARRIVE, entity.getSoundCategory(), 1, 1); + item.getWorld().spawnEntity(item); + entity.getWorld().playSoundFromEntity(null, entity, USounds.ITEM_DRAGON_BREATH_ARRIVE, entity.getSoundCategory(), 1, 1); if (stack.payload().getItem() == UItems.OATS && entity instanceof PlayerEntity player) { UCriteria.RECEIVE_OATS.trigger(player); @@ -395,7 +395,7 @@ public abstract class Living implements Equine, Caste } public static void transmitPassengers(@Nullable Entity entity) { - if (entity != null && entity.world instanceof ServerWorld sw) { + if (entity != null && entity.getWorld() instanceof ServerWorld sw) { sw.getChunkManager().sendToNearbyPlayers(entity, new EntityPassengersSetS2CPacket(entity)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java index 1de7dc8e..30357a43 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/PhysicsBodyProjectileEntity.java @@ -107,7 +107,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl @Override public void onPlayerCollision(PlayerEntity player) { - if (world.isClient || isNoClip() || shake > 0) { + if (getWorld().isClient || isNoClip() || shake > 0) { return; } @@ -132,26 +132,26 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl @Override protected void onBlockHit(BlockHitResult hit) { - BlockState state = world.getBlockState(hit.getBlockPos()); + BlockState state = getWorld().getBlockState(hit.getBlockPos()); BlockState posState = getBlockStateAtPos(); if (state.isIn(BlockTags.WOODEN_BUTTONS) && state.getBlock() instanceof ButtonBlock button) { - button.powerOn(state, world, hit.getBlockPos()); + button.powerOn(state, getWorld(), hit.getBlockPos()); } else if (posState.isIn(BlockTags.WOODEN_BUTTONS) && posState.getBlock() instanceof ButtonBlock button) { - button.powerOn(posState, world, getBlockPos()); + button.powerOn(posState, getWorld(), getBlockPos()); } if (state.getBlock() instanceof LeverBlock lever) { - lever.togglePower(state, world, hit.getBlockPos()); + lever.togglePower(state, getWorld(), hit.getBlockPos()); } else if (posState.getBlock() instanceof LeverBlock lever) { - lever.togglePower(posState, world, getBlockPos()); + lever.togglePower(posState, getWorld(), getBlockPos()); } BlockPos belowPos = getBlockPos().down(); - BlockState below = world.getBlockState(belowPos); + BlockState below = getWorld().getBlockState(belowPos); ItemStack stack = getStack(); if (below.getBlock() instanceof HopperBlock hopper) { - BlockEntity e = world.getBlockEntity(belowPos); + BlockEntity e = getWorld().getBlockEntity(belowPos); if (e instanceof Inventory inventory) { for (int i = 0; i < inventory.size(); i++) { ItemStack slotStack = inventory.getStack(i); @@ -171,18 +171,18 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } if (getVelocity().length() > 0.2F) { - boolean ownerCanModify = !world.isClient && Caster.of(getOwner()).filter(pony -> pony.canModifyAt(hit.getBlockPos())).isPresent(); + boolean ownerCanModify = !getWorld().isClient && Caster.of(getOwner()).filter(pony -> pony.canModifyAt(hit.getBlockPos())).isPresent(); - if (ownerCanModify && world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) { - if ((!isBouncy() || world.random.nextInt(200) == 0) && state.isIn(UTags.FRAGILE)) { - world.breakBlock(hit.getBlockPos(), true); + if (ownerCanModify && getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) { + if ((!isBouncy() || getWorld().random.nextInt(200) == 0) && state.isIn(UTags.FRAGILE)) { + getWorld().breakBlock(hit.getBlockPos(), true); } } if (isBouncy()) { Direction.Axis side = hit.getSide().getAxis(); - double randomisation = ((world.random.nextFloat() - 0.5F) / 5); + double randomisation = ((getWorld().random.nextFloat() - 0.5F) / 5); double inflectionAmount = randomisation + -0.4; double deflectionAmount = randomisation + 0.3; @@ -200,9 +200,9 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } addVelocity( - ((world.random.nextFloat() - 0.5F) / 5), - ((world.random.nextFloat() - 0.5F) / 5), - ((world.random.nextFloat() - 0.5F) / 5) + ((getWorld().random.nextFloat() - 0.5F) / 5), + ((getWorld().random.nextFloat() - 0.5F) / 5), + ((getWorld().random.nextFloat() - 0.5F) / 5) ); } else { super.onBlockHit(hit); @@ -212,7 +212,7 @@ public class PhysicsBodyProjectileEntity extends PersistentProjectileEntity impl } setSound(state.getSoundGroup().getStepSound()); - world.playSoundFromEntity(null, this, state.getSoundGroup().getStepSound(), SoundCategory.BLOCKS, 1, 1); + getWorld().playSoundFromEntity(null, this, state.getSoundGroup().getStepSound(), SoundCategory.BLOCKS, 1, 1); emitGameEvent(GameEvent.STEP); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java index dbe0b289..8b0b5452 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java @@ -58,7 +58,7 @@ public class SpellbookEntity extends MobEntity { if (player instanceof ServerPlayerEntity recipient && player.currentScreenHandler instanceof SpellbookScreenHandler book && getUuid().equals(book.entityId)) { - Channel.SERVER_SPELLBOOK_UPDATE.sendToPlayer(new MsgSpellbookStateChanged(book.syncId, state), recipient); + Channel.SERVER_SPELLBOOK_UPDATE.sendToPlayer(new MsgSpellbookStateChanged<>(book.syncId, state), recipient); } }); }); @@ -143,7 +143,7 @@ public class SpellbookEntity extends MobEntity { jumping = awake && isTouchingWater(); super.tick(); - if (world.isClient && isOpen()) { + if (getWorld().isClient && isOpen()) { for (int offX = -2; offX <= 1; ++offX) { for (int offZ = -2; offZ <= 1; ++offZ) { if (offX > -1 && offX < 1 && offZ == -1) { @@ -152,7 +152,7 @@ public class SpellbookEntity extends MobEntity { if (random.nextInt(320) == 0) { for (int offY = 0; offY <= 1; ++offY) { - world.addParticle(ParticleTypes.ENCHANT, + getWorld().addParticle(ParticleTypes.ENCHANT, getX(), getY(), getZ(), offX/2F + random.nextFloat(), offY/2F - random.nextFloat() + 0.5f, @@ -165,7 +165,7 @@ public class SpellbookEntity extends MobEntity { } if (awake) { - world.getOtherEntities(this, getBoundingBox().expand(2), EquinePredicates.PLAYER_UNICORN.and(e -> e instanceof PlayerEntity)).stream().findFirst().ifPresent(player -> { + getWorld().getOtherEntities(this, getBoundingBox().expand(2), EquinePredicates.PLAYER_UNICORN.and(e -> e instanceof PlayerEntity)).stream().findFirst().ifPresent(player -> { setBored(false); if (isOpen()) { Vec3d diff = player.getPos().subtract(getPos()); @@ -176,15 +176,15 @@ public class SpellbookEntity extends MobEntity { } }); - if (!world.isClient) { + if (!getWorld().isClient) { if (activeTicks > 0 && --activeTicks <= 0) { setBored(true); } } } - if (!world.isClient && world.random.nextInt(30) == 0) { - float celest = world.getSkyAngle(1) * 4; + if (!getWorld().isClient && getWorld().random.nextInt(30) == 0) { + float celest = getWorld().getSkyAngle(1) * 4; boolean daytime = celest > 3 || celest < 1; @@ -198,14 +198,14 @@ public class SpellbookEntity extends MobEntity { @Override public boolean damage(DamageSource source, float amount) { - if (!world.isClient) { + if (!getWorld().isClient) { remove(Entity.RemovalReason.KILLED); BlockSoundGroup sound = BlockSoundGroup.WOOD; - world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); + getWorld().playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); - if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { + if (getWorld().getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { dropStack(getPickBlockStack(), 1); } } @@ -232,7 +232,7 @@ public class SpellbookEntity extends MobEntity { @Override public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) { - return new SpellbookScreenHandler(syncId, inv, ScreenHandlerContext.create(world, getBlockPos()), state, getUuid()); + return new SpellbookScreenHandler(syncId, inv, ScreenHandlerContext.create(getWorld(), getBlockPos()), state, getUuid()); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java index 26721e32..612d0480 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/UTradeOffers.java @@ -87,7 +87,7 @@ public interface UTradeOffers { } private static Item random(Entity e, TagKey item, Random rng) { - return RegistryUtils.entriesForTag(e.world, item).getRandom(rng).get().value(); + return RegistryUtils.entriesForTag(e.getWorld(), item).getRandom(rng).get().value(); } static class JarredItemTradeOfferFactory implements TradeOffers.Factory { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java index 0103b766..d4f8133c 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/DynamicTargetGoal.java @@ -52,7 +52,7 @@ public class DynamicTargetGoal extends Goal { mob.setTarget(null); } - target = VecHelper.findInRange(mob, mob.world, mob.getPos(), 26, test) + target = VecHelper.findInRange(mob, mob.getWorld(), mob.getPos(), 26, test) .stream() .sorted(Comparator.comparing(e -> mob.distanceTo(e))) .findFirst(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java index 5f9880c0..255a4c68 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/EatMuffinGoal.java @@ -66,11 +66,11 @@ public class EatMuffinGoal extends BreakHeartGoal { eatingStarted = true; if (target instanceof PhysicsBodyProjectileEntity projectile) { - mob.eatFood(mob.world, projectile.getStack()); + mob.eatFood(mob.getWorld(), projectile.getStack()); projectile.discard(); if (mob instanceof AnimalEntity animal) { - if (mob.world.random.nextInt(12) == 0) { + if (mob.getWorld().random.nextInt(12) == 0) { Entity player = ((PhysicsBodyProjectileEntity) target).getOwner(); animal.lovePlayer(player instanceof PlayerEntity ? (PlayerEntity)player : null); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java index 2e92d5cb..3fdb9cf2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ai/WantItTakeItGoal.java @@ -62,11 +62,11 @@ public class WantItTakeItGoal extends BreakHeartGoal { mob.tryAttack(target); mob.swingHand(Hand.MAIN_HAND); - if (mob.world.random.nextInt(20) == 0) { + if (mob.getWorld().random.nextInt(20) == 0) { for (EquipmentSlot slot : EquipmentSlot.values()) { ItemStack stack = ((LivingEntity)target).getEquippedStack(slot); if (EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, stack) > 0) { - AwaitTickQueue.scheduleTask(mob.world, w -> { + AwaitTickQueue.scheduleTask(mob.getWorld(), w -> { target.equipStack(slot, ItemStack.EMPTY); mob.tryEquip(stack); }); @@ -76,7 +76,7 @@ public class WantItTakeItGoal extends BreakHeartGoal { } } } else if (target instanceof ItemEntity) { - AwaitTickQueue.scheduleTask(mob.world, w -> { + AwaitTickQueue.scheduleTask(mob.getWorld(), w -> { ItemEntity item = (ItemEntity)target; ItemStack stack = item.getStack(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java index 1252fd52..8cdc1901 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BeeBehaviour.java @@ -9,7 +9,7 @@ public class BeeBehaviour extends EntityBehaviour { @Override public BeeEntity onCreate(BeeEntity entity, EntityAppearance context, boolean replaceOld) { super.onCreate(entity, context, replaceOld); - if (replaceOld && entity.world.isClient) { + if (replaceOld && entity.getWorld().isClient) { InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_BEE, entity.getId()); } return entity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java index f7e81bef..7df21f65 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/BlazeBehaviour.java @@ -67,19 +67,19 @@ public class BlazeBehaviour extends EntityBehaviour { if (fireballsFired > 0) { if (!entity.isSilent()) { - entity.world.syncWorldEvent(null, WorldEvents.BLAZE_SHOOTS, entity.getBlockPos(), 0); + entity.getWorld().syncWorldEvent(null, WorldEvents.BLAZE_SHOOTS, entity.getBlockPos(), 0); } Vec3d rot = player.asEntity().getRotationVec(1); for (int i = 0; i < 1; ++i) { - SmallFireballEntity proj = new SmallFireballEntity(entity.world, player.asEntity(), + SmallFireballEntity proj = new SmallFireballEntity(entity.getWorld(), player.asEntity(), rot.getX() + entity.getRandom().nextGaussian(), rot.getY(), rot.getZ() + entity.getRandom().nextGaussian() ); proj.setPosition(proj.getX(), entity.getBodyY(0.5D) + 0.5D, proj.getZ()); - entity.world.spawnEntity(proj); + entity.getWorld().spawnEntity(proj); } } } else if (!firing) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java index f31f2904..45eb0668 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ChickenBehaviour.java @@ -36,7 +36,7 @@ public class ChickenBehaviour extends EntityBehaviour { player.asEntity().getInventory().removeStack(slot, 1); entity.playSound(SoundEvents.ENTITY_CHICKEN_EGG, 1, - (entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F + 4 + (entity.getWorld().random.nextFloat() - entity.getWorld().random.nextFloat()) * 0.2F + 4 ); entity.equipStack(EquipmentSlot.OFFHAND, egg); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java index 21fbbdcf..7024f9aa 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntityBehaviour.java @@ -110,7 +110,7 @@ public class EntityBehaviour { ((EntityDuck)to).setRemovalReason(from.getRemovalReason()); to.setOnGround(from.isOnGround()); - if (!from.world.isClient) { + if (!from.getWorld().isClient) { // player collision is not known on the server boolean clip = to.noClip; to.noClip = false; @@ -134,7 +134,7 @@ public class EntityBehaviour { BlockPos pos = BlockPos.ofFloored(x, y, z); - if (!from.world.isAir(pos) && !from.world.isWater(pos)) { + if (!from.getWorld().isAir(pos) && !from.getWorld().isWater(pos)) { y++; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java index bc411313..9ed861e7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/EntitySwap.java @@ -30,7 +30,7 @@ public interface EntitySwap { Swap YAW = Swap.of(Entity::getYaw, Entity::setYaw); Swap HEAD_YAW = Swap.of(Entity::getHeadYaw, (entity, headYaw) -> { entity.setHeadYaw(headYaw); - if (entity.world instanceof ServerWorld sw) { + if (entity.getWorld() instanceof ServerWorld sw) { sw.getChunkManager().sendToNearbyPlayers(entity, new EntitySetHeadYawS2CPacket(entity, (byte)MathHelper.floor(entity.getHeadYaw() * 256F / 360F))); } }); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java index e70103b9..bc3fafd2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/FallingBlockBehaviour.java @@ -48,7 +48,7 @@ public class FallingBlockBehaviour extends EntityBehaviour { BlockState state = entity.getBlockState(); if (state.getBlock() instanceof FallingBlock fb) { - fb.onLanding(entity.world, entity.getBlockPos(), state, state, entity); + fb.onLanding(entity.getWorld(), entity.getBlockPos(), state, state, entity); } } } @@ -73,9 +73,9 @@ public class FallingBlockBehaviour extends EntityBehaviour { BlockState lowerState = state.with(DoorBlock.HALF, DoubleBlockHalf.LOWER); BlockState upperState = state.with(DoorBlock.HALF, DoubleBlockHalf.UPPER); - context.attachExtraEntity(configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), upperState), block)); + context.attachExtraEntity(configure(MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY(), entity.getZ(), upperState), block)); - return configure(MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block); + return configure(MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY() + 1, entity.getZ(), lowerState), block); } if (block instanceof BlockEntityProvider bep) { @@ -90,10 +90,10 @@ public class FallingBlockBehaviour extends EntityBehaviour { BlockState state = entity.getBlockState(); if (state.contains(Properties.WATERLOGGED)) { - boolean logged = entity.world.isWater(entity.getBlockPos()); + boolean logged = entity.getWorld().isWater(entity.getBlockPos()); if (state.get(Properties.WATERLOGGED) != logged) { - entity = MixinFallingBlockEntity.createInstance(entity.world, entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged)); + entity = MixinFallingBlockEntity.createInstance(entity.getWorld(), entity.getX(), entity.getY(), entity.getZ(), state.with(Properties.WATERLOGGED, logged)); spell.getDisguise().setAppearance(entity); return; } @@ -112,7 +112,7 @@ public class FallingBlockBehaviour extends EntityBehaviour { be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0); } - be.setWorld(entity.world); + be.setWorld(entity.getWorld()); ((Positioned)be).setPos(entity.getBlockPos()); ceb.tick(); be.setWorld(null); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java index 352852aa..86572441 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/GhastBehaviour.java @@ -19,16 +19,16 @@ public class GhastBehaviour extends MobBehaviour { if (sneaking) { if (!entity.isSilent()) { - entity.world.syncWorldEvent(null, WorldEvents.GHAST_WARNS, entity.getBlockPos(), 0); + entity.getWorld().syncWorldEvent(null, WorldEvents.GHAST_WARNS, entity.getBlockPos(), 0); } } else { if (!entity.isSilent()) { - entity.world.syncWorldEvent(null, WorldEvents.GHAST_SHOOTS, entity.getBlockPos(), 0); + entity.getWorld().syncWorldEvent(null, WorldEvents.GHAST_SHOOTS, entity.getBlockPos(), 0); } Vec3d rot = player.asEntity().getRotationVec(1); - FireballEntity proj = new FireballEntity(entity.world, player.asEntity(), + FireballEntity proj = new FireballEntity(entity.getWorld(), player.asEntity(), rot.getX(), rot.getY(), rot.getZ(), @@ -40,7 +40,7 @@ public class GhastBehaviour extends MobBehaviour { proj.getZ() + rot.z * 4 ); - entity.world.spawnEntity(proj); + entity.getWorld().spawnEntity(proj); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java index 9a1366e0..52c846ff 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MinecartBehaviour.java @@ -11,7 +11,7 @@ public class MinecartBehaviour extends EntityBehaviour { @Override public AbstractMinecartEntity onCreate(AbstractMinecartEntity entity, EntityAppearance context, boolean replaceOld) { super.onCreate(entity, context, replaceOld); - if (replaceOld && entity.world.isClient) { + if (replaceOld && entity.getWorld().isClient) { InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_MINECART, entity.getId()); } return entity; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java index bdf69f65..a56ae3d9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/MobBehaviour.java @@ -34,7 +34,7 @@ public class MobBehaviour extends EntityBehaviour { @SuppressWarnings("unchecked") protected T getDummy(T entity) { if (dummy == null) { - dummy = (T)entity.getType().create(entity.world); + dummy = (T)entity.getType().create(entity.getWorld()); } return dummy; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java index 86d780d7..d4dbf2e2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/RangedAttackBehaviour.java @@ -28,7 +28,7 @@ public class RangedAttackBehaviour extends E if (player.sneakingChanged() && isSneakingOnGround(player)) { - ProjectileEntity spit = projectileSupplier.apply(entity.world, entity); + ProjectileEntity spit = projectileSupplier.apply(entity.getWorld(), entity); Vec3d rot = player.asEntity().getRotationVec(1); @@ -36,10 +36,10 @@ public class RangedAttackBehaviour extends E spit.setOwner(player.asEntity()); if (!entity.isSilent()) { - SoundEmitter.playSoundAt(entity, sound, 1, 1 + (entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F); + SoundEmitter.playSoundAt(entity, sound, 1, 1 + (entity.getWorld().random.nextFloat() - entity.getWorld().random.nextFloat()) * 0.2F); } - entity.world.spawnEntity(spit); + entity.getWorld().spawnEntity(spit); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java index aa027cd7..31715fe0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SheepBehaviour.java @@ -22,17 +22,17 @@ public class SheepBehaviour extends EntityBehaviour { if (player.sneakingChanged()) { BlockPos pos = entity.getBlockPos().down(); - BlockState state = entity.world.getBlockState(pos); + BlockState state = entity.getWorld().getBlockState(pos); boolean grass = state.isOf(Blocks.GRASS_BLOCK); if (player.asEntity().isSneaking()) { - if (grass && entity.world.isClient && entity.isSheared()) { + if (grass && entity.getWorld().isClient && entity.isSheared()) { entity.handleStatus((byte)10); } } else { if (entity.isSheared() && grass) { - entity.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); - entity.world.setBlockState(pos, Blocks.DIRT.getDefaultState(), 2); + entity.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); + entity.getWorld().setBlockState(pos, Blocks.DIRT.getDefaultState(), 2); entity.onEatingGrass(); } else if (!entity.isSheared()) { @@ -41,7 +41,7 @@ public class SheepBehaviour extends EntityBehaviour { player.asEntity().playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1, 1); entity.setSheared(true); - Random rng = entity.world.random; + Random rng = entity.getWorld().random; PlayerInventory inv = player.asEntity().getInventory(); int dropAmount = rng.nextInt(3); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java index 47c76ea1..7e298723 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/ShulkerBehaviour.java @@ -24,7 +24,7 @@ public class ShulkerBehaviour extends EntityBehaviour { Direction attachmentFace = shulker.getAttachedFace(); BlockPos pos = shulker.getBlockPos().offset(attachmentFace); - boolean noGravity = !shulker.isOnGround() && !shulker.world.isAir(pos) + boolean noGravity = !shulker.isOnGround() && !shulker.getWorld().isAir(pos) && (attachmentFace == Direction.UP || attachmentFace.getAxis() != Axis.Y); source.asEntity().setNoGravity(noGravity); @@ -54,7 +54,7 @@ public class ShulkerBehaviour extends EntityBehaviour { if (player.sneakingChanged()) { mx.callSetPeekAmount((int)(peekAmount / 0.01F)); } else if (peekAmount > 0.2 && mx.callGetPeekAmount() == 0) { - if (shulker.isAlive() && shulker.world.random.nextInt(1000) < shulker.ambientSoundChance++) { + if (shulker.isAlive() && shulker.getWorld().random.nextInt(1000) < shulker.ambientSoundChance++) { shulker.ambientSoundChance = -shulker.getMinAmbientSoundDelay(); shulker.playSound(SoundEvents.ENTITY_SHULKER_AMBIENT, 1, 1); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java index 14709927..b6ee8542 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SilverfishBehaviour.java @@ -14,10 +14,10 @@ public class SilverfishBehaviour extends EntityBehaviour { public void update(Pony player, SilverfishEntity entity, Disguise spell) { if (!player.isClient() && player.sneakingChanged() && player.asEntity().isSneaking()) { BlockPos pos = entity.getBlockPos().down(); - BlockState state = entity.world.getBlockState(pos); + BlockState state = entity.getWorld().getBlockState(pos); - if (StateMaps.SILVERFISH_AFFECTED.convert(entity.world, pos)) { - entity.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); + if (StateMaps.SILVERFISH_AFFECTED.convert(entity.getWorld(), pos)) { + entity.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, pos, Block.getRawIdFromState(state)); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java index f7720aae..ba89c936 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/behaviour/SpellcastingIllagerBehaviour.java @@ -18,7 +18,7 @@ public class SpellcastingIllagerBehaviour extends EntityBehaviour { if (pony.sneakingChanged() && pony.asEntity().isSneaking()) { entity.setHeadRollingTimeLeft(40); - if (!entity.world.isClient()) { + if (!entity.getWorld().isClient()) { entity.playSound(SoundEvents.ENTITY_VILLAGER_NO, 1, 1); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java b/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java index cd5c4f0a..9bad7931 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/collision/EntityCollisions.java @@ -34,7 +34,7 @@ public class EntityCollisions { } else if (entity instanceof FallingBlockEntity) { BlockPos pos = entity.getBlockPos(); output.accept(((FallingBlockEntity) entity).getBlockState() - .getCollisionShape(entity.world, entity.getBlockPos(), context) + .getCollisionShape(entity.getWorld(), entity.getBlockPos(), context) .offset(pos.getX(), pos.getY(), pos.getZ()) ); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java index 3c415da4..9231dfc6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/ButterfingersStatusEffect.java @@ -25,21 +25,21 @@ public class ButterfingersStatusEffect extends StatusEffect { amplifier = MathHelper.clamp(amplifier, 0, 5); final int scale = 500 + (int)(((5 - amplifier) / 5F) * 900); - if (entity.world.random.nextInt(scale / 4) == 0) { - applyInstantEffect(null, null, entity, amplifier, entity.world.random.nextInt(scale)); + if (entity.getWorld().random.nextInt(scale / 4) == 0) { + applyInstantEffect(null, null, entity, amplifier, entity.getWorld().random.nextInt(scale)); } } @Override public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) { - if (target.world.isClient) { + if (target.getWorld().isClient) { return; } if (target instanceof ServerPlayerEntity player) { if (player.dropSelectedItem(proximity < 1)) { - player.world.playSound(null, player.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, player.getSoundCategory()); + player.getWorld().playSound(null, player.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, player.getSoundCategory()); PlayerInventory inventory = player.getInventory(); player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(-2, 0, inventory.selectedSlot, inventory.getStack(inventory.selectedSlot))); } @@ -48,7 +48,7 @@ public class ButterfingersStatusEffect extends StatusEffect { if (!stack.isEmpty()) { target.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY); target.dropStack(stack); - target.world.playSound(null, target.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, target.getSoundCategory()); + target.getWorld().playSound(null, target.getBlockPos(), SoundEvents.BLOCK_HONEY_BLOCK_SLIDE, target.getSoundCategory()); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java index 908f2303..ebdd1a41 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/CorruptInfluenceStatusEffect.java @@ -28,35 +28,29 @@ public class CorruptInfluenceStatusEffect extends StatusEffect { @Override public void applyUpdateEffect(LivingEntity entity, int amplifier) { - if (entity.world.isClient) { + if (entity.getWorld().isClient) { return; } if (entity instanceof HostileEntity) { - int nearby = 0; - - for (Entity i : entity.world.getOtherEntities(entity, entity.getBoundingBox().expand(40))) { - if (i.getType() == entity.getType()) { - nearby++; - } - } + int nearby = entity.getWorld().getOtherEntities(entity, entity.getBoundingBox().expand(40), i -> i.getType() == entity.getType()).size(); if (nearby > 1) { if (Equine.of(entity).filter(eq -> eq instanceof Owned o && o.getMaster() != null).isPresent()) { return; } - if (entity.world.random.nextInt(2000) != 0) { + if (entity.getWorld().random.nextInt(2000) != 0) { return; } - } else if (entity.world.random.nextInt(200) != 0) { + } else if (entity.getWorld().random.nextInt(200) != 0) { return; } HostileEntity mob = (HostileEntity)entity; - HostileEntity clone = (HostileEntity)mob.getType().create(mob.world); + HostileEntity clone = (HostileEntity)mob.getType().create(mob.getWorld()); clone.copyPositionAndRotation(entity); Equine.of(clone).ifPresent(eq -> { @@ -64,10 +58,10 @@ public class CorruptInfluenceStatusEffect extends StatusEffect { ((Owned.Mutable)eq).setMaster(mob); } }); - mob.world.spawnEntity(clone); + mob.getWorld().spawnEntity(clone); if (!mob.isSilent()) { - mob.world.syncWorldEvent((PlayerEntity)null, WorldEvents.ZOMBIE_INFECTS_VILLAGER, mob.getBlockPos(), 0); + mob.getWorld().syncWorldEvent((PlayerEntity)null, WorldEvents.ZOMBIE_INFECTS_VILLAGER, mob.getBlockPos(), 0); } } else if (entity.age % 2000 == 0) { entity.damage(Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java index 7db09496..0ed77c13 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/effect/SunBlindnessStatusEffect.java @@ -80,7 +80,7 @@ public class SunBlindnessStatusEffect extends StatusEffect { return false; } - return isPositionExposedToSun(entity.world, entity.getBlockPos()); + return isPositionExposedToSun(entity.getWorld(), entity.getBlockPos()); } public static boolean isPositionExposedToSun(World world, BlockPos pos) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java b/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java index f74e587d..7ee274d7 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/MeteorlogicalUtil.java @@ -20,7 +20,7 @@ public interface MeteorlogicalUtil { } // we translate sun angle to a scale of 0-1 (0=sunrise, 1=sunset, >1 nighttime) - final float skyAngle = ((entity.world.getSkyAngle(1) + 0.25F) % 1F) * 2; + final float skyAngle = ((entity.getWorld().getSkyAngle(1) + 0.25F) % 1F) * 2; float playerYaw = MathHelper.wrapDegrees(entity.getHeadYaw()); float playerAngle = (-entity.getPitch(1) / 90F) / 2F; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 7963f14b..f6fa64e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -216,7 +216,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (typeChanged) { pony.spawnParticles(ParticleTypes.CLOUD, 10); - entity.playSound(entity.world.getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); + entity.playSound(entity.getWorld().getDimension().ultrawarm() ? USounds.ITEM_ICARUS_WINGS_CORRUPT : USounds.ITEM_ICARUS_WINGS_PURIFY, 0.1125F, 1.5F); } entity.getAbilities().allowFlying = type.canFlyCreative(entity); @@ -285,7 +285,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab ticksToGlide = MAX_TICKS_TO_GLIDE; if (!SpellPredicate.IS_DISGUISE.isOn(pony)) { entity.playSound(type.getWingFlapSound(), 0.25F, 1); - entity.world.emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); + entity.getWorld().emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); } } else { strafe *= 0.28; @@ -345,7 +345,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab if (type.isAvian()) { applyThrust(velocity); - if (pony.getObservedSpecies() != Race.BAT && entity.world.random.nextInt(9000) == 0) { + if (pony.getObservedSpecies() != Race.BAT && entity.getWorld().random.nextInt(9000) == 0) { entity.dropItem(UItems.PEGASUS_FEATHER); entity.playSound(USounds.ENTITY_PLAYER_PEGASUS_MOLT, 0.3F, 1); UCriteria.SHED_FEATHER.trigger(entity); @@ -355,7 +355,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab moveFlying(velocity); if (type.isAvian()) { - if (entity.world.isClient && ticksInAir % IDLE_FLAP_INTERVAL == 0 && entity.getVelocity().length() < 0.29) { + if (entity.getWorld().isClient && ticksInAir % IDLE_FLAP_INTERVAL == 0 && entity.getVelocity().length() < 0.29) { flapping = true; ticksToGlide = MAX_TICKS_TO_GLIDE; } @@ -370,7 +370,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab velocity.x *= 0.9896; velocity.z *= 0.9896; } else if (type == FlightType.INSECTOID && !SpellPredicate.IS_DISGUISE.isOn(pony)) { - if (entity.world.isClient && !soundPlaying) { + if (entity.getWorld().isClient && !soundPlaying) { soundPlaying = true; InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_CHANGELING_BUZZ, entity.getId()); } @@ -378,17 +378,17 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } private void tickArtificialFlight(MutableVector velocity) { - if (ticksInAir % 10 == 0 && !entity.world.isClient) { + if (ticksInAir % 10 == 0 && !entity.getWorld().isClient) { ItemStack stack = AmuletItem.getForEntity(entity); int damageInterval = 20; int minDamage = 1; float energyConsumed = 2 + (float)getHorizontalMotion() / 10F; - if (entity.world.hasRain(entity.getBlockPos())) { + if (entity.getWorld().hasRain(entity.getBlockPos())) { energyConsumed *= 3; } - if (entity.world.getDimension().ultrawarm()) { + if (entity.getWorld().getDimension().ultrawarm()) { energyConsumed *= 4; damageInterval /= 2; minDamage *= 3; @@ -400,8 +400,8 @@ public class PlayerPhysics extends EntityPhysics implements Tickab entity.playSound(USounds.ITEM_ICARUS_WINGS_WARN, 0.13F, 0.5F); } - if (entity.world.random.nextInt(damageInterval) == 0) { - stack.damage(minDamage + entity.world.random.nextInt(50), entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); + if (entity.getWorld().random.nextInt(damageInterval) == 0) { + stack.damage(minDamage + entity.getWorld().random.nextInt(50), entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); } if (!getFlightType().canFly()) { @@ -484,9 +484,9 @@ public class PlayerPhysics extends EntityPhysics implements Tickab BlockPos pos = BlockPos.ofFloored(entity.getCameraPosVec(1).add(entity.getRotationVec(1).normalize().multiply(2))); - BlockState state = entity.world.getBlockState(pos); + BlockState state = entity.getWorld().getBlockState(pos); - if (!entity.world.isAir(pos) && Block.isFaceFullSquare(state.getCollisionShape(entity.world, pos), entity.getHorizontalFacing().getOpposite())) { + if (!entity.getWorld().isAir(pos) && Block.isFaceFullSquare(state.getCollisionShape(entity.getWorld(), pos), entity.getHorizontalFacing().getOpposite())) { double motion = Math.sqrt(getHorizontalMotion()); float distance = (float)(motion * 20 - 3); @@ -524,10 +524,10 @@ public class PlayerPhysics extends EntityPhysics implements Tickab velocity.z += forward * MathHelper.cos(entity.getYaw() * 0.017453292F); - if (entity.world.hasRain(entity.getBlockPos())) { + if (entity.getWorld().hasRain(entity.getBlockPos())) { applyTurbulance(velocity); } else { - descentRate -= WeatherConditions.getUpdraft(new BlockPos.Mutable().set(entity.getBlockPos()), entity.world) / 3F; + descentRate -= WeatherConditions.getUpdraft(new BlockPos.Mutable().set(entity.getBlockPos()), entity.getWorld()) / 3F; } descentRate += 0.001F; @@ -553,7 +553,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab flapping = false; if (!SpellPredicate.IS_DISGUISE.isOn(pony)) { entity.playSound(getFlightType().getWingFlapSound(), 0.5F, 1); - entity.world.emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); + entity.getWorld().emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos()); } thrustScale = 1; if (manualFlap) { @@ -587,7 +587,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab private void applyTurbulance(MutableVector velocity) { int globalEffectStrength = MathHelper.clamp(entity.getWorld().getGameRules().getInt(UGameRules.WEATHER_EFFECTS_STRENGTH), 0, 100); float effectStrength = Math.min(1, (float)ticksInAir / MAX_TICKS_TO_WEATHER_EFFECTS) * (globalEffectStrength / 100F); - Vec3d gust = WeatherConditions.getGustStrength(entity.world, entity.getBlockPos()).multiply(globalEffectStrength / 100D); + Vec3d gust = WeatherConditions.getGustStrength(entity.getWorld(), entity.getBlockPos()).multiply(globalEffectStrength / 100D); if (effectStrength * gust.getX() >= 1) { SoundEmitter.playSoundAt(entity, USounds.AMBIENT_WIND_GUST, SoundCategory.AMBIENT, 3, 1); @@ -595,7 +595,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab float weight = 1 + (EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.8F) + (pony.getActualSpecies().canUseEarth() ? 1 : 0); - velocity.add(WeatherConditions.getAirflow(entity.getBlockPos(), entity.world), 0.04F * effectStrength); + velocity.add(WeatherConditions.getAirflow(entity.getBlockPos(), entity.getWorld()), 0.04F * effectStrength); velocity.add(Vec3d.fromPolar( (entity.getPitch() + (float)gust.getY()) * MathHelper.RADIANS_PER_DEGREE, (entity.getYaw() + (float)gust.getZ()) * MathHelper.RADIANS_PER_DEGREE @@ -603,11 +603,11 @@ public class PlayerPhysics extends EntityPhysics implements Tickab effectStrength * (float)gust.getX() / weight ); - if (!entity.world.isClient && effectStrength > 0.9F && entity.world.isThundering() && entity.world.random.nextInt(9000) == 0) { - LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world); + if (!entity.getWorld().isClient && effectStrength > 0.9F && entity.getWorld().isThundering() && entity.getWorld().random.nextInt(9000) == 0) { + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld()); lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ()); - entity.world.spawnEntity(lightning); + entity.getWorld().spawnEntity(lightning); UCriteria.LIGHTNING_STRUCK.trigger(entity); } } @@ -633,19 +633,19 @@ public class PlayerPhysics extends EntityPhysics implements Tickab boolean isEarthPonySmash = pony.getObservedSpecies().canUseEarth() && !isFlying(); int damage = TraceHelper.findBlocks(entity, speed + 4, 1, state -> (isEarthPonySmash && !state.isAir()) || state.isIn(UTags.GLASS_PANES)).stream() .flatMap(pos -> BlockPos.streamOutwards(pos, 2, 2, 2)) - .filter(pos -> (isEarthPonySmash && !entity.world.isAir(pos)) || entity.world.getBlockState(pos).isIn(UTags.GLASS_PANES)) + .filter(pos -> (isEarthPonySmash && !entity.getWorld().isAir(pos)) || entity.getWorld().getBlockState(pos).isIn(UTags.GLASS_PANES)) .reduce(0, (u, pos) -> { if (pony.canModifyAt(pos, ModificationType.PHYSICAL)) { if (isEarthPonySmash) { - BlockDestructionManager.of(entity.world).damageBlock(pos, (int)entity.world.getRandom().nextTriangular(5, 3)); - if (BlockDestructionManager.of(entity.world).getBlockDestruction(pos) >= 9) { - entity.world.breakBlock(pos, true); + BlockDestructionManager.of(entity.getWorld()).damageBlock(pos, (int)entity.getWorld().getRandom().nextTriangular(5, 3)); + if (BlockDestructionManager.of(entity.getWorld()).getBlockDestruction(pos) >= 9) { + entity.getWorld().breakBlock(pos, true); } } else { - entity.world.breakBlock(pos, true); + entity.getWorld().breakBlock(pos, true); } } else { - ParticleUtils.spawnParticles(new MagicParticleEffect(0x00AAFF), entity.world, Vec3d.ofCenter(pos), 15); + ParticleUtils.spawnParticles(new MagicParticleEffect(0x00AAFF), entity.getWorld(), Vec3d.ofCenter(pos), 15); } return 1; }, Integer::sum); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index ff70e8e0..23e9eb8b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -299,7 +299,7 @@ public class Pony extends Living implements Copyable, Update } public void onSpawn() { - if (entity.world instanceof ServerWorld sw + if (entity.getWorld() instanceof ServerWorld sw && getObservedSpecies() == Race.BAT && sw.getServer().getSaveProperties().getGameMode() != GameMode.ADVENTURE && SunBlindnessStatusEffect.isPositionExposedToSun(sw, getOrigin())) { @@ -434,13 +434,13 @@ public class Pony extends Living implements Copyable, Update private void updateCorruptionDecay() { if (!isClient() && !UItems.ALICORN_AMULET.isApplicable(entity)) { if (entity.age % (10 * ItemTracker.SECONDS) == 0) { - if (entity.world.random.nextInt(100) == 0) { + if (entity.getWorld().random.nextInt(100) == 0) { corruption.add(-1); setDirty(); } if (entity.getHealth() >= entity.getMaxHealth() - 1 && !entity.getHungerManager().isNotFull()) { - corruption.add(-entity.world.random.nextInt(4)); + corruption.add(-entity.getWorld().random.nextInt(4)); setDirty(); } } @@ -608,7 +608,7 @@ public class Pony extends Living implements Copyable, Update } protected void directTakeEnergy(double foodSubtract) { - if (!entity.isCreative() && !entity.world.isClient) { + if (!entity.isCreative() && !entity.getWorld().isClient) { magicExhaustion += ManaConsumptionUtil.consumeMana(mana.getMana(), foodSubtract); } } @@ -707,7 +707,7 @@ public class Pony extends Living implements Copyable, Update boolean forcedSwap = (!alive && entity instanceof ServerPlayerEntity - && entity.world.getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH) + && entity.getWorld().getGameRules().getBoolean(UGameRules.SWAP_TRIBE_ON_DEATH) && oldPlayer.respawnRace.isUnset()) || oldPlayer.getActualSpecies().isUnset(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java index 58b6febf..1afa15e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java @@ -75,7 +75,7 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public ParticleEffect getParticleEffect(IItemEntity entity) { - return ((ItemEntity)entity).world.random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME; + return ((ItemEntity)entity).getWorld().random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME; } @Override @@ -102,14 +102,14 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab public void interactWithPlayer(IItemEntity item, PlayerEntity player) { ItemEntity entity = (ItemEntity)item; - if (!player.world.isClient && !entity.isRemoved() && !player.isCreative()) { + if (!player.getWorld().isClient && !entity.isRemoved() && !player.isCreative()) { if (player.getPos().distanceTo(entity.getPos()) < 0.5) { - if (entity.world.random.nextInt(150) == 0) { + if (entity.getWorld().random.nextInt(150) == 0) { entity.setPickupDelay(0); entity.onPlayerCollision(player); if (player.getMainHandStack().getItem() == this) { - TypedActionResult result = use(player.world, player, Hand.MAIN_HAND); + TypedActionResult result = use(player.getWorld(), player, Hand.MAIN_HAND); if (result.getResult() == ActionResult.SUCCESS) { entity.setPickupDelay(1000); @@ -286,8 +286,8 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab public ActionResult onGroundTick(IItemEntity item) { ItemEntity entity = (ItemEntity)item; - if (entity.world.random.nextInt(500) == 0) { - entity.world.playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); + if (entity.getWorld().random.nextInt(500) == 0) { + entity.getWorld().playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); } return ActionResult.PASS; @@ -295,12 +295,12 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public void inFrameTick(ItemFrameEntity entity) { - Random rng = entity.world.random; + Random rng = entity.getWorld().random; if (rng.nextInt(1500) == 0) { - entity.world.playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); + entity.getWorld().playSound(null, entity.getBlockPos(), USounds.ITEM_ALICORN_AMULET_AMBIENT, SoundCategory.HOSTILE, 0.5F, 1); for (int i = 0; i < 5; i++) { - entity.world.addParticle(rng.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME, + entity.getWorld().addParticle(rng.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME, rng.nextTriangular(entity.getX(), 0.5), rng.nextTriangular(entity.getY(), 0.5), rng.nextTriangular(entity.getZ(), 0.5), @@ -310,13 +310,13 @@ public class AlicornAmuletItem extends AmuletItem implements ItemTracker.Trackab } if ((entity.age / 1000) % 10 == 0 && entity.age % 50 == 0) { - for (Entity target : VecHelper.findInRange(entity, entity.world, entity.getPos(), 10, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) { + for (Entity target : VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), 10, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR)) { for (ItemStack equipment : target.getItemsEquipped()) { if (equipment.getItem() == UItems.GROGARS_BELL) { ChargeableItem chargeable = (ChargeableItem)UItems.GROGARS_BELL; if (chargeable.hasCharge(equipment)) { ChargeableItem.consumeEnergy(equipment, 3); - ParticleUtils.spawnParticle(entity.world, + ParticleUtils.spawnParticle(entity.getWorld(), new FollowingParticleEffect(UParticles.HEALTH_DRAIN, entity, 0.4F) .withChild(ParticleTypes.COMPOSTER), target.getEyePos(), Vec3d.ZERO); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java index 5c00d94c..e49b3eed 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java @@ -25,32 +25,32 @@ public class AppleItem { private static ActionResult onGroundTick(IItemEntity item) { ItemEntity entity = item.get().asEntity(); - if (!entity.isRemoved() && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) { + if (!entity.isRemoved() && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.getWorld().random.nextInt(150) < 10) { - if (!entity.world.isClient) { + if (!entity.getWorld().isClient) { entity.remove(RemovalReason.KILLED); - ItemEntity neu = EntityType.ITEM.create(entity.world); + ItemEntity neu = EntityType.ITEM.create(entity.getWorld()); neu.copyPositionAndRotation(entity); neu.setStack(new ItemStack(UItems.ROTTEN_APPLE)); - entity.world.spawnEntity(neu); + entity.getWorld().spawnEntity(neu); - ItemEntity copy = EntityType.ITEM.create(entity.world); + ItemEntity copy = EntityType.ITEM.create(entity.getWorld()); copy.copyPositionAndRotation(entity); copy.setStack(entity.getStack()); copy.getStack().decrement(1); - entity.world.spawnEntity(copy); + entity.getWorld().spawnEntity(copy); } float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.uniqueOffset) * 0.1F + 0.1F; for (int i = 0; i < 3; i++) { - entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), - entity.world.random.nextGaussian() - 0.5F, - entity.world.random.nextGaussian() - 0.5F, - entity.world.random.nextGaussian() - 0.5F); + entity.getWorld().addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(), + entity.getWorld().random.nextGaussian() - 0.5F, + entity.getWorld().random.nextGaussian() - 0.5F, + entity.getWorld().random.nextGaussian() - 0.5F); } entity.playSound(USounds.ITEM_APPLE_ROT, 0.5F, 1.5F); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java b/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java index b3ed6200..314df0ae 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/CrystalHeartItem.java @@ -106,18 +106,18 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art entity.addSpin(2, 10); BlockPos pos = entity.getBlockPos(); - entity.world.addParticle(ParticleTypes.COMPOSTER, - pos.getX() + entity.world.getRandom().nextFloat(), - pos.getY() + entity.world.getRandom().nextFloat(), - pos.getZ() + entity.world.getRandom().nextFloat(), + entity.getWorld().addParticle(ParticleTypes.COMPOSTER, + pos.getX() + entity.getWorld().getRandom().nextFloat(), + pos.getY() + entity.getWorld().getRandom().nextFloat(), + pos.getZ() + entity.getWorld().getRandom().nextFloat(), 0, 0, 0); - if (entity.world.getTime() % 80 == 0 && !entity.world.isClient) { + if (entity.getWorld().getTime() % 80 == 0 && !entity.getWorld().isClient) { List inputs = new ArrayList<>(); List outputs = new ArrayList<>(); List containers = new ArrayList<>(); - VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, TARGET_PREDICATE).forEach(e -> { + VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), 20, TARGET_PREDICATE).forEach(e -> { LivingEntity living = (LivingEntity)e; if (e instanceof PlayerEntity @@ -130,7 +130,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art inputs.add(living); } }); - VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, i -> { + VecHelper.findInRange(entity, entity.getWorld(), entity.getPos(), 20, i -> { return i instanceof ItemEntity ie && isFillable(ie.getStack()) && Equine.of(i).filter(p -> p.getSpecies() == Race.CHANGELING).isPresent(); }).forEach(i -> containers.add((ItemEntity)i)); @@ -177,7 +177,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art @Override public ActionResult onArtifactDestroyed(FloatingArtefactEntity entity) { entity.playSound(USounds.ENTITY_CRYSTAL_HEART_DEACTIVATE, 0.75F, 1); - entity.dropStack(new ItemStack(UItems.CRYSTAL_SHARD, 1 + entity.world.random.nextInt(5)), 0); + entity.dropStack(new ItemStack(UItems.CRYSTAL_SHARD, 1 + entity.getWorld().random.nextInt(5)), 0); return ActionResult.SUCCESS; } @@ -188,13 +188,13 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art private boolean findPyramid(FloatingArtefactEntity entity, Direction direction) { BlockPos tip = entity.getBlockPos().offset(direction); - BlockState tipState = entity.world.getBlockState(tip); + BlockState tipState = entity.getWorld().getBlockState(tip); if (!tipState.isIn(UTags.CRYSTAL_HEART_ORNAMENT) || (!tipState.contains(EndRodBlock.FACING)|| tipState.get(EndRodBlock.FACING) != direction.getOpposite())) { return false; } tip = tip.offset(direction); - if (!isDiamond(entity.world.getBlockState(tip))) { + if (!isDiamond(entity.getWorld().getBlockState(tip))) { return false; } tip = tip.offset(direction); @@ -203,7 +203,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art return BlockPos.streamOutwards(center, 1, 0, 1) .filter(p -> p.getX() == center.getX() || p.getZ() == center.getZ()) - .map(entity.world::getBlockState) + .map(entity.getWorld()::getBlockState) .allMatch(this::isDiamond); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java b/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java index 6ac2b43b..39d8598d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/EnchantableItem.java @@ -45,7 +45,7 @@ public interface EnchantableItem extends ItemConvertible { return TypedActionResult.fail(SpellType.EMPTY_KEY.withTraits()); } - if (!player.world.isClient && consume) { + if (!player.getWorld().isClient && consume) { player.swingHand(player.getStackInHand(Hand.OFF_HAND) == stack ? Hand.OFF_HAND : Hand.MAIN_HAND); player.getItemCooldownManager().set(stack.getItem(), 20); diff --git a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java index b2aeef6d..6a5b9c08 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/FilledJarItem.java @@ -106,8 +106,8 @@ public class FilledJarItem extends JarItem implements ChameleonItem { float healthDiff = prevHealth - ((LivingEntity)entity).getHealth(); - if (projectile.world instanceof ServerWorld && healthDiff > 2) { - ((ServerWorld)projectile.world).spawnParticles(ParticleTypes.DAMAGE_INDICATOR, entity.getX(), entity.getBodyY(0.5D), entity.getZ(), (int)(healthDiff / 2F), 0.1, 0, 0.1, 0.2); + if (projectile.getWorld() instanceof ServerWorld && healthDiff > 2) { + ((ServerWorld)projectile.getWorld()).spawnParticles(ParticleTypes.DAMAGE_INDICATOR, entity.getX(), entity.getBodyY(0.5D), entity.getZ(), (int)(healthDiff / 2F), 0.1, 0, 0.1, 0.2); } } else { entity.addVelocity( @@ -125,9 +125,9 @@ public class FilledJarItem extends JarItem implements ChameleonItem { @Override public void onImpact(MagicProjectileEntity projectile) { ItemStack stack = getAppearanceStack(projectile.getStack()); - stack.damage(1, projectile.world.random, null); + stack.damage(1, projectile.getWorld().random, null); projectile.dropStack(stack); - projectile.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); + projectile.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); } public ItemStack withContents(ItemStack contents) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java b/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java index 5ff0cde5..663dd8a5 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/item/GlowingRecipe.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.item; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.recipe.RecipeSerializer; @@ -16,7 +16,7 @@ public class GlowingRecipe extends ItemCombinationRecipe { } @Override - public final ItemStack craft(CraftingInventory inventory, DynamicRegistryManager registries) { + public final ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registries) { Pair pair = runMatch(inventory); ItemStack result = pair.getLeft().copy(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java b/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java index 62c91309..ccdaa038 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ItemCombinationRecipe.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.item; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.recipe.book.CraftingRecipeCategory; @@ -20,13 +20,13 @@ public abstract class ItemCombinationRecipe extends SpecialCraftingRecipe { } @Override - public final boolean matches(CraftingInventory inventory, World world) { + public final boolean matches(RecipeInputInventory inventory, World world) { Pair result = runMatch(inventory); return !result.getLeft().isEmpty() && !result.getRight().isEmpty(); } - protected Pair runMatch(CraftingInventory inventory) { + protected Pair runMatch(RecipeInputInventory inventory) { ItemStack bangle = ItemStack.EMPTY; ItemStack dust = ItemStack.EMPTY; diff --git a/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java b/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java index 0bce42f5..73a68e55 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java +++ b/src/main/java/com/minelittlepony/unicopia/item/JarInsertRecipe.java @@ -1,6 +1,6 @@ package com.minelittlepony.unicopia.item; -import net.minecraft.inventory.CraftingInventory; +import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.book.CraftingRecipeCategory; @@ -15,7 +15,7 @@ public class JarInsertRecipe extends ItemCombinationRecipe { } @Override - public final ItemStack craft(CraftingInventory inventory, DynamicRegistryManager registries) { + public final ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager registries) { Pair pair = runMatch(inventory); return UItems.FILLED_JAR.setAppearance(UItems.FILLED_JAR.getDefaultStack(), pair.getRight()); diff --git a/src/main/java/com/minelittlepony/unicopia/item/JarItem.java b/src/main/java/com/minelittlepony/unicopia/item/JarItem.java index 338c0b6a..809576a2 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/JarItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/JarItem.java @@ -44,32 +44,32 @@ public class JarItem extends ProjectileItem implements ItemImpl.GroundTickCallba entity.setInvulnerable(true); if (!lightning - && !entity.world.isClient + && !entity.getWorld().isClient && !entity.isRemoved() && entity.getItemAge() > 100 - && entity.world.isThundering() - && entity.world.isSkyVisible(entity.getBlockPos()) - && entity.world.random.nextInt(130) == 0) { - LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world); + && entity.getWorld().isThundering() + && entity.getWorld().isSkyVisible(entity.getBlockPos()) + && entity.getWorld().random.nextInt(130) == 0) { + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.getWorld()); lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ()); entity.remove(RemovalReason.DISCARDED); - entity.world.spawnEntity(lightning); + entity.getWorld().spawnEntity(lightning); - ItemEntity neu = EntityType.ITEM.create(entity.world); + ItemEntity neu = EntityType.ITEM.create(entity.getWorld()); neu.copyPositionAndRotation(entity); neu.setStack(new ItemStack(this == UItems.RAIN_CLOUD_JAR ? UItems.STORM_CLOUD_JAR : UItems.LIGHTNING_JAR)); neu.setInvulnerable(true); - entity.world.spawnEntity(neu); + entity.getWorld().spawnEntity(neu); - ItemEntity copy = EntityType.ITEM.create(entity.world); + ItemEntity copy = EntityType.ITEM.create(entity.getWorld()); copy.copyPositionAndRotation(entity); copy.setInvulnerable(true); copy.setStack(entity.getStack()); copy.getStack().decrement(1); - entity.world.spawnEntity(copy); + entity.getWorld().spawnEntity(copy); } return ActionResult.PASS; } @@ -81,8 +81,8 @@ public class JarItem extends ProjectileItem implements ItemImpl.GroundTickCallba @Override public void onImpact(MagicProjectileEntity projectile) { - if (!projectile.world.isClient()) { - ServerWorld world = (ServerWorld)projectile.world; + if (!projectile.getWorld().isClient()) { + ServerWorld world = (ServerWorld)projectile.getWorld(); if (rain || thunder) { // clear weather time = number of ticks for which the weather is clear @@ -128,22 +128,22 @@ public class JarItem extends ProjectileItem implements ItemImpl.GroundTickCallba } if (lightning) { - ParticleUtils.spawnParticle(projectile.world, UParticles.LIGHTNING_BOLT, projectile.getPos(), Vec3d.ZERO); + ParticleUtils.spawnParticle(projectile.getWorld(), UParticles.LIGHTNING_BOLT, projectile.getPos(), Vec3d.ZERO); } if (rain || thunder) { - projectile.world.syncWorldEvent(WorldEvents.SPLASH_POTION_SPLASHED, projectile.getBlockPos(), thunder ? 0x888888 : 0xF8F8F8); + projectile.getWorld().syncWorldEvent(WorldEvents.SPLASH_POTION_SPLASHED, projectile.getBlockPos(), thunder ? 0x888888 : 0xF8F8F8); - for (int i = projectile.world.random.nextInt(3) + 1; i >= 0; i--) { - ParticleUtils.spawnParticle(projectile.world, UParticles.CLOUDS_ESCAPING, + for (int i = projectile.getWorld().random.nextInt(3) + 1; i >= 0; i--) { + ParticleUtils.spawnParticle(projectile.getWorld(), UParticles.CLOUDS_ESCAPING, projectile.getX(), projectile.getY(), projectile.getZ(), - projectile.world.random.nextFloat() - 0.5, + projectile.getWorld().random.nextFloat() - 0.5, 0, - projectile.world.random.nextFloat() - 0.5 + projectile.getWorld().random.nextFloat() - 0.5 ); } } - projectile.world.syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); + projectile.getWorld().syncWorldEvent(WorldEvents.BLOCK_BROKEN, projectile.getBlockPos(), Block.getRawIdFromState(Blocks.GLASS.getDefaultState())); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java index adbf5474..65cdb292 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/PegasusAmuletItem.java @@ -32,8 +32,8 @@ public class PegasusAmuletItem extends AmuletItem implements ItemTracker.Trackab @Override public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { - if (entity.world.getTime() % 6 == 0 && entity instanceof LivingEntity living && isApplicable(living)) { - ParticleUtils.spawnParticles(entity.world.getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); + if (entity.getWorld().getTime() % 6 == 0 && entity instanceof LivingEntity living && isApplicable(living)) { + ParticleUtils.spawnParticles(entity.getWorld().getDimension().ultrawarm() ? ParticleTypes.SOUL_FIRE_FLAME : ParticleTypes.COMPOSTER, entity, 1); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java b/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java index 14360d98..d9bca4b7 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/PineappleItem.java @@ -23,7 +23,7 @@ public class PineappleItem extends Item { user.eatFood(world, stack.copy()); if (!world.isClient) { stack.damage(1, user, u -> { - AwaitTickQueue.scheduleTask(u.world, w -> { + AwaitTickQueue.scheduleTask(u.getWorld(), w -> { w.playSoundFromEntity(null, u, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 1, 0.7F); }); }); diff --git a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java index 07f46a74..a9febf20 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java @@ -47,9 +47,9 @@ public class StaffItem extends SwordItem { for (int i = 0; i < 130; i++) { w.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.OAK_LOG.getDefaultState()), - target.getX() + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), - (target.getY() + dims.height / 2) + (target.world.random.nextFloat() - 0.5F) * dims.height, - target.getZ() + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), + target.getX() + (target.getWorld().random.nextFloat() - 0.5F) * (dims.width + 1), + (target.getY() + dims.height / 2) + (target.getWorld().random.nextFloat() - 0.5F) * dims.height, + target.getZ() + (target.getWorld().random.nextFloat() - 0.5F) * (dims.width + 1), 0, 0, 0 ); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index f2f5623c..70d07536 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -20,6 +20,7 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.Registries; public interface UItems { @@ -137,7 +138,7 @@ public interface UItems { Item BAT_BADGE = register(Race.BAT); Item CHANGELING_BADGE = register(Race.CHANGELING); - static T register(String name, T item, ItemGroup group) { + static T register(String name, T item, RegistryKey group) { return ItemGroupRegistry.register(register(name, item), group); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java index 21ef9f4c..a3d13d6e 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/URecipes.java +++ b/src/main/java/com/minelittlepony/unicopia/item/URecipes.java @@ -47,7 +47,7 @@ public interface URecipes { } Identifier modId = new Identifier("unicopiamc", id.getPath()); - LootTable table = manager.getTable(modId); + LootTable table = manager.getLootTable(modId); if (table != LootTable.EMPTY) { supplier.pools(List.of(table.pools)); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java index 883d6ad2..438769db 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java @@ -80,18 +80,18 @@ public class ZapAppleItem extends Item implements ChameleonItem, ToxicHolder, Mu public TypedActionResult onFedTo(ItemStack stack, PlayerEntity player, Entity e) { - LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.world); + LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(e.getWorld()); lightning.refreshPositionAfterTeleport(e.getX(), e.getY(), e.getZ()); lightning.setCosmetic(true); if (player instanceof ServerPlayerEntity) { lightning.setChanneler((ServerPlayerEntity)player); } - if (e.world instanceof ServerWorld) { - e.onStruckByLightning((ServerWorld)e.world, lightning); + if (!e.getWorld().isClient) { + e.onStruckByLightning((ServerWorld)e.getWorld(), lightning); UCriteria.FEED_TRICK_APPLE.trigger(player); } - player.world.spawnEntity(lightning); + player.getWorld().spawnEntity(lightning); if (!player.getAbilities().creativeMode) { stack.decrement(1); diff --git a/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java b/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java index 0dcadd0d..c82ff3bc 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java @@ -11,10 +11,13 @@ import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.item.*; import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; public interface ItemGroupRegistry { - Map> REGISTRY = new HashMap<>(); + Map, Set> REGISTRY = new HashMap<>(); static List getVariations(Item item) { if (item instanceof MultiItem) { @@ -23,20 +26,22 @@ public interface ItemGroupRegistry { return List.of(item.getDefaultStack()); } - static T register(T item, ItemGroup group) { + static T register(T item, RegistryKey group) { REGISTRY.computeIfAbsent(group, g -> new LinkedHashSet<>()).add(item); return item; } - static ItemGroup createDynamic(String name, Supplier icon, Supplier> items) { - return FabricItemGroup.builder(Unicopia.id(name)).entries((context, entries) -> { + static RegistryKey createDynamic(String name, Supplier icon, Supplier> items) { + RegistryKey key = RegistryKey.of(RegistryKeys.ITEM_GROUP, Unicopia.id(name)); + Registry.register(Registries.ITEM_GROUP, key.getValue(), FabricItemGroup.builder().entries((context, entries) -> { items.get().forEach(item -> { entries.addAll(ItemGroupRegistry.getVariations(item)); }); - }).icon(icon).build(); + }).icon(icon).build()); + return key; } - static ItemGroup createGroupFromTag(String name, Supplier icon) { + static RegistryKey createGroupFromTag(String name, Supplier icon) { TagKey key = UTags.item("groups/" + name); return createDynamic(name, icon, () -> { return Registries.ITEM.getEntryList(key) diff --git a/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java b/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java index 26fe630d..080a07b0 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java +++ b/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java @@ -9,22 +9,23 @@ import com.minelittlepony.unicopia.item.toxin.ToxicHolder; import net.minecraft.item.*; import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKey; public interface UItemGroups { - ItemGroup ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> { + RegistryKey ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> { return Stream.concat(Stream.of(Items.APPLE), UItems.ITEMS.stream() .filter(item -> !(item instanceof ChameleonItem) || ((ChameleonItem)item).isFullyDisguised())); }); - ItemGroup HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> { + RegistryKey HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> { return Registries.ITEM.stream() .filter(item -> ((ToxicHolder)item).getToxic(item.getDefaultStack()) != Toxic.EMPTY); }); - ItemGroup EARTH_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("earth_pony", UItems.EARTH_BADGE::getDefaultStack); - ItemGroup UNICORN_ITEMS = ItemGroupRegistry.createGroupFromTag("unicorn", UItems.UNICORN_BADGE::getDefaultStack); - ItemGroup PEGASUS_ITEMS = ItemGroupRegistry.createGroupFromTag("pegasus", UItems.PEGASUS_BADGE::getDefaultStack); - ItemGroup BAT_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("bat_pony", UItems.BAT_BADGE::getDefaultStack); - ItemGroup CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.CHANGELING_BADGE::getDefaultStack); + RegistryKey EARTH_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("earth_pony", UItems.EARTH_BADGE::getDefaultStack); + RegistryKey UNICORN_ITEMS = ItemGroupRegistry.createGroupFromTag("unicorn", UItems.UNICORN_BADGE::getDefaultStack); + RegistryKey PEGASUS_ITEMS = ItemGroupRegistry.createGroupFromTag("pegasus", UItems.PEGASUS_BADGE::getDefaultStack); + RegistryKey BAT_PONY_ITEMS = ItemGroupRegistry.createGroupFromTag("bat_pony", UItems.BAT_BADGE::getDefaultStack); + RegistryKey CHANGELING_ITEMS = ItemGroupRegistry.createGroupFromTag("changeling", UItems.CHANGELING_BADGE::getDefaultStack); static void bootstrap() { ItemGroupRegistry.bootstrap(); diff --git a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java index d5ecaeda..2b054e88 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/item/toxin/Toxin.java @@ -18,7 +18,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.Difficulty; public interface Toxin extends Affliction { - Predicate IF_NOT_PEACEFUL = Predicate.of(Text.of("when not in peaceful "), (player, stack) -> player.world.getDifficulty() != Difficulty.PEACEFUL); + Predicate IF_NOT_PEACEFUL = Predicate.of(Text.of("when not in peaceful "), (player, stack) -> player.getWorld().getDifficulty() != Difficulty.PEACEFUL); Toxin INNERT = of(Text.of("No Effect"), (player, stack) -> {}); @@ -45,7 +45,7 @@ public interface Toxin extends Affliction { Toxin LOVE_CONSUMPTION = of(Text.literal("Love"), (player, stack) -> { player.heal(stack.isFood() ? stack.getItem().getFoodComponent().getHunger() : 1); player.removeStatusEffect(StatusEffects.NAUSEA); - if (player.world.random.nextInt(10) == 0) { + if (player.getWorld().random.nextInt(10) == 0) { player.removeStatusEffect(UEffects.FOOD_POISONING); } }); @@ -59,7 +59,7 @@ public interface Toxin extends Affliction { } default Toxin withChance(int max) { - return Predicate.of(Text.of("1 in " + max + " chance of "), (player, stack) -> player.world.random.nextInt(max) == 0).then(this); + return Predicate.of(Text.of("1 in " + max + " chance of "), (player, stack) -> player.getWorld().random.nextInt(max) == 0).then(this); } Text getName(); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java index 931de7f8..e6cbed71 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinLivingEntity.java @@ -168,7 +168,7 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ activeItemStack = stack; itemUseTimeLeft = time; - if (!world.isClient) { + if (!getWorld().isClient) { setLivingFlag(1, !stack.isEmpty()); setLivingFlag(2, hand == Hand.OFF_HAND); } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java index 6d5ef789..d836f0fc 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinMobEntity.java @@ -36,13 +36,13 @@ abstract class MixinMobEntity extends LivingEntity implements Equine.Container> info) { - if (!world.isClient) { + if (!getWorld().isClient) { get().trySleep(pos).ifPresent(reason -> { ((PlayerEntity)(Object)this).sendMessage(reason, true); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java index 9d012156..5debbac8 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerInventory.java @@ -41,7 +41,7 @@ abstract class MixinPlayerInventory implements Inventory, Nameable { for (int i = 0; i < original.size(); i++) { ItemStack stack = original.get(i); if (EnchantmentHelper.getLevel(Enchantments.BINDING_CURSE, stack) == 0 - && EnchantmentUtil.consumeEnchantment(UEnchantments.HEART_BOUND, 1, stack, player.world.random, EnchantmentUtil.getLuck(3, player))) { + && EnchantmentUtil.consumeEnchantment(UEnchantments.HEART_BOUND, 1, stack, player.getWorld().random, EnchantmentUtil.getLuck(3, player))) { original.set(i, ItemStack.EMPTY); UCriteria.USE_SOULMATE.trigger(player); storedCombinedInventory.get(group).set(i, stack); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java index 2c567e7f..9ec1f042 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java @@ -26,7 +26,7 @@ abstract class MixinServerPlayNetworkHandler implements EntityTrackingListener, @Inject(method = "onPlayerMove(Lnet/minecraft/network/packet/c2s/play/PlayerMoveC2SPacket;)V", at = @At("HEAD")) private void beforePlayerMove(PlayerMoveC2SPacket packet, CallbackInfo info) { ServerPlayerEntity player = ((ServerPlayNetworkHandler)(Object)this).player; - NetworkThreadUtils.forceMainThread(packet, this, player.getWorld()); + NetworkThreadUtils.forceMainThread(packet, this, player.getServerWorld()); flyingSurvival = Pony.of(player).getPhysics().isFlyingSurvival; if (flyingSurvival) { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java index d6fd67a5..58faae77 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinInGameHud.java @@ -9,15 +9,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.minelittlepony.unicopia.client.gui.UHud; import com.minelittlepony.unicopia.entity.effect.RaceChangeStatusEffect; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.player.PlayerEntity; @Mixin(InGameHud.class) abstract class MixinInGameHud { - @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;F)V", at = @At("HEAD")) - private void onRender(MatrixStack stack, float tickDelta, CallbackInfo info) { - UHud.INSTANCE.render((InGameHud)(Object)this, stack, tickDelta); + @Inject(method = "render(Lnet/minecraft/client/gui/DrawContext;F)V", at = @At("HEAD")) + private void onRender(DrawContext context, float tickDelta, CallbackInfo info) { + UHud.INSTANCE.render((InGameHud)(Object)this, context, tickDelta); } } diff --git a/src/main/java/com/minelittlepony/unicopia/network/Channel.java b/src/main/java/com/minelittlepony/unicopia/network/Channel.java index ecec7f6a..5e6f08cc 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/Channel.java +++ b/src/main/java/com/minelittlepony/unicopia/network/Channel.java @@ -35,7 +35,7 @@ public interface Channel { ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { Pony pony = Pony.of(handler.player); if (pony.getActualSpecies() == Race.UNSET) { - Race race = WorldTribeManager.forWorld(handler.player.getWorld()).getDefaultRace(); + Race race = WorldTribeManager.forWorld(handler.player.getServerWorld()).getDefaultRace(); if (!race.isPermitted(handler.player)) { race = Race.UNSET; } diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java index d5e702fa..cbed2041 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgRequestSpeciesChange.java @@ -39,11 +39,11 @@ public record MsgRequestSpeciesChange ( player.setSpecies(newRace.isPermitted(sender) ? newRace : WorldTribeManager.forWorld((ServerWorld)player.asWorld()).getDefaultRace()); if (force) { - if (sender.world.getGameRules().getBoolean(UGameRules.ANNOUNCE_TRIBE_JOINS)) { + if (sender.getWorld().getGameRules().getBoolean(UGameRules.ANNOUNCE_TRIBE_JOINS)) { Text message = Text.translatable("respawn.reason.joined_new_tribe", sender.getDisplayName(), player.getActualSpecies().getDisplayName(), player.getActualSpecies().getAltDisplayName()); - sender.world.getPlayers().forEach(p -> { + sender.getWorld().getPlayers().forEach(p -> { ((ServerPlayerEntity)p).sendMessageToClient(message, false); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java b/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java index fd85b6bb..34a90ed9 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java +++ b/src/main/java/com/minelittlepony/unicopia/network/MsgSpellbookStateChanged.java @@ -17,6 +17,10 @@ public record MsgSpellbookStateChanged ( SpellbookState state ) implements HandledPacket { + public static MsgSpellbookStateChanged create(SpellbookScreenHandler handler, SpellbookState state) { + return new MsgSpellbookStateChanged<>(handler.syncId, state); + } + public MsgSpellbookStateChanged(PacketByteBuf buffer) { this(buffer.readInt(), new SpellbookState().fromPacket(buffer)); } diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java index a7a4eb5d..fa190703 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleHandle.java @@ -28,7 +28,7 @@ public class ParticleHandle { public Optional update(UUID id, String partName, ParticleSource source, Consumer constructor) { return get(partName).or(() -> { - if (source.asEntity().world.isClient) { + if (source.asEntity().getWorld().isClient) { new ClientHandle().addParticle(id, partName, source, constructor); } return get(partName); diff --git a/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java b/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java index f851f53e..27a7caff 100644 --- a/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/particle/ParticleUtils.java @@ -20,7 +20,7 @@ public interface ParticleUtils { } static void spawnParticles(ParticleEffect effect, Entity entity, int count) { - spawnParticles(entity.world, getShapeFor(entity), effect, count); + spawnParticles(entity.getWorld(), getShapeFor(entity), effect, count); } static void spawnParticles(ParticleEffect effect, World world, Vec3d origin, int count) { diff --git a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java index cd831019..d32d308a 100644 --- a/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/projectile/MagicProjectileEntity.java @@ -168,7 +168,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster 90) { discard(); } @@ -183,7 +183,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster spell.tick(this, Situation.PROJECTILE)); if (getHydrophobic()) { - if (world.getBlockState(getBlockPos()).getMaterial().isLiquid()) { + if (getWorld().getBlockState(getBlockPos()).isLiquid()) { Vec3d vel = getVelocity(); double velY = vel.y; @@ -198,7 +198,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster { + homingTarget.ifPresent(getWorld(), e -> { setNoGravity(true); noClip = true; setVelocity(getVelocity().add(e.getPos().subtract(getPos()).normalize().multiply(0.2)).multiply(0.6, 0.6, 0.6)); @@ -225,7 +225,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster { Optional.ofNullable(predicate.apply(spell)).ifPresent(consumer); return Operation.SKIP; - }, world.isClient); + }, getWorld().isClient); Optional.ofNullable(predicate.apply(getItem().getItem())).ifPresent(consumer); } diff --git a/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java b/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java index 6dc96b19..ade56cb9 100644 --- a/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java +++ b/src/main/java/com/minelittlepony/unicopia/trinkets/UnicopiaTrinket.java @@ -57,7 +57,7 @@ public class UnicopiaTrinket implements Trinket { @Override public void tick(ItemStack stack, SlotReference slot, LivingEntity entity) { - item.inventoryTick(stack, entity.world, entity, slot.index(), false); + item.inventoryTick(stack, entity.getWorld(), entity, slot.index(), false); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java b/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java index b9cd1b0e..033898ad 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java +++ b/src/main/java/com/minelittlepony/unicopia/util/SoundEmitter.java @@ -18,7 +18,7 @@ public interface SoundEmitter extends EntityConvertable { } default float getRandomPitch() { - return getRandomPitch(asEntity().world.getRandom()); + return getRandomPitch(asEntity().getWorld().getRandom()); } static void playSoundAt(Entity entity, SoundEvent sound, float volume, float pitch) { @@ -26,7 +26,7 @@ public interface SoundEmitter extends EntityConvertable { } static void playSoundAt(Entity entity, SoundEvent sound, SoundCategory category, float volume, float pitch) { - entity.world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound, category, volume, pitch); + entity.getWorld().playSound(null, entity.getX(), entity.getY(), entity.getZ(), sound, category, volume, pitch); } static float getRandomPitch(Random rng) { diff --git a/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java b/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java index e8a2ddca..f5b6f3df 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java +++ b/src/main/java/com/minelittlepony/unicopia/util/TraceHelper.java @@ -66,7 +66,7 @@ public class TraceHelper { final Vec3d start = e.getCameraPosVec(tickDelta); return BlockView.raycast(start, start.add(orientation.multiply(distance)), new ArrayList(), (ctx, pos) -> { - if (predicate.test(e.world.getBlockState(pos))) { + if (predicate.test(e.getWorld().getBlockState(pos))) { ctx.add(pos); } return null;