diff --git a/build.gradle b/build.gradle index 1e13db20..4f99ed42 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,6 @@ -// Fabric build script -// 03/06/2019 -// https://github.com/FabricMC/fabric-example-mod/blob/master/build.gradle - plugins { id 'java-library' - id 'fabric-loom' version '0.2.5-SNAPSHOT' + id 'fabric-loom' version '0.2.6-SNAPSHOT' id 'maven-publish' } @@ -59,7 +55,9 @@ dependencies { modApi "com.minelittlepony:Kirin:${project.kirin_version}" include "com.minelittlepony:Kirin:${project.kirin_version}" - modImplementation "io.github.prospector.modmenu:ModMenu:1.6.2-93" + modCompileOnly("io.github.prospector:modmenu:${project.modmenu_version}") { + transitive = false + } } processResources { diff --git a/gradle.properties b/gradle.properties index 87535fd0..a212e308 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,19 +2,20 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.14.4 - yarn_mappings=1.14.4+build.2 - loader_version=0.4.8+ + # check these on https://fabricmc.net/use + minecraft_version=1.15.2 + yarn_mappings=1.15.2+build.7:v2 + loader_version=0.7.6+build.180 # Mod Properties - group=com.minelittlepony - displayname=Unicopia - authors=Sollace - description=Magical Abilities for Mine Little Pony! - version=3 - release=SNAPSHOT + group=com.minelittlepony + displayname=Unicopia + authors=Sollace + description=Magical Abilities for Mine Little Pony! + version=3 + release=SNAPSHOT # Dependencies - fabric_version=0.3.0+ - kirin_version=1.14.4-1.4.4 + fabric_version=0.4.29+ + modmenu_version=1.8.+ + kirin_version=1.5.2-1.15.2 diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java index 68fb37c6..3b8bafcb 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingDisguiseAbility.java @@ -9,8 +9,8 @@ import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.InAnimate; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.magic.spell.DisguiseSpell; +import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.VecHelper; -import com.minelittlepony.unicopia.util.particles.UParticles; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -76,7 +76,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility { } } - player.getEntityWorld().playSound(null, player.getBlockPos(), SoundEvents.ENTITY_PARROT_IMITATE_POLAR_BEAR, SoundCategory.PLAYERS, 1.4F, 0.4F); + player.getEntityWorld().playSound(null, player.getBlockPos(), SoundEvents.ENTITY_PARROT_IMITATE_RAVAGER, SoundCategory.PLAYERS, 1.4F, 0.4F); iplayer.getEffect(DisguiseSpell.class).orElseGet(() -> { DisguiseSpell disc = new DisguiseSpell(); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java index 52081bc0..f12ec0c7 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/ChangelingFeedAbility.java @@ -9,6 +9,8 @@ import org.lwjgl.glfw.GLFW; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.particles.ParticleUtils; +import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.VecHelper; @@ -68,7 +70,7 @@ public class ChangelingFeedAbility implements Ability { } private boolean canFeed(Pony player) { - return player.getOwner().getHealth() < player.getOwner().getHealthMaximum() || player.getOwner().canConsume(false); + return player.getOwner().getHealth() < player.getOwner().getMaximumHealth() || player.getOwner().canConsume(false); } private boolean canDrain(Entity e) { @@ -101,7 +103,7 @@ public class ChangelingFeedAbility implements Ability { public void apply(Pony iplayer, Hit data) { PlayerEntity player = iplayer.getOwner(); - float maximumHealthGain = player.getHealthMaximum() - player.getHealth(); + float maximumHealthGain = player.getMaximumHealth() - player.getHealth(); int maximumFoodGain = player.canConsume(false) ? (20 - player.getHungerManager().getFoodLevel()) : 0; if (maximumHealthGain > 0 || maximumFoodGain > 0) { @@ -134,13 +136,12 @@ public class ChangelingFeedAbility implements Ability { living.damage(d, damage); } - // TODO: ParticleTypeRegistry - //ParticleTypeRegistry.spawnParticles(UParticles.CHANGELING_MAGIC, living, 7); + ParticleUtils.spawnParticles(UParticles.CHANGELING_MAGIC, living, 7); if (changeling.hasStatusEffect(StatusEffects.NAUSEA)) { - living.addPotionEffect(changeling.removePotionEffect(StatusEffects.NAUSEA)); + living.addStatusEffect(changeling.removeStatusEffectInternal(StatusEffects.NAUSEA)); } else if (changeling.getEntityWorld().random.nextInt(2300) == 0) { - living.addPotionEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1)); + living.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1)); } if (living instanceof PlayerEntity) { @@ -148,7 +149,7 @@ public class ChangelingFeedAbility implements Ability { damage *= 1.6F; if (!changeling.hasStatusEffect(StatusEffects.HEALTH_BOOST)) { - changeling.addPotionEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1)); + changeling.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1)); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java index b866bd52..c17281cc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java @@ -4,8 +4,8 @@ import org.lwjgl.glfw.GLFW; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.VecHelper; -import com.minelittlepony.unicopia.util.particles.UParticles; import net.minecraft.block.BlockState; import net.minecraft.item.BoneMealItem; @@ -95,7 +95,7 @@ public class EarthPonyGrowAbility implements Ability { player.addExertion(3); if (player.getWorld().isClient()) { - player.spawnParticles(UParticles.UNICORN_MAGIC, 1); + player.spawnParticles(MagicParticleEffect.UNICORN, 1); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index c3b20862..79315bb1 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -133,9 +133,9 @@ public class EarthPonyStompAbility implements Ability { - if (i.getSquaredDistance(player.x, player.y, player.z, true) <= rad*rad) { + if (i.getSquaredDistance(player.getX(), player.getY(), player.getZ(), true) <= rad*rad) { spawnEffect(player.world, i); } }); @@ -169,7 +169,7 @@ public class EarthPonyStompAbility implements Ability @Override public void preApply(Pony player) { - player.spawnParticles(UParticles.UNICORN_MAGIC, 10); + player.spawnParticles(MagicParticleEffect.UNICORN, 10); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java index d2053913..df538668 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornCastingAbility.java @@ -5,7 +5,7 @@ import org.lwjgl.glfw.GLFW; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.magic.spell.ShieldSpell; -import com.minelittlepony.unicopia.util.particles.UParticles; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; /** * A magic casting ability for unicorns. @@ -60,11 +60,11 @@ public class UnicornCastingAbility implements Ability { @Override public void preApply(Pony player) { - player.spawnParticles(UParticles.UNICORN_MAGIC, 5); + player.spawnParticles(MagicParticleEffect.UNICORN, 5); } @Override public void postApply(Pony player) { - player.spawnParticles(UParticles.UNICORN_MAGIC, 5); + player.spawnParticles(MagicParticleEffect.UNICORN, 5); } } diff --git a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java index deec704c..7f40b5b2 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/UnicornTeleportAbility.java @@ -4,8 +4,8 @@ import org.lwjgl.glfw.GLFW; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.VecHelper; -import com.minelittlepony.unicopia.util.particles.UParticles; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -131,10 +131,10 @@ public class UnicornTeleportAbility implements Ability { } } - player.setPosition( - data.x + (player.x - Math.floor(player.x)), + player.setPos( + data.x + (player.getX() - Math.floor(player.getX())), data.y, - data.z + (player.z - Math.floor(player.z))); + data.z + (player.getZ() - Math.floor(player.getZ()))); iplayer.subtractEnergyCost(distance); player.fallDistance /= distance; @@ -166,11 +166,11 @@ public class UnicornTeleportAbility implements Ability { @Override public void preApply(Pony player) { player.addExertion(3); - player.spawnParticles(UParticles.UNICORN_MAGIC, 5); + player.spawnParticles(MagicParticleEffect.UNICORN, 5); } @Override public void postApply(Pony player) { - player.spawnParticles(UParticles.UNICORN_MAGIC, 5); + player.spawnParticles(MagicParticleEffect.UNICORN, 5); } } diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java b/src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java index e42e7954..808f6df8 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/AdvancementPredicate.java @@ -24,7 +24,7 @@ class AdvancementPredicate { } public boolean test(ServerWorld world, PlayerAdvancementTracker tracker) { - Advancement advancement = world.getServer().getAdvancementManager().get(id); + Advancement advancement = world.getServer().getAdvancementLoader().get(id); return advancement != null && tracker.getProgress(advancement).isDone(); } diff --git a/src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java b/src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java index ccd3247a..e37bd1b8 100644 --- a/src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java +++ b/src/main/java/com/minelittlepony/unicopia/advancement/BOHDeathCriterion.java @@ -36,7 +36,7 @@ public class BOHDeathCriterion extends AbstractCriterion { e.trigger((ServerWorld)player.world, key); @@ -68,7 +68,7 @@ public class BOHDeathCriterion extends AbstractCriterion listener.getConditions().test(world, tracker)) - .forEach(winner -> winner.apply(advancement)); + .forEach(winner -> winner.grant(advancement)); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/AbstractDoorBlock.java b/src/main/java/com/minelittlepony/unicopia/block/AbstractDoorBlock.java index f6d3d49b..98f9df04 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/AbstractDoorBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/AbstractDoorBlock.java @@ -10,6 +10,7 @@ import net.minecraft.block.DoorBlock; import net.minecraft.block.Material; import net.minecraft.block.enums.DoubleBlockHalf; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -31,7 +32,7 @@ public abstract class AbstractDoorBlock extends DoorBlock { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { return toggleDoor(world, pos, false, true, player); } @@ -52,15 +53,15 @@ public abstract class AbstractDoorBlock extends DoorBlock { return player == null || material != Material.METAL; } - protected boolean toggleDoor(World world, BlockPos pos, boolean open, boolean force, @Nullable PlayerEntity player) { + protected ActionResult toggleDoor(World world, BlockPos pos, boolean open, boolean force, @Nullable PlayerEntity player) { if (!canOpen(player)) { - return false; + return ActionResult.PASS; } BlockState state = world.getBlockState(pos); if (state.getBlock() != this) { - return false; + return ActionResult.PASS; } BlockPos lower = getPrimaryDoorPos(state, pos); @@ -68,11 +69,11 @@ public abstract class AbstractDoorBlock extends DoorBlock { BlockState mainDoor = pos == lower ? state : world.getBlockState(lower); if (mainDoor.getBlock() != this) { - return false; + return ActionResult.PASS; } if (!force && mainDoor.get(OPEN) == open) { - return false; + return ActionResult.FAIL; } state = mainDoor.cycle(OPEN); @@ -83,7 +84,7 @@ public abstract class AbstractDoorBlock extends DoorBlock { world.playLevelEvent(player, sound.getId(), pos, 0); - return true; + return ActionResult.SUCCESS; } protected BlockPos getPrimaryDoorPos(BlockState state, BlockPos pos) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockGrowingCuccoon.java b/src/main/java/com/minelittlepony/unicopia/block/BlockGrowingCuccoon.java index a138eec0..3f1d5754 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/BlockGrowingCuccoon.java +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockGrowingCuccoon.java @@ -8,8 +8,8 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; import net.fabricmc.fabric.api.block.FabricBlockSettings; +import net.fabricmc.fabric.api.tools.FabricToolTags; import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityContext; @@ -18,22 +18,23 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtHelper; import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.IntProperty; import net.minecraft.util.StringIdentifiable; -import net.minecraft.util.TagHelper; import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; -import net.minecraft.world.ViewableWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldView; public class BlockGrowingCuccoon extends Block { @@ -53,7 +54,6 @@ public class BlockGrowingCuccoon extends Block { Block.createCuboidShape(2, 0, 2, 14, 12, 14), }; - @SuppressWarnings("deprecation") public BlockGrowingCuccoon() { super(FabricBlockSettings.of(UMaterials.HIVE) .ticksRandomly() @@ -61,11 +61,11 @@ public class BlockGrowingCuccoon extends Block { .lightLevel(9) .slipperiness(0.5F) .sounds(BlockSoundGroup.SLIME) - .breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.SHOVELS, 2) + .breakByTool(FabricToolTags.SHOVELS, 2) .build() ); - setDefaultState(stateFactory.getDefaultState() + setDefaultState(stateManager.getDefaultState() .with(AGE, 0) .with(SHAPE, Shape.BULB)); } @@ -87,18 +87,13 @@ public class BlockGrowingCuccoon extends Block { return true; } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Override public Block.OffsetType getOffsetType() { return Block.OffsetType.XZ; } @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { if (!checkSupport(world, pos)) { breakConnected(world, pos); return; @@ -108,7 +103,7 @@ public class BlockGrowingCuccoon extends Block { BlockPos below = pos.down(); - if (world.isBlockLoaded(below)) { + if (world.isChunkLoaded(below)) { boolean spaceBelow = world.isAir(below); Shape shape = state.get(SHAPE); @@ -163,7 +158,7 @@ public class BlockGrowingCuccoon extends Block { } @Override - public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { return super.canPlaceAt(state, world, pos) && checkSupport(world, pos); } @@ -200,7 +195,7 @@ public class BlockGrowingCuccoon extends Block { PlayerEntity player = (PlayerEntity)living; skull.setTag(new CompoundTag()); - skull.getTag().put("SkullOwner", TagHelper.serializeProfile(new CompoundTag(), player.getGameProfile())); + skull.getTag().put("SkullOwner", NbtHelper.fromGameProfile(new CompoundTag(), player.getGameProfile())); player.dropItem(skull, true); } else { living.dropItem(Items.SKELETON_SKULL, 1); @@ -244,7 +239,7 @@ public class BlockGrowingCuccoon extends Block { @Override - protected void appendProperties(StateFactory.Builder builder) { + protected void appendProperties(StateManager.Builder builder) { builder.add(AGE, SHAPE); } @@ -264,9 +259,9 @@ public class BlockGrowingCuccoon extends Block { .offset(offset.x, offset.y, offset.z) .getBoundingBox(); - double x = bounds.minX + (bounds.maxX - bounds.minX) * rand.nextFloat(); - double y = bounds.minY; - double z = bounds.minZ + (bounds.maxZ - bounds.minZ) * rand.nextFloat(); + double x = bounds.x1 + (bounds.x2 - bounds.x1) * rand.nextFloat(); + double y = bounds.y1; + double z = bounds.z1 + (bounds.z2 - bounds.z1) * rand.nextFloat(); world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/ChiselledChitinBlock.java b/src/main/java/com/minelittlepony/unicopia/block/ChiselledChitinBlock.java index 3f937b95..2c28673f 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/ChiselledChitinBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/ChiselledChitinBlock.java @@ -11,7 +11,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.MaterialColor; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; @@ -27,7 +27,7 @@ public class ChiselledChitinBlock extends Block { .materialColor(MaterialColor.BLACK) .build() ); - setDefaultState(stateFactory.getDefaultState() + setDefaultState(stateManager.getDefaultState() .with(Properties.FACING, Direction.UP) ); } @@ -49,7 +49,7 @@ public class ChiselledChitinBlock extends Block { } @Override - protected void appendProperties(StateFactory.Builder builder) { + protected void appendProperties(StateManager.Builder builder) { builder.add(Properties.FACING); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/ChitinBlock.java b/src/main/java/com/minelittlepony/unicopia/block/ChitinBlock.java index 9716d175..489d4136 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/ChitinBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/ChitinBlock.java @@ -10,7 +10,7 @@ import net.minecraft.block.Blocks; import net.minecraft.block.MaterialColor; import net.minecraft.entity.EntityContext; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.EnumProperty; import net.minecraft.util.StringIdentifiable; import net.minecraft.util.math.BlockPos; @@ -29,7 +29,7 @@ public class ChitinBlock extends Block { .materialColor(MaterialColor.BLACK) .build() ); - setDefaultState(stateFactory.getDefaultState().with(COVERING, Covering.UNCOVERED)); + setDefaultState(stateManager.getDefaultState().with(COVERING, Covering.UNCOVERED)); // TODO: drops: // UItems.chitin_shell x 3 @@ -72,7 +72,7 @@ public class ChitinBlock extends Block { } @Override - protected void appendProperties(StateFactory.Builder builder) { + protected void appendProperties(StateManager.Builder builder) { builder.add(COVERING); } diff --git a/src/main/java/com/minelittlepony/unicopia/block/FruitLeavesBlock.java b/src/main/java/com/minelittlepony/unicopia/block/FruitLeavesBlock.java index c3a7cbd3..a911bbe9 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/FruitLeavesBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/FruitLeavesBlock.java @@ -16,11 +16,13 @@ import net.minecraft.block.Material; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.DyeItem; import net.minecraft.item.ItemStack; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; +import net.minecraft.util.ActionResult; import net.minecraft.util.DyeColor; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -48,13 +50,19 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful { .build() ); - setDefaultState(stateFactory.getDefaultState() + setDefaultState(stateManager.getDefaultState() .with(HEAVY, false) .with(DISTANCE, 7) .with(PERSISTENT, false) ); } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(HEAVY); + } + public FruitLeavesBlock hardy(boolean value) { hardy = value; return this; @@ -81,7 +89,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { ItemStack stack = player.getStackInHand(hand); if (Pony.of(player).getSpecies().canUseEarth()) { @@ -104,15 +112,15 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful { } } - return true; + return ActionResult.SUCCESS; } - return false; + return ActionResult.PASS; } @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { - if (!world.isClient && world.isBlockLoaded(pos) && !state.get(PERSISTENT)) { + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { + if (!world.isClient && world.isChunkLoaded(pos) && !state.get(PERSISTENT)) { int growthChance = getGrowthChance(world, pos, state); if (!state.get(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) { @@ -123,7 +131,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful { if (state.get(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) { dropContents(world, pos, state, 0); } else { - super.onScheduledTick(state, world, pos, rand); + super.scheduledTick(state, world, pos, rand); } } } @@ -132,7 +140,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful { protected int getGrowthChance(World world, BlockPos pos, BlockState state) { int chance = baseGrowthChance; - if (!hardy && !world.isDaylight()) { + if (!hardy && !world.isDay()) { chance *= 40; } @@ -169,10 +177,4 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful { world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_PLACE, SoundCategory.BLOCKS, 0.3F, 1); world.setBlockState(pos, state.with(HEAVY, false)); } - - @Override - protected void appendProperties(StateFactory.Builder builder) { - super.appendProperties(builder); - builder.add(HEAVY); - } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/GlowingGemBlock.java b/src/main/java/com/minelittlepony/unicopia/block/GlowingGemBlock.java index c9d5a3c6..e4fd136a 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/GlowingGemBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/GlowingGemBlock.java @@ -4,7 +4,7 @@ import java.util.Random; import com.minelittlepony.unicopia.gas.CloudType; import com.minelittlepony.unicopia.gas.Gas; -import com.minelittlepony.unicopia.util.particles.UParticles; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.block.Block; @@ -16,12 +16,14 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.Properties; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -65,12 +67,17 @@ public class GlowingGemBlock extends TorchBlock implements Gas { .sounds(BlockSoundGroup.GLASS) .build() ); - setDefaultState(stateFactory.getDefaultState() + setDefaultState(stateManager.getDefaultState() .with(Properties.FACING, Direction.UP) .with(ON, true) ); } + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(Properties.FACING).add(ON); + } + @Override public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { switch (state.get(Properties.FACING)) { @@ -83,7 +90,7 @@ public class GlowingGemBlock extends TorchBlock implements Gas { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { if (!state.get(ON)) { ItemStack held = player.getStackInHand(hand); @@ -99,10 +106,10 @@ public class GlowingGemBlock extends TorchBlock implements Gas { } } - return true; + return ActionResult.SUCCESS; } - return false; + return ActionResult.PASS; } @Override @@ -126,7 +133,7 @@ public class GlowingGemBlock extends TorchBlock implements Gas { if (state.get(ON)) { for (int i = 0; i < 3; i++) { - world.addParticle(UParticles.UNICORN_MAGIC, + world.addParticle(MagicParticleEffect.UNICORN, x - 0.3, y - 0.3, z - 0.3, rand.nextFloat(), rand.nextFloat(), rand.nextFloat()); } @@ -136,7 +143,7 @@ public class GlowingGemBlock extends TorchBlock implements Gas { } @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random random) { + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { if (world.hasRain(pos)) { if (state.get(ON)) { world.playSound(null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); @@ -188,9 +195,4 @@ public class GlowingGemBlock extends TorchBlock implements Gas { return 0; } - - @Override - protected void appendProperties(StateFactory.Builder builder) { - builder.add(Properties.FACING).add(ON); - } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java b/src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java index 8610b20c..db70001e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/HiveWallBlock.java @@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; import net.fabricmc.fabric.api.block.FabricBlockSettings; +import net.fabricmc.fabric.api.tools.FabricToolTags; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -22,18 +23,20 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemPlacementContext; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.StringIdentifiable; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ViewableWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldView; public class HiveWallBlock extends FallingBlock { @@ -42,7 +45,6 @@ public class HiveWallBlock extends FallingBlock { private static final Shape shape = new Sphere(false, 1.5); - @SuppressWarnings("deprecation") public HiveWallBlock() { super(FabricBlockSettings.of(UMaterials.HIVE) .noCollision() @@ -51,16 +53,21 @@ public class HiveWallBlock extends FallingBlock { .ticksRandomly() .lightLevel(1) .sounds(BlockSoundGroup.SAND) - .breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.PICKAXES, 1) + .breakByTool(FabricToolTags.PICKAXES, 1) .build() ); - setDefaultState(stateFactory.getDefaultState() + setDefaultState(stateManager.getDefaultState() .with(STATE, State.GROWING).with(AXIS, Axis.Y) ); } @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { + protected void appendProperties(StateManager.Builder builder) { + builder.add(STATE).add(AXIS); + } + + @Override + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { if (rand.nextInt(300) == 0) { world.playSound(null, pos, USounds.INSECT, SoundCategory.BLOCKS, 1, 1); @@ -137,7 +144,7 @@ public class HiveWallBlock extends FallingBlock { } @Override - public int getTickRate(ViewableWorld view) { + public int getTickRate(WorldView view) { return 10; } @@ -200,7 +207,7 @@ public class HiveWallBlock extends FallingBlock { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { if (hand == Hand.MAIN_HAND && player.getStackInHand(hand).isEmpty()) { Pony iplayer = Pony.of(player); @@ -214,11 +221,11 @@ public class HiveWallBlock extends FallingBlock { } }); - return true; + return ActionResult.SUCCESS; } } - return false; + return ActionResult.PASS; } @Override @@ -257,7 +264,7 @@ public class HiveWallBlock extends FallingBlock { } protected boolean canSpreadInto(World world, BlockPos pos, Axis axis) { - if (world.isBlockLoaded(pos) && isEmptySpace(world, pos)) { + if (world.isChunkLoaded(pos) && isEmptySpace(world, pos)) { boolean one = false; for (Direction facing : axis.getFacings()) { @@ -277,11 +284,6 @@ public class HiveWallBlock extends FallingBlock { return false; } - @Override - protected void appendProperties(StateFactory.Builder builder) { - builder.add(STATE).add(AXIS); - } - public enum State implements StringIdentifiable { GROWING, STABLE, diff --git a/src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java b/src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java index 41ba1abe..cef8153e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/SlimeLayerBlock.java @@ -1,7 +1,6 @@ package com.minelittlepony.unicopia.block; import net.fabricmc.fabric.api.block.FabricBlockSettings; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; @@ -23,11 +22,6 @@ public class SlimeLayerBlock extends SnowBlock { // TODO: drops Items.SLIME_BALL x1 } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Override public void onSteppedOn(World world, BlockPos pos, Entity entity) { float factor = getMotionFactor(world.getBlockState(pos)); diff --git a/src/main/java/com/minelittlepony/unicopia/block/StickBlock.java b/src/main/java/com/minelittlepony/unicopia/block/StickBlock.java index ddff8843..b7c1031e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/StickBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/StickBlock.java @@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.block; import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.FarmlandBlock; import net.minecraft.block.Material; @@ -12,6 +11,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.LeadItem; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -20,8 +20,8 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; -import net.minecraft.world.ViewableWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldView; public class StickBlock extends Block { @@ -43,11 +43,6 @@ public class StickBlock extends Block { // TODO: drops Items.STICK x1 } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Deprecated @Override public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { @@ -61,18 +56,21 @@ public class StickBlock extends Block { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { if (!world.isClient) { return LeadItem.attachHeldMobsToBlock(player, world, pos); } ItemStack stack = player.getStackInHand(hand); - return stack.getItem() == Items.LEAD || stack.isEmpty(); + if (stack.getItem() == Items.LEAD || stack.isEmpty()) { + return ActionResult.SUCCESS; + } + return ActionResult.PASS; } @Override - public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { Block block = state.getBlock(); return block instanceof StickBlock || block instanceof FarmlandBlock; diff --git a/src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java b/src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java index aab179e5..56d394a2 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/TallCropBlock.java @@ -12,7 +12,8 @@ import net.minecraft.block.CropBlock; import net.minecraft.entity.EntityContext; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; -import net.minecraft.state.StateFactory; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.state.StateManager; import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.IntProperty; import net.minecraft.util.StringIdentifiable; @@ -21,8 +22,8 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; -import net.minecraft.world.ViewableWorld; import net.minecraft.world.World; +import net.minecraft.world.WorldView; public class TallCropBlock extends CropBlock { @@ -53,6 +54,11 @@ public class TallCropBlock extends CropBlock { setDefaultState(getDefaultState().with(HALF, Half.BOTTOM)); } + @Override + protected void appendProperties(StateManager.Builder builder) { + builder.add(AGE, HALF); + } + @Override public OffsetType getOffsetType() { return OffsetType.XZ; @@ -74,8 +80,8 @@ public class TallCropBlock extends CropBlock { } @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { - if (rand.nextInt(10) != 0 && world.isBlockLoaded(pos) && world.getLightLevel(pos.up()) >= 9) { + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { + if (rand.nextInt(10) != 0 && world.isChunkLoaded(pos) && world.getLightLevel(pos.up()) >= 9) { if (canGrow(world, rand, pos, state)) { growUpwards(world, pos, state, 1); } @@ -123,7 +129,7 @@ public class TallCropBlock extends CropBlock { } @Override - public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { return getHalf(state) != Half.BOTTOM || super.canPlaceAt(state, world, pos); } @@ -160,11 +166,6 @@ public class TallCropBlock extends CropBlock { return super.getGrowthAmount(world) / 2; } - @Override - protected void appendProperties(StateFactory.Builder builder) { - builder.add(AGE, HALF); - } - @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { if (getHalf(state) != Half.MIDDLE) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/TomatoPlantBlock.java b/src/main/java/com/minelittlepony/unicopia/block/TomatoPlantBlock.java index 019fab89..9ef5b361 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/TomatoPlantBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/TomatoPlantBlock.java @@ -15,10 +15,12 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.loot.context.LootContext; import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.SoundCategory; -import net.minecraft.state.StateFactory; +import net.minecraft.state.StateManager; import net.minecraft.state.property.EnumProperty; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.StringIdentifiable; import net.minecraft.util.hit.BlockHitResult; @@ -26,9 +28,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; -import net.minecraft.world.ViewableWorld; import net.minecraft.world.World; -import net.minecraft.world.loot.context.LootContext; +import net.minecraft.world.WorldView; public class TomatoPlantBlock extends CropBlock { @@ -49,6 +50,12 @@ public class TomatoPlantBlock extends CropBlock { // if mature: UItems.tomato } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(TYPE); + } + @Deprecated @Override public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { @@ -56,12 +63,6 @@ public class TomatoPlantBlock extends CropBlock { return StickBlock.BOUNDING_BOX.offset(off.x, off.y, off.z); } - @Override - protected void appendProperties(StateFactory.Builder builder) { - super.appendProperties(builder); - builder.add(TYPE); - } - @Override public Block.OffsetType getOffsetType() { return Block.OffsetType.XZ; @@ -73,7 +74,7 @@ public class TomatoPlantBlock extends CropBlock { } @Override - public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { if (world.getBlockState(pos.down()).getBlock() instanceof TomatoPlantBlock) { return true; } @@ -106,7 +107,7 @@ public class TomatoPlantBlock extends CropBlock { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { if (hand == Hand.MAIN_HAND && isMature(state)) { if (player.getStackInHand(hand).isEmpty()) { @@ -126,11 +127,11 @@ public class TomatoPlantBlock extends CropBlock { world.setBlockState(pos, state.with(getAgeProperty(), 0)); - return true; + return ActionResult.SUCCESS; } } - return false; + return ActionResult.PASS; } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index 8cda718d..b45c771d 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -24,9 +24,9 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public interface UBlocks { - CloudBlock normal_cloud = register(new CloudBlock(UMaterials.CLOUD, CloudType.NORMAL), "cloud_block"); - CloudBlock enchanted_cloud = register(new CloudBlock(UMaterials.CLOUD, CloudType.ENCHANTED), "enchanted_cloud_block"); - CloudBlock packed_cloud = register(new CloudBlock(UMaterials.CLOUD, CloudType.PACKED), "packed_cloud_block"); + CloudBlock normal_cloud = register(new CloudBlock(CloudType.NORMAL), "cloud_block"); + CloudBlock enchanted_cloud = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block"); + CloudBlock packed_cloud = register(new CloudBlock(CloudType.PACKED), "packed_cloud_block"); CloudStairsBlock cloud_stairs = register(new CloudStairsBlock(normal_cloud.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs"); @@ -43,7 +43,7 @@ public interface UBlocks { CloudAnvilBlock anvil = register(new CloudAnvilBlock(), "anvil"); - CloudFenceBlock cloud_fence = register(new CloudFenceBlock(UMaterials.CLOUD, CloudType.NORMAL), "cloud_fence"); + CloudFenceBlock cloud_fence = register(new CloudFenceBlock(CloudType.NORMAL), "cloud_fence"); TallCropBlock alfalfa = register(new TallCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).build()), "alfalfa"); diff --git a/src/main/java/com/minelittlepony/unicopia/block/USlab.java b/src/main/java/com/minelittlepony/unicopia/block/USlab.java index e248ce66..6d039cda 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/USlab.java +++ b/src/main/java/com/minelittlepony/unicopia/block/USlab.java @@ -3,12 +3,12 @@ package com.minelittlepony.unicopia.block; import java.util.Random; import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.SlabBlock; import net.minecraft.block.enums.SlabType; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; @@ -37,20 +37,9 @@ public abstract class USlab extends SlabBlock { return state.get(TYPE) == SlabType.DOUBLE; } - @Deprecated @Override - public boolean isOpaque(BlockState state) { - return isDouble(state) && modelBlock != null && modelBlock.isOpaque(state); - } - - @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { - modelBlock.onScheduledTick(state, world, pos, rand); - } - - @Override - public BlockRenderLayer getRenderLayer() { - return modelBlock.getRenderLayer(); + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { + modelBlock.scheduledTick(state, world, pos, rand); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index 1239195c..b30dde8f 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -1,39 +1,39 @@ package com.minelittlepony.unicopia.client; +import com.minelittlepony.unicopia.client.particle.ChangelingMagicParticle; +import com.minelittlepony.unicopia.client.particle.DiskParticle; +import com.minelittlepony.unicopia.client.particle.MagicParticle; +import com.minelittlepony.unicopia.client.particle.RaindropsParticle; +import com.minelittlepony.unicopia.client.particle.SphereParticle; import com.minelittlepony.unicopia.client.render.ButterflyEntityRenderer; import com.minelittlepony.unicopia.client.render.CloudEntityRenderer; import com.minelittlepony.unicopia.client.render.CuccoonEntityRenderer; import com.minelittlepony.unicopia.client.render.RainbowEntityRenderer; import com.minelittlepony.unicopia.client.render.SpearEntityRenderer; -import com.minelittlepony.unicopia.client.render.RenderSpellbook; +import com.minelittlepony.unicopia.client.render.SpellbookEntityRender; import com.minelittlepony.unicopia.client.render.SpellcastEntityRenderer; -import com.minelittlepony.unicopia.entity.ButterflyEntity; -import com.minelittlepony.unicopia.entity.CloudEntity; -import com.minelittlepony.unicopia.entity.CuccoonEntity; -import com.minelittlepony.unicopia.entity.ProjectileEntity; -import com.minelittlepony.unicopia.entity.RainbowEntity; -import com.minelittlepony.unicopia.entity.SpearEntity; -import com.minelittlepony.unicopia.entity.SpellbookEntity; -import com.minelittlepony.unicopia.entity.SpellcastEntity; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; +import com.minelittlepony.unicopia.entity.UEntities; +import com.minelittlepony.unicopia.particles.UParticles; + +import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.FlyingItemEntityRenderer; public interface URenderers { static void bootstrap() { - EntityRendererRegistry.INSTANCE.register(CloudEntity.class, CloudEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(SpellcastEntity.class, SpellcastEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(ProjectileEntity.class, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer())); - EntityRendererRegistry.INSTANCE.register(SpellbookEntity.class, RenderSpellbook::new); - EntityRendererRegistry.INSTANCE.register(RainbowEntity.class, RainbowEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(ButterflyEntity.class, ButterflyEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(CuccoonEntity.class, CuccoonEntityRenderer::new); - EntityRendererRegistry.INSTANCE.register(SpearEntity.class, SpearEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.CLOUD, CloudEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.MAGIC_SPELL, SpellcastEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer())); + EntityRendererRegistry.INSTANCE.register(UEntities.SPELLBOOK, SpellbookEntityRender::new); + EntityRendererRegistry.INSTANCE.register(UEntities.RAINBOW, RainbowEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.BUTTERFLY, ButterflyEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.CUCCOON, CuccoonEntityRenderer::new); + EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_SPEAR, SpearEntityRenderer::new); - // TODO: ParticleFactoryRegistry - //ParticleFactoryRegistry.instance().register(UParticles.UNICORN_MAGIC, MagicParticle::new); - //ParticleFactoryRegistry.instance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle::new); - //ParticleFactoryRegistry.instance().register(UParticles.RAIN_DROPS, RaindropsParticle::new); - //ParticleFactoryRegistry.instance().register(UParticles.SPHERE, SphereParticle::new); - //ParticleFactoryRegistry.instance().register(UParticles.DISK, DiskParticle::new); + ParticleFactoryRegistry.getInstance().register(UParticles.UNICORN_MAGIC, MagicParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(UParticles.RAIN_DROPS, RaindropsParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle.Factory::new); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java index a2a95e39..6332e7d0 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java +++ b/src/main/java/com/minelittlepony/unicopia/client/UnicopiaClient.java @@ -13,7 +13,6 @@ import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.ability.Abilities; import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.client.render.DisguiseRenderer; import com.minelittlepony.unicopia.ducks.Colourful; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.UItems; @@ -21,10 +20,8 @@ import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.network.MsgRequestCapabilities; import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity; import com.mojang.authlib.GameProfile; -import com.mojang.blaze3d.platform.GlStateManager; - import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.render.ColorProviderRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.event.client.ClientTickCallback; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -36,7 +33,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ExtendedBlockView; +import net.minecraft.world.BlockRenderView; public class UnicopiaClient extends InteractionManager implements ClientModInitializer { @@ -52,6 +49,45 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti */ private static Race clientPlayerRace = getclientPlayerRace(); + @Override + public void onInitializeClient() { + clientPlayerRace = getclientPlayerRace(); + InteractionManager.instance = this; + + ClientTickCallback.EVENT.register(this::tick); + ClientReadyCallback.EVENT.register(client -> { + Abilities.getInstance().getValues().forEach(keyboard::addKeybind); + }); + + //BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem")); + + ColorProviderRegistry.ITEM.register((stack, tint) -> { + return getLeavesColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tint); + }, UItems.apple_leaves); + ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.apple_leaves); + ColorProviderRegistry.ITEM.register((stack, tint) -> { + if (MAGI.test(MinecraftClient.getInstance().player)) { + return SpellRegistry.instance().getSpellTintFromStack(stack); + } + return 0xFFFFFF; + }, UItems.spell, UItems.curse); + } + + private void tick(MinecraftClient client) { + PlayerEntity player = client.player; + + if (player != null && !player.removed) { + Race newRace = getclientPlayerRace(); + + if (newRace != clientPlayerRace) { + clientPlayerRace = newRace; + + Unicopia.getConnection().send(new MsgRequestCapabilities(player, clientPlayerRace), Target.SERVER); + } + } + + keyboard.onKeyInput(); + } private static Race getclientPlayerRace() { if (!Config.getInstance().ignoresMineLittlePony() && MinecraftClient.getInstance().player != null) { @@ -93,72 +129,7 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti return MinecraftClient.getInstance().options.perspective; } - public void postRenderEntity(Entity entity) { - if (entity instanceof PlayerEntity) { - Pony iplayer = Pony.of((PlayerEntity)entity); - - if (iplayer.getGravity().getGravitationConstant() < 0) { - GlStateManager.translated(0, entity.getDimensions(entity.getPose()).height, 0); - GlStateManager.scalef(1, -1, 1); - entity.prevPitch *= -1; - entity.pitch *= -1; - } - } - } - - public boolean renderEntity(Entity entity, float renderPartialTicks) { - - if (DisguiseRenderer.getInstance().renderDisguise(entity, renderPartialTicks)) { - return true; - } - - if (entity instanceof PlayerEntity) { - Pony iplayer = Pony.of((PlayerEntity)entity); - - if (iplayer.getGravity().getGravitationConstant() < 0) { - GlStateManager.scalef(1, -1, 1); - GlStateManager.translated(0, -entity.getDimensions(entity.getPose()).height, 0); - entity.prevPitch *= -1; - entity.pitch *= -1; - } - - if (DisguiseRenderer.getInstance().renderDisguiseToGui(iplayer)) { - return true; - } - - if (iplayer.isInvisible()) { - return true; - } - } - - return false; - } - - @Override - public void onInitializeClient() { - clientPlayerRace = getclientPlayerRace(); - InteractionManager.instance = this; - - ClientTickCallback.EVENT.register(this::tick); - ClientReadyCallback.EVENT.register(client -> { - Abilities.getInstance().getValues().forEach(keyboard::addKeybind); - }); - - //BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem")); - - ColorProviderRegistry.ITEM.register((stack, tint) -> { - return getLeavesColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tint); - }, UItems.apple_leaves); - ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.apple_leaves); - ColorProviderRegistry.ITEM.register((stack, tint) -> { - if (MAGI.test(MinecraftClient.getInstance().player)) { - return SpellRegistry.instance().getSpellTintFromStack(stack); - } - return 0xFFFFFF; - }, UItems.spell, UItems.curse); - } - - private static int getLeavesColor(BlockState state, @Nullable ExtendedBlockView world, @Nullable BlockPos pos, int tint) { + private static int getLeavesColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tint) { Block block = state.getBlock(); if (block instanceof Colourful) { @@ -172,19 +143,4 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti return GrassColors.getColor(0.5D, 1); } - private void tick(MinecraftClient client) { - PlayerEntity player = client.player; - - if (player != null && !player.removed) { - Race newRace = getclientPlayerRace(); - - if (newRace != clientPlayerRace) { - clientPlayerRace = newRace; - - Unicopia.getConnection().send(new MsgRequestCapabilities(player, clientPlayerRace), Target.SERVER); - } - } - - keyboard.onKeyInput(); - } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/ClientHooks.java b/src/main/java/com/minelittlepony/unicopia/client/gui/ClientHooks.java index 6a939483..7012dc9c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/ClientHooks.java +++ b/src/main/java/com/minelittlepony/unicopia/client/gui/ClientHooks.java @@ -2,20 +2,16 @@ package com.minelittlepony.unicopia.client.gui; import com.minelittlepony.unicopia.client.gui.UHud; import com.minelittlepony.unicopia.entity.player.Pony; -import com.mojang.blaze3d.platform.GlStateManager; - import net.minecraft.client.MinecraftClient; @Deprecated // TODO: forge events class ClientHooks { public static void beforePreRenderHud() { - GlStateManager.pushMatrix(); - MinecraftClient client = MinecraftClient.getInstance(); if (client.player != null && client.world != null) { - UHud.instance.repositionElements(Pony.of(client.player), client.window, true); + UHud.instance.repositionElements(Pony.of(client.player), client.getWindow(), true); } } @@ -24,9 +20,7 @@ class ClientHooks { MinecraftClient client = MinecraftClient.getInstance(); if (client.player != null && client.world != null) { - UHud.instance.renderHud(Pony.of(client.player), client.window); + UHud.instance.renderHud(Pony.of(client.player), client.getWindow()); } - - GlStateManager.popMatrix(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java index 769ee723..4515c7e5 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/ChangelingMagicParticle.java @@ -5,7 +5,7 @@ import net.fabricmc.api.Environment; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.particle.DustParticleEffect; +import net.minecraft.particle.DefaultParticleType; import net.minecraft.world.World; public class ChangelingMagicParticle extends MagicParticle { @@ -31,7 +31,7 @@ public class ChangelingMagicParticle extends MagicParticle { } @Environment(EnvType.CLIENT) - public static class Factory implements ParticleFactory { + public static class Factory implements ParticleFactory { private final SpriteProvider provider; public Factory(SpriteProvider provider) { @@ -39,7 +39,7 @@ public class ChangelingMagicParticle extends MagicParticle { } @Override - public Particle createParticle(DustParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) { + public Particle createParticle(DefaultParticleType effect, World world, double x, double y, double z, double dx, double dy, double dz) { MagicParticle particle = new MagicParticle(world, x, y, z, dx, dy, dz); particle.setSprite(provider); return particle; diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java index ca629593..2ddac01d 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/DiskParticle.java @@ -1,28 +1,28 @@ package com.minelittlepony.unicopia.client.particle; -import net.minecraft.client.render.BufferBuilder; +import com.minelittlepony.unicopia.client.render.model.DiskModel; + +import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.Camera; -import net.minecraft.particle.ParticleEffect; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.world.World; -import org.lwjgl.opengl.GL14; - -import com.minelittlepony.unicopia.client.render.DiskModel; -import com.mojang.blaze3d.platform.GlStateManager; - public class DiskParticle extends SphereParticle { private static final DiskModel model = new DiskModel(); - protected double rotX; - protected double rotY; - protected double rotZ; + protected float rotX; + protected float rotY; + protected float rotZ; - public DiskParticle(ParticleEffect type, World w, + public DiskParticle(World w, double x, double y, double z, float radius, int red, int green, int blue, float alpha, - double rX, double rY, double rZ) { + float rX, float rY, float rZ) { super(w, x, y, z, radius, red, green, blue, alpha); rotX = rX; @@ -31,17 +31,17 @@ public class DiskParticle extends SphereParticle { } @Override - public void buildGeometry(BufferBuilder buffer, Camera viewer, float partialTicks, float x, float z, float yz, float xy, float xz) { + public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) { if (alpha <= 0) { return; } - GL14.glBlendColor(red, green, blue, alpha); - - model.setPosition(this.x, this.y, this.z); - model.render(radius); - - GlStateManager.color4f(1, 1, 1, 1); + MatrixStack matrices = new MatrixStack(); + VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); + model.setPosition(x, y, z); + model.setRotation(rotX, rotY, rotZ); + model.render(matrices, radius, immediate.getBuffer(RenderLayer.getTranslucent()), 1, 1, red, green, blue, alpha); + immediate.draw(); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java index 1277b257..d67ddf38 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/MagicParticle.java @@ -1,13 +1,14 @@ package com.minelittlepony.unicopia.client.particle; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.particle.v1.FabricSpriteProvider; import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteBillboardParticle; -import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.particle.DustParticleEffect; import net.minecraft.world.World; public class MagicParticle extends SpriteBillboardParticle { @@ -96,16 +97,16 @@ public class MagicParticle extends SpriteBillboardParticle { } @Environment(EnvType.CLIENT) - public static class Factory implements ParticleFactory { - private final SpriteProvider provider; + public static class Factory implements ParticleFactory { + private final FabricSpriteProvider provider; - public Factory(SpriteProvider provider) { + public Factory(FabricSpriteProvider provider) { this.provider = provider; } @Override - public Particle createParticle(DustParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) { - MagicParticle particle = effect.getAlpha() > 0 ? + public Particle createParticle(MagicParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) { + MagicParticle particle = effect.hasTint() ? new MagicParticle(world, x, y, z, dx, dy, dz, effect.getRed(), effect.getGreen(), effect.getBlue()) : new MagicParticle(world, x, y, z, dx, dy, dz); particle.setSprite(provider); diff --git a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java index 2b590e2b..2e7c244a 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java +++ b/src/main/java/com/minelittlepony/unicopia/client/particle/SphereParticle.java @@ -5,20 +5,18 @@ import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.SpriteProvider; -import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Camera; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; import net.minecraft.particle.DefaultParticleType; -import net.minecraft.particle.ParticleEffect; import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import com.minelittlepony.unicopia.client.render.SphereModel; +import com.minelittlepony.unicopia.client.render.model.SphereModel; import com.minelittlepony.unicopia.magic.Caster; -import com.minelittlepony.unicopia.util.particles.ParticleConnection.AttachableParticle; -import com.mojang.blaze3d.platform.GlStateManager; +import com.minelittlepony.unicopia.particles.ParticleConnection.AttachableParticle; public class SphereParticle extends Particle implements AttachableParticle { @@ -33,11 +31,7 @@ public class SphereParticle extends Particle implements AttachableParticle { private static final SphereModel model = new SphereModel(); - public SphereParticle(ParticleEffect type, World w, - double x, double y, double z, - float radius, - int red, int green, int blue, float alpha, - double vX, double vY, double vZ) { + public SphereParticle(World w, double x, double y, double z, float radius, int red, int green, int blue, float alpha, double vX, double vY, double vZ) { this(w, x, y, z, radius, red, green, blue, alpha); this.velocityX = vX; @@ -68,66 +62,6 @@ public class SphereParticle extends Particle implements AttachableParticle { this.caster = caster; } - @Override - public ParticleTextureSheet getType() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void tick() { - super.tick(); - - if (caster != null) { - if (!caster.hasEffect() || caster.getEffect().isDead() || caster.getEntity().removed) { - markDead(); - } else { - Entity e = caster.getEntity(); - - if (caster.getWorld().getEntityById(e.getEntityId()) == null) { - markDead(); - } - - setPos(e.x, e.y, e.z); - } - } else { - radius *= 0.9998281; - } - } - - @Override - public void buildGeometry(BufferBuilder buffer, Camera viewer, float partialTicks, float x, float z, float yz, float xy, float xz) { - if (alpha <= 0 || radius <= 0) { - return; - } - - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - GlStateManager.depthMask(false); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - - GlStateManager.enableAlphaTest(); - GlStateManager.enableBlend(); - MinecraftClient.getInstance().gameRenderer.disableLightmap(); - GlStateManager.enableLighting(); - - GL14.glBlendColor(red, green, blue, alpha); - - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.disableTexture(); - - model.setPosition(this.x, this.y, this.z); - model.render(radius); - - GlStateManager.enableTexture(); - GlStateManager.disableLighting(); - MinecraftClient.getInstance().gameRenderer.enableLightmap(); - - GlStateManager.disableBlend(); - GlStateManager.depthMask(true); - GlStateManager.color4f(1, 1, 1, 1); - GL11.glPopAttrib(); - } - @Override public void setAttribute(int key, Object value) { if (key == 0) { @@ -147,6 +81,45 @@ public class SphereParticle extends Particle implements AttachableParticle { } } + @Override + public ParticleTextureSheet getType() { + return ParticleTextureSheet.CUSTOM; + } + + @Override + public void tick() { + super.tick(); + + if (caster != null) { + if (!caster.hasEffect() || caster.getEffect().isDead() || caster.getEntity().removed) { + markDead(); + } else { + Entity e = caster.getEntity(); + + if (caster.getWorld().getEntityById(e.getEntityId()) == null) { + markDead(); + } + + setPos(e.getX(), e.getY(), e.getZ()); + } + } else { + radius *= 0.9998281; + } + } + + @Override + public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) { + if (alpha <= 0 || radius <= 0) { + return; + } + + MatrixStack matrices = new MatrixStack(); + VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers(); + model.setPosition(x, y, z); + model.render(matrices, radius, immediate.getBuffer(RenderLayer.getTranslucent()), 1, 1, red, green, blue, alpha); + immediate.draw(); + } + public static class Factory implements ParticleFactory { private final SpriteProvider provider; @@ -155,7 +128,7 @@ public class SphereParticle extends Particle implements AttachableParticle { } @Override - public Particle createParticle(DefaultParticleType defaultParticleType_1, World world, double x, double y, double z, double dx, double dy, double dz) { + public Particle createParticle(DefaultParticleType type, World world, double x, double y, double z, double dx, double dy, double dz) { RaindropsParticle particle = new RaindropsParticle(world, x, y, z, dx, dy, dz); particle.setSprite(provider); return particle; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java index 016c5ca8..a1dec684 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/ButterflyEntityRenderer.java @@ -2,11 +2,11 @@ package com.minelittlepony.unicopia.client.render; import com.minelittlepony.unicopia.client.render.model.ButterflyEntityModel; import com.minelittlepony.unicopia.entity.ButterflyEntity; -import com.mojang.blaze3d.platform.GlStateManager; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; @@ -17,22 +17,22 @@ public class ButterflyEntityRenderer extends LivingEntityRenderer quadList = new ArrayList<>(); - - public ModelQuads addFace(Vertex... vertices) { - quadList.add(new TexturedShape2d(vertices)); - - return this; - } - - @Override - public void render(BufferBuilder renderer, float scale) { - for (Quad i : quadList) { - i.render(renderer, scale); - } - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/RainbowEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/RainbowEntityRenderer.java index a2020394..b74a5821 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/RainbowEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/RainbowEntityRenderer.java @@ -4,9 +4,11 @@ import org.lwjgl.opengl.GL11; import com.minelittlepony.unicopia.entity.RainbowEntity; import com.minelittlepony.unicopia.util.WorldHelper; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.platform.GlStateManager.DstFactor; +import com.mojang.blaze3d.platform.GlStateManager.SrcFactor; +import com.mojang.blaze3d.systems.RenderSystem; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Tessellator; @@ -23,7 +25,12 @@ public class RainbowEntityRenderer extends EntityRenderer { private static final Identifier TEXTURE = new Identifier("unicopia", "textures/environment/rainbow.png"); - public void doRender(RainbowEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { + @Override + public Identifier getTexture(RainbowEntity entity) { + return TEXTURE; + } + + public void render(RainbowEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { float distance = MinecraftClient.getInstance().getCameraEntity().distanceTo(entity); float maxDistance = 16 * MinecraftClient.getInstance().options.viewDistance; double r = entity.getRadius(); @@ -37,39 +44,31 @@ public class RainbowEntityRenderer extends EntityRenderer { return; } - bindEntityTexture(entity); + RenderSystem.pushMatrix(); + RenderSystem.disableLighting(); + RenderSystem.disableCull(); + RenderSystem.enableBlend(); + RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.pushMatrix(); - GlStateManager.disableLighting(); - GlStateManager.disableCull(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + RenderSystem.translated(x, y, z); + RenderSystem.rotatef(entityYaw, 0, 1, 0); - GlStateManager.translated(x, y, z); - GlStateManager.rotatef(entityYaw, 0, 1, 0); - - GlStateManager.color4f(1, 1, 1, opacity); + RenderSystem.color4f(1, 1, 1, opacity); Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBufferBuilder(); + BufferBuilder bufferbuilder = tessellator.getBuffer(); - bufferbuilder.begin(GL11.GL_QUADS, VertexFormats.POSITION_UV); - bufferbuilder.vertex(-r, r, 0).texture(1, 0).end(); - bufferbuilder.vertex( r, r, 0).texture(0, 0).end(); - bufferbuilder.vertex( r, 0, 0).texture(0, 1).end(); - bufferbuilder.vertex(-r, 0, 0).texture(1, 1).end(); + bufferbuilder.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE); + bufferbuilder.vertex(-r, r, 0).texture(1, 0).next(); + bufferbuilder.vertex( r, r, 0).texture(0, 0).next(); + bufferbuilder.vertex( r, 0, 0).texture(0, 1).next(); + bufferbuilder.vertex(-r, 0, 0).texture(1, 1).next(); tessellator.draw(); - GlStateManager.disableBlend(); - GlStateManager.enableCull(); - GlStateManager.enableLighting(); - GlStateManager.popMatrix(); + RenderSystem.disableBlend(); + RenderSystem.enableCull(); + RenderSystem.enableLighting(); + RenderSystem.popMatrix(); } - - @Override - protected Identifier getTexture(RainbowEntity entity) { - return TEXTURE; - } - } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/RenderSpellbook.java b/src/main/java/com/minelittlepony/unicopia/client/render/RenderSpellbook.java deleted file mode 100644 index 3cf1a5aa..00000000 --- a/src/main/java/com/minelittlepony/unicopia/client/render/RenderSpellbook.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.minelittlepony.unicopia.client.render; - -import com.minelittlepony.unicopia.client.render.model.SpellbookModel; -import com.minelittlepony.unicopia.entity.SpellbookEntity; -import com.mojang.blaze3d.platform.GlStateManager; - -import net.minecraft.util.math.MathHelper; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.render.entity.LivingEntityRenderer; -import net.minecraft.util.Identifier; - -public class RenderSpellbook extends LivingEntityRenderer { - - private static final Identifier BLUE = new Identifier("unicopia", "textures/entity/enchanting_table_book_blue.png"); - private static final Identifier NORMAL = new Identifier("unicopia", "textures/entity/enchanting_table_book.png"); - - public RenderSpellbook(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) { - super(manager, new SpellbookModel(), 0); - } - - @Override - protected Identifier getTexture(SpellbookEntity entity) { - return entity.getIsAltered() ? BLUE : NORMAL; - } - - @Override - protected float getLyingAngle(SpellbookEntity entity) { - return 0; - } - - @Override - protected void render(SpellbookEntity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float increment) { - - float breath = MathHelper.sin((entity.age + stutter) / 20) * 0.01F + 0.1F; - - float first_page_rot = walkSpeed + (breath * 10); - float second_page_rot = 1 - first_page_rot; - float open_angle = 0.9f - walkSpeed; - - if (first_page_rot > 1) first_page_rot = 1; - if (second_page_rot > 1) second_page_rot = 1; - - if (!entity.getIsOpen()) { - GlStateManager.translatef(0, 1.44f, 0); - } else { - GlStateManager.translatef(0, 1.2f + breath, 0); - } - GlStateManager.pushMatrix(); - - if (!entity.getIsOpen()) { - first_page_rot = second_page_rot = open_angle = 0; - GlStateManager.rotatef(90.0F, 1.0F, 0.0F, 0.0F); - GlStateManager.rotatef(90.0F, 0.0F, 0.0F, 1.0F); - GlStateManager.translatef(-0.25f, 0, 0); - } else { - GlStateManager.rotatef(-60.0F, 0.0F, 0.0F, 1.0F); - } - - GlStateManager.enableCull(); - super.render(entity, 0, first_page_rot, second_page_rot, open_angle, 0, 0.0625F); - - GlStateManager.popMatrix(); - } - - @Override - protected void setupTransforms(SpellbookEntity entity, float p_77043_2_, float p_77043_3_, float partialTicks) { - GlStateManager.rotatef(-MathHelper.lerp(entity.prevYaw, entity.yaw, partialTicks), 0, 1, 0); - } - - @Override - protected boolean hasLabel(SpellbookEntity targetEntity) { - return super.hasLabel(targetEntity) - && (targetEntity.isCustomNameVisible() - || targetEntity.hasCustomName() - && targetEntity == renderManager.targetedEntity); - } -} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/SpearEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/SpearEntityRenderer.java index 820a1aed..6d11db4e 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/SpearEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/SpearEntityRenderer.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.client.render; import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.entity.SpearEntity; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.ProjectileEntityRenderer; import net.minecraft.util.Identifier; @@ -16,7 +16,7 @@ public class SpearEntityRenderer extends ProjectileEntityRenderer { } @Override - protected Identifier getTexture(SpearEntity entity) { + public Identifier getTexture(SpearEntity entity) { return TEXTURE; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/SpellbookEntityRender.java b/src/main/java/com/minelittlepony/unicopia/client/render/SpellbookEntityRender.java new file mode 100644 index 00000000..b347cfff --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/client/render/SpellbookEntityRender.java @@ -0,0 +1,59 @@ +package com.minelittlepony.unicopia.client.render; + +import com.minelittlepony.unicopia.client.render.model.SpellbookModel; +import com.minelittlepony.unicopia.entity.SpellbookEntity; +import net.minecraft.util.math.MathHelper; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.util.math.Vector3f; +import net.minecraft.util.Identifier; + +public class SpellbookEntityRender extends LivingEntityRenderer { + + private static final Identifier BLUE = new Identifier("unicopia", "textures/entity/enchanting_table_book_blue.png"); + private static final Identifier NORMAL = new Identifier("unicopia", "textures/entity/enchanting_table_book.png"); + + public SpellbookEntityRender(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) { + super(manager, new SpellbookModel(), 0); + } + + @Override + public Identifier getTexture(SpellbookEntity entity) { + return entity.getIsAltered() ? BLUE : NORMAL; + } + + @Override + protected float getLyingAngle(SpellbookEntity entity) { + return 0; + } + + @Override + protected void setupTransforms(SpellbookEntity entity, MatrixStack matrices, float p_77043_2_, float p_77043_3_, float partialTicks) { + + if (!entity.getIsOpen()) { + matrices.translate(0, 1.44f, 0); + } else { + matrices.translate(0, 1.2f + MathHelper.sin((entity.age + partialTicks) / 20) * 0.01F + 0.1F, 0); + } + + if (!entity.getIsOpen()) { + matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90)); + matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(90)); + matrices.translate(-0.25f, 0, 0); + } else { + matrices.multiply(Vector3f.NEGATIVE_Z.getDegreesQuaternion(60)); + } + + matrices.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(MathHelper.lerp(entity.prevYaw, entity.yaw, partialTicks))); + } + + @Override + protected boolean hasLabel(SpellbookEntity targetEntity) { + return super.hasLabel(targetEntity) + && (targetEntity.isCustomNameVisible() + || targetEntity.hasCustomName() + && targetEntity == renderManager.targetedEntity); + } +} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/SpellcastEntityRenderer.java b/src/main/java/com/minelittlepony/unicopia/client/render/SpellcastEntityRenderer.java index eb14bcaf..380223f1 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/SpellcastEntityRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/SpellcastEntityRenderer.java @@ -2,39 +2,86 @@ package com.minelittlepony.unicopia.client.render; import com.minelittlepony.unicopia.client.render.model.GemEntityModel; import com.minelittlepony.unicopia.entity.SpellcastEntity; +import com.mojang.blaze3d.platform.GlStateManager; -import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; -import net.minecraft.client.render.VisibleRegion; +import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry; +import net.minecraft.client.render.Frustum; +import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.LivingEntityRenderer; +import net.minecraft.client.render.entity.feature.FeatureRenderer; +import net.minecraft.client.render.entity.feature.FeatureRendererContext; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; public class SpellcastEntityRenderer extends LivingEntityRenderer { - private static final Identifier gem = new Identifier("unicopia", "textures/entity/gem.png"); + private static final Identifier TEXTURE = new Identifier("unicopia", "textures/entity/gem.png"); public SpellcastEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) { super(manager, new GemEntityModel(), 0); + addFeature(new TierFeature(this)); } @Override - protected Identifier getTexture(SpellcastEntity entity) { - return gem; + public Identifier getTexture(SpellcastEntity entity) { + return TEXTURE; } @Override - public boolean isVisible(SpellcastEntity livingEntity, VisibleRegion camera, double camX, double camY, double camZ) { + public boolean shouldRender(SpellcastEntity entity, Frustum visibleRegion, double cameraX, double cameraY, double cameraZ) { return true; } @Override protected float getLyingAngle(SpellcastEntity entity) { + return 0; } + @Override + public void render(SpellcastEntity livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { + super.render(livingEntity, f, g, matrixStack, vertexConsumerProvider, i); + } + @Override protected boolean hasLabel(SpellcastEntity targetEntity) { return super.hasLabel(targetEntity) && (targetEntity.isCustomNameVisible() || targetEntity.hasCustomName() && targetEntity == renderManager.targetedEntity); } + + class TierFeature extends FeatureRenderer { + + public TierFeature(FeatureRendererContext context) { + super(context); + } + + @Override + public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, SpellcastEntity entity, float limbAngle, float limbDistance, float tickDelta, float customAngle, float headYaw, float headPitch) { + + int tiers = Math.min(entity.getCurrentLevel(), 5); + + for (int i = 0; i <= tiers; i++) { + float grow = (1 + i) * 0.2F; + + matrices.scale(1 + grow, 1 + grow, 1 + grow); + matrices.translate(0, -grow, 0); + + if (i == 5) { + matrices.push(); + matrices.translate(0.6F, 0.8F, 0); + matrices.scale(0.4F, 0.4F, 0.4F); + FeatureRenderer.render(model, model, TEXTURE, matrices, vertexConsumers, light, entity, limbAngle, limbDistance, entity.age, headYaw, headPitch, 1, 1, 1, 1); + matrices.pop(); + } + } + + for (int i = entity.getCurrentLevel(); i > 0; i--) { + matrices.push(); + GlStateManager.translatef(0.6F, 0, 0); + FeatureRenderer.render(model, model, TEXTURE, matrices, vertexConsumers, light, entity, limbAngle, limbDistance, entity.age, headYaw, headPitch, 1, 1, 1, 1); + matrices.pop(); + } + } + } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/SphereModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/SphereModel.java deleted file mode 100644 index b96918c4..00000000 --- a/src/main/java/com/minelittlepony/unicopia/client/render/SphereModel.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.minelittlepony.unicopia.client.render; - -import org.lwjgl.opengl.GL11; - -import com.mojang.blaze3d.platform.GlStateManager; - -import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; -import net.minecraft.client.util.GlAllocationUtils; - -public class SphereModel { - - private int displayList; - private boolean baked; - - protected double posX; - protected double posY; - protected double posZ; - - protected float rotX; - protected float rotY; - protected float rotZ; - - public void setPosition(double x, double y, double z) { - posX = x - BlockEntityRenderDispatcher.renderOffsetX; - posY = y - BlockEntityRenderDispatcher.renderOffsetY; - posZ = z - BlockEntityRenderDispatcher.renderOffsetZ; - } - - public void setRotation(float x, float y, float z) { - rotX = x; - rotY = y; - rotZ = z; - } - - public void render(float scale) { - if (scale == 0) { - return; - } - - if (!baked) { - baked = true; - bake(); - } - - GlStateManager.pushMatrix(); - - if (posX != 0 && posY != 9 && posZ != 0) { - GlStateManager.translated(posX, posY, posZ); - } - - glRotate(rotX, 1, 0, 0); - glRotate(rotY, 0, 1, 0); - glRotate(rotZ, 0, 0, 1); - - GlStateManager.scalef(scale, scale, scale); - - GlStateManager.callList(displayList); - - GlStateManager.popMatrix(); - } - - private void bake() { - displayList = GlAllocationUtils.genLists(1); - GlStateManager.newList(displayList, GL11.GL_COMPILE); - - drawShape(); - - GlStateManager.endList(); - } - - protected void drawShape() { - - /*Sphere sphere = new Sphere(); - - sphere.setDrawStyle(GLU.GLU_FILL); - sphere.setNormals(GLU.GLU_SMOOTH); - sphere.draw(1, 32, 32);*/ - // TODO: GLU Sphere - } - - static void glRotate(float angle, float x, float y, float z) { - if (angle != 0) { - GlStateManager.rotatef(angle, x, y, z); - } - } - -} diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/TexturedShape2d.java b/src/main/java/com/minelittlepony/unicopia/client/render/TexturedShape2d.java deleted file mode 100644 index 26fc3f54..00000000 --- a/src/main/java/com/minelittlepony/unicopia/client/render/TexturedShape2d.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.minelittlepony.unicopia.client.render; - -import net.minecraft.client.model.Quad; -import net.minecraft.client.model.Vertex; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.Tessellator; -import net.minecraft.client.render.VertexFormats; -import net.minecraft.util.math.Vec3d; - -public class TexturedShape2d extends Quad { - - protected boolean invertNormal; - - public TexturedShape2d(Vertex... vertices) { - super(vertices); - } - - public TexturedShape2d(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) { - super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight); - } - - public TexturedShape2d setInvertNormal() { - invertNormal = true; - return this; - } - - @Override - public void render(BufferBuilder renderer, float scale) { - Vec3d vec3d = vertices[1].pos.reverseSubtract(vertices[0].pos); - Vec3d vec3d1 = vertices[1].pos.reverseSubtract(vertices[2].pos); - Vec3d vec3d2 = vec3d1.crossProduct(vec3d).normalize(); - float f = (float)vec3d2.x; - float f1 = (float)vec3d2.y; - float f2 = (float)vec3d2.z; - - if (invertNormal) { - f = -f; - f1 = -f1; - f2 = -f2; - } - - renderer.begin(7, VertexFormats.POSITION_UV_NORMAL); - - for (int i = 0; i < vertexCount; ++i) { - Vertex positiontexturevertex = vertices[i]; - renderer - .vertex(positiontexturevertex.pos.x * scale, positiontexturevertex.pos.y * scale, positiontexturevertex.pos.z * scale) - .texture(positiontexturevertex.u, positiontexturevertex.v) - .normal(f, f1, f2) - .end(); - } - - Tessellator.getInstance().draw(); - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java index 321266ef..4c4e1fef 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/ButterflyEntityModel.java @@ -1,73 +1,70 @@ package com.minelittlepony.unicopia.client.render.model; import com.minelittlepony.unicopia.entity.ButterflyEntity; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.model.Cuboid; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.MathHelper; public class ButterflyEntityModel extends EntityModel { - private Cuboid body; + private ModelPart body; - private Cuboid leftWingInner; - private Cuboid leftWingOuter; + private ModelPart leftWingInner; + private ModelPart leftWingOuter; - private Cuboid rightWingInner; - private Cuboid rightWingOuter; + private ModelPart rightWingInner; + private ModelPart rightWingOuter; public ButterflyEntityModel() { textureWidth = 64; textureHeight = 64; - body = new Cuboid(this, 0, 0); - body.rotationPointZ = -10; - body.rotationPointY = 12; + body = new ModelPart(this, 0, 0); + body.pivotX = -10; + body.pivotY = 12; - rightWingInner = new Cuboid(this, 42, 0); + rightWingInner = new ModelPart(this, 42, 0); rightWingInner.roll = -0.2F; - rightWingInner.addBox(-13, -5, 0, 10, 19, 1); + rightWingInner.addCuboid(-13, -5, 0, 10, 19, 1); body.addChild(rightWingInner); - rightWingOuter = new Cuboid(this, 24, 16); - rightWingOuter.setRotationPoint(-13, 10, 0.1F); + rightWingOuter = new ModelPart(this, 24, 16); + rightWingOuter.setPivot(-13, 10, 0.1F); rightWingOuter.roll = -0.2F; - rightWingOuter.addBox(0, 0, 0, 10, 12, 1); + rightWingOuter.addCuboid(0, 0, 0, 10, 12, 1); rightWingInner.addChild(rightWingOuter); - leftWingInner = new Cuboid(this, 42, 0); + leftWingInner = new ModelPart(this, 42, 0); leftWingInner.mirror = true; leftWingInner.roll = 0.2F; - leftWingInner.addBox(2, -5, 0, 10, 19, 1); + leftWingInner.addCuboid(2, -5, 0, 10, 19, 1); body.addChild(leftWingInner); - leftWingOuter = new Cuboid(this, 24, 16); + leftWingOuter = new ModelPart(this, 24, 16); leftWingOuter.mirror = true; leftWingOuter.roll = -0.2F; - leftWingOuter.setRotationPoint(2, 10, 0.1F); - leftWingOuter.addBox(0, 0, 0, 10, 12, 1); + leftWingOuter.setPivot(2, 10, 0.1F); + leftWingOuter.addCuboid(0, 0, 0, 10, 12, 1); leftWingInner.addChild(leftWingOuter); } @Override - public void render(ButterflyEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - - setAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); - - GlStateManager.disableLighting(); - - body.render(scale); - - GlStateManager.enableLighting(); + public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + RenderSystem.disableLighting(); + body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); + RenderSystem.enableLighting(); } @Override - public void setAngles(ButterflyEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) { + public void setAngles(ButterflyEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float headYaw, float headPitch) { float flap = MathHelper.cos(ageInTicks) * (float)Math.PI / 4; diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java index ad970229..a8c2404c 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/CloudEntityModel.java @@ -1,32 +1,37 @@ package com.minelittlepony.unicopia.client.render.model; +import com.google.common.collect.ImmutableList; import com.minelittlepony.unicopia.entity.CloudEntity; -import net.minecraft.client.model.Cuboid; -import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.entity.model.CompositeEntityModel; -public class CloudEntityModel extends EntityModel { +public class CloudEntityModel extends CompositeEntityModel { - private final Cuboid body; + private final ModelPart body; public CloudEntityModel() { - body = new Cuboid(this, 0, 0); + body = new ModelPart(this, 0, 0); body.setTextureSize(250, 90); body.setTextureOffset(0, 0); - body.addBox(-24, 5, -24, 48, 10, 48); + body.addCuboid(-24, 5, -24, 48, 10, 48); body.setTextureOffset(0, 58); - body.addBox(-10, 14.999F, -10, 30, 2, 30); + body.addCuboid(-10, 14.999F, -10, 30, 2, 30); body.setTextureOffset(120, 58); - body.addBox(-10, 3.001F, -10, 30, 2, 30); + body.addCuboid(-10, 3.001F, -10, 30, 2, 30); - body.rotationPointY += 4.2; + body.pivotY += 4.2; } @Override - public void render(CloudEntity cloud, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - body.render(scale); + public Iterable getParts() { + return ImmutableList.of(body); + } + + @Override + public void setAngles(CloudEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/CuccoonEntityModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/CuccoonEntityModel.java index 6aa0feca..afcc7be6 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/CuccoonEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/CuccoonEntityModel.java @@ -1,68 +1,65 @@ package com.minelittlepony.unicopia.client.render.model; import com.minelittlepony.unicopia.entity.CuccoonEntity; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.platform.GlStateManager.DestFactor; -import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; +import com.mojang.blaze3d.platform.GlStateManager.DstFactor; +import com.mojang.blaze3d.platform.GlStateManager.SrcFactor; +import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.model.Cuboid; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; public class CuccoonEntityModel extends EntityModel { - private final Cuboid body; + private final ModelPart body; + + private float breatheAmount; public CuccoonEntityModel() { - body = new Cuboid(this, 0, 0); + body = new ModelPart(this, 0, 0); body.setTextureSize(250, 250); body.setTextureOffset(0, 0); // cuccoon shape - body.addBox(-4, -2, -4, 8, 2, 8); - body.addBox(-7.5F, 0, -7.5F, 15, 6, 15); - body.addBox(-10, 4, -10, 20, 6, 20); - body.addBox(-11.5F, 10, -11.5F, 23, 8, 23); - body.addBox(-10, 17, -10, 20, 6, 20); - body.addBox(-11.5F, 22, -11.5F, 23, 2, 23); - - - // pile of blocks - // body.addBox(-10, offsetY + 10, -10, 12, 12, 12); - // body.addBox(-14, offsetY + 14, 4, 10, 10, 10); - // body.addBox(-17, offsetY + 17, 3, 8, 8, 8); - // body.addBox(0, offsetY + 10, 0, 12, 12, 12); - // body.addBox(-7, offsetY + 6, -7, 16, 16, 16); - // body.addBox(-7, offsetY + 0, -7, 12, 12, 12); + body.addCuboid(-4, -2, -4, 8, 2, 8); + body.addCuboid(-7.5F, 0, -7.5F, 15, 6, 15); + body.addCuboid(-10, 4, -10, 20, 6, 20); + body.addCuboid(-11.5F, 10, -11.5F, 23, 8, 23); + body.addCuboid(-10, 17, -10, 20, 6, 20); + body.addCuboid(-11.5F, 22, -11.5F, 23, 2, 23); } @Override - public void render(CuccoonEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + matrices.push(); - float breatheAmount = entity.getBreatheAmount(ageInTicks) / 8; + RenderSystem.enableBlend(); + RenderSystem.enableAlphaTest(); + RenderSystem.enableRescaleNormal(); - GlStateManager.pushMatrix(); + RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.enableBlend(); - GlStateManager.enableAlphaTest(); - GlStateManager.enableNormalize(); + matrices.scale(1 - breatheAmount, 1 + breatheAmount, 1 - breatheAmount); + matrices.translate(0, -breatheAmount * 1.3F, 0); - GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); + body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); - GlStateManager.scalef(1 - breatheAmount, 1 + breatheAmount, 1 - breatheAmount); - GlStateManager.translatef(0, -breatheAmount * 1.3F, 0); + matrices.scale(0.9F, 0.9F, 0.9F); + matrices.translate(0, 0.2F, 0); - body.render(scale); + body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); - GlStateManager.scalef(0.9F, 0.9F, 0.9F); - GlStateManager.translatef(0, 0.2F, 0); + RenderSystem.disableRescaleNormal(); + RenderSystem.disableAlphaTest(); + RenderSystem.disableBlend(); - body.render(scale); + matrices.pop(); + } - GlStateManager.disableNormalize(); - GlStateManager.disableAlphaTest(); - GlStateManager.disableBlend(); - - GlStateManager.popMatrix(); + @Override + public void setAngles(CuccoonEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { + breatheAmount = entity.getBreatheAmount(customAngle) / 8; } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/DiskModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/DiskModel.java new file mode 100644 index 00000000..84bb6fdd --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/DiskModel.java @@ -0,0 +1,23 @@ +package com.minelittlepony.unicopia.client.render.model; + +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.util.math.Matrix4f; +import net.minecraft.client.util.math.MatrixStack; + +public class DiskModel extends SphereModel { + + @Override + public void render(MatrixStack.Entry matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) { + Matrix4f model = matrices.getModel(); + + final double num_rings = 30; + final double zenithIncrement = Math.PI / num_rings; + + double radius = 1; + + for(double zenith = 0; zenith < Math.PI; zenith += zenithIncrement) { + drawVertex(model, vertexWriter, radius, zenith, Math.PI, light, overlay, r, g, b, a); + } + } + +} diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java index ac7a8a43..cbefae22 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/GemEntityModel.java @@ -1,82 +1,42 @@ package com.minelittlepony.unicopia.client.render.model; -import com.minelittlepony.unicopia.client.render.ModelQuads; import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.util.Color; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; - -import net.minecraft.client.model.Cuboid; -import net.minecraft.client.model.Vertex; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.EntityPose; import net.minecraft.util.math.MathHelper; public class GemEntityModel extends EntityModel { - private Cuboid body; + private ModelPart body; + + private int tint; public GemEntityModel() { textureWidth = 256; textureHeight = 256; - body = new Cuboid(this); - body.y = 1.2f; - - int size = 1; - - body.boxes.add(new ModelQuads(body).addFace( - new Vertex( size, 0, size, 0, 0.5f), - new Vertex(-size, 0, size, 0.25f, 0.25f), - new Vertex( 0, size * 2, 0, 0, 0.25f), - new Vertex( 0, size * 2, 0, 0, 0.25f) - ).addFace( - new Vertex( size, 0, size, 0, 0.25f), - new Vertex(-size, 0, size, 0.25f, 0), - new Vertex( 0, -size * 2, 0, 0.25f, 0.25f), - new Vertex( 0, -size * 2, 0, 0.25f, 0.25f) - ).addFace( - new Vertex(size, 0, -size, 0.25f, 0.5f), - new Vertex(size, 0, size, 0.5f, 0.25f), - new Vertex(0, size * 2, 0, 0.25f, 0.25f), - new Vertex(0, size * 2, 0, 0.25f, 0.25f) - ).addFace( - new Vertex(size, 0, -size, 0.25f, 0.25f), - new Vertex(size, 0, size, 0.5f, 0), - new Vertex(0, -size * 2, 0, 0.5f, 0.25f), - new Vertex(0, -size * 2, 0, 0.5f, 0.25f) - ).addFace( - new Vertex(-size, 0, -size, 0.5f, 0.5f), - new Vertex( size, 0, -size, 0.75f, 0.25f), - new Vertex( 0, size * 2, 0, 0.5f, 0.25f), - new Vertex( 0, size * 2, 0, 0.5f, 0.25f) - ).addFace( - new Vertex(-size, 0, -size, 0.5f, 0.25f), - new Vertex( size, 0, -size, 0.75f, 0), - new Vertex( 0, -size * 2, 0, 0.75f, 0.25f), - new Vertex( 0, -size * 2, 0, 0.75f, 0.25f) - ).addFace( - new Vertex(-size, 0, size, 0.75f, 0.5f), - new Vertex(-size, 0, -size, 1, 0.25f), - new Vertex( 0, size * 2, 0, 0.75f, 0.25f), - new Vertex( 0, size * 2, 0, 0.75f, 0.25f) - ).addFace( - new Vertex(-size, 0, size, 0.75f, 0.25f), - new Vertex(-size, 0, -size, 1, 0), - new Vertex( 0, -size * 2, 0, 1, 0.25f), - new Vertex( 0, -size * 2, 0, 1, 0.25f) - )); + body = new ModelPart(this); + body.pivotY = 1.2f; } @Override - public void render(SpellcastEntity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float scale) { + public void setAngles(SpellcastEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { + tint = entity.hasEffect() ? entity.getEffect().getTint() : -1; - GlStateManager.pushMatrix(); + float floatOffset = MathHelper.sin((entity.age + customAngle) / 10 + entity.hoverStart) / 10 + 0.1F; - float floatOffset = MathHelper.sin((entity.age + stutter) / 10 + entity.hoverStart) / 10 + 0.1F; - GlStateManager.translated(0, floatOffset - entity.getEyeHeight(EntityPose.STANDING), 0); + boolean unstable = entity.overLevelCap(); - floatOffset = (entity.age + stutter) / 20; + body.pivotX = unstable ? (float)Math.sin(customAngle) / 5F : 0; + body.pivotY = 1.2F + floatOffset - entity.getEyeHeight(EntityPose.STANDING); + body.pivotZ = unstable ? (float)Math.cos(customAngle) / 5F : 0; + body.pitch = unstable ? (float)Math.sin(customAngle) : 0; + + floatOffset = (entity.age + customAngle) / 20; if (entity.getCurrentLevel() > 0) { floatOffset *= entity.getCurrentLevel() + 1; } @@ -84,74 +44,19 @@ public class GemEntityModel extends EntityModel { floatOffset += entity.hoverStart; floatOffset *= 180 / (float)Math.PI; - GlStateManager.pushMatrix(); + body.yaw = floatOffset; - if (entity.overLevelCap()) { - GlStateManager.translated(Math.sin(stutter) / 5, 0, Math.cos(stutter) / 5); - - GlStateManager.rotatef((float)Math.sin(stutter), 0, 1, 0); - } - - GlStateManager.rotated(floatOffset, 0, 1, 0); - - body.render(scale); - - GlStateManager.enableBlend(); - GlStateManager.disableAlphaTest(); - GlStateManager.blendFunc(1, 1); - - setLightingConditionsBrightness(0xF0F0); - - if (entity.hasEffect()) { - int tint = entity.getEffect().getTint(); - GlStateManager.color4f(Color.r(tint), Color.g(tint), Color.b(tint), 1); - } - - int tiers = Math.min(entity.getCurrentLevel(), 5); - - for (int i = 0; i <= tiers; i++) { - float grow = (1 + i) * 0.2F; - - GlStateManager.scalef(1 + grow, 1 + grow, 1 + grow); - GlStateManager.translatef(0, -grow, 0); - renderOverlay(grow, scale); - - if (i == 5) { - GlStateManager.pushMatrix(); - GlStateManager.rotatef(-floatOffset * 0.9F, 0, 1, 0); - GlStateManager.translatef(0.6F, 0.8F, 0); - GlStateManager.scalef(0.4F, 0.4F, 0.4F); - renderOverlay(grow, scale); - GlStateManager.popMatrix(); - } - - } - GlStateManager.popMatrix(); - - for (int i = entity.getCurrentLevel(); i > 0; i--) { - GlStateManager.pushMatrix(); - GlStateManager.rotatef(floatOffset / i, 0, 1, 0); - GlStateManager.translatef(0.6F, 0, 0); - renderOverlay(0.6F, scale); - GlStateManager.popMatrix(); - } - - setLightingConditionsBrightness(entity.getLightmapCoordinates()); - - GlStateManager.disableBlend(); - GlStateManager.enableAlphaTest(); - - GlStateManager.popMatrix(); } - protected void renderOverlay(float grow, float scale) { - body.render(scale); + @Override + public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + if (tint != -1) { + red = Color.r(tint); + green = Color.g(tint); + blue = Color.b(tint); + } + + body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); } - private void setLightingConditionsBrightness(int brightness) { - int texX = brightness % 0x10000; - int texY = brightness / 0x10000; - - GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, texX, texY); - } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java index ce6043c9..a1fe1542 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/SpellbookModel.java @@ -1,49 +1,69 @@ package com.minelittlepony.unicopia.client.render.model; +import java.util.List; + +import com.google.common.collect.ImmutableList; import com.minelittlepony.unicopia.entity.SpellbookEntity; -import net.minecraft.client.model.Cuboid; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModel; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.MathHelper; public class SpellbookModel extends EntityModel { - private final Cuboid leftCover = (new Cuboid(this)).setTextureOffset(0, 0).addBox(-6.0F, -5.0F, 0.0F, 6, 10, 0); - private final Cuboid rightCover = (new Cuboid(this)).setTextureOffset(16, 0).addBox(0.0F, -5.0F, 0.0F, 6, 10, 0); - private final Cuboid leftBlock = (new Cuboid(this)).setTextureOffset(0, 10).addBox(0.0F, -4.0F, -0.99F, 5, 8, 1); - private final Cuboid rightBlock = (new Cuboid(this)).setTextureOffset(12, 10).addBox(0.0F, -4.0F, -0.01F, 5, 8, 1); - private final Cuboid leftPage = (new Cuboid(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0); - private final Cuboid rightPage = (new Cuboid(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0); - private final Cuboid spine = (new Cuboid(this)).setTextureOffset(12, 0).addBox(-1.0F, -5.0F, 0.0F, 2, 10, 0); + private final ModelPart leftCover = (new ModelPart(64, 32, 0, 0)).addCuboid(-6, -5, -0.005F, 6, 10, 0.005F); + private final ModelPart rightCover = (new ModelPart(64, 32, 16, 0)).addCuboid(0, -5, -0.005F, 6, 10, 0.005F); + private final ModelPart leftBlock = (new ModelPart(64, 32, 0, 10)).addCuboid(0, -4, -0.99F, 5, 8, 1); + private final ModelPart rightBlock = (new ModelPart(64, 32, 12, 10)).addCuboid(0, -4, -0.01F, 5, 8, 1); + private final ModelPart leftPage = (new ModelPart(64, 32, 24, 10)).addCuboid(0, -4, 0, 5, 8, 0.005F); + private final ModelPart rightPage = (new ModelPart(64, 32, 24, 10)).addCuboid(0, -4, 0, 5, 8, 0.005F); + private final ModelPart spine = (new ModelPart(64, 32, 12, 0)).addCuboid(-1, -5, 0, 2, 10, 0.005F); + + private final List parts = ImmutableList.of(leftCover, rightCover, spine, leftBlock, rightBlock, leftPage, rightPage); public SpellbookModel() { - this.leftCover.setRotationPoint(0.0F, 0.0F, -1.0F); - this.rightCover.setRotationPoint(0.0F, 0.0F, 1.0F); - this.spine.yaw = 1.5707964F; + leftCover.setPivot(0, 0, -1); + rightCover.setPivot(0, 0, 1); + spine.yaw = 1.5707964F; } @Override - public void render(SpellbookEntity entity, float float_1, float float_2, float float_3, float float_4, float float_5, float float_6) { - this.leftCover.render(float_6); - this.rightCover.render(float_6); - this.spine.render(float_6); - this.leftBlock.render(float_6); - this.rightBlock.render(float_6); - this.leftPage.render(float_6); - this.rightPage.render(float_6); + public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + parts.forEach(modelPart -> { + modelPart.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha); + }); + } + + public void setPageAngles(float breath, float leftPageRot, float rightPageRot, float openAngle) { + float j = (MathHelper.sin(breath * 0.02F) * 0.1F + 1.25F) * openAngle; + leftCover.yaw = 3.1415927F + j; + rightCover.yaw = -j; + leftBlock.yaw = j; + rightBlock.yaw = -j; + leftPage.yaw = j - j * 2 * leftPageRot; + rightPage.yaw = j - j * 2 * rightPageRot; + leftBlock.pivotX = MathHelper.sin(j); + rightBlock.pivotX = MathHelper.sin(j); + leftPage.pivotX = MathHelper.sin(j); + rightPage.pivotX = MathHelper.sin(j); } @Override - public void setAngles(SpellbookEntity entity, float float_1, float float_2, float float_3, float float_4, float float_5, float float_6) { - float float_7 = (MathHelper.sin(float_1 * 0.02F) * 0.1F + 1.25F) * float_4; - this.leftCover.yaw = 3.1415927F + float_7; - this.rightCover.yaw = -float_7; - this.leftBlock.yaw = float_7; - this.rightBlock.yaw = -float_7; - this.leftPage.yaw = float_7 - float_7 * 2.0F * float_2; - this.rightPage.yaw = float_7 - float_7 * 2.0F * float_3; - this.leftBlock.rotationPointX = MathHelper.sin(float_7); - this.rightBlock.rotationPointX = MathHelper.sin(float_7); - this.leftPage.rotationPointX = MathHelper.sin(float_7); - this.rightPage.rotationPointX = MathHelper.sin(float_7); + public void setAngles(SpellbookEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) { + float breath = MathHelper.sin((entity.age + customAngle) / 20) * 0.01F + 0.1F; + + float first_page_rot = limbDistance + (breath * 10); + float second_page_rot = 1 - first_page_rot; + float open_angle = 0.9f - limbDistance; + + if (first_page_rot > 1) first_page_rot = 1; + if (second_page_rot > 1) second_page_rot = 1; + + if (!entity.getIsOpen()) { + first_page_rot = second_page_rot = open_angle = 0; + } + + setPageAngles(breath, first_page_rot, second_page_rot, open_angle); } } diff --git a/src/main/java/com/minelittlepony/unicopia/client/render/model/SphereModel.java b/src/main/java/com/minelittlepony/unicopia/client/render/model/SphereModel.java new file mode 100644 index 00000000..ca75094a --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/client/render/model/SphereModel.java @@ -0,0 +1,99 @@ +package com.minelittlepony.unicopia.client.render.model; + +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; +import net.minecraft.client.util.math.Matrix4f; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.util.math.Vector3f; +import net.minecraft.client.util.math.Vector4f; +import net.minecraft.util.math.Quaternion; +import net.minecraft.util.math.Vec3d; + +public class SphereModel { + + protected Vec3d pos; + + protected Quaternion rotX; + protected Quaternion rotY; + protected Quaternion rotZ; + + public void setPosition(double x, double y, double z) { + pos = new Vec3d(x, y, z).subtract(BlockEntityRenderDispatcher.INSTANCE.camera.getPos()); + } + + public void setRotation(float x, float y, float z) { + rotX = Vector3f.POSITIVE_X.getDegreesQuaternion(x); + rotY = Vector3f.POSITIVE_Y.getDegreesQuaternion(y); + rotZ = Vector3f.POSITIVE_Z.getDegreesQuaternion(z); + } + + public void render(MatrixStack matrices, float scale, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) { + if (scale == 0) { + return; + } + + matrices.push(); + + matrices.translate(pos.x, pos.y, pos.z); + matrices.multiply(rotX); + matrices.multiply(rotY); + matrices.multiply(rotZ); + + matrices.scale(scale, scale, scale); + + render(matrices.peek(), vertexWriter, light, overlay, r, g, b, a); + + matrices.pop(); + } + + public void render(MatrixStack.Entry matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) { + + Matrix4f model = matrices.getModel(); + + final double num_rings = 30; + final double num_sectors = 30; + final double two_pi = Math.PI * 2; + final double zenithIncrement = Math.PI / num_rings; + final double azimuthIncrement = two_pi / num_sectors; + + double radius = 1; + + for(double zenith = 0; zenith < Math.PI; zenith += zenithIncrement) { + for(double azimuth = 0; azimuth < two_pi; azimuth += azimuthIncrement) { + drawVertex(model, vertexWriter, radius, zenith, azimuth, light, overlay, r, g, b, a); // top left + drawVertex(model, vertexWriter, radius, zenith + zenithIncrement, azimuth, light, overlay, r, g, b, a); // top right + drawVertex(model, vertexWriter, radius, zenith + zenithIncrement, azimuth + azimuthIncrement, light, overlay, r, g, b, a); // bottom right + drawVertex(model, vertexWriter, radius, zenith, azimuth + azimuthIncrement, light, overlay, r, g, b, a); // bottom left + } + } + } + + protected void drawQuad(Matrix4f model, VertexConsumer vertexWriter, + double radius, double zenith, double azimuth, + double zenithIncrement, double azimuthIncrement, + int light, int overlay, float r, float g, float b, float a) { + + + } + + protected void drawVertex(Matrix4f model, VertexConsumer vertexWriter, + double radius, double zenith, double azimuth, + int light, int overlay, float r, float g, float b, float a) { + Vector4f position = convertToCartesianCoord(radius, zenith, azimuth); + position.transform(model); + vertexWriter.vertex(position.getX(), position.getY(), position.getZ(), + r, g, b, a, + 0, 0, overlay, light, 0, 0, 0); + } + + protected Vector4f convertToCartesianCoord(double radius, double zenith, double azimuth) { + + double tanq = Math.tan(zenith); + + double x = Math.pow(radius, 2) / (2 * tanq) - (tanq / 2); + double y = x * tanq; + double z = radius / Math.tan(azimuth); + + return new Vector4f((float)x, (float)y, (float)z, 1); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java index 395e04e0..d2b3d020 100644 --- a/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java +++ b/src/main/java/com/minelittlepony/unicopia/command/DisguiseCommand.java @@ -49,7 +49,7 @@ public class DisguiseCommand { } static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, CompoundTag nbt, boolean isSelf) throws CommandSyntaxException { - nbt = nbt.method_10553(); + nbt = nbt.copy(); nbt.putString("id", id.toString()); Pony iplayer = Pony.of(player); diff --git a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java b/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java index 8f34cfb9..891eef86 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java +++ b/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingContainer.java @@ -67,14 +67,14 @@ public class BagOfHoldingContainer extends Container { @Override public ItemStack transferSlot(PlayerEntity playerIn, int index) { ItemStack resultingStack = ItemStack.EMPTY; - Slot slot = slotList.get(index); + Slot slot = slots.get(index); if (slot != null && slot.hasStack()) { ItemStack originalStack = slot.getStack(); resultingStack = originalStack.copy(); if (index < inventory.getInvSize()) { - if (!insertItem(originalStack, inventory.getInvSize(), slotList.size(), true)) { + if (!insertItem(originalStack, inventory.getInvSize(), slots.size(), true)) { return ItemStack.EMPTY; } } else if (!insertItem(originalStack, 0, inventory.getInvSize(), false)) { diff --git a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java b/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java index e528c86e..b3b27638 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java +++ b/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingInventory.java @@ -20,6 +20,8 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.BasicInventory; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import net.minecraft.loot.context.LootContextParameters; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.server.network.ServerPlayerEntity; @@ -30,8 +32,6 @@ import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.explosion.Explosion.DestructionType; -import net.minecraft.world.loot.context.LootContext; -import net.minecraft.world.loot.context.LootContextParameters; public class BagOfHoldingInventory extends BasicInventory implements NbtSerialisable { @@ -54,14 +54,14 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis } public static void iterateContents(ItemStack stack, BiFunction itemConsumer) { - if (stack.hasTag() && stack.getTag().containsKey("inventory")) { + if (stack.hasTag() && stack.getTag().contains("inventory")) { CompoundTag compound = stack.getSubTag("inventory"); - if (compound.containsKey("items")) { + if (compound.contains("items")) { ListTag list = compound.getList("items", NBT_COMPOUND); for (int i = 0; i < list.size(); i++) { - ItemStack item = ItemStack.fromTag(list.getCompoundTag(i)); + ItemStack item = ItemStack.fromTag(list.getCompound(i)); if (!item.isEmpty() && !itemConsumer.apply(i, item)) { break; } @@ -135,7 +135,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis BOHDeathCriterion.INSTANCE.trigger((ServerPlayerEntity)player); } player.damage(MagicalDamageSource.create("paradox"), 1000); - player.world.createExplosion(player, player.x, player.y, player.z, 5, DestructionType.DESTROY); + player.world.createExplosion(player, player.getX(), player.getY(), player.getZ(), 5, DestructionType.DESTROY); } } @@ -154,7 +154,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis return isIllegalBlock(Block.getBlockFromItem(stack.getItem())) || stack.getItem().isIn(UTags.HAMMERPACE_IMMUNE) - || (compound != null && compound.containsKey("invalid")); + || (compound != null && compound.contains("invalid")); } protected boolean isIllegalBlock(Block block) { diff --git a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingScreen.java b/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingScreen.java index 5b4a4ea3..37fd9e61 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/container/BagOfHoldingScreen.java @@ -4,12 +4,12 @@ import com.minelittlepony.common.client.gui.element.Scrollbar; import com.minelittlepony.unicopia.item.BagOfHoldingItem; import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; +import net.minecraft.client.gui.screen.ingame.ContainerScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; -public class BagOfHoldingScreen extends AbstractContainerScreen { +public class BagOfHoldingScreen extends ContainerScreen { private static final Identifier CHEST_GUI_TEXTURE = new Identifier("textures/gui/container/generic_54.png"); private final int inventoryRows; @@ -21,15 +21,16 @@ public class BagOfHoldingScreen extends AbstractContainerScreen player.container.close(player)); @@ -116,7 +116,7 @@ public class SpellBookContainer extends Container { @Override public ItemStack transferSlot(PlayerEntity player, int index) { ItemStack stack = ItemStack.EMPTY; - Slot slot = slotList.get(index); + Slot slot = slots.get(index); if (slot != null && slot.hasStack()) { ItemStack slotStack = slot.getStack(); diff --git a/src/main/java/com/minelittlepony/unicopia/client/gui/SpellBookScreen.java b/src/main/java/com/minelittlepony/unicopia/container/SpellBookScreen.java similarity index 93% rename from src/main/java/com/minelittlepony/unicopia/client/gui/SpellBookScreen.java rename to src/main/java/com/minelittlepony/unicopia/container/SpellBookScreen.java index f0bf3f6b..452f4410 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/gui/SpellBookScreen.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellBookScreen.java @@ -1,10 +1,9 @@ -package com.minelittlepony.unicopia.client.gui; +package com.minelittlepony.unicopia.container; import org.lwjgl.opengl.GL11; import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.unicopia.Unicopia; -import com.minelittlepony.unicopia.container.SpellBookContainer; import com.minelittlepony.unicopia.container.SpellBookContainer.SpellbookSlot; import com.minelittlepony.unicopia.enchanting.IPageUnlockListener; import com.minelittlepony.unicopia.enchanting.Page; @@ -13,14 +12,14 @@ import com.minelittlepony.unicopia.enchanting.Pages; import com.minelittlepony.unicopia.entity.player.Pony; import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; +import net.minecraft.client.gui.screen.ingame.ContainerScreen; import net.minecraft.client.texture.MissingSprite; import net.minecraft.container.Slot; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; -public class SpellBookScreen extends AbstractContainerScreen implements IPageUnlockListener { +public class SpellBookScreen extends ContainerScreen implements IPageUnlockListener { private static Page currentPage; @@ -48,11 +47,11 @@ public class SpellBookScreen extends AbstractContainerScreen public void init() { super.init(); - addButton(nextPage = new PageButton(left + 360, top + 185, true)).onClick(v -> { + addButton(nextPage = new PageButton(x + 360, y + 185, true)).onClick(v -> { currentPage = currentPage.next(); onPageChange(); }); - addButton(prevPage = new PageButton(left + 20, top + 185, false)).onClick(v -> { + addButton(prevPage = new PageButton(x + 20, y + 185, false)).onClick(v -> { currentPage = currentPage.prev(); onPageChange(); }); diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java index 50b381b8..16ecb9cf 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookResultSlot.java @@ -5,15 +5,21 @@ import com.minelittlepony.unicopia.enchanting.SpellCraftingEvent; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.MagicGemItem; import com.minelittlepony.unicopia.magic.spell.SpellRegistry; +import com.mojang.datafixers.util.Pair; +import net.minecraft.container.PlayerContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; import net.minecraft.item.MusicDiscItem; import net.minecraft.recipe.RecipeType; import net.minecraft.util.DefaultedList; +import net.minecraft.util.Identifier; public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { + // TODO: need to register this + public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "empty_slot_gem"); + private final Pony player; private final SpellBookInventory craftMatrix; @@ -95,7 +101,7 @@ public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { } @Override - public String getBackgroundSprite() { - return "unicopia:items/empty_slot_gem"; + public Pair getBackgroundSprite() { + return Pair.of(PlayerContainer.BLOCK_ATLAS_TEXTURE, EMPTY_GEM_SLOT); } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java b/src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java index 76f3ccef..0ab3f03b 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java +++ b/src/main/java/com/minelittlepony/unicopia/enchanting/Pages.java @@ -19,7 +19,7 @@ import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.resource.JsonDataLoader; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; -import net.minecraft.util.SystemUtil; +import net.minecraft.util.Util; import net.minecraft.util.profiler.Profiler; public class Pages extends JsonDataLoader implements IdentifiableResourceReloadListener { @@ -38,7 +38,7 @@ public class Pages extends JsonDataLoader implements IdentifiableResourceReloadL private final Map pages = Maps.newHashMap(); private List pagesByIndex = Lists.newArrayList(); - private final Map conditionFactories = SystemUtil.consume(Maps.newHashMap(), m -> { + private final Map conditionFactories = Util.make(Maps.newHashMap(), m -> { m.put("unicopia:compound_condition", CompoundCondition::new); m.put("unicopia:page_state", PageStateCondition::new); m.put("unicopia:spell_crafting", SpellCraftingEvent.Condition::new); @@ -53,12 +53,6 @@ public class Pages extends JsonDataLoader implements IdentifiableResourceReloadL return ID; } - @Override - protected Map prepare(ResourceManager manager, Profiler profiler) { - // TODO: broken synthetic - return super.method_20731(manager, profiler); - } - @Override protected void apply(Map data, ResourceManager manager, Profiler profiled) { pages.clear(); diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/AffineIngredients.java b/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/AffineIngredients.java index 82fd3bf2..62b226c3 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/AffineIngredients.java +++ b/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/AffineIngredients.java @@ -37,12 +37,6 @@ public class AffineIngredients extends JsonDataLoader implements IdentifiableRes return ID; } - @Override - protected Map prepare(ResourceManager manager, Profiler profiler) { - // TODO: broken synthetic - return super.method_20731(manager, profiler); - } - @Override protected void apply(Map data, ResourceManager manager, Profiler profiled) { storedIngredients.clear(); diff --git a/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/SpellIngredient.java b/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/SpellIngredient.java index cbd91cb6..8c27423c 100644 --- a/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/SpellIngredient.java +++ b/src/main/java/com/minelittlepony/unicopia/enchanting/recipe/SpellIngredient.java @@ -10,12 +10,12 @@ import com.google.gson.JsonParseException; import net.minecraft.item.ItemStack; import net.minecraft.util.DefaultedList; import net.minecraft.util.PacketByteBuf; -import net.minecraft.util.SystemUtil; +import net.minecraft.util.Util; public interface SpellIngredient { SpellIngredient EMPTY = new SingleSpellIngredient(ItemStack.EMPTY, false); - Map> SERIALIZERS = SystemUtil.consume(new HashMap<>(), map -> { + Map> SERIALIZERS = Util.make(new HashMap<>(), map -> { map.put("compound", CompoundSpellIngredient.SERIALIZER); map.put("single", SingleSpellIngredient.SERIALIZER); map.put("affine", AffineIngredient.SERIALIZER); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java index 9565b8d7..815dea94 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ButterflyEntity.java @@ -88,7 +88,7 @@ public class ButterflyEntity extends AmbientEntity { super.tick(); Vec3d vel = getVelocity(); - setVelocity(vel.x, y * 0.6, vel.z); + setVelocity(vel.x, getY() * 0.6, vel.z); } public boolean isResting() { @@ -156,14 +156,18 @@ public class ButterflyEntity extends AmbientEntity { // select a new hovering position if (hoveringPosition == null || random.nextInt(30) == 0 || hoveringPosition.getSquaredDistance(pos) < 4) { - hoveringPosition = new BlockPos(x + random.nextInt(7) - random.nextInt(7), y + random.nextInt(6) - 2, z + random.nextInt(7) - random.nextInt(7)); + hoveringPosition = new BlockPos( + getX() + random.nextInt(7) - random.nextInt(7), + getY() + random.nextInt(6) - 2, + getZ() + random.nextInt(7) - random.nextInt(7) + ); } // hover casually towards the chosen position - double changedX = hoveringPosition.getX() + 0.5D - x; - double changedY = hoveringPosition.getY() + 0.1D - y; - double changedZ = hoveringPosition.getZ() + 0.5D - z; + double changedX = hoveringPosition.getX() + 0.5D - getX(); + double changedY = hoveringPosition.getY() + 0.1D - getY(); + double changedZ = hoveringPosition.getZ() + 0.5D - getZ(); Vec3d vel = getVelocity(); @@ -185,7 +189,8 @@ public class ButterflyEntity extends AmbientEntity { } @Override - public void handleFallDamage(float distance, float damageMultiplier) { + public boolean handleFallDamage(float distance, float damageMultiplier) { + return false; } @Override @@ -195,7 +200,7 @@ public class ButterflyEntity extends AmbientEntity { @Override public boolean canSpawn(IWorld world, SpawnType type) { if (type == SpawnType.NATURAL) { - return y < world.getSeaLevel() && world.getLightLevel(getBlockPos()) > 7; + return getY() < world.getSeaLevel() && world.getLightLevel(getBlockPos()) > 7; } return true; } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java index bc253916..76120747 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CloudEntity.java @@ -10,8 +10,8 @@ import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloud import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.UItems; -import com.minelittlepony.unicopia.util.particles.ParticleEmitter; -import com.minelittlepony.unicopia.util.particles.UParticles; +import com.minelittlepony.unicopia.particles.ParticleEmitter; +import com.minelittlepony.unicopia.particles.UParticles; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -102,11 +102,6 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate return false; } - @Override - public int getLightmapCoordinates() { - return 0xF000F0; - } - @Override public float getBrightnessAtEyes() { return 0xF000F0; @@ -149,7 +144,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate @Override protected void pushAway(Entity other) { if (other instanceof CloudEntity || other instanceof PlayerEntity) { - if (other.y > y) { + if (other.getY() > getY()) { return; } @@ -175,9 +170,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate if (getIsRaining()) { if (world.isClient) { for (int i = 0; i < 30 * getCloudSize(); i++) { - double x = MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX); - double y = getBoundingBox().minY + getHeight()/2; - double z = MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ); + double x = MathHelper.nextDouble(random, boundingbox.x1, boundingbox.x2); + double y = getBoundingBox().y1 + getHeight()/2; + double z = MathHelper.nextDouble(random, boundingbox.z1, boundingbox.z2); ParticleEffect particleId = canSnowHere(new BlockPos(x, y, z)) ? ParticleTypes.ITEM_SNOWBALL : UParticles.RAIN_DROPS; @@ -186,21 +181,20 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate Box rainedArea = boundingbox .expand(1, 0, 1) - .expand(0, -(y - getGroundPosition(x, z).getY()), 0); + .expand(0, -(getY() - getGroundPosition(getBlockPos()).getY()), 0); - for (PlayerEntity j : world.getEntities(PlayerEntity.class, rainedArea)) { - if (!canSnowHere(j.getBlockPos())) { - j.world.playSound(j, j.getBlockPos(), SoundEvents.WEATHER_RAIN, SoundCategory.AMBIENT, 0.1F, 0.6F); - } + for (PlayerEntity j : world.getEntities(PlayerEntity.class, rainedArea, j -> canSnowHere(j.getBlockPos()))) { + j.world.playSound(j, j.getBlockPos(), SoundEvents.WEATHER_RAIN, SoundCategory.AMBIENT, 0.1F, 0.6F); } } double width = getDimensions(getPose()).width; - BlockPos pos = getGroundPosition( - x + random.nextFloat() * width, - z + random.nextFloat() * width - ); + BlockPos pos = getGroundPosition(new BlockPos( + getX() + random.nextFloat() * width, + getY(), + getZ() + random.nextFloat() * width + )); if (getIsThundering()) { if (random.nextInt(3000) == 0) { @@ -246,7 +240,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } } - state.getBlock().onRainTick(world, below); + state.getBlock().rainTick(world, below); } } @@ -277,7 +271,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate for (Entity i : world.getEntities(this, boundingbox .expand(1 / (1 + getCloudSize())), EquinePredicates.ENTITY_INTERACT_WITH_CLOUDS)) { - if (i.y > y + 0.5) { + if (i.getY() > getY() + 0.5) { applyGravityCompensation(i); } } @@ -285,9 +279,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate if (isOnFire() && !dead) { for (int i = 0; i < 5; i++) { world.addParticle(ParticleTypes.CLOUD, - MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX), - MathHelper.nextDouble(random, boundingbox.minY, boundingbox.maxY), - MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ), 0, 0.25, 0); + MathHelper.nextDouble(random, boundingbox.x1, boundingbox.x2), + MathHelper.nextDouble(random, boundingbox.y1, boundingbox.y2), + MathHelper.nextDouble(random, boundingbox.z1, boundingbox.z2), 0, 0.25, 0); } } @@ -308,7 +302,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate @Override public double getMountedHeightOffset() { - return getBoundingBox().maxY - getBoundingBox().minY - 0.25; + return getBoundingBox().y2 - getBoundingBox().y1 - 0.25; } @Override @@ -320,14 +314,14 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate @Override public void onPlayerCollision(PlayerEntity player) { - if (player.y >= y) { + if (player.getY() >= getY()) { if (applyGravityCompensation(player)) { - double difX = player.x - player.prevX; - double difZ = player.z - player.prevZ; - double difY = player.y - player.prevY; + double difX = player.getX() - player.prevX; + double difZ = player.getZ() - player.prevZ; + double difY = player.getY() - player.prevY; player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6); - player.distanceWalked = (float)(player.distanceWalked + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6); + player.distanceTraveled = (float)(player.distanceTraveled + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6); if (Pony.of(player).stepOnCloud()) { BlockSoundGroup soundtype = BlockSoundGroup.WOOL; @@ -343,15 +337,15 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate protected void mobTick() { if (!getStationary()) { if (!hasVehicle()) { - double distance = targetAltitude - y; + double distance = targetAltitude - getY(); - if (targetAltitude < y && !world.isAir(getBlockPos())) { + if (targetAltitude < getY() && !world.isAir(getBlockPos())) { distance = 0; } if (Math.abs(distance) < 1 && random.nextInt(7000) == 0) { targetAltitude = getRandomFlyingHeight(); - distance = targetAltitude - y; + distance = targetAltitude - getY(); } if (Math.abs(distance) < 1) { @@ -449,10 +443,10 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } else if (stack != null && stack.getItem() instanceof ShovelItem) { return super.damage(source, amount * 1.5f); } else if (canFly) { - if (player.y < y || !world.isAir(getBlockPos())) { - targetAltitude = y + 5; - } else if (player.y > y) { - targetAltitude = y - 5; + if (player.getY() < getY() || !world.isAir(getBlockPos())) { + targetAltitude = getY() + 5; + } else if (player.getY() > getY()) { + targetAltitude = getY() - 5; } } } @@ -610,7 +604,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } public void spawnThunderbolt() { - spawnThunderbolt(getGroundPosition(x, z)); + spawnThunderbolt(getGroundPosition(getBlockPos())); } public void spawnThunderbolt(BlockPos pos) { @@ -619,10 +613,10 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate } } - private BlockPos getGroundPosition(double x, double z) { - BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(x, y, z)); + private BlockPos getGroundPosition(BlockPos inPos) { + BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, inPos); - if (pos.getY() >= y) { + if (pos.getY() >= getY()) { while (World.isValid(pos)) { pos = pos.down(); if (world.getBlockState(pos).hasSolidTopSurface(world, pos, this)) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java index 8376f873..438beb3f 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ConstructionCloudEntity.java @@ -82,7 +82,7 @@ public class ConstructionCloudEntity extends CloudEntity { if (hit != null) { Direction direction = hit.getSide(); - mc.hitResult = hit = new BlockHitResult(hit.getPos(), direction, new BlockPos(hit.getPos()), false); + mc.crosshairTarget = hit = new BlockHitResult(hit.getPos(), direction, new BlockPos(hit.getPos()), false); int oldCount = stack.getCount(); ActionResult result = mc.interactionManager.interactBlock(((ClientPlayerEntity)player), (ClientWorld)player.world, hand, hit); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java index 6ae83aaf..ea08e5ec 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/CuccoonEntity.java @@ -9,8 +9,8 @@ import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.MagicalDamageSource; -import com.minelittlepony.unicopia.util.particles.UParticles; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; @@ -124,12 +124,12 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate if (passenger instanceof LivingEntity) { LivingEntity living = (LivingEntity)passenger; - if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getHealthMaximum()) { - living.addPotionEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 20, 2)); + if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getMaximumHealth()) { + living.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 20, 2)); } - if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getHealthMaximum()) { - living.addPotionEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 2000, 4)); + if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getMaximumHealth()) { + living.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 2000, 4)); } } } @@ -137,9 +137,9 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate if (world.isClient) { EntityDimensions dims = getDimensions(getPose()); - double x = this.x + dims.width * random.nextFloat() - dims.width/2; - double y = this.y + dims.height * random.nextFloat(); - double z = this.z + dims.width * random.nextFloat() - dims.width/2; + double x = getX() + dims.width * random.nextFloat() - dims.width/2; + double y = getY() + dims.height * random.nextFloat(); + double z = getZ() + dims.width * random.nextFloat() - dims.width/2; world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); } @@ -153,22 +153,22 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate if (hasPassengers()) { Entity passenger = getPrimaryPassenger(); - if (player.canConsume(false) || player.getHealth() < player.getHealthMaximum()) { + if (player.canConsume(false) || player.getHealth() < player.getMaximumHealth()) { DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player); Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7); if (passenger instanceof LivingEntity) { if (player.hasStatusEffect(StatusEffects.NAUSEA)) { - ((LivingEntity)passenger).addPotionEffect(player.removePotionEffect(StatusEffects.NAUSEA)); + ((LivingEntity)passenger).addStatusEffect(player.removeStatusEffectInternal(StatusEffects.NAUSEA)); } else if (random.nextInt(2300) == 0) { - ((LivingEntity)passenger).addPotionEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1)); + ((LivingEntity)passenger).addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1)); } } if (passenger instanceof PlayerEntity) { if (!player.hasStatusEffect(StatusEffects.HEALTH_BOOST)) { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1)); } } @@ -226,9 +226,9 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate double d1 = random.nextGaussian() * 0.02; world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.getDefaultState()), - x + random.nextFloat() * dims.width * 2 - dims.width, - y + random.nextFloat() * dims.height, - z + random.nextFloat() * dims.width * 2 - dims.width, + getX() + random.nextFloat() * dims.width * 2 - dims.width, + getY() + random.nextFloat() * dims.height, + getZ() + random.nextFloat() * dims.width * 2 - dims.width, d2, d0, d1); } } @@ -244,7 +244,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate i -= j; - world.spawnEntity(new ExperienceOrbEntity(world, x, y, z, j)); + world.spawnEntity(new ExperienceOrbEntity(world, getX(), getY(), getZ(), j)); } removeAllPassengers(); @@ -292,7 +292,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate } @Override - public void setEquippedStack(EquipmentSlot slot, ItemStack stack) { + public void equipStack(EquipmentSlot slot, ItemStack stack) { } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java b/src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java index 3de32b71..ec097f88 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/FollowCasterGoal.java @@ -15,7 +15,7 @@ import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; -import net.minecraft.world.ViewableWorld; +import net.minecraft.world.WorldView; public class FollowCasterGoal extends Goal { @@ -25,7 +25,7 @@ public class FollowCasterGoal extends Goal { protected LivingEntity owner; - protected final ViewableWorld world; + protected final WorldView world; public final double followSpeed; @@ -79,15 +79,15 @@ public class FollowCasterGoal extends Goal { @Override public void start() { timeout = 0; - oldWaterCost = entity.getPathNodeTypeWeight(PathNodeType.WATER); - entity.setPathNodeTypeWeight(PathNodeType.WATER, 0); + oldWaterCost = entity.getPathfindingPenalty(PathNodeType.WATER); + entity.setPathfindingPenalty(PathNodeType.WATER, 0); } @Override public void stop() { owner = null; navigation.stop(); - entity.setPathNodeTypeWeight(PathNodeType.WATER, oldWaterCost); + entity.setPathfindingPenalty(PathNodeType.WATER, oldWaterCost); } @Override @@ -107,15 +107,15 @@ public class FollowCasterGoal extends Goal { return; } - int x = MathHelper.floor(owner.x) - 2; - int y = MathHelper.floor(owner.getBoundingBox().minY); - int z = MathHelper.floor(owner.z) - 2; + int x = MathHelper.floor(owner.getX()) - 2; + int y = MathHelper.floor(owner.getBoundingBox().y1); + int z = MathHelper.floor(owner.getZ()) - 2; for (int offX = 0; offX <= 4; offX++) { for (int offZ = 0; offZ <= 4; offZ++) { if ((offX < 1 || offZ < 1 || offX > 3 || offZ > 3) && canMoveInto(new BlockPos(x + offX, y - 1, z + offZ))) { - entity.setPositionAndAngles((x + offX) + 0.5F, y, (z + offZ) + 0.5F, entity.headYaw, entity.pitch); + entity.updatePositionAndAngles((x + offX) + 0.5F, y, (z + offZ) + 0.5F, entity.headYaw, entity.pitch); navigation.stop(); return; @@ -131,4 +131,4 @@ public class FollowCasterGoal extends Goal { && world.isAir(pos.up()) && world.isAir(pos.up(2)); } -} \ No newline at end of file +} diff --git a/src/main/java/com/minelittlepony/unicopia/entity/LivingEntityCapabilities.java b/src/main/java/com/minelittlepony/unicopia/entity/LivingEntityCapabilities.java index d1fa2f03..4538ccc9 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/LivingEntityCapabilities.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/LivingEntityCapabilities.java @@ -115,7 +115,7 @@ public class LivingEntityCapabilities implements RaceContainer, Ca @Override public void fromNBT(CompoundTag compound) { - if (compound.containsKey("effect")) { + if (compound.contains("effect")) { setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java index acaefb75..a7ad62b4 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/ProjectileEntity.java @@ -54,14 +54,14 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv } public ProjectileEntity(EntityType type, World world, LivingEntity thrower) { - this(type, world, thrower.x, thrower.y + thrower.getStandingEyeHeight(), thrower.z); + this(type, world, thrower.getX(), thrower.getY() + thrower.getStandingEyeHeight(), thrower.getZ()); setOwner(thrower); } public ProjectileEntity(EntityType type, World world, double x, double y, double z) { super(type, world); - setPosition(x, y, z); + setPos(x, y, z); } @Override @@ -224,7 +224,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv ParticleEffect effect = getParticleParameters(); for(int i = 0; i < 8; i++) { - world.addParticle(effect, x, y, z, 0, 0, 0); + world.addParticle(effect, getX(), getY(), getZ(), 0, 0, 0); } } @@ -234,7 +234,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv public void readCustomDataFromTag(CompoundTag compound) { super.readCustomDataFromTag(compound); - if (compound.containsKey("effect")) { + if (compound.contains("effect")) { setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java index 043142cf..61761e17 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/RainbowEntity.java @@ -42,7 +42,7 @@ public class RainbowEntity extends Entity implements InAnimate { float yaw = (int)MathHelper.nextDouble(random, 0, 360); - setPositionAndAngles(0, 0, 0, yaw, 0); + updatePositionAndAngles(0, 0, 0, yaw, 0); radius = MathHelper.nextDouble(random, RAINBOW_MIN_SIZE, RAINBOW_MAX_SIZE); ticksAlive = 10000; @@ -59,10 +59,8 @@ public class RainbowEntity extends Entity implements InAnimate { } @Override - public void setPosition(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; + public void setPos(double x, double y, double z) { + super.setPos(x, y, z); float width = getDimensions(getPose()).width; setBoundingBox(new Box( @@ -77,7 +75,7 @@ public class RainbowEntity extends Entity implements InAnimate { } @Override - public boolean shouldRenderAtDistance(double distance) { + public boolean shouldRender(double distance) { return true; } @@ -96,8 +94,8 @@ public class RainbowEntity extends Entity implements InAnimate { if (!removed) { Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos()); - world.getEntities(RainbowEntity.class, bounds).forEach(this::attackCompetitor); - world.getEntities(RainbowEntity.Spawner.class, bounds).forEach(this::attackCompetitor); + world.getEntities(RainbowEntity.class, bounds, null).forEach(this::attackCompetitor); + world.getEntities(RainbowEntity.Spawner.class, bounds, null).forEach(this::attackCompetitor); } } @@ -137,8 +135,8 @@ public class RainbowEntity extends Entity implements InAnimate { Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos()); return super.canSpawn(world, type) - && world.getEntities(RainbowEntity.class, bounds).isEmpty() - && world.getEntities(RainbowEntity.Spawner.class, bounds).isEmpty(); + && world.getEntities(RainbowEntity.class, bounds, null).isEmpty() + && world.getEntities(RainbowEntity.Spawner.class, bounds, null).isEmpty(); } @Override @@ -157,7 +155,7 @@ public class RainbowEntity extends Entity implements InAnimate { public void trySpawnRainbow() { RainbowEntity rainbow = UEntities.RAINBOW.create(world); - rainbow.setPosition(x, y, z); + rainbow.setPos(getX(), getY(), getZ()); world.spawnEntity(rainbow); } } @@ -168,7 +166,7 @@ public class RainbowEntity extends Entity implements InAnimate { } @Override - public void method_11188(ClientPlayPacketListener listener) { + public void apply(ClientPlayPacketListener listener) { // TODO: Packet needs to be registered, and handling separated MinecraftClient client = MinecraftClient.getInstance(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java index 7fc72204..c9e1005b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpearEntity.java @@ -67,8 +67,8 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile { } @Override - public void method_7449(int amount) { - super.method_7449(amount); + public void setPunch(int amount) { + super.setPunch(amount); getDataTracker().set(KNOCKBACK, amount); } @@ -99,7 +99,7 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile { LivingEntity target = (LivingEntity)entity; if (!world.isClient) { - target.setStuckArrows(target.getStuckArrows() + 1); + target.setStuckArrowCount(target.getStuckArrowCount() + 1); } int knockback = getDataTracker().get(KNOCKBACK); @@ -171,7 +171,7 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile { @Override public void launch(Entity shooter, float pitch, float yaw, float pitchOffset, float velocity, float inaccuracy) { - method_7474(shooter, pitch, yaw, pitchOffset, velocity, inaccuracy); + setProperties(shooter, pitch, yaw, pitchOffset, velocity, inaccuracy); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java index aa602aa1..2619a429 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpellbookEntity.java @@ -4,7 +4,7 @@ import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.item.UItems; import net.minecraft.container.Container; -import net.minecraft.container.NameableContainerProvider; +import net.minecraft.container.NameableContainerFactory; import net.minecraft.entity.EntityType; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; @@ -24,7 +24,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameRules; import net.minecraft.world.World; -public class SpellbookEntity extends MobEntity implements NameableContainerProvider, IMagicals { +public class SpellbookEntity extends MobEntity implements NameableContainerFactory, IMagicals { private static final TrackedData OPENED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN); private static final TrackedData ALTERED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN); @@ -85,7 +85,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi @Override public void tick() { boolean open = getIsOpen(); - jumping = open && isInWater(); + jumping = open && isTouchingWater(); super.tick(); if (open && world.isClient) { @@ -98,7 +98,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi if (random.nextInt(320) == 0) { for (int offY = 0; offY <= 1; ++offY) { world.addParticle(ParticleTypes.ENCHANT, - x, y, z, + getX(), getY(), getZ(), offX/2F + random.nextFloat(), offY/2F - random.nextFloat() + 0.5f, offZ/2F + random.nextFloat() @@ -110,7 +110,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi } if (world.random.nextInt(30) == 0) { - float celest = world.getStarsBrightness(1) * 4; + float celest = world.getSkyAngleRadians(1) * 4; boolean isDay = celest > 3 || celest < 1; @@ -136,7 +136,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi BlockSoundGroup sound = BlockSoundGroup.WOOD; - world.playSound(x, y, z, sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); + world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { dropItem(UItems.spellbook, 1); @@ -178,7 +178,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi super.readCustomDataFromTag(compound); setIsOpen(compound.getBoolean("open")); - setUserSetState(compound.containsKey("force_open") ? compound.getBoolean("force_open") : null); + setUserSetState(compound.contains("force_open") ? compound.getBoolean("force_open") : null); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java index 6083cb2c..ac5d1d59 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/SpellcastEntity.java @@ -79,14 +79,14 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste } @Override - public boolean shouldRenderAtDistance(double distance) { + public boolean shouldRender(double distance) { if (getCurrentLevel() > 0) { distance /= getCurrentLevel(); } if (distance > 0) { distance--; } - return super.shouldRenderAtDistance(distance); + return super.shouldRender(distance); } @Override @@ -223,7 +223,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste } else if (world.random.nextInt((int)(exhaustionChance * 500)) == 0) { setEffect(null); } else if (world.random.nextInt((int)(exhaustionChance * 3500)) == 0) { - world.createExplosion(this, x, y, z, getCurrentLevel()/2, DestructionType.BREAK); + world.createExplosion(this, getX(), getY(), getZ(), getCurrentLevel()/2, DestructionType.BREAK); remove(); } } @@ -266,7 +266,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste protected void onDeath() { BlockSoundGroup sound = BlockSoundGroup.STONE; - world.playSound(x, y, z, sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true); + world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true); if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { int level = getCurrentLevel(); @@ -352,14 +352,14 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste @Override public void readCustomDataFromTag(CompoundTag compound) { super.readCustomDataFromTag(compound); - if (compound.containsKey("affinity")) { + if (compound.contains("affinity")) { setAffinity(Affinity.of(compound.getString("affinity"))); } setOwner(compound.getUuid("owner")); setCurrentLevel(compound.getInt("level")); - if (compound.containsKey("effect")) { + if (compound.contains("effect")) { setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); } } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java b/src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java index 7e60e819..105452bc 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/WildCloudEntity.java @@ -90,10 +90,10 @@ public class WildCloudEntity extends CloudEntity { targetAltitude = getRandomFlyingHeight(); - if (y < minSpawnHeight) { + if (getY() < minSpawnHeight) { minSpawnHeight += random.nextInt(Math.max(1, (int)getMaximumFlyingHeight() - (int)minSpawnHeight)); - setPositionAndAngles(x, minSpawnHeight - 1, z, yaw, pitch); + updatePositionAndAngles(getX(), minSpawnHeight - 1, getZ(), yaw, pitch); moveToBoundingBoxCenter(); } @@ -115,7 +115,7 @@ public class WildCloudEntity extends CloudEntity { setIsRaining(packData.leader.getIsRaining()); setIsThundering(packData.leader.getIsThundering()); - setPositionAndAngles(position.x, position.y, position.z, packData.leader.yaw, packData.leader.pitch); + updatePositionAndAngles(position.x, position.y, position.z, packData.leader.yaw, packData.leader.pitch); checkBlockCollision(); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/AbilityDelegate.java b/src/main/java/com/minelittlepony/unicopia/entity/player/AbilityDelegate.java index ebcf23ba..fbb323f2 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/AbilityDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/AbilityDelegate.java @@ -144,7 +144,7 @@ class AbilityDelegate implements AbilityReceiver, Updatable, NbtSerialisable { warmup = compound.getInt("warmup"); cooldown = compound.getInt("cooldown"); - if (compound.containsKey("activeAbility")) { + if (compound.contains("activeAbility")) { Abilities.getInstance() .getPowerFromName(compound.getString("activeAbility")) .ifPresent(p -> activeAbility = p); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java b/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java index 800062f3..4e368355 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/GravityDelegate.java @@ -10,8 +10,8 @@ import com.minelittlepony.unicopia.entity.FlightControl; import com.minelittlepony.unicopia.entity.Updatable; import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.mixin.MixinEntity; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.NbtSerialisable; -import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.util.MutableVector; import net.minecraft.entity.Entity; @@ -134,14 +134,14 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl rnd.nextGaussian() * entity.getWidth() ); - player.addParticle(UParticles.UNICORN_MAGIC, pos, velocity.toImmutable()); + player.addParticle(MagicParticleEffect.UNICORN, pos, velocity.toImmutable()); } } entity.abilities.allowFlying = checkCanFly(player); if (!entity.abilities.creativeMode) { - entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isInWater(); + entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isTouchingWater(); } isFlying = entity.abilities.flying && !entity.abilities.creativeMode; @@ -153,7 +153,7 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl } if (gravity < 0) { - entity.onGround = !entity.world.isAir(new BlockPos(entity.x, entity.y + entity.getHeight() + 0.5F, entity.z)); + entity.onGround = !entity.world.isAir(new BlockPos(entity.getX(), entity.getY() + entity.getHeight() + 0.5F, entity.getZ())); if (entity.onGround) { entity.abilities.flying = false; @@ -263,8 +263,8 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl } } - lastTickPosX = entity.x; - lastTickPosZ = entity.z; + lastTickPosX = entity.getX(); + lastTickPosZ = entity.getZ(); entity.setVelocity(velocity.toImmutable()); } @@ -325,8 +325,8 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl } protected double getHorizontalMotion(Entity e) { - double motionX = e.x - lastTickPosX; - double motionZ = e.z - lastTickPosZ; + double motionX = e.getX() - lastTickPosX; + double motionZ = e.getZ() - lastTickPosZ; return (motionX * motionX) + (motionZ * motionZ); @@ -382,7 +382,7 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl isFlying = compound.getBoolean("isFlying"); isRainbooming = compound.getBoolean("isRainbooming"); - if (compound.containsKey("gravity")) { + if (compound.contains("gravity")) { gravity = compound.getFloat("gravity"); } else { gravity = 0; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerImpl.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerImpl.java index ed14592f..81cfd703 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerImpl.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerImpl.java @@ -327,8 +327,8 @@ public class PlayerImpl implements Pony { @Override public boolean stepOnCloud() { - if (entity.fallDistance > 1 || entity.distanceWalked > nextStepDistance) { - nextStepDistance = entity.distanceWalked + 2; + if (entity.fallDistance > 1 || entity.distanceTraveled > nextStepDistance) { + nextStepDistance = entity.distanceTraveled + 2; entity.fallDistance = 0; return true; @@ -372,16 +372,16 @@ public class PlayerImpl implements Pony { player.getHungerManager().add(-health/2, -saturation/2); - player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true)); } else { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true)); } if (player.world.getDifficulty() != Difficulty.PEACEFUL && player.world.random.nextInt(20) == 0) { - player.addPotionEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true)); + player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true)); } - player.addPotionEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true)); } } @@ -408,7 +408,7 @@ public class PlayerImpl implements Pony { powers.fromNBT(compound.getCompound("powers")); gravity.fromNBT(compound.getCompound("gravity")); - if (compound.containsKey("effect")) { + if (compound.contains("effect")) { setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); } diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java index 95fc941b..b7a75bb8 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPageStats.java @@ -45,7 +45,7 @@ public class PlayerPageStats implements NbtSerialisable, PageOwner { @Override public void fromNBT(CompoundTag compound) { pageStates.clear(); - if (compound.containsKey("pageStates")) { + if (compound.contains("pageStates")) { CompoundTag pages = compound.getCompound("pageStates"); pages.getKeys().forEach(key -> { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java index c3066ae4..5da31fa5 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java @@ -5,13 +5,15 @@ import java.util.Random; import com.minelittlepony.unicopia.util.WorldEvent; import net.fabricmc.fabric.api.block.FabricBlockSettings; +import net.fabricmc.fabric.api.tools.FabricToolTags; import net.minecraft.block.AnvilBlock; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -19,23 +21,17 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; public class CloudAnvilBlock extends AnvilBlock implements Gas { - @SuppressWarnings("deprecation") public CloudAnvilBlock() { super(FabricBlockSettings.of(Material.WOOL) .strength(0.025F, 1) .resistance(2000) - .breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.SHOVELS, 0) + .breakByTool(FabricToolTags.SHOVELS, 0) .sounds(BlockSoundGroup.WOOL) .ticksRandomly() .build() ); } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Override public void onLandedUpon(World world, BlockPos pos, Entity entityIn, float fallDistance) { if (!applyLanding(entityIn, fallDistance)) { @@ -54,8 +50,8 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { } @Override - public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - return false; + public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + return ActionResult.PASS; } @Override @@ -66,7 +62,7 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { } @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { BlockState below = world.getBlockState(pos.down()); if (below.getBlock() instanceof Gas) { @@ -75,7 +71,7 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { } } - super.onScheduledTick(state, world, pos, rand); + super.scheduledTick(state, world, pos, rand); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java index 5f3d6d6d..c50335b5 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java @@ -7,15 +7,12 @@ import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.item.MossItem; import com.minelittlepony.unicopia.util.HoeUtil; -import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.block.Block; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; -import net.minecraft.block.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemUsageContext; -import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; @@ -25,10 +22,8 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable { private final CloudType variant; - public CloudBlock(Material material, CloudType variant) { - super(FabricBlockSettings.of(material) - .strength(0.5F, 1) - .sounds(BlockSoundGroup.WOOL) + public CloudBlock(CloudType variant) { + super(variant.configure() .ticksRandomly() .build() ); @@ -42,12 +37,7 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable { } @Override - public boolean isOpaque(BlockState state) { - return variant != CloudType.NORMAL; - } - - @Override - public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { + public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { if (rand.nextInt(10) == 0) { pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2)); state = world.getBlockState(pos); @@ -60,11 +50,6 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable { } } - @Override - public BlockRenderLayer getRenderLayer() { - return variant == CloudType.NORMAL ? BlockRenderLayer.TRANSLUCENT : super.getRenderLayer(); - } - @Override public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { if (beside.getBlock() instanceof Gas) { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java index 06dc4c0f..901fc686 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudDoorBlock.java @@ -4,11 +4,12 @@ import com.minelittlepony.unicopia.block.AbstractDoorBlock; import com.minelittlepony.unicopia.block.UMaterials; import net.fabricmc.fabric.api.block.FabricBlockSettings; -import net.minecraft.block.BlockRenderLayer; +import net.fabricmc.fabric.api.tools.FabricToolTags; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; @@ -16,20 +17,21 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; public class CloudDoorBlock extends AbstractDoorBlock implements Gas { - - @SuppressWarnings("deprecation") public CloudDoorBlock() { super(FabricBlockSettings.of(UMaterials.CLOUD) .sounds(BlockSoundGroup.WOOL) .hardness(3) .resistance(200) - .breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.SHOVELS, 0) + .breakByTool(FabricToolTags.SHOVELS, 0) .build()); } @Override - public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - return getCanInteract(state, player) && super.activate(state, worldIn, pos, player, hand, hit); + public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + if (!getCanInteract(state, player)) { + return ActionResult.PASS; + } + return super.onUse(state, worldIn, pos, player, hand, hit); } @Deprecated @@ -40,11 +42,6 @@ public class CloudDoorBlock extends AbstractDoorBlock implements Gas { return Math.max(hardness, Math.min(60, hardness + (pos.getY() - 100))); } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Override public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) { if (!applyBouncyness(state, entity)) { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java index 1ee677b9..ebd7107f 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudFarmlandBlock.java @@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.gas; import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.ducks.Farmland; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.FarmlandBlock; import net.minecraft.entity.Entity; @@ -20,11 +19,6 @@ public class CloudFarmlandBlock extends FarmlandBlock implements Farmland, Gas { super(settings); } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Override public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java index 0fd9d2e0..02f35ecc 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudFenceBlock.java @@ -1,13 +1,9 @@ package com.minelittlepony.unicopia.gas; -import net.fabricmc.fabric.api.block.FabricBlockSettings; -import net.minecraft.block.BlockRenderLayer; import net.minecraft.block.BlockState; import net.minecraft.block.FenceBlock; -import net.minecraft.block.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; @@ -16,13 +12,8 @@ public class CloudFenceBlock extends FenceBlock implements Gas { private final CloudType variant; - public CloudFenceBlock(Material material, CloudType variant) { - super(FabricBlockSettings.of(material) - .hardness(0.5F) - .resistance(1) - .sounds(BlockSoundGroup.WOOL) - .build()); - + public CloudFenceBlock(CloudType variant) { + super(variant.configure().build()); this.variant = variant; } @@ -31,21 +22,11 @@ public class CloudFenceBlock extends FenceBlock implements Gas { return variant == CloudType.NORMAL; } - @Override - public boolean isOpaque(BlockState state) { - return false; - } - @Override public CloudType getCloudMaterialType(BlockState blockState) { return variant; } - @Override - public BlockRenderLayer getRenderLayer() { - return BlockRenderLayer.TRANSLUCENT; - } - @Override public void onLandedUpon(World world, BlockPos pos, Entity entityIn, float fallDistance) { if (!applyLanding(entityIn, fallDistance)) { diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java index 9e2d164e..bf80dd80 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java @@ -1,17 +1,30 @@ package com.minelittlepony.unicopia.gas; import com.minelittlepony.unicopia.EquinePredicates; +import com.minelittlepony.unicopia.block.UMaterials; import com.minelittlepony.unicopia.entity.CloudEntity; +import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.sound.BlockSoundGroup; public enum CloudType { NORMAL, PACKED, ENCHANTED; + public FabricBlockSettings configure() { + FabricBlockSettings settings = FabricBlockSettings.of(UMaterials.CLOUD) + .strength(0.5F, 1) + .sounds(BlockSoundGroup.WOOL); + if (this != NORMAL ) { + settings.nonOpaque(); + } + return settings; + } + public boolean canInteract(Entity e) { if (e == null) { return false; diff --git a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java index 191b0763..bd55112d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AlicornAmuletItem.java @@ -73,9 +73,9 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem World world = entity.world; - double x = entity.x + world.random.nextFloat() - 0.5; - double z = entity.z + world.random.nextFloat() - 0.5; - double y = entity.y + world.random.nextFloat(); + double x = entity.getX() + world.random.nextFloat() - 0.5; + double z = entity.getY() + world.random.nextFloat() - 0.5; + double y = entity.getZ() + world.random.nextFloat(); ParticleEffect particle = world.random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME; @@ -138,7 +138,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem int hideFlags = 0; - if (!compound.containsKey("HideFlags") || ((hideFlags = compound.getInt("HideFlags")) & 2) == 0) { + if (!compound.contains("HideFlags") || ((hideFlags = compound.getInt("HideFlags")) & 2) == 0) { compound.putInt("HideFlags", hideFlags | 2); } @@ -153,7 +153,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem PlayerEntity player = (PlayerEntity)entity; - if (player.getHealth() < player.getHealthMaximum()) { + if (player.getHealth() < player.getMaximumHealth()) { player.heal(0.5F); } else if (player.canConsume(false)) { player.getHungerManager().add(1, 0); @@ -210,7 +210,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem if (stack.getDamage() >= getMaxDamage() - 1) { stack.damage(10, player, p -> p.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); - player.damage(MagicalDamageSource.ALICORN_AMULET, player.getHealthMaximum() - 0.01F); + player.damage(MagicalDamageSource.ALICORN_AMULET, player.getMaximumHealth() - 0.01F); player.getHungerManager().setFoodLevel(1); Vec3d pos = player.getPos(); @@ -233,7 +233,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem LocalDifficulty difficulty = player.getWorld().getLocalDifficulty(player.getOrigin()); float amount = (attachedTime * (1 + needfulness)) * (1 + difficulty.getClampedLocalDifficulty()); - amount = Math.min(amount, player.getOwner().getHealthMaximum()); + amount = Math.min(amount, player.getOwner().getMaximumHealth()); player.getOwner().damage(MagicalDamageSource.ALICORN_AMULET, amount); diff --git a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java index 7574873f..9d8230bf 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/AppleItem.java @@ -92,7 +92,7 @@ public class AppleItem extends Item implements Toxic, ItemEntityCapabilities.Tic float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 0.1F + 0.1F; for (int i = 0; i < 3; i++) { - entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.x, entity.y + bob, entity.z, + 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); diff --git a/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java b/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java index e54da728..66a2c38d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/BagOfHoldingItem.java @@ -16,7 +16,7 @@ import com.minelittlepony.unicopia.util.VecHelper; import net.fabricmc.fabric.api.container.ContainerProviderRegistry; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.item.TooltipContext; -import net.minecraft.container.NameableContainerProvider; +import net.minecraft.container.NameableContainerFactory; import net.minecraft.entity.Entity; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; @@ -122,7 +122,7 @@ public class BagOfHoldingItem extends Item implements MagicalItem { return Affinity.NEUTRAL; } - public static class ContainerProvider implements NameableContainerProvider { + public static class ContainerProvider implements NameableContainerFactory { private Text customname = null; diff --git a/src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java b/src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java index bd2e2272..79dece12 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/CloudPlacerItem.java @@ -36,7 +36,7 @@ public class CloudPlacerItem extends Item implements Dispensable { public void placeCloud(World world, BlockPos pos) { CloudEntity cloud = cloudSupplier.create(world); - cloud.setPositionAndAngles(pos, 0, 0); + cloud.refreshPositionAndAngles(pos, 0, 0); world.spawnEntity(cloud); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java b/src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java index 3c89994d..faa2a7c1 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/RottenTomatoItem.java @@ -54,7 +54,7 @@ public class RottenTomatoItem extends TomatoItem implements TossableItem { duration += Math.max(0, effect.getDuration()); } - entity.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, duration, 4)); + entity.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, duration, 4)); } return entity.eatFood(world, stack); diff --git a/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java b/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java index 395c2a95..c2772bbb 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/SpellbookItem.java @@ -40,8 +40,8 @@ public class SpellbookItem extends BookItem implements Dispensable { if (!context.getWorld().isClient && EquinePredicates.MAGI.test(player)) { BlockPos pos = context.getBlockPos().offset(context.getSide()); - double diffX = player.x - (pos.getX() + 0.5); - double diffZ = player.z - (pos.getZ() + 0.5); + double diffX = player.getX() - (pos.getX() + 0.5); + double diffZ = player.getZ() - (pos.getZ() + 0.5); float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX) + Math.PI); placeBook(context.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw); @@ -58,8 +58,7 @@ public class SpellbookItem extends BookItem implements Dispensable { private static void placeBook(World world, int x, int y, int z, float yaw) { SpellbookEntity book = UEntities.SPELLBOOK.create(world); - book.setPositionAndAngles(x + 0.5, y, z + 0.5, yaw, 0); - //book.renderYawOffset = 0; + book.updatePositionAndAngles(x + 0.5, y, z + 0.5, yaw, 0); book.prevYaw = yaw; world.spawnEntity(book); diff --git a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java index 9e44219a..c15137b6 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/StaffItem.java @@ -44,9 +44,9 @@ public class StaffItem extends SwordItem { for (int i = 0; i < 130; i++) { w.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.OAK_LOG.getDefaultState()), - target.x + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), - (target.y + dims.height / 2) + (target.world.random.nextFloat() - 0.5F) * dims.height, - target.z + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), + 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), 0, 0, 0 ); } diff --git a/src/main/java/com/minelittlepony/unicopia/item/StickItem.java b/src/main/java/com/minelittlepony/unicopia/item/StickItem.java index e614c88c..a862f5c5 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/StickItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/StickItem.java @@ -44,7 +44,7 @@ public class StickItem extends Item { ItemStack itemstack = context.getStack(); if (player instanceof ServerPlayerEntity) { - Criterions.PLACED_BLOCK.handle((ServerPlayerEntity)player, pos.up(), itemstack); + Criterions.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack); } if (player == null || !player.abilities.creativeMode) { diff --git a/src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java b/src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java index 3d463bef..13fc1a36 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/TomatoItem.java @@ -23,7 +23,7 @@ public class TomatoItem extends Item { @Override public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) { stack = super.finishUsing(stack, world, entity); - entity.removePotionEffect(StatusEffects.NAUSEA); + entity.removeStatusEffect(StatusEffects.NAUSEA); return stack; } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UEffects.java b/src/main/java/com/minelittlepony/unicopia/item/UEffects.java index b4cf1bee..5611e584 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UEffects.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UEffects.java @@ -20,7 +20,7 @@ public interface UEffects { StatusEffectInstance foodEffect = e.getStatusEffect(p); nausea = new StatusEffectInstance(StatusEffects.NAUSEA, foodEffect.getDuration(), foodEffect.getAmplifier(), foodEffect.isAmbient(), foodEffect.shouldShowParticles()); - e.addPotionEffect(nausea); + e.addStatusEffect(nausea); } e.damage(MagicalDamageSource.FOOD_POISONING, i); diff --git a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java index 9c62e648..86b4ec5d 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java +++ b/src/main/java/com/minelittlepony/unicopia/item/ZapAppleItem.java @@ -74,7 +74,7 @@ public class ZapAppleItem extends AppleItem { player.damage(MagicalDamageSource.ZAP_APPLE, 120); if (w instanceof ServerWorld) { - ((ServerWorld) w).addLightning(new LightningEntity(w, player.x, player.y, player.z, false)); + ((ServerWorld) w).addLightning(new LightningEntity(w, player.getX(), player.getY(), player.getZ(), false)); } return stack; @@ -87,7 +87,7 @@ public class ZapAppleItem extends AppleItem { } public TypedActionResult onFedTo(ItemStack stack, PlayerEntity player, Entity e) { - e.onStruckByLightning(new LightningEntity(e.world, e.x, e.y, e.z, false)); + e.onStruckByLightning(new LightningEntity(e.world, e.getX(), e.getY(), e.getZ(), false)); if (!player.abilities.creativeMode) { stack.decrement(1); @@ -105,7 +105,7 @@ public class ZapAppleItem extends AppleItem { } public Item getAppearance(ItemStack stack) { - if (stack.hasTag() && stack.getTag().containsKey("appearance")) { + if (stack.hasTag() && stack.getTag().contains("appearance")) { return Registry.ITEM.get(new Identifier(stack.getTag().getString("appearance"))); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/Castable.java b/src/main/java/com/minelittlepony/unicopia/magic/Castable.java index 0b3ce024..5f7a8962 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/Castable.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/Castable.java @@ -49,7 +49,7 @@ public interface Castable extends MagicalItem, Dispensable { SpellcastEntity spell = new SpellcastEntity(null, world); spell.setAffinity(getAffinity(stack)); - spell.setPositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0); + spell.updatePositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0); spell.setEffect(effect); world.spawnEntity(spell); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/Caster.java b/src/main/java/com/minelittlepony/unicopia/magic/Caster.java index 54dca826..c562a5e3 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/Caster.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/Caster.java @@ -7,8 +7,8 @@ import java.util.stream.Stream; import javax.annotation.Nullable; import com.minelittlepony.unicopia.entity.Owned; +import com.minelittlepony.unicopia.particles.ParticleSource; import com.minelittlepony.unicopia.util.VecHelper; -import com.minelittlepony.unicopia.util.particles.ParticleSource; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/TossedMagicEffect.java b/src/main/java/com/minelittlepony/unicopia/magic/TossedMagicEffect.java index 92f0e711..7fb90213 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/TossedMagicEffect.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/TossedMagicEffect.java @@ -46,7 +46,7 @@ public interface TossedMagicEffect extends MagicEffect, Tossable> { Entity entity = caster.getOwner(); - world.playSound(null, entity.x, entity.y, entity.z, getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); + world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); if (caster.isLocal()) { AdvancedProjectile projectile = new ProjectileEntity(null, world, caster.getOwner()); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractAttachableSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractAttachableSpell.java index e50c13cf..09479810 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractAttachableSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AbstractAttachableSpell.java @@ -105,7 +105,7 @@ public abstract class AbstractAttachableSpell extends AbstractSpell { public void fromNBT(CompoundTag compound) { super.fromNBT(compound); - if (compound.containsKey("target")) { + if (compound.contains("target")) { targettedEntityId = compound.getUuid("target"); } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java index dd9dc002..f8fbe682 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AttractiveSpell.java @@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.magic.spell; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.MagicalDamageSource; -import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.entity.Entity; @@ -35,7 +35,7 @@ public class AttractiveSpell extends ShieldSpell { Vec3d pos = source.getOriginVector(); source.spawnParticles(new Sphere(false, range), range * 9, p -> { - source.addParticle(UParticles.UNICORN_MAGIC, p, p.subtract(pos)); // getTint() + source.addParticle(new MagicParticleEffect(getTint()), p, p.subtract(pos)); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/AwkwardSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/AwkwardSpell.java index ebf0d89b..44d63d75 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/AwkwardSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/AwkwardSpell.java @@ -26,6 +26,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; @@ -64,7 +65,7 @@ public class AwkwardSpell extends AbstractSpell implements TossedMagicEffect, Us if (shouldSpawnParticle(type)) { try { - source.getWorld().addParticle(type.getParametersFactory().read(type, new StringReader("0 0 0")), pos.x, pos.y, pos.z, 0, 0, 0); + source.addParticle(type.getParametersFactory().read(type, new StringReader("0 0 0")), pos, Vec3d.ZERO); } catch (CommandSyntaxException e) { e.printStackTrace(); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java index fb9d7081..1334a334 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChangelingTrapSpell.java @@ -25,10 +25,10 @@ import net.minecraft.item.AutomaticItemPlacementContext; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtHelper; import net.minecraft.particle.ParticleTypes; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; -import net.minecraft.util.TagHelper; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -116,8 +116,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff entity.limbDistance = 0; entity.lastLimbDistance = 0; - entity.x = Math.floor(entity.x) + 0.4; - entity.z = Math.floor(entity.z) + 0.4; + entity.setPos(Math.floor(entity.getX()) + 0.4, entity.getY(), Math.floor(entity.getZ()) + 0.4); entity.hurtTime = 2; entity.horizontalCollision = true; @@ -129,7 +128,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff StatusEffectInstance SLIME_REGEN = new StatusEffectInstance(StatusEffects.REGENERATION, 0); - entity.addPotionEffect(SLIME_REGEN); + entity.addStatusEffect(SLIME_REGEN); if (caster.isLocal()) { if (struggleCounter <= 0) { @@ -212,7 +211,7 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff super.toNBT(compound); if (previousTrappedPosition != null) { - compound.put("previousTrappedPosition", TagHelper.serializeBlockPos(previousTrappedPosition)); + compound.put("previousTrappedPosition", NbtHelper.fromBlockPos(previousTrappedPosition)); } compound.putInt("struggle", struggleCounter); } @@ -224,8 +223,8 @@ public class ChangelingTrapSpell extends AbstractSpell implements TossedMagicEff previousTrappedPosition = null; struggleCounter = compound.getInt("struggle"); - if (compound.containsKey("previousTrappedPosition")) { - previousTrappedPosition = TagHelper.deserializeBlockPos(compound.getCompound("previousTrappedPosition")); + if (compound.contains("previousTrappedPosition")) { + previousTrappedPosition = NbtHelper.toBlockPos(compound.getCompound("previousTrappedPosition")); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java index 2ba52d4e..50ca2397 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ChargingSpell.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.magic.spell; import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Line; @@ -49,11 +50,9 @@ public class ChargingSpell extends AbstractAttachableSpell { Shape line = new Line(start, target.getPos()); source.spawnParticles(line, (int)line.getVolumeOfSpawnableSpace(), pos -> { - // TODO: ParticleTypeRegistry - // ParticleTypeRegistry.getTnstance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos.add(start), 0, 0, 0, getTint()); + source.addParticle(new MagicParticleEffect(getTint()), pos.add(start), Vec3d.ZERO); }); } - } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java index 579101e0..fbcde2d1 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/DarknessSpell.java @@ -6,10 +6,10 @@ import java.util.function.Consumer; import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.CasterUtils; +import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.PosHelper; -import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -21,6 +21,7 @@ import net.minecraft.entity.ai.goal.FleeEntityGoal; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; @@ -65,7 +66,7 @@ public class DarknessSpell extends AbstractAttachableSpell { SpellcastEntity living = (SpellcastEntity)caster.getEntity(); living.getGoals().add(1, new FleeEntityGoal<>(living, PlayerEntity.class, 3, 4, 4)); - living.setPosition(living.x, living.y, living.z); + living.setPos(living.getX(), living.getY(), living.getZ()); } } @@ -108,8 +109,9 @@ public class DarknessSpell extends AbstractAttachableSpell { Fertilizable growable = (Fertilizable)state.getBlock(); if (growable.canGrow(source.getWorld(), source.getWorld().random, pos, state)) { - growable.grow(source.getWorld(), source.getWorld().random, pos, state); - + if (source.getWorld() instanceof ServerWorld) { + growable.grow((ServerWorld)source.getWorld(), source.getWorld().random, pos, state); + } return; } } @@ -125,7 +127,7 @@ public class DarknessSpell extends AbstractAttachableSpell { } private void applyLight(Caster source, LivingEntity entity) { - if (entity.getHealth() < entity.getHealthMaximum()) { + if (entity.getHealth() < entity.getMaximumHealth()) { entity.heal(1); } } @@ -137,7 +139,7 @@ public class DarknessSpell extends AbstractAttachableSpell { } if (!isLightholder(entity)) { - entity.addPotionEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100, 3)); + entity.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 100, 3)); Vec3d origin = source.getOriginVector(); Vec3d to = entity.getPosVector(); @@ -156,7 +158,7 @@ public class DarknessSpell extends AbstractAttachableSpell { } else { if (entity.hasStatusEffect(StatusEffects.BLINDNESS)) { - entity.removePotionEffect(StatusEffects.BLINDNESS); + entity.removeStatusEffect(StatusEffects.BLINDNESS); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java index 0fabee01..e8711a2e 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/DisguiseSpell.java @@ -17,7 +17,8 @@ import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.SuppressableEffect; -import com.minelittlepony.unicopia.util.particles.UParticles; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; +import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.projectile.ProjectileUtil; import com.mojang.authlib.GameProfile; @@ -207,19 +208,19 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, to.onGround = from.onGround; if (isAttachedEntity(entity)) { - to.x = Math.floor(from.x) + 0.5; - to.y = Math.floor(from.y); - to.z = Math.floor(from.z) + 0.5; + double x = Math.floor(from.getX()) + 0.5; + double y = Math.floor(from.getX()); + double z = Math.floor(from.getX()) + 0.5; - to.prevX = to.x; - to.prevY = to.y; - to.prevZ = to.z; + to.prevX = x; + to.prevY = y; + to.prevZ = z; - to.prevRenderX = to.x; - to.prevRenderY = to.x; - to.prevRenderZ = to.x; + to.lastRenderX = x; + to.lastRenderY = y; + to.lastRenderZ = z; - to.setPosition(to.x, to.y, to.z); + to.setPos(x, y, z); } else { to.copyPositionAndRotation(from); @@ -227,35 +228,32 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, to.prevY = from.prevY; to.prevZ = from.prevZ; - to.prevRenderX = from.prevRenderX; - to.prevRenderY = from.prevRenderY; - to.prevRenderZ = from.prevRenderZ; + to.lastRenderX = from.lastRenderX; + to.lastRenderY = from.lastRenderY; + to.lastRenderZ = from.lastRenderZ; } if (to instanceof PlayerEntity) { PlayerEntity l = (PlayerEntity)to; - l.field_7500 = l.x; - l.field_7521 = l.y; - l.field_7499 = l.z; + l.field_7500 = l.getX(); + l.field_7521 = l.getY(); + l.field_7499 = l.getZ(); } to.setVelocity(from.getVelocity()); to.prevPitch = from.prevPitch; to.prevYaw = from.prevYaw; - - //to.distanceWalkedOnStepModified = from.distanceWalkedOnStepModified; - //to.distanceWalkedModified = from.distanceWalkedModified; - //to.prevDistanceWalkedModified = from.prevDistanceWalkedModified; + to.distanceTraveled = from.distanceTraveled; if (to instanceof LivingEntity) { LivingEntity l = (LivingEntity)to; l.headYaw = from.headYaw; l.prevHeadYaw = from.prevHeadYaw; - //l.renderYawOffset = from.renderYawOffset; - //l.prevRenderYawOffset = from.prevRenderYawOffset; + l.bodyYaw = from.bodyYaw; + l.prevBodyYaw = from.prevBodyYaw; l.limbDistance = from.limbDistance; l.limbAngle = from.limbAngle; @@ -274,7 +272,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, ItemStack neu = from.getEquippedStack(i); ItemStack old = l.getEquippedStack(i); if (old != neu) { - l.setEquippedStack(i, neu); + l.equipStack(i, neu); } } } @@ -321,7 +319,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, if (entity != null) { entity.setInvisible(true); - entity.y = Integer.MIN_VALUE; + entity.setPos(entity.getX(), Integer.MIN_VALUE, entity.getY()); } return true; @@ -408,7 +406,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, if (player.isClientPlayer() && InteractionManager.instance().getViewMode() == 0) { entity.setInvisible(true); - entity.y = Integer.MIN_VALUE; + entity.setPos(entity.getX(), Integer.MIN_VALUE, entity.getY()); } return player.getSpecies() == Race.CHANGELING; @@ -426,7 +424,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, @Override public void render(Caster source) { if (getSuppressed()) { - source.spawnParticles(UParticles.UNICORN_MAGIC, 5); + source.spawnParticles(MagicParticleEffect.UNICORN, 5); source.spawnParticles(UParticles.CHANGELING_MAGIC, 5); } else if (source.getWorld().random.nextInt(30) == 0) { source.spawnParticles(UParticles.CHANGELING_MAGIC, 2); @@ -460,7 +458,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, removeDisguise(); } - if (compound.containsKey("entity")) { + if (compound.contains("entity")) { entityId = newId; entityNbt = compound.getCompound("entity"); @@ -529,7 +527,7 @@ public class DisguiseSpell extends AbstractSpell implements AttachedMagicEffect, static abstract class PlayerAccess extends PlayerEntity { public PlayerAccess() { super(null, null); } static TrackedData getModelBitFlag() { - return PLAYER_MODEL_BIT_MASK; + return PLAYER_MODEL_PARTS; } } } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java index 355fcfa6..4f626955 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/FaithfulAssistantSpell.java @@ -73,7 +73,7 @@ public class FaithfulAssistantSpell extends AbstractSpell { living.getGoals().add(1, new SwimGoal(living)); living.getGoals().add(2, new FollowCasterGoal<>((Caster)caster, 1, 4, 70)); - living.setPosition(living.x, living.y, living.z); + living.setPos(living.getX(), living.getY(), living.getZ()); } } @@ -120,7 +120,7 @@ public class FaithfulAssistantSpell extends AbstractSpell { public void fromNBT(CompoundTag compound) { super.fromNBT(compound); - if (compound.containsKey("effect")) { + if (compound.contains("effect")) { if (piggyBackSpell != null) { piggyBackSpell.fromNBT(compound.getCompound("effect")); } else { diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/GenericSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/GenericSpell.java index dbd05c9b..409aab95 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/GenericSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/GenericSpell.java @@ -5,6 +5,7 @@ import java.util.function.Supplier; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.MagicEffect; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; public class GenericSpell extends AbstractSpell { @@ -41,8 +42,7 @@ public class GenericSpell extends AbstractSpell { @Override public void render(Caster source) { - // TODO: ParticleTypeRegistry - // source.spawnParticles(UParticles.UNICORN_MAGIC, 1, getTint()); + source.spawnParticles(new MagicParticleEffect(getTint()), 1); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java index f08c140e..d767fa43 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/GlowingSpell.java @@ -39,7 +39,7 @@ public class GlowingSpell extends GenericSpell implements HeldMagicEffect { ChunkBlockLightProvider provider = (ChunkBlockLightProvider)view; - provider.queueLightCheck(lastPos); + provider.checkBlock(lastPos); } } @@ -68,7 +68,7 @@ public class GlowingSpell extends GenericSpell implements HeldMagicEffect { ChunkBlockLightProvider provider = (ChunkBlockLightProvider)view; if (lastPos != null && !lastPos.equals(pos)) { - provider.queueLightCheck(lastPos); + provider.checkBlock(lastPos); } lastPos = pos; @@ -76,8 +76,8 @@ public class GlowingSpell extends GenericSpell implements HeldMagicEffect { int light = provider.getLightLevel(pos); if (light < 8) { - provider.method_15514(pos, 8); - provider.queueLightCheck(pos); + provider.addLightSource(pos, 8); + provider.checkBlock(pos); } return true; @@ -87,7 +87,7 @@ public class GlowingSpell extends GenericSpell implements HeldMagicEffect { public void toNBT(CompoundTag compound) { super.toNBT(compound); - if (compound.containsKey("lastX")) { + if (compound.contains("lastX")) { lastPos = new BlockPos(compound.getInt("lastX"), compound.getInt("lastY"), compound.getInt("lastZ")); } else { lastPos = null; diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java index d1ea9f0a..e3abdc7e 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/IceSpell.java @@ -148,7 +148,7 @@ public class IceSpell extends AbstractSpell.RangedAreaSpell implements Useable, if (!state.equals(converted)) { world.setBlockState(pos, converted, 3); - } else if (state.getMaterial() != UMaterials.CLOUD && world.doesBlockHaveSolidTopSurface(pos, owner) + } else if (state.getMaterial() != UMaterials.CLOUD && world.isTopSolid(pos, owner) || (id == Blocks.SNOW) || state.matches(BlockTags.LEAVES)) { incrementIce(world, pos.up()); diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java index eb7440be..da311cf1 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/NecromancySpell.java @@ -87,7 +87,7 @@ public class NecromancySpell extends AbstractSpell.RangedAreaSpell { protected void spawnMonster(Caster source, Vec3d pos) { int index = (int)MathHelper.nextDouble(source.getWorld().random, 0, spawns.size()); LivingEntity zombie = spawns.get(index).create(source.getWorld()); - zombie.setPosition(pos.x, pos.y, pos.z); + zombie.setPos(pos.x, pos.y, pos.z); zombie.setVelocity(0, 0.3, 0); @@ -102,7 +102,7 @@ public class NecromancySpell extends AbstractSpell.RangedAreaSpell { source.spawnParticles(affectRegion, 5, pos -> { if (!source.getWorld().isAir(new BlockPos(pos).down())) { - source.getWorld().addParticle(ParticleTypes.FLAME, pos.x, pos.y, pos.z, 0, 0, 0); + source.addParticle(ParticleTypes.FLAME, pos, Vec3d.ZERO); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java index a4d3e636..3195427c 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/PortalSpell.java @@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.magic.CastResult; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.Useable; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -28,6 +29,7 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -150,7 +152,7 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl public boolean update(Caster source) { if (!source.getWorld().isClient) { getDestinationPortal().ifPresent(dest -> - source.getWorld().getEntities(Entity.class, getTeleportBounds().offset(source.getOrigin())).stream() + source.getWorld().getEntities(Entity.class, getTeleportBounds().offset(source.getOrigin()), null).stream() .filter(this::canTeleport) .forEach(i -> teleportEntity(source, dest, i))); } @@ -160,10 +162,9 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl @Override public void render(Caster source) { - // TODO: ParticleTypeRegistry - /*source.spawnParticles(getPortalZone(), 10, pos -> { - ParticleTypeRegistry.getTnstance().spawnParticle(UParticles.UNICORN_MAGIC, false, pos, 0, 0, 0, getTint()); - });*/ + source.spawnParticles(getPortalZone(), 10, pos -> { + source.addParticle(new MagicParticleEffect(getTint()), pos, Vec3d.ZERO); + }); } public Shape getPortalZone() { @@ -184,7 +185,7 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl } protected boolean canTeleport(Entity i) { - return !(i instanceof IMagicals) && i.portalCooldown == 0; + return !(i instanceof IMagicals) && i.netherPortalCooldown == 0; } protected void teleportEntity(Caster source, PortalSpell dest, Entity i) { @@ -196,9 +197,9 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl Direction offset = i.getHorizontalFacing(); - double destX = dest.position.getX() + (i.x - source.getOrigin().getX()); - double destY = dest.position.getY() + (i.y - source.getOrigin().getY()); - double destZ = dest.position.getZ() + (i.z - source.getOrigin().getZ()); + double destX = dest.position.getX() + (i.getX() - source.getOrigin().getX()); + double destY = dest.position.getY() + (i.getY() - source.getOrigin().getY()); + double destZ = dest.position.getZ() + (i.getZ() - source.getOrigin().getZ()); if (axis != Direction.Axis.Y) { destX += offset.getOffsetX(); @@ -206,17 +207,17 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl destZ += offset.getOffsetZ(); } - i.portalCooldown = i.getDefaultPortalCooldown(); + i.netherPortalCooldown = i.getDefaultNetherPortalCooldown(); i.getEntityWorld().playSound(null, i.getBlockPos(), SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.PLAYERS, 1, 1); if (dest.axis != axis) { if (xi != dest.axis) { - i.setPositionAndAngles(i.x, i.y, i.z, i.yaw + 90, i.pitch); + i.updatePositionAndAngles(i.getX(), i.getY(), i.getZ(), i.yaw + 90, i.pitch); } } - i.setPosition(destX, destY, destZ); + i.setPos(destX, destY, destZ); i.getEntityWorld().playSound(null, i.getBlockPos(), SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.PLAYERS, 1, 1); } @@ -312,19 +313,19 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl public void fromNBT(CompoundTag compound) { super.fromNBT(compound); - if (compound.containsKey("destination")) { + if (compound.contains("destination")) { destinationPos = NbtSerialisable.readBlockPos(compound.getCompound("destination")); } - if (compound.containsKey("casterId")) { + if (compound.contains("casterId")) { casterId = compound.getUuid("casterId"); } - if (compound.containsKey("destinationId")) { + if (compound.contains("destinationId")) { destinationId = compound.getUuid("destinationId"); } - if (compound.containsKey("axis")) { + if (compound.contains("axis")) { axis = Direction.Axis.fromName(compound.getString("axis").toLowerCase(Locale.ROOT)); if (axis == null) { diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/RevealingSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/RevealingSpell.java index 6a59777d..4a7cbe82 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/RevealingSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/RevealingSpell.java @@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.magic.spell; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.SuppressableEffect; -import com.minelittlepony.unicopia.util.particles.UParticles; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -47,11 +47,12 @@ public class RevealingSpell extends AbstractSpell { public void render(Caster source) { Shape area = new Sphere(false, 15); - source.spawnParticles(area, 5, pos -> { - source.addParticle(UParticles.UNICORN_MAGIC, pos, Vec3d.ZERO); // getTint() - }); + MagicParticleEffect effect = new MagicParticleEffect(getTint()); - source.spawnParticles(UParticles.UNICORN_MAGIC, 5); //getTint() + source.spawnParticles(area, 5, pos -> { + source.addParticle(effect, pos, Vec3d.ZERO); + }); + source.spawnParticles(effect, 5); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java index d1c69851..88f9a975 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ScorchSpell.java @@ -5,14 +5,15 @@ import javax.annotation.Nullable; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.TossedMagicEffect; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; import com.minelittlepony.unicopia.util.PosHelper; -import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.util.projectile.AdvancedProjectile; import com.minelittlepony.unicopia.util.shape.Sphere; import net.minecraft.block.BlockState; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.explosion.Explosion.DestructionType; public class ScorchSpell extends FireSpell implements TossedMagicEffect { @@ -44,9 +45,7 @@ public class ScorchSpell extends FireSpell implements TossedMagicEffect { if (!state.equals(newState)) { source.getWorld().setBlockState(pos, newState, 3); source.spawnParticles(new Sphere(false, 1), 5, p -> { - p = PosHelper.offset(p, pos); - - source.getWorld().addParticle(ParticleTypes.SMOKE, p.x, p.y, p.z, 0, 0, 0); + source.addParticle(ParticleTypes.SMOKE, PosHelper.offset(p, pos), Vec3d.ZERO); }); } @@ -56,7 +55,7 @@ public class ScorchSpell extends FireSpell implements TossedMagicEffect { @Override public void render(Caster source) { source.spawnParticles(ParticleTypes.FLAME, 3); - source.spawnParticles(UParticles.UNICORN_MAGIC, 3); // getTint() + source.spawnParticles(new MagicParticleEffect(getTint()), 3); } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java index 2438cc2d..acca6a03 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/ShieldSpell.java @@ -8,8 +8,9 @@ import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.AttachedMagicEffect; import com.minelittlepony.unicopia.magic.Caster; -import com.minelittlepony.unicopia.util.particles.ParticleConnection; -import com.minelittlepony.unicopia.util.particles.UParticles; +import com.minelittlepony.unicopia.particles.MagicParticleEffect; +import com.minelittlepony.unicopia.particles.ParticleConnection; +import com.minelittlepony.unicopia.particles.UParticles; import com.minelittlepony.unicopia.util.projectile.ProjectileUtil; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -48,7 +49,7 @@ public class ShieldSpell extends AbstractSpell.RangedAreaSpell implements Attach float radius = 4 + (source.getCurrentLevel() * 2); source.spawnParticles(new Sphere(true, radius), (int)(radius * 6), pos -> { - source.addParticle(UParticles.UNICORN_MAGIC, pos, Vec3d.ZERO); // getTint() + source.addParticle(new MagicParticleEffect(getTint()), pos, Vec3d.ZERO); }); particlEffect diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java index 36736f1f..bab200a8 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/SiphoningSpell.java @@ -46,7 +46,7 @@ public class SiphoningSpell extends AbstractSpell.RangedAreaSpell { if (source.getAffinity() == Affinity.BAD) { if (owner != null) { float healthGain = 0; - float maxHealthGain = owner.getHealthMaximum() - owner.getHealth(); + float maxHealthGain = owner.getMaximumHealth() - owner.getHealth(); if (maxHealthGain > 0) { float attackAmount = Math.max(maxHealthGain / target.size(), 0.5F); @@ -80,7 +80,7 @@ public class SiphoningSpell extends AbstractSpell.RangedAreaSpell { } else { target.forEach(e -> { - float maxHealthGain = e.getHealthMaximum() - e.getHealth(); + float maxHealthGain = e.getMaximumHealth() - e.getHealth(); if (maxHealthGain <= 0) { if (source.getWorld().random.nextInt(30) == 0) { @@ -118,10 +118,7 @@ public class SiphoningSpell extends AbstractSpell.RangedAreaSpell { double dist = pos.distanceTo(origin); Vec3d velocity = pos.subtract(origin).normalize().multiply(direction * dist); - - source.getWorld().addParticle( - direction == 1 ? ParticleTypes.HEART : ParticleTypes.ANGRY_VILLAGER, - pos.x, pos.y, pos.z, velocity.x, velocity.y, velocity.z); + source.addParticle(direction == 1 ? ParticleTypes.HEART : ParticleTypes.ANGRY_VILLAGER, pos, velocity); } }); } diff --git a/src/main/java/com/minelittlepony/unicopia/magic/spell/SpellRegistry.java b/src/main/java/com/minelittlepony/unicopia/magic/spell/SpellRegistry.java index c6ab8ecf..41dc8417 100644 --- a/src/main/java/com/minelittlepony/unicopia/magic/spell/SpellRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/magic/spell/SpellRegistry.java @@ -69,7 +69,7 @@ public class SpellRegistry { @Nullable public MagicEffect createEffectFromNBT(CompoundTag compound) { - if (compound.containsKey("effect_id")) { + if (compound.contains("effect_id")) { MagicEffect effect = getSpellFromName(compound.getString("effect_id")); if (effect != null) { @@ -145,7 +145,7 @@ public class SpellRegistry { } public static boolean stackHasEnchantment(ItemStack stack) { - return !stack.isEmpty() && stack.hasTag() && stack.getTag().containsKey("spell"); + return !stack.isEmpty() && stack.hasTag() && stack.getTag().contains("spell"); } @Nonnull diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java new file mode 100644 index 00000000..97322081 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinEntityRenderDispatcher.java @@ -0,0 +1,64 @@ +package com.minelittlepony.unicopia.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.minelittlepony.unicopia.entity.player.Pony; +import com.minelittlepony.unicopia.magic.spell.DisguiseSpell; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; + +@Mixin(EntityRenderDispatcher.class) +abstract class MixinEntityRenderDispatcher { + @Inject(method = "render(Lnet/minecraft/entity/Entity;DDDFFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private void beforeRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { + matrices.push(); + + if (!(entity instanceof PlayerEntity)) { + return; + } + + Pony pony = Pony.of((PlayerEntity)entity); + + if (pony.getGravity().getGravitationConstant() < 0) { + matrices.translate(0, entity.getDimensions(entity.getPose()).height, 0); + matrices.scale(1, -1, 1); + entity.prevPitch *= -1; + entity.pitch *= -1; + } + + DisguiseSpell effect = pony.getEffect(DisguiseSpell.class, false); + + if (effect == null || effect.isDead()) { + return; + } + + Entity e = effect.getDisguise(); + + if (e != null) { + info.cancel(); + ((EntityRenderDispatcher)(Object)this).render(entity, x, y, z, yaw, tickDelta, matrices, vertexConsumers, light); + } + } + + @Inject(method = "render(Lnet/minecraft/entity/Entity;DDDFFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private void afterRender(E entity, double x, double y, double z, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo info) { + matrices.pop(); + + if (!(entity instanceof PlayerEntity)) { + return; + } + + Pony pony = Pony.of((PlayerEntity)entity); + + if (pony.getGravity().getGravitationConstant() < 0) { + entity.prevPitch *= -1; + entity.pitch *= -1; + } + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java b/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java index 116ea4f7..99b5361c 100644 --- a/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java +++ b/src/main/java/com/minelittlepony/unicopia/network/EffectSync.java @@ -33,7 +33,7 @@ public class EffectSync { public boolean has() { CompoundTag comp = owned.getEntity().getDataTracker().get(param); - if (comp == null || !comp.containsKey("effect_id")) { + if (comp == null || !comp.contains("effect_id")) { if (effect != null) { effect.setDead(); effect = null; @@ -66,7 +66,7 @@ public class EffectSync { CompoundTag comp = owned.getEntity().getDataTracker().get(param); - if (comp == null || !comp.containsKey("effect_id")) { + if (comp == null || !comp.contains("effect_id")) { if (effect != null) { effect.setDead(); effect = null; diff --git a/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java b/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java new file mode 100644 index 00000000..d83db22d --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/particles/MagicParticleEffect.java @@ -0,0 +1,92 @@ +package com.minelittlepony.unicopia.particles; + +import java.util.Locale; + +import com.minelittlepony.unicopia.util.Color; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.CommandSyntaxException; + +import net.minecraft.particle.ParticleEffect; +import net.minecraft.particle.ParticleType; +import net.minecraft.util.PacketByteBuf; +import net.minecraft.util.registry.Registry; + +public class MagicParticleEffect implements ParticleEffect { + + public static final MagicParticleEffect UNICORN = new MagicParticleEffect(false, 0, 0, 0); + public static final ParticleEffect.Factory UNICORN_FACTORY = new ParticleEffect.Factory() { + @Override + public MagicParticleEffect read(ParticleType particleType, StringReader reader) throws CommandSyntaxException { + reader.expect(' '); + boolean f = reader.readBoolean(); + reader.expect(' '); + float g = (float)reader.readDouble(); + reader.expect(' '); + float h = (float)reader.readDouble(); + reader.expect(' '); + float i = (float)reader.readDouble(); + return new MagicParticleEffect(f, g, h, i); + } + + @Override + public MagicParticleEffect read(ParticleType particleType, PacketByteBuf buf) { + return new MagicParticleEffect(buf.readBoolean(), buf.readFloat(), buf.readFloat(), buf.readFloat()); + } + }; + + private final boolean tinted; + private final float red; + private final float green; + private final float blue; + + public MagicParticleEffect(int tint) { + this(true, Color.r(tint), Color.g(tint), Color.b(tint)); + } + + public MagicParticleEffect(float r, float g, float b) { + this(true, r, g, b); + } + + protected MagicParticleEffect(boolean tint, float r, float g, float b) { + tinted = tint; + red = r; + green = g; + blue = b; + } + + + public boolean hasTint() { + return false; + } + + public float getRed() { + return red; + } + + public float getGreen() { + return green; + } + + public float getBlue() { + return blue; + } + + @Override + public ParticleType getType() { + return UParticles.UNICORN_MAGIC; + } + + @Override + public void write(PacketByteBuf buf) { + buf.writeBoolean(tinted); + buf.writeFloat(red); + buf.writeFloat(green); + buf.writeFloat(blue); + } + + @Override + public String asString() { + return String.format(Locale.ROOT, "%s %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getId(getType()), red, green, blue); + } + +} diff --git a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleConnection.java b/src/main/java/com/minelittlepony/unicopia/particles/ParticleConnection.java similarity index 94% rename from src/main/java/com/minelittlepony/unicopia/util/particles/ParticleConnection.java rename to src/main/java/com/minelittlepony/unicopia/particles/ParticleConnection.java index 3e3e65f5..fe5eec68 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleConnection.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/ParticleConnection.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.util.particles; +package com.minelittlepony.unicopia.particles; import java.util.Optional; import java.util.function.Supplier; diff --git a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleEmitter.java b/src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/util/particles/ParticleEmitter.java rename to src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java index b9ad4e86..e01d1e5a 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleEmitter.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/ParticleEmitter.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.util.particles; +package com.minelittlepony.unicopia.particles; import java.util.EnumSet; import java.util.Random; diff --git a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleSource.java b/src/main/java/com/minelittlepony/unicopia/particles/ParticleSource.java similarity index 95% rename from src/main/java/com/minelittlepony/unicopia/util/particles/ParticleSource.java rename to src/main/java/com/minelittlepony/unicopia/particles/ParticleSource.java index 99b48551..99b43b9f 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleSource.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/ParticleSource.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.util.particles; +package com.minelittlepony.unicopia.particles; import java.util.function.Consumer; diff --git a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleUtils.java b/src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java similarity index 78% rename from src/main/java/com/minelittlepony/unicopia/util/particles/ParticleUtils.java rename to src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java index abdc08dc..b31e048d 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/particles/ParticleUtils.java +++ b/src/main/java/com/minelittlepony/unicopia/particles/ParticleUtils.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.util.particles; +package com.minelittlepony.unicopia.particles; import com.minelittlepony.unicopia.util.shape.Shape; import com.minelittlepony.unicopia.util.shape.Sphere; @@ -13,15 +13,15 @@ public final class ParticleUtils { public static void spawnParticles(ParticleEffect particleId, Entity entity, int count) { double halfDist = entity.getStandingEyeHeight() / 1.5; - double middle = entity.getBoundingBox().minY + halfDist; + double middle = entity.getBoundingBox().y1 + halfDist; Shape shape = new Sphere(false, (float)halfDist + entity.getWidth()); shape.randomPoints(count, entity.world.random).forEach(point -> { entity.world.addParticle(particleId, - entity.x + point.x, + entity.getX() + point.x, middle + point.y, - entity.z + point.z, + entity.getZ() + point.z, 0, 0, 0); }); } diff --git a/src/main/java/com/minelittlepony/unicopia/particles/UParticles.java b/src/main/java/com/minelittlepony/unicopia/particles/UParticles.java new file mode 100644 index 00000000..b94bb561 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/particles/UParticles.java @@ -0,0 +1,22 @@ +package com.minelittlepony.unicopia.particles; + +import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; +import net.minecraft.particle.DefaultParticleType; +import net.minecraft.particle.ParticleType; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; + +public interface UParticles { + + ParticleType UNICORN_MAGIC = register(FabricParticleTypes.complex(MagicParticleEffect.UNICORN_FACTORY), "unicorn_magic"); + DefaultParticleType CHANGELING_MAGIC = register(FabricParticleTypes.simple(), "changeling_magic"); + + DefaultParticleType RAIN_DROPS = register(FabricParticleTypes.simple(), "rain_drops"); + + DefaultParticleType SPHERE = register(FabricParticleTypes.simple(true), "sphere"); + DefaultParticleType DISK = register(FabricParticleTypes.simple(), "disk"); + + static > T register(T type, String name) { + return Registry.register(Registry.PARTICLE_TYPE, new Identifier("unicopia", name), type); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java b/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java index f3d8c593..d308af97 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java @@ -16,15 +16,15 @@ import net.minecraft.structure.processor.BlockIgnoreStructureProcessor; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableIntBoundingBox; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.decorator.Decorator; -import net.minecraft.world.gen.decorator.DecoratorConfig; +import net.minecraft.world.gen.decorator.NopeDecoratorConfig; import net.minecraft.world.gen.feature.AbstractTempleFeature; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.FeatureConfig; @@ -53,7 +53,7 @@ class CloudDungeonFeature extends AbstractTempleFeature { Biomes.ICE_SPIKES, Biomes.TAIGA ).forEach(biome -> { - biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, Biome.configureFeature(UStructures.CLOUD_HOUSE, FeatureConfig.DEFAULT, Decorator.NOPE, DecoratorConfig.DEFAULT)); + biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, UStructures.CLOUD_HOUSE.configure(FeatureConfig.DEFAULT).createDecoratedFeature(Decorator.NOPE.configure(NopeDecoratorConfig.DEFAULT))); }); } @@ -78,8 +78,8 @@ class CloudDungeonFeature extends AbstractTempleFeature { } public static class Start extends StructureStart { - public Start(StructureFeature feature, int x, int z, Biome biome, MutableIntBoundingBox bound, int var6, long var7) { - super(feature, x, z, biome, bound, var6, var7); + public Start(StructureFeature feature, int x, int z, BlockBox bound, int var6, long var7) { + super(feature, x, z, bound, var6, var7); } @Override @@ -131,7 +131,7 @@ class CloudDungeonFeature extends AbstractTempleFeature { } @Override - protected void handleMetadata(String var1, BlockPos var2, IWorld var3, Random var4, MutableIntBoundingBox var5) { + protected void handleMetadata(String var1, BlockPos var2, IWorld var3, Random var4, BlockBox var5) { } } } diff --git a/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java b/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java index bd7ec0f0..ea74da74 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/CustomSaplingGenerator.java @@ -3,28 +3,66 @@ package com.minelittlepony.unicopia.structure; import java.util.Random; import javax.annotation.Nullable; +import com.google.common.collect.ImmutableList; + import net.minecraft.block.BlockState; import net.minecraft.block.sapling.SaplingGenerator; -import net.minecraft.world.gen.feature.AbstractTreeFeature; -import net.minecraft.world.gen.feature.DefaultFeatureConfig; -import net.minecraft.world.gen.feature.OakTreeFeature; +import net.minecraft.world.gen.decorator.BeehiveTreeDecorator; +import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.foliage.BlobFoliagePlacer; +import net.minecraft.world.gen.stateprovider.SimpleStateProvider; public class CustomSaplingGenerator extends SaplingGenerator { - private final int height; - - private final BlockState log; - private final BlockState leaves; + private final BranchedTreeFeatureConfig fancyConfig; + private final BranchedTreeFeatureConfig fancyHiveConfig; + private final BranchedTreeFeatureConfig hiveConfig; + private final BranchedTreeFeatureConfig config; public CustomSaplingGenerator(int height, BlockState log, BlockState leaves) { - this.height = height; - this.log = log; - this.leaves = leaves; + fancyConfig = new BranchedTreeFeatureConfig.Builder( + new SimpleStateProvider(log), + new SimpleStateProvider(leaves), + new BlobFoliagePlacer(0, 0)) + .baseHeight(height) + .build(); + fancyHiveConfig = new BranchedTreeFeatureConfig.Builder( + new SimpleStateProvider(log), + new SimpleStateProvider(leaves), + new BlobFoliagePlacer(0, 0)) + .treeDecorators(ImmutableList.of(new BeehiveTreeDecorator(0.05F))) + .baseHeight(height) + .build(); + + hiveConfig = new BranchedTreeFeatureConfig.Builder( + new SimpleStateProvider(log), + new SimpleStateProvider(leaves), + new BlobFoliagePlacer(2, 0)) + .baseHeight(height) + .heightRandA(height / 2) + .foliageHeight((height * 2) / 3) + .noVines() + .treeDecorators(ImmutableList.of(new BeehiveTreeDecorator(0.05F))) + .build(); + + config = new BranchedTreeFeatureConfig.Builder( + new SimpleStateProvider(log), + new SimpleStateProvider(leaves), + new BlobFoliagePlacer(2, 0)) + .baseHeight(4) + .heightRandA(2) + .foliageHeight(3) + .noVines() + .build(); } @Override @Nullable - protected AbstractTreeFeature createTreeFeature(Random random) { - return new OakTreeFeature(DefaultFeatureConfig::deserialize, true, height, log, leaves, false); + protected ConfiguredFeature createTreeFeature(Random random, boolean hives) { + return random.nextInt(10) == 0 + ? Feature.FANCY_TREE.configure(hives ? fancyHiveConfig : fancyConfig) + : Feature.NORMAL_TREE.configure(hives ? hiveConfig : config); } - } +} diff --git a/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java b/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java index 64e03d8d..7711533c 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java @@ -16,8 +16,8 @@ import net.minecraft.structure.processor.BlockIgnoreStructureProcessor; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; import net.minecraft.util.Identifier; +import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MutableIntBoundingBox; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; @@ -56,7 +56,7 @@ class RuinFeature extends AbstractTempleFeature { Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS ).forEach(biome -> { - biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES, Biome.configureFeature(UStructures.CLOUD_HOUSE, FeatureConfig.DEFAULT, Decorator.NOPE, DecoratorConfig.DEFAULT)); + biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES, UStructures.CLOUD_HOUSE.configure(FeatureConfig.DEFAULT).createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT))); }); } @@ -81,8 +81,8 @@ class RuinFeature extends AbstractTempleFeature { } public static class Start extends StructureStart { - public Start(StructureFeature feature, int x, int z, Biome biome, MutableIntBoundingBox bound, int var6, long var7) { - super(feature, x, z, biome, bound, var6, var7); + public Start(StructureFeature feature, int x, int z, BlockBox bound, int var6, long var7) { + super(feature, x, z, bound, var6, var7); } @Override @@ -134,7 +134,7 @@ class RuinFeature extends AbstractTempleFeature { } @Override - protected void handleMetadata(String var1, BlockPos var2, IWorld var3, Random var4, MutableIntBoundingBox var5) { + protected void handleMetadata(String var1, BlockPos var2, IWorld var3, Random var4, BlockBox var5) { } } } diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java index 2e347078..0383de27 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicBlockItem.java @@ -86,13 +86,13 @@ public class ToxicBlockItem extends BlockItem implements Toxic, Toxin { public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) { if (toxicity.toxicWhenRaw()) { - player.addPotionEffect(toxicity.getPoisonEffect()); + player.addStatusEffect(toxicity.getPoisonEffect()); } if (toxicity.isLethal()) { - player.addPotionEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); + player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); } else if (toxicity.toxicWhenCooked()) { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java index 2e7a952e..038872f9 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/ToxicItem.java @@ -84,13 +84,13 @@ public class ToxicItem extends Item implements Toxic, Toxin { public void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack) { if (toxicity.toxicWhenRaw()) { - player.addPotionEffect(toxicity.getPoisonEffect()); + player.addStatusEffect(toxicity.getPoisonEffect()); } if (toxicity.isLethal()) { - player.addPotionEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); + player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 300, 7, false, false)); } else if (toxicity.toxicWhenCooked()) { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 3, 1, false, false)); } } } diff --git a/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java b/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java index 8f492bfe..29ef8730 100644 --- a/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java +++ b/src/main/java/com/minelittlepony/unicopia/toxin/Toxin.java @@ -9,22 +9,22 @@ import net.minecraft.item.ItemStack; public interface Toxin { Toxin DAMAGE = (player, toxicity, stack) -> { if (player.world.random.nextInt(30) == 0) { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 1, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.INSTANT_DAMAGE, 1, 1, false, false)); } }; Toxin RADIOACTIVITY = (player, toxicity, stack) -> { if (player.world.random.nextInt(30) == 0) { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.GLOWING, 10, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 10, 1, false, false)); } }; Toxin NAUSEA = (player, toxicity, stack) -> { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 30, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 30, 1, false, false)); }; Toxin STRENGTH = (player, toxicity, stack) -> { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 30, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 30, 1, false, false)); }; Toxin BLINDNESS = (player, toxicity, stack) -> { - player.addPotionEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 30, 1, false, false)); + player.addStatusEffect(new StatusEffectInstance(StatusEffects.BLINDNESS, 30, 1, false, false)); }; void addSecondaryEffects(PlayerEntity player, Toxicity toxicity, ItemStack stack); diff --git a/src/main/java/com/minelittlepony/unicopia/util/MotionCompositor.java b/src/main/java/com/minelittlepony/unicopia/util/MotionCompositor.java index 1ac5b1bc..e75daf91 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/MotionCompositor.java +++ b/src/main/java/com/minelittlepony/unicopia/util/MotionCompositor.java @@ -28,9 +28,9 @@ public abstract class MotionCompositor { protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) { // since model roll should probably be calculated from model rotation rather than entity rotation... - double roll = sensibleAngle(player.field_6220 - player.field_6220); + double roll = sensibleAngle(player.prevBodyYaw - player.bodyYaw); double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ); - float modelYaw = sensibleAngle(player.field_6220); + float modelYaw = sensibleAngle(player.bodyYaw); // detecting that we're flying backwards and roll must be inverted if (Math.abs(sensibleAngle((float) Math.toDegrees(Math.atan2(motionX, motionZ)) + modelYaw)) > 90) { diff --git a/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java b/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java index a37596c2..b6a9b7a5 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java +++ b/src/main/java/com/minelittlepony/unicopia/util/OreReplacer.java @@ -9,7 +9,6 @@ import org.apache.logging.log4j.Logger; import com.google.common.collect.Lists; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundTag; import net.minecraft.recipe.Ingredient; import net.minecraft.recipe.Recipe; import net.minecraft.recipe.RecipeType; @@ -46,7 +45,7 @@ public class OreReplacer { boolean altered = false; - ItemStack[] stacks = ingredient.getStackArray(); + ItemStack[] stacks = ingredient.getMatchingStacksClient(); for (int k = 0; k < stacks.length; k++) { ItemStack stack = stacks[k]; @@ -132,7 +131,7 @@ public class OreReplacer { stack.getItem().appendStacks(ItemGroup.SEARCH, newList); if (stack.hasTag()) { - newList.forEach(i -> i.setTag((CompoundTag)stack.getTag().copy())); + newList.forEach(i -> i.setTag(stack.getTag().copy())); } newStacks.addAll(newList); diff --git a/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java index 842084fc..512039e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/util/dummy/DummyClientPlayerEntity.java @@ -10,9 +10,11 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.PlayerListEntry; +import net.minecraft.client.network.packet.PlayerListS2CPacket; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.world.GameMode; @@ -45,7 +47,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen playerInfo = connection.getPlayerListEntry(getGameProfile().getId()); if (playerInfo == null) { - playerInfo = new PlayerListEntry(getGameProfile()); + playerInfo = new PlayerListEntry(new Packet().entry()); } } @@ -78,4 +80,14 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen name.getStyle().setItalic(true); return name; } + + private final class Packet extends PlayerListS2CPacket { + PlayerListS2CPacket.Entry entry() { + return new PlayerListS2CPacket.Entry( + getGameProfile(), + 0, + GameMode.NOT_SET, + new LiteralText(getGameProfile().getName())); + } + } } diff --git a/src/main/java/com/minelittlepony/unicopia/util/particles/UParticles.java b/src/main/java/com/minelittlepony/unicopia/util/particles/UParticles.java deleted file mode 100644 index 30bb4568..00000000 --- a/src/main/java/com/minelittlepony/unicopia/util/particles/UParticles.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.minelittlepony.unicopia.util.particles; - -import net.minecraft.particle.DefaultParticleType; -import net.minecraft.util.Identifier; - -public interface UParticles { - // TODO: ParticleTypeRegistry - interface ParticleTypeRegistry { - static ParticleTypeRegistry getTnstance() {return null;} - DefaultParticleType register(Identifier id); - } - DefaultParticleType UNICORN_MAGIC = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "unicorn_magic")); - DefaultParticleType CHANGELING_MAGIC = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "changeling_magic")); - - DefaultParticleType RAIN_DROPS = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "rain_drops")); - - DefaultParticleType SPHERE = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "sphere")); - DefaultParticleType DISK = ParticleTypeRegistry.getTnstance().register(new Identifier("unicopia", "disk")); -} diff --git a/src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java b/src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java index cdd57552..ffd4e08a 100644 --- a/src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java +++ b/src/main/java/com/minelittlepony/unicopia/util/projectile/TossableItem.java @@ -51,7 +51,7 @@ public interface TossableItem extends Tossable, Dispensable { default void toss(World world, ItemStack itemstack, PlayerEntity player) { - world.playSound(null, player.x, player.y, player.z, getThrowSound(itemstack), SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); + world.playSound(null, player.getX(), player.getY(), player.getZ(), getThrowSound(itemstack), SoundCategory.NEUTRAL, 0.5F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); if (!world.isClient) { AdvancedProjectile projectile = createProjectile(world, player); diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index 76e5b42e..4820e3f2 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -15,6 +15,7 @@ ], "client": [ "client.MixinCamera", + "client.MixinEntityRenderDispatcher", "client.MixinGameRenderer", "client.MixinKeyboardInput", "client.MixinMouse"