1.16.5 -> 1.17

This commit is contained in:
Sollace 2021-08-04 15:38:03 +02:00
parent 8bfa54b408
commit 55e990882e
133 changed files with 688 additions and 629 deletions

View file

@ -1,32 +1,43 @@
plugins {
id 'java-library'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'org.ajoberstar.reckon' version '0.13.0'
}
apply plugin: 'fabric-loom'
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
version = "${project.minecraft_version}-${project.version}"
if (project.release != 'RELEASE') {
version += "-${project.release}"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(16)
}
}
group = project.group
description = project.displayname
archivesBaseName = project.name
// check for updates every build when on CI
if (System.env.CI) {
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
minecraft {
refmapName = 'unicopia.mixin.refmap.json'
accessWidener 'src/main/resources/unicopia.aw'
}
reckon {
scopeFromProp()
stageFromProp('beta', 'rc', 'final')
}
repositories {
mavenLocal()
maven {
name = 'modmenu'
url = 'https://maven.terraformersmc.com/releases'
}
maven {
name = 'minelp'
url = 'https://repo.minelittlepony-mod.com/maven/snapshot'
}
maven {
name = 'minelp-release'
url = 'https://repo.minelittlepony-mod.com/maven/release'
}
}
dependencies {
@ -34,23 +45,20 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modApi "net.fabricmc:fabric-loader:${project.loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"
modApi "com.minelittlepony:MineLittlePony:${project.minelp_version}"
modApi "com.minelittlepony:minelittlepony:${project.minelp_version}"
modApi "com.minelittlepony:Kirin:${project.kirin_version}"
include "com.minelittlepony:Kirin:${project.kirin_version}"
modApi "com.minelittlepony:kirin:${project.kirin_version}"
include "com.minelittlepony:kirin:${project.kirin_version}"
modCompileOnly("io.github.prospector:modmenu:${project.modmenu_version}") {
transitive = false
}
modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
}
processResources {
inputs.property "version", project.version
inputs.property "version", project.version.toString()
filesMatching("fabric.mod.json") {
expand "version": project.version
expand "version": project.version.toString()
}
}
@ -62,16 +70,3 @@ task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
repositories {
maven {
name = 'minelp'
url = 'https://repo.minelittlepony-mod.com/maven/snapshot'
}
maven {
name = 'minelp-release'
url = 'https://repo.minelittlepony-mod.com/maven/release'
}
}

View file

@ -3,20 +3,18 @@ org.gradle.daemon=false
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.4
loader_version=0.11.1
fabric_version=0.30.3+1.16
minecraft_version=1.17
yarn_mappings=1.17+build.5
loader_version=0.11.3
fabric_version=0.34.9+1.17
# Mod Properties
group=com.minelittlepony
displayname=Unicopia
authors=Sollace
description=Magical Abilities for Mine Little Pony!
version=9
release=BETA
# Dependencies
modmenu_version=1.14.+
minelp_version=4.2.2-1.16.5-1.16-SNAPSHOT
kirin_version=1.7.1-1.16.2-SNAPSHOT
modmenu_version=2.0.0-beta.7
minelp_version=4.3.4
kirin_version=1.9.1

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
@ -24,9 +24,9 @@ public interface EquinePredicates {
Predicate<Entity> PLAYER_BAT = IS_PLAYER.and(ofRace(Race.BAT));
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(raceMatches(Race::canCast));
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(ofRace(Race.CHANGELING));
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(e -> ((PlayerEntity)e).abilities.creativeMode || RACE_INTERACT_WITH_CLOUDS.test(e));
Predicate<Entity> PLAYER_PEGASUS = IS_PLAYER.and(e -> ((PlayerEntity)e).getAbilities().creativeMode || RACE_INTERACT_WITH_CLOUDS.test(e));
Predicate<Entity> IS_CASTER = e -> !e.removed && (e instanceof Caster || PLAYER_UNICORN.test(e));
Predicate<Entity> IS_CASTER = e -> !e.isRemoved() && (e instanceof Caster || PLAYER_UNICORN.test(e));
Predicate<LivingEntity> HAS_WANT_IT_NEED_IT = e -> EnchantmentHelper.getEquipmentLevel(UEnchantments.WANT_IT_NEED_IT, e) > 0;

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
import com.minelittlepony.unicopia.entity.player.dummy.DummyServerPlayerEntity;
@ -38,7 +38,7 @@ public class InteractionManager {
*
* Returns an implementation of PlayerEntity appropriate to the side being called on.
*/
@Nonnull
@NotNull
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
if (observer.world instanceof ServerWorld) {
return new DummyServerPlayerEntity((ServerWorld)observer.world, profile);

View file

@ -6,7 +6,7 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.google.common.base.Strings;
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
@ -107,7 +107,7 @@ public enum Race implements Affine {
}
public boolean isPermitted(@Nullable PlayerEntity sender) {
if (isOp() && (sender == null || !sender.abilities.creativeMode)) {
if (isOp() && (sender == null || !sender.getAbilities().creativeMode)) {
return false;
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.PersistentState;
import net.minecraft.world.dimension.DimensionType;
@ -9,8 +9,10 @@ public class WorldTribeManager extends PersistentState {
private Race defaultRace = Unicopia.getConfig().preferredRace.get();
public WorldTribeManager(ServerWorld world) {
super(nameFor(world.getDimension()));
public WorldTribeManager() {}
public WorldTribeManager(NbtCompound nbt) {
defaultRace = Race.fromName(nbt.getString("defaultRace"));
}
public Race getDefaultRace() {
@ -22,12 +24,7 @@ public class WorldTribeManager extends PersistentState {
}
@Override
public void fromTag(CompoundTag tag) {
defaultRace = Race.fromName(tag.getString("defaultRace"));
}
@Override
public CompoundTag toTag(CompoundTag tag) {
public NbtCompound writeNbt(NbtCompound tag) {
tag.putString("defaultRace", defaultRace.name());
return tag;
}
@ -37,6 +34,6 @@ public class WorldTribeManager extends PersistentState {
}
public static WorldTribeManager forWorld(ServerWorld world) {
return world.getPersistentStateManager().getOrCreate(() -> new WorldTribeManager(world), nameFor(world.getDimension()));
return world.getPersistentStateManager().getOrCreate(WorldTribeManager::new, WorldTribeManager::new, nameFor(world.getDimension()));
}
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;

View file

@ -8,7 +8,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
@ -16,11 +16,11 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.util.Tickable;
public class AbilityDispatcher implements Tickable, NbtSerialisable {
@ -78,10 +78,10 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
if (compound.contains("stats")) {
stats.clear();
CompoundTag li = compound.getCompound("stats");
NbtCompound li = compound.getCompound("stats");
li.getKeys().forEach(key -> {
getStat(AbilitySlot.valueOf(key)).fromNBT(li.getCompound(key));
});
@ -89,8 +89,8 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
}
@Override
public void fromNBT(CompoundTag compound) {
CompoundTag li = new CompoundTag();
public void fromNBT(NbtCompound compound) {
NbtCompound li = new NbtCompound();
stats.forEach((key, value) -> li.put(key.name(), value.toNBT()));
compound.put("stats", li);
}
@ -251,7 +251,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
compound.putInt("warmup", warmup);
compound.putInt("cooldown", cooldown);
compound.putInt("maxWarmup", maxWarmup);
@ -263,7 +263,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
warmup = compound.getInt("warmup");
cooldown = compound.getInt("cooldown");
maxWarmup = compound.getInt("maxWarmup");

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Lists;
import com.minelittlepony.unicopia.BlockDestructionManager;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.BlockDestructionManager;
import com.minelittlepony.unicopia.Race;
@ -58,7 +58,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
@Nullable
@Override
public Hit tryActivate(Pony player) {
if (!player.getMaster().isOnGround() && player.getMaster().getVelocity().y * player.getPhysics().getGravitySignum() < 0 && !player.getMaster().abilities.flying) {
if (!player.getMaster().isOnGround() && player.getMaster().getVelocity().y * player.getPhysics().getGravitySignum() < 0 && !player.getMaster().getAbilities().flying) {
thrustDownwards(player);
return Hit.INSTANCE;
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
@ -73,7 +73,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
} else if (player.getOrigin().getY() < 120) {
tell(player, "ability.unicopia.too_low");
} else {
if (!player.getMaster().abilities.creativeMode) {
if (!player.getMaster().getAbilities().creativeMode) {
stack.decrement(1);
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability;
import java.util.Random;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Streams;
import com.minelittlepony.unicopia.Race;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Streams;
import com.minelittlepony.unicopia.Race;

View file

@ -4,7 +4,7 @@ import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Owned;

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.spell.SpellPredicate;

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability.magic;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.item.GemstoneItem;
import com.minelittlepony.unicopia.item.UItems;
@ -83,7 +83,7 @@ public interface Thrown extends Spell, ProjectileDelegate {
projectile.setThrowDamage(getThrowDamage(caster));
projectile.setSpell(this);
projectile.setHydrophobic();
projectile.setProperties(entity, entity.pitch, entity.yaw, 0, 1.5F, 1);
projectile.setProperties(entity, entity.getPitch(), entity.getYaw(), 0, 1.5F, 1);
world.spawnEntity(projectile);

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability.magic.spell;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.UEntities;
import com.minelittlepony.unicopia.ability.magic.Attached;
@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.OrientedBillboardParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleHandle;
import com.minelittlepony.unicopia.particle.UParticles;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
@ -74,7 +74,7 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
if (dimension != null) {
@ -84,7 +84,7 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
if (compound.contains("dimension")) {
dimension = new Identifier(compound.getString("dimension"));

View file

@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Affinity;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Spell;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
public abstract class AbstractSpell implements Spell {
@ -69,13 +69,13 @@ public abstract class AbstractSpell implements Spell {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
compound.putBoolean("dead", isDead);
compound.putUuid("uuid", uuid);
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
isDirty = false;
if (compound.contains("uuid")) {
uuid = compound.getUuid("uuid");

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.List;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Thrown;
@ -14,7 +14,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
@ -88,7 +88,7 @@ public class AttractiveSpell extends ShieldSpell implements Thrown {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
if (homingPos != null) {
compound.put("homingPos", NbtHelper.fromBlockPos(homingPos));
@ -96,7 +96,7 @@ public class AttractiveSpell extends ShieldSpell implements Thrown {
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
if (compound.contains("homingPos")) {
homingPos = NbtHelper.toBlockPos(compound.getCompound("homingPos"));

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.FlightType;
import com.minelittlepony.unicopia.Owned;
@ -25,7 +25,7 @@ import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
public class DisguiseSpell extends AbstractSpell implements Attached, Suppressable, FlightType.Provider, PlayerDimensions.Provider, ProjectileImpactListener {
@ -178,7 +178,7 @@ public class DisguiseSpell extends AbstractSpell implements Attached, Suppressab
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
compound.putInt("suppressionCounter", suppressionCounter);
@ -186,7 +186,7 @@ public class DisguiseSpell extends AbstractSpell implements Attached, Suppressab
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
suppressionCounter = compound.getInt("suppressionCounter");

View file

@ -20,6 +20,7 @@ import net.minecraft.block.PlantBlock;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.TntEntity;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.BlockPos;
@ -63,7 +64,7 @@ public class IceSpell extends AbstractSpell implements Thrown, Attached {
protected boolean applyEntitySingle(LivingEntity owner, Entity e) {
if (e instanceof TntEntity) {
e.remove();
e.remove(RemovalReason.DISCARDED);
e.getEntityWorld().setBlockState(e.getBlockPos(), Blocks.TNT.getDefaultState());
} else if (e.isOnFire()) {
e.extinguish();

View file

@ -15,7 +15,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.block.BlockState;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
@ -72,7 +72,7 @@ public class JoustingSpell extends AbstractSpell implements Attached {
((Pony)source).getMagicalReserves().getEnergy().multiply(0.2F);
}
return !source.getEntity().removed && age++ < 90 + 7 * (source.getLevel().get() + 1);
return !source.getEntity().isRemoved() && age++ < 90 + 7 * (source.getLevel().get() + 1);
}
private boolean canBreak(BlockPos pos, LivingEntity entity) {
@ -85,13 +85,13 @@ public class JoustingSpell extends AbstractSpell implements Attached {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
compound.putInt("age", age);
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
age = compound.getInt("age");
}

View file

@ -13,8 +13,8 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@ -89,7 +89,7 @@ public class NecromancySpell extends AbstractPlacedSpell {
summonedEntities.forEach(ref -> {
ref.ifPresent(caster.getWorld(), e -> {
if (master != null) {
master.dealDamage(master, e);
master.applyDamageEffects(master, e);
}
if (caster.getWorld().random.nextInt(2000) != 0) {
e.setHealth(0);
@ -117,23 +117,23 @@ public class NecromancySpell extends AbstractPlacedSpell {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
if (summonedEntities.size() > 0) {
ListTag list = new ListTag();
NbtList list = new NbtList();
summonedEntities.forEach(ref -> list.add(ref.toNBT()));
compound.put("summonedEntities", list);
}
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
summonedEntities.clear();
if (compound.contains("summonedEntities")) {
compound.getList("summonedEntities", 10).forEach(tag -> {
EntityReference<LivingEntity> ref = new EntityReference<>();
ref.fromNBT((CompoundTag)tag);
ref.fromNBT((NbtCompound)tag);
summonedEntities.add(ref);
});
}

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.ability.magic.spell;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.block.state.StateMaps;

View file

@ -27,6 +27,7 @@ import net.minecraft.entity.EyeOfEnderEntity;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.TntEntity;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
@ -157,7 +158,7 @@ public class ShieldSpell extends AbstractSpell implements Attached, Thrown {
if (!ProjectileUtil.isProjectileThrownBy(target, source.getMaster())) {
if (distance < 1) {
target.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 0.1F, 1);
target.remove();
target.remove(RemovalReason.DISCARDED);
} else {
ProjectileUtil.ricochet(target, pos, 0.9F);
}

View file

@ -17,7 +17,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.util.math.BlockPos;
@ -71,7 +71,7 @@ public class SiphoningSpell extends AbstractPlacedSpell {
}
private Stream<LivingEntity> getTargets(Caster<?> source) {
return VecHelper.findInRange(null, source.getWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_SPECTATOR_OR_PEACEFUL.and(e -> e instanceof LivingEntity))
return VecHelper.findInRange(null, source.getWorld(), source.getOriginVector(), 4 + source.getLevel().get(), EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> e instanceof LivingEntity))
.stream()
.map(e -> (LivingEntity)e);
}
@ -147,13 +147,13 @@ public class SiphoningSpell extends AbstractPlacedSpell {
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
compound.putInt("upset", ticksUpset);
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
ticksUpset = compound.getInt("upset");
}

View file

@ -6,14 +6,14 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Affinity;
import com.minelittlepony.unicopia.ability.magic.Affine;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.Spell;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
@ -168,7 +168,7 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
}
@Nullable
public static Spell fromNBT(@Nullable CompoundTag compound) {
public static Spell fromNBT(@Nullable NbtCompound compound) {
if (compound != null && compound.contains("effect_id")) {
Spell effect = getKey(new Identifier(compound.getString("effect_id"))).create();
@ -182,8 +182,8 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
return null;
}
public static CompoundTag toNBT(Spell effect) {
CompoundTag compound = effect.toNBT();
public static NbtCompound toNBT(Spell effect) {
NbtCompound compound = effect.toNBT();
compound.putString("effect_id", effect.getType().getId().toString());

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.block.state;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.block.enums.DoubleBlockHalf;
@ -27,8 +27,8 @@ public interface BlockStateConverter {
*
* @return The converted state if there is one, otherwise the original state is returned
*/
@Nonnull
BlockState getConverted(World world, @Nonnull BlockState state);
@NotNull
BlockState getConverted(World world, @NotNull BlockState state);
/**
* Attempts to convert a block state at a position.

View file

@ -4,8 +4,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -31,8 +31,8 @@ class BlockStateMap implements BlockStateConverter {
}
@Override
@Nonnull
public BlockState getConverted(World world, @Nonnull BlockState state) {
@NotNull
public BlockState getConverted(World world, @NotNull BlockState state) {
for (StateMapping i : mappings) {
if (i.test(state)) {
return i.apply(world, state);

View file

@ -4,7 +4,7 @@ import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -124,7 +124,7 @@ interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockSta
* @return True if the state can be converted
*/
@Override
boolean test(@Nonnull BlockState state);
boolean test(@NotNull BlockState state);
/**
* Converts the given state based on this mapping
@ -133,13 +133,13 @@ interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockSta
*
* @return The converted state
*/
@Nonnull
@NotNull
@Override
BlockState apply(World world, @Nonnull BlockState state);
BlockState apply(World world, @NotNull BlockState state);
/**
* Gets the inverse of this mapping if one exists. Otherwise returns itself.
*/
@Nonnull
@NotNull
StateMapping inverse();
}

View file

@ -1,7 +1,7 @@
package com.minelittlepony.unicopia.client;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.entity.player.Pony;
@ -15,7 +15,7 @@ import net.minecraft.entity.player.PlayerEntity;
public class ClientInteractionManager extends InteractionManager {
@Override
@Nonnull
@NotNull
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
if (observer.world instanceof ClientWorld) {
return new DummyClientPlayerEntity((ClientWorld)observer.world, profile);

View file

@ -15,7 +15,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.TranslatableText;

View file

@ -7,7 +7,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Multimap;
import com.minelittlepony.unicopia.entity.Equine;
@ -25,7 +25,7 @@ import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.attribute.EntityAttributeModifier.Operation;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
@ -152,7 +152,7 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
if (!stack.isEmpty()) {
return stack.getEnchantments()
.stream()
.map(t -> (CompoundTag)t)
.map(t -> (NbtCompound)t)
.map(tag -> Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(tag.getString("id")))
.map(ench -> new Pair<>(tag.getInt("lvl"), ench)))
.filter(Optional::isPresent)

View file

@ -60,7 +60,7 @@ public interface URenderers {
AccessoryFeatureRenderer.register(AmuletFeatureRenderer::new);
AccessoryFeatureRenderer.register(WingsFeatureRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer()));
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, FlyingItemEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.FLOATING_ARTEFACT, FloatingArtefactEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(UEntities.CAST_SPELL, CastSpellEntityRenderer::new);
@ -84,10 +84,10 @@ public interface URenderers {
matrices.push();
matrices.scale(0.5F, 0.5F, 0.5F);
matrices.translate(0.0125, 0.1, 0);
renderer.renderItem(item.getAppearanceStack(stack), mode, light, overlay, matrices, immediate);
renderer.renderItem(item.getAppearanceStack(stack), mode, light, overlay, matrices, immediate, 0);
matrices.pop();
}
renderer.renderItem(item.createAppearanceStack(stack, UItems.EMPTY_JAR), mode, light, OverlayTexture.DEFAULT_UV, matrices, immediate);
renderer.renderItem(item.createAppearanceStack(stack, UItems.EMPTY_JAR), mode, light, OverlayTexture.DEFAULT_UV, matrices, immediate, 0);
immediate.draw();
if (mode == ModelTransformation.Mode.GUI) {
@ -96,7 +96,7 @@ public interface URenderers {
matrices.push();
});
FabricModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity) -> {
FabricModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> {
return GemstoneItem.isEnchanted(stack) ? 1 + GemstoneItem.getSpellKey(stack).getAffinity().ordinal() : 0;
});
ColorProviderRegistry.ITEM.register((stack, i) -> {

View file

@ -69,7 +69,7 @@ public class UnicopiaClient implements ClientModInitializer {
private void onScreenInit(Screen screen, ButtonList buttons) {
if (screen instanceof CreateWorldScreen) {
buttons.add(SettingsScreen.createRaceSelector(screen));
buttons.addButton(SettingsScreen.createRaceSelector(screen));
}
}

View file

@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.BufferRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper;
@ -110,7 +111,7 @@ class ManaRingSlot extends Slot {
RenderSystem.disableTexture();
RenderSystem.defaultBlendFunc();
bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
Matrix4f model = matrices.peek().getModel();

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.client.gui;
import java.util.Set;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.common.client.gui.GameGui;
import com.minelittlepony.common.client.gui.ScrollContainer;
@ -54,9 +54,9 @@ public class SettingsScreen extends GameGui {
super(new TranslatableText("unicopia.options.title"), parent);
content.margin.setVertical(30);
content.padding.setHorizontal(10);
content.padding.top = 10;
content.padding.bottom = 20;
content.getContentPadding().setHorizontal(10);
content.getContentPadding().top = 10;
content.getContentPadding().bottom = 20;
}
@Override
@ -89,7 +89,7 @@ public class SettingsScreen extends GameGui {
RIGHT = LEFT;
}
children().add(content);
getChildElements().add(content);
int row = 0;
@ -115,7 +115,7 @@ public class SettingsScreen extends GameGui {
content.addButton(new EnumSlider<>(LEFT, row += 25, config.preferredRace.get()))
.onChange(config.preferredRace::set)
.setFormatter(v -> new TranslatableText("unicopia.options.preferred_race", v.getDisplayName()).getString());
.setTextFormat(v -> new TranslatableText("unicopia.options.preferred_race", v.getValue().getDisplayName()));
if (server != null) {
row += 20;
@ -125,7 +125,7 @@ public class SettingsScreen extends GameGui {
content.addButton(new EnumSlider<>(LEFT, row += 20, tribes.getDefaultRace()))
.onChange(tribes::setDefaultRace)
.setFormatter(v -> new TranslatableText("unicopia.options.world.default_race", v.getDisplayName()).getString())
.setTextFormat(v -> new TranslatableText("unicopia.options.world.default_race", v.getValue().getDisplayName()))
.setEnabled(client.isInSingleplayer());
}

View file

@ -97,7 +97,6 @@ class Slot {
// progress
UHud.fill(matrices, slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF);
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.client.gui;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
@ -25,6 +25,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Arm;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.Quaternion;
public class UHud extends DrawableHelper {
@ -73,10 +74,9 @@ public class UHud extends DrawableHelper {
renderMessage(matrices, tickDelta);
}
RenderSystem.enableAlphaTest();
RenderSystem.enableBlend();
client.getTextureManager().bindTexture(HUD_TEXTURE);
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
boolean swap = client.options.keySneak.isPressed();
@ -84,7 +84,6 @@ public class UHud extends DrawableHelper {
slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta));
RenderSystem.disableBlend();
RenderSystem.disableAlphaTest();
matrices.pop();
@ -100,13 +99,17 @@ public class UHud extends DrawableHelper {
int x = scaledWidth / 2 + 67;
int y = scaledHeight - 25;
RenderSystem.pushMatrix();
RenderSystem.translatef(x, y, 0);
RenderSystem.rotatef(45, -0.2F, 1, 0);
MatrixStack view = RenderSystem.getModelViewStack();
view.push();
view.translate(x, y, 0);
view.multiply(new Quaternion(-9, 45, 0, true));
InventoryScreen.drawEntity(0, 0, scale, 0, -20, client.player);
RenderSystem.popMatrix();
view.pop();
});
}
}
private void renderMessage(MatrixStack matrices, float tickDelta) {
@ -139,9 +142,9 @@ public class UHud extends DrawableHelper {
void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) {
stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> {
client.getTextureManager().bindTexture(ability.getIcon(Pony.of(client.player), client.options.keySneak.isPressed()));
RenderSystem.setShaderTexture(0, ability.getIcon(Pony.of(client.player), client.options.keySneak.isPressed()));
drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v);
client.getTextureManager().bindTexture(HUD_TEXTURE);
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
});
}

View file

@ -1,8 +1,8 @@
package com.minelittlepony.unicopia.client.minelittlepony;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.IModel;
import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback;
import com.minelittlepony.api.model.IModel;
import com.minelittlepony.api.model.ModelAttributes;
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.player.Pony;
@ -20,7 +20,7 @@ public class Main implements ClientModInitializer {
PonyModelPrepareCallback.EVENT.register(this::onPonyModelPrepared);
}
private void onPonyModelPrepared(Entity entity, IModel model, EquineRenderManager.Mode mode) {
private void onPonyModelPrepared(Entity entity, IModel model, ModelAttributes.Mode mode) {
if (hookErroring) return;
try {
if (entity instanceof PlayerEntity) {

View file

@ -10,8 +10,9 @@ import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Vec3f;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
@ -43,8 +44,6 @@ public abstract class AbstractBillboardParticle extends Particle {
GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA,
GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA
);
RenderSystem.alphaFunc(516, 0.003921569F);
Vec3d cam = camera.getPos();
@ -55,7 +54,6 @@ public abstract class AbstractBillboardParticle extends Particle {
renderQuads(te, buffer, renderX, renderY, renderZ, tickDelta);
RenderSystem.enableCull();
RenderSystem.defaultAlphaFunc();
RenderSystem.defaultBlendFunc();
}
@ -65,10 +63,10 @@ public abstract class AbstractBillboardParticle extends Particle {
MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
}
protected void renderQuad(Tessellator te, BufferBuilder buffer, Vector3f[] corners, float alpha, float tickDelta) {
int light = getColorMultiplier(tickDelta);
protected void renderQuad(Tessellator te, BufferBuilder buffer, Vec3f[] corners, float alpha, float tickDelta) {
int light = getBrightness(tickDelta);
buffer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT);
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT);
buffer.vertex(corners[0].getX(), corners[0].getY(), corners[0].getZ()).texture(0, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corners[1].getX(), corners[1].getY(), corners[1].getZ()).texture(1, 0).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();

View file

@ -64,8 +64,8 @@ public class MagicParticle extends SpriteBillboardParticle {
}
@Override
public int getColorMultiplier(float tint) {
int light = super.getColorMultiplier(tint);
public int getBrightness(float tint) {
int light = super.getBrightness(tint);
float timer = (float)age / (float)maxAge;
int v = light >> 16 & 255;

View file

@ -6,7 +6,7 @@ import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Vec3f;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.Quaternion;
@ -20,8 +20,8 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl
fixed = effect.isAngleFixed();
if (fixed) {
rotation.hamiltonProduct(Vector3f.POSITIVE_X.getDegreesQuaternion(180 - effect.getYaw()));
rotation.hamiltonProduct(Vector3f.POSITIVE_Y.getDegreesQuaternion(effect.getPitch()));
rotation.hamiltonProduct(Vec3f.POSITIVE_X.getDegreesQuaternion(180 - effect.getYaw()));
rotation.hamiltonProduct(Vec3f.POSITIVE_Y.getDegreesQuaternion(effect.getPitch()));
}
}
@ -35,16 +35,16 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl
@Override
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
Vector3f[] corners = new Vector3f[]{
new Vector3f(-1, -1, 0),
new Vector3f(-1, 1, 0),
new Vector3f( 1, 1, 0),
new Vector3f( 1, -1, 0)
Vec3f[] corners = new Vec3f[]{
new Vec3f(-1, -1, 0),
new Vec3f(-1, 1, 0),
new Vec3f( 1, 1, 0),
new Vec3f( 1, -1, 0)
};
float scale = getScale(tickDelta);
for(int k = 0; k < 4; ++k) {
Vector3f corner = corners[k];
Vec3f corner = corners[k];
corner.rotate(rotation);
corner.scale(scale);
corner.add(x, y, z);

View file

@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.ParticleHandle.Link;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Vec3f;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.Identifier;
@ -60,11 +60,11 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
float alpha = 1 - (float)age / maxAge;
for (int i = 0; i < segments.size() - 1; i++) {
Vector3f[] corners = segments.get(i).getPlane(segments.get(i + 1));
Vec3f[] corners = segments.get(i).getPlane(segments.get(i + 1));
float scale = getScale(tickDelta);
for (int k = 0; k < 4; ++k) {
Vector3f corner = corners[k];
Vec3f corner = corners[k];
corner.scale(scale);
corner.add(x, y, z);
}
@ -107,14 +107,14 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
private final class Segment {
Vec3d position;
Vector3f offset;
Vec3f offset;
int age;
int maxAge;
Segment(Vec3d position) {
this.position = position;
this.offset = new Vector3f((float)(position.getX() - x), (float)(position.getY() - y), (float)(position.getZ() - z));
this.offset = new Vec3f((float)(position.getX() - x), (float)(position.getY() - y), (float)(position.getZ() - z));
this.maxAge = 90;
}
@ -126,7 +126,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
return segments.indexOf(this) < segments.size() - 1 && age++ >= maxAge;
}
Vector3f[] getPlane(Segment to) {
Vec3f[] getPlane(Segment to) {
float fromX = offset.getX();
float toX = to.offset.getX();
@ -139,11 +139,11 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
float toTopY = to.offset.getY() + 1;
float toBottomY = to.offset.getY();
return new Vector3f[]{
new Vector3f(fromX, fromBottomY, fromZ), // bottom left
new Vector3f(fromX, fromTopY, fromZ), // top left
new Vector3f(toX, toTopY, toZ), // top right
new Vector3f(toX, toBottomY, toZ) // bottom right
return new Vec3f[]{
new Vec3f(fromX, fromBottomY, fromZ), // bottom left
new Vec3f(fromX, fromTopY, fromZ), // top left
new Vec3f(toX, toTopY, toZ), // top right
new Vec3f(toX, toBottomY, toZ) // bottom right
};
}
}

View file

@ -9,7 +9,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Vec3f;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
@ -91,7 +91,7 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
}
@Override
protected int getColorMultiplier(float tint) {
protected int getBrightness(float tint) {
return 0xF000F0;
}
@ -105,22 +105,22 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
for (int i = 0; i < TEXTURES.length; i++) {
bindTexture(TEXTURES[i]);
RenderSystem.color3f(colorRed, colorGreen, colorBlue);
RenderSystem.setShaderColor(colorRed, colorGreen, colorBlue, alpha);
Vector3f[] corners = new Vector3f[]{
new Vector3f(-1, -1, 0),
new Vector3f(-1, 1, 0),
new Vector3f( 1, 1, 0),
new Vector3f( 1, -1, 0)
Vec3f[] corners = new Vec3f[]{
new Vec3f(-1, -1, 0),
new Vec3f(-1, 1, 0),
new Vec3f( 1, 1, 0),
new Vec3f( 1, -1, 0)
};
float scale = getScale(tickDelta);
float ringSpeed = (i % 2 == 0 ? i : -1) * i;
Quaternion ringAngle = Vector3f.POSITIVE_Z.getDegreesQuaternion(angle * ringSpeed);
Quaternion ringAngle = Vec3f.POSITIVE_Z.getDegreesQuaternion(angle * ringSpeed);
for(int k = 0; k < 4; ++k) {
Vector3f corner = corners[k];
Vec3f corner = corners[k];
corner.rotate(ringAngle);
corner.rotate(rotation);
corner.scale(scale);

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.client.particle;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.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.Vec3f;
import net.minecraft.util.math.Vector4f;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3d;
@ -21,9 +21,9 @@ public class SphereModel {
}
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);
rotX = Vec3f.POSITIVE_X.getDegreesQuaternion(x);
rotY = Vec3f.POSITIVE_Y.getDegreesQuaternion(y);
rotZ = Vec3f.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) {

View file

@ -4,8 +4,15 @@ import java.util.HashMap;
import java.util.Map;
import com.minelittlepony.unicopia.item.AmuletItem;
import net.minecraft.client.model.Dilation;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.ModelData;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.ModelPartBuilder;
import net.minecraft.client.model.ModelPartData;
import net.minecraft.client.model.ModelTransform;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
@ -22,7 +29,7 @@ import net.minecraft.util.registry.Registry;
public class AmuletFeatureRenderer<E extends LivingEntity> implements AccessoryFeatureRenderer.Feature<E> {
private final AmuletModel model = new AmuletModel(0.3F);
private final AmuletModel model;
private final Map<Identifier, Identifier> textures = new HashMap<>();
@ -30,6 +37,7 @@ public class AmuletFeatureRenderer<E extends LivingEntity> implements AccessoryF
public AmuletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
this.context = context;
this.model = new AmuletModel(AmuletModel.getData(new Dilation(0.3F)).createModel());
}
@Override
@ -49,22 +57,29 @@ public class AmuletFeatureRenderer<E extends LivingEntity> implements AccessoryF
static class AmuletModel extends Model {
private final ModelPart torso;
private final ModelPart amulet;
public AmuletModel(float dilate) {
public AmuletModel(ModelPart tree) {
super(RenderLayer::getEntityTranslucent);
torso = new ModelPart(this, 0, 0);
torso.addCuboid(-4, 0, -2, 8, 12, 4, dilate);
torso.setPivot(0, 0, 0);
amulet = tree.getChild("amulet");
}
public static TexturedModelData getData(Dilation dilation) {
ModelData data = new ModelData();
ModelPartData root = data.getRoot();
root.addChild("amulet", ModelPartBuilder.create().cuboid(-4, 0, -2, 8, 12, 4, dilation), ModelTransform.NONE);
return TexturedModelData.of(data, 64, 64);
}
public void setAngles(LivingEntity entity, BipedEntityModel<?> biped) {
torso.copyPositionAndRotation(biped.torso);
amulet.copyTransform(biped.body);
}
@Override
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) {
torso.render(matrices, vertexConsumer, i, j, f, g, h, k);
amulet.render(matrices, vertexConsumer, i, j, f, g, h, k);
}
}
}

View file

@ -4,8 +4,14 @@ import com.minelittlepony.common.util.Color;
import com.minelittlepony.unicopia.item.FriendshipBraceletItem;
import com.minelittlepony.unicopia.item.GlowableItem;
import net.minecraft.client.model.Dilation;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.ModelData;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.ModelPartBuilder;
import net.minecraft.client.model.ModelPartData;
import net.minecraft.client.model.ModelTransform;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
@ -13,6 +19,7 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.render.entity.model.EntityModelPartNames;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EquipmentSlot;
@ -27,13 +34,16 @@ public class BraceletFeatureRenderer<E extends LivingEntity> implements Accessor
private static final Identifier TEXTURE = new Identifier("unicopia", "textures/models/armor/bracelet.png");
private final BraceletModel steveModel = new BraceletModel(0.3F, false);
private final BraceletModel alexModel = new BraceletModel(0.3F, true);
private final BraceletModel steveModel;
private final BraceletModel alexModel;
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
public BraceletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
this.context = context;
Dilation dilation = new Dilation(0.3F);
steveModel = new BraceletModel(BraceletModel.getData(dilation, false).createModel(), false);
alexModel = new BraceletModel(BraceletModel.getData(dilation, true).createModel(), true);
}
@Override
@ -74,19 +84,26 @@ public class BraceletFeatureRenderer<E extends LivingEntity> implements Accessor
private final boolean alex;
public BraceletModel(float dilate, boolean alex) {
public BraceletModel(ModelPart tree, boolean alex) {
super(RenderLayer::getEntityTranslucent);
this.alex = alex;
rightArm = new ModelPart(this, 0, alex ? 6 : 0);
rightArm.addCuboid(-3, 7, -2, alex ? 3 : 4, 2, 4, dilate);
leftArm = new ModelPart(this, 0, alex ? 6 : 0);
leftArm.mirror = true;
leftArm.addCuboid(-1, 7, -2, alex ? 3 : 4, 2, 4, dilate);
this.leftArm = tree.getChild(EntityModelPartNames.LEFT_ARM);
this.rightArm = tree.getChild(EntityModelPartNames.RIGHT_ARM);
}
public static TexturedModelData getData(Dilation dilation, boolean alex) {
ModelData data = new ModelData();
ModelPartData root = data.getRoot();
root.addChild(EntityModelPartNames.RIGHT_ARM, ModelPartBuilder.create().uv(0, alex ? 6 : 0).cuboid(-3, 7, -2, alex ? 3 : 4, 2, 4, dilation), ModelTransform.NONE);
root.addChild(EntityModelPartNames.LEFT_ARM, ModelPartBuilder.create().mirrored().uv(0, alex ? 6 : 0).cuboid(-1, 7, -2, alex ? 3 : 4, 2, 4, dilation), ModelTransform.NONE);
return TexturedModelData.of(data, 64, 64);
}
public void setAngles(BipedEntityModel<?> biped) {
leftArm.copyPositionAndRotation(biped.leftArm);
rightArm.copyPositionAndRotation(biped.rightArm);
leftArm.copyTransform(biped.leftArm);
rightArm.copyTransform(biped.rightArm);
if (alex) {
rightArm.pivotX++;
}

View file

@ -2,16 +2,15 @@ package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.entity.CastSpellEntity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.util.Identifier;
public class CastSpellEntityRenderer extends EntityRenderer<CastSpellEntity> {
public CastSpellEntityRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher);
public CastSpellEntityRenderer(EntityRendererFactory.Context ctx) {
super(ctx);
}
@Override

View file

@ -3,27 +3,26 @@ package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.entity.FloatingArtefactEntity;
import com.minelittlepony.unicopia.item.UItems;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtefactEntity> {
private final ItemRenderer itemRenderer;
public FloatingArtefactEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager);
itemRenderer = context.getItemRenderer();
public FloatingArtefactEntityRenderer(EntityRendererFactory.Context ctx) {
super(ctx);
itemRenderer = ctx.getItemRenderer();
}
@Override
@ -35,7 +34,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtef
stack = UItems.EMPTY_JAR.getDefaultStack();
}
final BakedModel model = this.itemRenderer.getHeldItemModel(stack, entity.world, null);
final BakedModel model = this.itemRenderer.getHeldItemModel(stack, entity.world, null, 0);
final float variance = 0.25F;
final float verticalOffset = entity.getVerticalOffset(timeDelta);
@ -46,7 +45,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtef
transforms.push();
transforms.scale(scale, scale, scale);
transforms.translate(0, verticalOffset + variance * modelScaleY, 0);
transforms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(entity.getRotation(timeDelta)));
transforms.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(entity.getRotation(timeDelta)));
itemRenderer.renderItem(stack, ModelTransformation.Mode.GROUND, false, transforms, renderContext, lightUv, OverlayTexture.DEFAULT_UV, model);

View file

@ -7,11 +7,12 @@ import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.client.render.VertexFormats;
public final class RenderLayers extends RenderLayer {
private RenderLayers(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize,
private RenderLayers(String name, VertexFormat vertexFormat, DrawMode drawMode, int expectedBufferSize,
boolean hasCrumbling, boolean translucent, Runnable startAction, Runnable endAction) {
super(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, startAction, endAction);
}
@ -27,45 +28,35 @@ public final class RenderLayers extends RenderLayer {
});
public static RenderLayer getTintedTexturedLayer(float red, float green, float blue, float alpha) {
return RenderLayer.of("mlp_tint_layer", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, 7, 256, true, true, RenderLayer.MultiPhaseParameters.builder()
return RenderLayer.of("mlp_tint_layer", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, true, RenderLayer.MultiPhaseParameters.builder()
.texture(new Color(red, green, blue, alpha))
.shader(EYES_SHADER)
.writeMaskState(COLOR_MASK)
.alpha(ONE_TENTH_ALPHA)
.depthTest(LEQUAL_DEPTH_TEST)
.transparency(GLOWING_TRANSPARENCY)
.shadeModel(SMOOTH_SHADE_MODEL)
.lightmap(DISABLE_LIGHTMAP)
.overlay(DISABLE_OVERLAY_COLOR)
.cull(DISABLE_CULLING)
.build(true));
}
private static class Color extends Texture {
private static class Color extends TextureBase {
private final float red;
private final float green;
private final float blue;
private final float alpha;
public Color(float red, float green, float blue, float alpha) {
super();
super(
() -> RenderSystem.setShaderColor(red, green, blue, alpha),
() -> RenderSystem.setShaderColor(1, 1, 1, 1)
);
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
@Override
public void startDrawing() {
RenderSystem.blendColor(red, green, blue, alpha);
super.startDrawing();
}
@Override
public void endDrawing() {
super.endDrawing();
RenderSystem.blendColor(1, 1, 1, 1);
}
@Override
public boolean equals(Object other) {
return super.equals(other)

View file

@ -3,8 +3,14 @@ package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems;
import net.minecraft.client.model.Dilation;
import net.minecraft.client.model.Model;
import net.minecraft.client.model.ModelData;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.model.ModelPartBuilder;
import net.minecraft.client.model.ModelPartData;
import net.minecraft.client.model.ModelTransform;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
@ -23,12 +29,13 @@ public class WingsFeatureRenderer<E extends LivingEntity> implements AccessoryFe
private static final Identifier ICARUS_WINGS_CORRUPTED = new Identifier("unicopia", "textures/models/wings/icarus_corrupted.png");
private static final Identifier PEGASUS_WINGS = new Identifier("unicopia", "textures/models/wings/pegasus.png");
private final WingsModel model = new WingsModel();
private final WingsModel model;
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
public WingsFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
this.context = context;
this.model = new WingsModel(WingsModel.getData(Dilation.NONE).createModel());
}
@Override
@ -51,19 +58,24 @@ public class WingsFeatureRenderer<E extends LivingEntity> implements AccessoryFe
private final ModelPart root;
private final Wing[] wings;
public WingsModel() {
public WingsModel(ModelPart tree) {
super(RenderLayer::getEntityTranslucent);
this.textureHeight = 23;
this.textureWidth = 24;
root = new ModelPart(this, 0, 0);
root = tree;
wings = new Wing[] {
new Wing(this, root, -1),
new Wing(this, root, 1)
new Wing(tree.getChild("left_wing"), -1),
new Wing(tree.getChild("right_wing"), 1)
};
}
static TexturedModelData getData(Dilation dilation) {
ModelData data = new ModelData();
Wing.getData("left_wing", data.getRoot(), dilation, -1);
Wing.getData("right_wing", data.getRoot(), dilation, 1);
return TexturedModelData.of(data, 24, 23);
}
public void setAngles(LivingEntity entity, BipedEntityModel<?> biped) {
root.copyPositionAndRotation(biped.torso);
root.copyTransform(biped.body);
for (Wing wing : wings) {
wing.setAngles(entity);
}
@ -75,36 +87,36 @@ public class WingsFeatureRenderer<E extends LivingEntity> implements AccessoryFe
}
static class Wing {
ModelPart base;
final ModelPart base;
ModelPart[] feathers;
final ModelPart[] feathers = new ModelPart[8];
int k;
final int k;
Wing(Model model, ModelPart torso, int k) {
Wing(ModelPart tree, int k) {
this.k = k;
base = new ModelPart(model, 0, 0);
base.setPivot(k * 2, 2, 2 + k * 0.5F);
base.addCuboid(0, 0, 0, 2, 10, 2);
feathers = new ModelPart[8];
base = tree;
for (int i = 0; i < feathers.length; i++) {
int texX = (i % 2) * 8;
ModelPart feather = new ModelPart(model, 8 + texX, 0);
feather.setPivot(0, 9, 0);
int featherLength = 21 - i * 2;
feather.addCuboid(-k * (i % 2) / 90F, 0, 0, 2, featherLength, 2);
base.addChild(feather);
feathers[i] = feather;
feathers[i] = base.getChild("feather_" + i);
}
}
torso.addChild(base);
static void getData(String name, ModelPartData parent, Dilation dilation, int k) {
ModelPartData base = parent.addChild(name,
ModelPartBuilder.create().cuboid(0, 0, 0, 2, 10, 2, dilation),
ModelTransform.pivot(k * 2, 2, 2 + k * 0.5F));
int featherCount = 8;
for (int i = 0; i < featherCount; i++) {
int texX = (i % 2) * 8;
int featherLength = 21 - i * 2;
base.addChild("feather_" + i,
ModelPartBuilder.create()
.uv(8 + texX, 0)
.cuboid(-k * (i % 2) / 90F, 0, 0, 2, featherLength, 2, dilation),
ModelTransform.pivot(0, 9, 0));
}
}
void setAngles(LivingEntity entity) {

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.client.render;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
@ -9,6 +9,7 @@ import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -16,14 +17,13 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.model.Model;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Vec3f;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -71,8 +71,8 @@ public class WorldRenderDelegate {
roll = pony instanceof Pony ? ((Pony)pony).getInterpolator().interpolate("g_roll", roll, 15) : roll;
matrices.translate(x, y + owner.getHeight() / 2, z);
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(roll));
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(roll));
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(roll));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(roll));
matrices.translate(-x, -y - owner.getHeight() / 2, -z);
if (negative) {
@ -132,9 +132,9 @@ public class WorldRenderDelegate {
BlockEntity blockEntity = ve.getBlockEntity();
if (blockEntity != null) {
BlockEntityRenderer<BlockEntity> r = BlockEntityRenderDispatcher.INSTANCE.get(blockEntity);
BlockEntityRenderer<BlockEntity> r = MinecraftClient.getInstance().getBlockEntityRenderDispatcher().get(blockEntity);
if (r != null) {
blockEntity.setPos(e.getBlockPos());
((MixinBlockEntity)blockEntity).setPos(e.getBlockPos());
matrices.push();
BlockState state = blockEntity.getCachedState();
@ -143,7 +143,7 @@ public class WorldRenderDelegate {
matrices.translate(x, y, z);
matrices.multiply(direction.getRotationQuaternion());
matrices.multiply(Vector3f.NEGATIVE_X.getDegreesQuaternion(90));
matrices.multiply(Vec3f.NEGATIVE_X.getDegreesQuaternion(90));
matrices.translate(-0.5, 0, -0.5);
@ -161,7 +161,7 @@ public class WorldRenderDelegate {
}
e.setFireTicks(fireTicks);
dispatcher.render(e, x, y, z, e.yaw, tickDelta, matrices, vertexConsumers, light);
dispatcher.render(e, x, y, z, e.getYaw(), tickDelta, matrices, vertexConsumers, light);
e.setFireTicks(0);
if (model != null) {
@ -184,10 +184,10 @@ public class WorldRenderDelegate {
private void flipAngles(Entity entity) {
if (entity instanceof PlayerEntity) {
entity.prevYaw *= -1;
entity.yaw *= -1;
entity.setYaw(entity.getYaw() * -1);
entity.prevPitch *= -1;
entity.pitch *= -1;
entity.setPitch(entity.getPitch() * -1);
}
if (entity instanceof LivingEntity) {

View file

@ -45,7 +45,7 @@ public class MagicAuraSoundInstance extends MovingSoundInstance {
y = pos.y;
z = pos.z;
if (!living.getEntity().removed && data.isPresent()) {
if (!living.getEntity().isRemoved() && data.isPresent()) {
float level = data.get().level;
if (level != targetVolume) {
setTargetVolume(level);

View file

@ -11,12 +11,12 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.argument.EntitySummonArgumentType;
import net.minecraft.command.argument.NbtCompoundTagArgumentType;
import net.minecraft.command.argument.NbtCompoundArgumentType;
import net.minecraft.command.suggestion.SuggestionProviders;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.TranslatableText;
@ -38,18 +38,18 @@ public class DisguiseCommand {
.executes(context -> disguise(context.getSource(),
context.getSource().getPlayer(),
EntitySummonArgumentType.getEntitySummon(context, "entity"),
new CompoundTag(), true))
.then(CommandManager.argument("nbt", NbtCompoundTagArgumentType.nbtCompound())
new NbtCompound(), true))
.then(CommandManager.argument("nbt", NbtCompoundArgumentType.nbtCompound())
.executes(context -> disguise(context.getSource(),
context.getSource().getPlayer(),
EntitySummonArgumentType.getEntitySummon(context, "entity"),
NbtCompoundTagArgumentType.getCompoundTag(context, "nbt"), false))
NbtCompoundArgumentType.getNbtCompound(context, "nbt"), false))
));
dispatcher.register(builder);
}
static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, CompoundTag nbt, boolean isSelf) throws CommandSyntaxException {
static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, NbtCompound nbt, boolean isSelf) throws CommandSyntaxException {
nbt = nbt.copy();
nbt.putString("id", id.toString());

View file

@ -19,7 +19,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
@ -66,7 +66,7 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
public void tick() {
super.tick();
if (removed) {
if (isRemoved()) {
return;
}
@ -83,11 +83,11 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
}
LivingEntity master = getMaster();
if (master == null || master.removed) {
if (master == null || master.isRemoved()) {
if (orphanedTicks-- > 0) {
return;
}
remove();
remove(RemovalReason.DISCARDED);
return;
}
@ -104,13 +104,13 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
return true;
}).isPresent()) {
remove();
remove(RemovalReason.DISCARDED);
}
}
@Override
public void remove() {
super.remove();
public void remove(RemovalReason reason) {
super.remove(reason);
if (world.isClient) {
world.getLightingProvider().checkBlock(getBlockPos());
}
@ -162,7 +162,7 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
}
@Override
protected void writeCustomDataToTag(CompoundTag tag) {
protected void writeCustomDataToNbt(NbtCompound tag) {
tag.put("owner", owner.toNBT());
dataTracker.get(SPELL).ifPresent(spellId -> {
tag.putUuid("spellId", spellId);
@ -171,7 +171,7 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
}
@Override
protected void readCustomDataFromTag(CompoundTag tag) {
protected void readCustomDataFromNbt(NbtCompound tag) {
if (tag.contains("owner")) {
owner.fromNBT(tag.getCompound("owner"));
}

View file

@ -20,11 +20,11 @@ import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
public class Creature extends Living<LivingEntity> {
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
public static final TrackedData<Float> GRAVITY = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final LevelStore LEVELS = Levelled.fixed(0);
@ -94,7 +94,7 @@ public class Creature extends Living<LivingEntity> {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
getSpellSlot().get(true).ifPresent(effect -> {
compound.put("effect", SpellType.toNBT(effect));
@ -103,7 +103,7 @@ public class Creature extends Living<LivingEntity> {
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
if (compound.contains("effect")) {
setSpell(SpellType.fromNBT(compound.getCompound("effect")));

View file

@ -7,19 +7,19 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.item.enchantment.SimpleEnchantment;
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtString;
import net.minecraft.util.Identifier;
import net.minecraft.util.Tickable;
import net.minecraft.util.registry.Registry;
public class Enchantments implements NbtSerialisable, Tickable {
@ -74,19 +74,19 @@ public class Enchantments implements NbtSerialisable, Tickable {
}
@Override
public void toNBT(CompoundTag compound) {
ListTag list = new ListTag();
public void toNBT(NbtCompound compound) {
NbtList list = new NbtList();
equippedEnchantments.forEach(enchant -> {
Identifier id = Registry.ENCHANTMENT.getId(enchant);
if (id != null) {
list.add(StringTag.of(id.toString()));
list.add(NbtString.of(id.toString()));
}
});
compound.put("enchants", list);
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
equippedEnchantments.clear();
if (compound.contains("enchants")) {
compound.getList("enchants", 8).forEach(tag -> {

View file

@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.entity;
import com.minelittlepony.unicopia.entity.player.PlayerAttributes;
import com.minelittlepony.unicopia.util.Copieable;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.FenceGateBlock;
@ -12,11 +12,10 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.BlockStateParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -97,8 +96,8 @@ public class EntityPhysics<T extends Entity> implements Physics, Copieable<Entit
if (entity.world.getBlockState(pos).isAir()) {
BlockPos below = pos.down();
Block block = entity.world.getBlockState(below).getBlock();
if (block.isIn(BlockTags.FENCES) || block.isIn(BlockTags.WALLS) || block instanceof FenceGateBlock) {
BlockState block = entity.world.getBlockState(below);
if (block.isIn(BlockTags.FENCES) || block.isIn(BlockTags.WALLS) || block.getBlock() instanceof FenceGateBlock) {
entity.setOnGround(true);
return below;
}
@ -158,12 +157,12 @@ public class EntityPhysics<T extends Entity> implements Physics, Copieable<Entit
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
compound.putFloat("gravity", getBaseGravityModifier());
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
setBaseGravityModifier(compound.getFloat("gravity"));
}

View file

@ -4,12 +4,12 @@ import java.util.Optional;
import java.util.UUID;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
@ -24,7 +24,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
public void set(@Nullable T entity) {
if (entity != null) {
uuid = entity.getUuid();
clientId = entity.getEntityId();
clientId = entity.getId();
pos = Optional.of(entity.getPos());
}
}
@ -35,7 +35,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
public boolean isPresent(World world) {
T entity = get(world);
return entity != null && !entity.removed;
return entity != null && !entity.isRemoved();
}
public void ifPresent(World world, Consumer<T> consumer) {
@ -59,7 +59,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
}
@Override
public void toNBT(CompoundTag tag) {
public void toNBT(NbtCompound tag) {
if (uuid != null) {
tag.putUuid("uuid", uuid);
}
@ -70,7 +70,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
}
@Override
public void fromNBT(CompoundTag tag) {
public void fromNBT(NbtCompound tag) {
uuid = tag.containsUuid("uuid") ? tag.getUuid("uuid") : null;
pos = tag.contains("pos") ? Optional.ofNullable(NbtSerialisable.readVector(tag.getList("pos", 6))) : Optional.empty();
clientId = tag.getInt("clientId");

View file

@ -2,16 +2,16 @@ package com.minelittlepony.unicopia.entity;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.projectile.ProjectileImpactListener;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.util.Tickable;
public interface Equine<T extends Entity> extends NbtSerialisable, Tickable, ProjectileImpactListener {
Race getSpecies();

View file

@ -11,7 +11,7 @@ import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
@ -142,17 +142,17 @@ public class FloatingArtefactEntity extends Entity {
}
@Override
protected void readCustomDataFromTag(CompoundTag compound) {
ItemStack itemStack = ItemStack.fromTag(compound.getCompound("Item"));
protected void readCustomDataFromNbt(NbtCompound compound) {
ItemStack itemStack = ItemStack.fromNbt(compound.getCompound("Item"));
setStack(itemStack);
setState(State.valueOf(compound.getInt("State")));
}
@Override
protected void writeCustomDataToTag(CompoundTag compound) {
protected void writeCustomDataToNbt(NbtCompound compound) {
ItemStack stack = getStack();
if (!stack.isEmpty()) {
compound.put("Item", stack.toTag(new CompoundTag()));
compound.put("Item", stack.writeNbt(new NbtCompound()));
}
compound.putInt("State", getState().ordinal());
}
@ -167,7 +167,7 @@ public class FloatingArtefactEntity extends Entity {
health -= amount;
if (health <= 0) {
remove();
remove(RemovalReason.KILLED);
ItemStack stack = getStack();

View file

@ -18,7 +18,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.ActionResult;
@ -91,14 +91,14 @@ public class ItemImpl implements Equine<ItemEntity>, Owned<ItemEntity> {
});
}
if (stack.getItem().isIn(UTags.FALLS_SLOWLY)) {
if (stack.isIn(UTags.FALLS_SLOWLY)) {
if (!owner.isOnGround() && Math.signum(owner.getVelocity().y) != getPhysics().getGravitySignum()) {
double ticks = ((Entity)owner).age;
double shift = Math.sin(ticks / 9D) / 9D;
double rise = -Math.cos(ticks / 9D) * getPhysics().getGravitySignum();
owner.prevYaw = owner.prevYaw;
owner.yaw += 0.3F;
owner.setYaw(owner.getYaw() + 0.3F);
owner.setVelocity(
owner.getVelocity()
@ -139,13 +139,13 @@ public class ItemImpl implements Equine<ItemEntity>, Owned<ItemEntity> {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
compound.putString("owner_species", getSpecies().name());
physics.toNBT(compound);
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
setSpecies(Race.fromName(compound.getString("owner_species")));
physics.fromNBT(compound);
}

View file

@ -1,6 +1,5 @@
package com.minelittlepony.unicopia.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
class ItemPhysics extends EntityPhysics<ItemEntity> {
@ -22,7 +21,7 @@ class ItemPhysics extends EntityPhysics<ItemEntity> {
);
if (!entity.isOnGround()
|| Entity.squaredHorizontalLength(entity.getVelocity()) > 9.999999747378752E-6D) {
|| entity.getVelocity().horizontalLengthSquared() > 9.999999747378752E-6D) {
float above = 0.98f;
if (entity.verticalCollision) {

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.entity;
import java.util.Optional;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
@ -20,7 +20,7 @@ import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Hand;
public abstract class Living<T extends LivingEntity> implements Equine<T>, Caster<T> {
@ -42,11 +42,11 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
private final Enchantments enchants = new Enchantments(this);
protected Living(T entity, TrackedData<CompoundTag> effect) {
protected Living(T entity, TrackedData<NbtCompound> effect) {
this.entity = entity;
this.effectDelegate = new EffectSync(this, effect);
entity.getDataTracker().startTracking(effect, new CompoundTag());
entity.getDataTracker().startTracking(effect, new NbtCompound());
}
public void waitForFall(Runnable action) {
@ -164,19 +164,19 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
.isPresent();
}
protected void handleFall(float distance, float damageMultiplier) {
protected void handleFall(float distance, float damageMultiplier, DamageSource cause) {
getSpellSlot().get(SpellType.DISGUISE, false).ifPresent(spell -> {
spell.getDisguise().onImpact(this, distance, damageMultiplier);
spell.getDisguise().onImpact(this, distance, damageMultiplier, cause);
});
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
enchants.toNBT(compound);
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
enchants.fromNBT(compound);
}
}

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.entity;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import net.minecraft.entity.Entity;

View file

@ -28,7 +28,7 @@ public class BreakHeartGoal extends Goal {
}
protected boolean canTarget(Entity e) {
return !e.removed
return !e.isRemoved()
&& e instanceof FloatingArtefactEntity
&& ((FloatingArtefactEntity)e).getStack().getItem() == UItems.CRYSTAL_HEART
&& mob.getVisibilityCache().canSee(e);

View file

@ -5,7 +5,7 @@ import java.util.Optional;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.util.VecHelper;

View file

@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.particle.UParticles;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
@ -18,7 +19,7 @@ import net.minecraft.util.Hand;
public class WantItTakeItGoal extends BreakHeartGoal {
private final TargetPredicate predicate = new TargetPredicate()
private final TargetPredicate predicate = TargetPredicate.createAttackable()
.setBaseMaxDistance(64)
.setPredicate(EquinePredicates.HAS_WANT_IT_NEED_IT);
@ -30,7 +31,7 @@ public class WantItTakeItGoal extends BreakHeartGoal {
@Override
protected boolean canTarget(Entity e) {
return (!e.removed && e instanceof ItemEntity && EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, ((ItemEntity)e).getStack()) > 0)
return (!e.isRemoved() && e instanceof ItemEntity && EnchantmentHelper.getLevel(UEnchantments.WANT_IT_NEED_IT, ((ItemEntity)e).getStack()) > 0)
|| (e instanceof LivingEntity && predicate.test(mob, (LivingEntity)e));
}
@ -78,11 +79,11 @@ public class WantItTakeItGoal extends BreakHeartGoal {
ItemEntity item = (ItemEntity)target;
ItemStack stack = item.getStack();
if (!item.removed) {
if (!item.isRemoved()) {
mob.tryEquip(stack);
mob.method_29499(item);
mob.triggerItemPickedUpByEntityCriteria(item);
mob.sendPickup(item, stack.getCount());
item.remove();
item.remove(RemovalReason.DISCARDED);
}
}, 0);
}

View file

@ -35,9 +35,9 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
if (egg.isEmpty()) {
egg = new ItemStack(Items.EGG);
int slot = player.getMaster().inventory.method_7371(egg);
int slot = player.getMaster().getInventory().indexOf(egg);
if (slot > -1) {
player.getMaster().inventory.removeStack(slot, 1);
player.getMaster().getInventory().removeStack(slot, 1);
entity.playSound(SoundEvents.ENTITY_CHICKEN_EGG,
1,
(entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F + 4
@ -54,7 +54,7 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
Entity src = source.getEntity();
if (src.isOnGround() || src instanceof PlayerEntity && ((PlayerEntity)src).abilities.flying) {
if (src.isOnGround() || src instanceof PlayerEntity && ((PlayerEntity)src).getAbilities().flying) {
return;
}

View file

@ -7,8 +7,8 @@ import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Predicate;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.FlightType;
import com.minelittlepony.unicopia.InteractionManager;
@ -31,6 +31,7 @@ import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.Flutterer;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.decoration.AbstractDecorationEntity;
import net.minecraft.entity.mob.AmbientEntity;
import net.minecraft.entity.mob.FlyingEntity;
@ -39,7 +40,7 @@ import net.minecraft.entity.mob.SpiderEntity;
import net.minecraft.entity.mob.VexEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ShulkerBulletEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.function.BooleanBiFunction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
@ -49,7 +50,7 @@ import net.minecraft.world.WorldAccess;
public class Disguise implements NbtSerialisable {
@Nonnull
@NotNull
private String entityId = "";
@Nullable
@ -63,7 +64,7 @@ public class Disguise implements NbtSerialisable {
private Optional<EntityDimensions> dimensions = Optional.empty();
@Nullable
private CompoundTag entityNbt;
private NbtCompound entityNbt;
@Nullable
public Entity getAppearance() {
@ -110,12 +111,12 @@ public class Disguise implements NbtSerialisable {
}
}
private synchronized void createPlayer(CompoundTag nbt, GameProfile profile, Caster<?> source) {
private synchronized void createPlayer(NbtCompound nbt, GameProfile profile, Caster<?> source) {
remove();
entity = InteractionManager.instance().createPlayer(source.getEntity(), profile);
entity.setCustomName(source.getMaster().getName());
((PlayerEntity)entity).fromTag(nbt.getCompound("playerNbt"));
((PlayerEntity)entity).readNbt(nbt.getCompound("playerNbt"));
entity.setUuid(UUID.randomUUID());
entity.extinguish();
@ -124,7 +125,7 @@ public class Disguise implements NbtSerialisable {
public Entity getOrCreate(Caster<?> source) {
if (entity == null && entityNbt != null) {
CompoundTag nbt = entityNbt;
NbtCompound nbt = entityNbt;
entityNbt = null;
attachments.clear();
@ -133,16 +134,14 @@ public class Disguise implements NbtSerialisable {
nbt.getUuid("playerId"),
nbt.getString("playerName")
), source);
new Thread(() -> createPlayer(nbt, SkullBlockEntity.loadProperties(new GameProfile(
null,
nbt.getString("playerName")
)), source)).start();
SkullBlockEntity.loadProperties(new GameProfile(null, nbt.getString("playerName")), profile ->{ });
} else {
if (source.isClient()) {
entity = EntityType.fromTag(nbt).map(type -> type.create(source.getWorld())).orElse(null);
entity = EntityType.fromNbt(nbt).map(type -> type.create(source.getWorld())).orElse(null);
if (entity != null) {
try {
entity.fromTag(nbt);
entity.readNbt(nbt);
} catch (Exception ignored) {
// Mojang pls
}
@ -161,8 +160,8 @@ public class Disguise implements NbtSerialisable {
return entity;
}
public void onImpact(Caster<?> pony, float distance, float damageMultiplier) {
EntityBehaviour.forEntity(entity).onImpact(pony, entity, distance, damageMultiplier);
public void onImpact(Caster<?> pony, float distance, float damageMultiplier, DamageSource cause) {
EntityBehaviour.forEntity(entity).onImpact(pony, entity, distance, damageMultiplier, cause);
}
private void onEntityLoaded(Caster<?> source) {
@ -251,7 +250,7 @@ public class Disguise implements NbtSerialisable {
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
compound.putString("entityId", entityId);
if (entityNbt != null) {
@ -262,7 +261,7 @@ public class Disguise implements NbtSerialisable {
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
String newId = compound.getString("entityId");
if (!newId.contentEquals(entityId)) {
@ -279,7 +278,7 @@ public class Disguise implements NbtSerialisable {
if (entity != null) {
try {
entity.fromTag(entityNbt);
entity.readNbt(entityNbt);
} catch (Exception ignored) {
// Mojang pls
}
@ -296,8 +295,8 @@ public class Disguise implements NbtSerialisable {
|| entity instanceof FallingBlockEntity;
}
private static CompoundTag encodeEntityToNBT(Entity entity) {
CompoundTag entityNbt = new CompoundTag();
private static NbtCompound encodeEntityToNBT(Entity entity) {
NbtCompound entityNbt = new NbtCompound();
if (entity instanceof PlayerEntity) {
GameProfile profile = ((PlayerEntity)entity).getGameProfile();
@ -306,13 +305,13 @@ public class Disguise implements NbtSerialisable {
entityNbt.putUuid("playerId", profile.getId());
entityNbt.putString("playerName", profile.getName());
CompoundTag tag = new CompoundTag();
NbtCompound tag = new NbtCompound();
entity.saveToTag(tag);
entity.writeNbt(tag);
entityNbt.put("playerNbt", tag);
} else {
entity.saveToTag(entityNbt);
entity.writeNbt(entityNbt);
}
return entityNbt;

View file

@ -3,21 +3,24 @@ package com.minelittlepony.unicopia.entity.behaviour;
import java.util.Optional;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.ItemWielder;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinEntity;
import com.minelittlepony.unicopia.util.Registries;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.passive.LlamaEntity;
import net.minecraft.entity.passive.SnowGolemEntity;
@ -47,7 +50,7 @@ public class EntityBehaviour<T extends Entity> {
}
public void onImpact(Caster<?> source, T entity, float distance, float damageMultiplier) {
public void onImpact(Caster<?> source, T entity, float distance, float damageMultiplier, DamageSource cause) {
}
@ -59,7 +62,7 @@ public class EntityBehaviour<T extends Entity> {
public void onDestroy(T entity) {
entity.setInvulnerable(false);
entity.setNoGravity(false);
entity.remove();
entity.remove(RemovalReason.KILLED);
}
public Optional<Double> getCameraDistance(Entity entity, Pony player) {
@ -97,7 +100,7 @@ public class EntityBehaviour<T extends Entity> {
public void copyBaseAttributes(LivingEntity from, Entity to, Vec3d positionOffset) {
// Set first because position calculations rely on it
to.age = from.age;
to.removed = from.removed;
((MixinEntity)to).setRemovalReason(from.getRemovalReason());
to.setOnGround(from.isOnGround());
if (!from.world.isClient) {
@ -143,10 +146,6 @@ public class EntityBehaviour<T extends Entity> {
to.prevY = positionOffset.y + from.prevY;
to.prevZ = positionOffset.z + from.prevZ;
to.chunkX = from.chunkX;
to.chunkY = from.chunkY;
to.chunkZ = from.chunkZ;
to.lastRenderX = positionOffset.x + from.lastRenderX;
to.lastRenderY = positionOffset.y + from.lastRenderY;
to.lastRenderZ = positionOffset.z + from.lastRenderZ;
@ -162,9 +161,9 @@ public class EntityBehaviour<T extends Entity> {
to.setVelocity(from.getVelocity());
to.pitch = from.pitch;
to.setPitch(from.getPitch());
to.prevPitch = from.prevPitch;
to.yaw = from.yaw;
to.setYaw(from.getYaw());
to.prevYaw = from.prevYaw;
to.horizontalSpeed = from.horizontalSpeed;
to.prevHorizontalSpeed = from.prevHorizontalSpeed;
@ -245,7 +244,7 @@ public class EntityBehaviour<T extends Entity> {
protected boolean isSneakingOnGround(Caster<?> source) {
Entity e = source.getEntity();
return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).abilities.flying));
return e.isSneaking() && (e.isOnGround() || !(e instanceof PlayerEntity && ((PlayerEntity)e).getAbilities().flying));
}
public static <T extends Entity> void register(Supplier<EntityBehaviour<T>> behaviour, EntityType<?>... types) {

View file

@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
@ -21,9 +22,9 @@ import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
@ -39,10 +40,10 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
}
@Override
public void onImpact(Caster<?> source, FallingBlockEntity entity, float distance, float damageMultiplier) {
public void onImpact(Caster<?> source, FallingBlockEntity entity, float distance, float damageMultiplier, DamageSource cause) {
if (source.getEntity().fallDistance > 3) {
entity.fallDistance = source.getEntity().fallDistance;
entity.handleFallDamage(distance, damageMultiplier);
entity.handleFallDamage(distance, damageMultiplier, cause);
BlockState state = entity.getBlockState();
if (state.getBlock() instanceof FallingBlock) {
@ -77,9 +78,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
}
if (block instanceof BlockEntityProvider) {
BlockEntity b = ((BlockEntityProvider)block).createBlockEntity(entity.world);
((MixinBlockEntity)b).setCachedState(state);
context.addBlockEntity(b);
context.addBlockEntity(((BlockEntityProvider)block).createBlockEntity(entity.getBlockPos(), state));
}
return configure(entity, block);
@ -115,9 +114,10 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0);
}
be.setLocation(entity.world, entity.getBlockPos());
be.setWorld(entity.world);
((MixinBlockEntity)be).setPos(entity.getBlockPos());
ceb.tick();
be.setLocation(null, entity.getBlockPos());
be.setWorld(null);
}
}
}

View file

@ -28,9 +28,12 @@ public class GhastBehaviour extends MobBehaviour<GhastEntity> {
Vec3d rot = player.getEntity().getRotationVec(1);
FireballEntity proj = new FireballEntity(entity.world, entity, rot.getX(), rot.getY(), rot.getZ());
proj.explosionPower = entity.getFireballStrength() * (player.getLevel().get() + 1);
proj.setOwner(player.getMaster());
FireballEntity proj = new FireballEntity(entity.world, player.getMaster(),
rot.getX(),
rot.getY(),
rot.getZ(),
entity.getFireballStrength() * (player.getLevel().get() + 1)
);
proj.updatePosition(
entity.getX() + rot.x * 4,
entity.getBodyY(0.5D) + 0.5,

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.entity.behaviour;
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.RabbitEntity;
@ -12,7 +11,7 @@ public class HoppingBehaviour extends EntityBehaviour<LivingEntity> {
public void update(Pony player, LivingEntity entity, DisguiseSpell spell) {
if (player.getEntity().isOnGround()) {
if (Entity.squaredHorizontalLength(player.getEntity().getVelocity()) > 0.01) {
if (player.getEntity().getVelocity().horizontalLengthSquared() > 0.01) {
player.getMaster().jump();
if (entity instanceof RabbitEntity) {
((RabbitEntity)entity).startJump();

View file

@ -21,10 +21,10 @@ public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
@Override
public void update(Caster<?> source, AbstractMinecartEntity entity, DisguiseSpell spell) {
entity.yaw -= 90;
entity.setYaw(entity.getYaw() - 90);
entity.prevYaw -= 90;
entity.pitch = 0;
entity.setPitch(0);
entity.prevPitch = 0;
if (source.getEntity() instanceof LivingEntity) {

View file

@ -44,13 +44,14 @@ public class SheepBehaviour extends EntityBehaviour<SheepEntity> {
entity.setSheared(true);
Random rng = entity.world.random;
PlayerInventory inv = player.getMaster().inventory;
PlayerInventory inv = player.getMaster().getInventory();
int dropAmount = rng.nextInt(3);
int slot;
do {
slot = inv.method_7371(dropType);
slot = inv.indexOf(dropType);
if (slot < 0) {
break;
}

View file

@ -5,7 +5,6 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.mixin.MixinShulkerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.mob.ShulkerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.BlockPos;
@ -17,12 +16,10 @@ import net.minecraft.util.math.Vec3d;
public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
@Override
public void update(Caster<?> source, ShulkerEntity shulker, DisguiseSpell spell) {
shulker.yaw = 0;
shulker.setYaw(0);
shulker.prevBodyYaw = 0;
shulker.bodyYaw = 0;
shulker.setAttachedBlock(null);
super.update(source, shulker, spell);
Direction attachmentFace = shulker.getAttachedFace();
@ -45,7 +42,7 @@ public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
float peekAmount = 30;
double speed = !player.getEntity().isSneaking() ? 0.29 : 0;
speed += Math.sqrt(Entity.squaredHorizontalLength(player.getEntity().getVelocity())) * 2;
speed += Math.sqrt(player.getEntity().getVelocity().horizontalLengthSquared()) * 2;
peekAmount = (float)MathHelper.clamp(speed, 0, 1);
peekAmount = player.getInterpolator().interpolate("peek", peekAmount, 5);
@ -56,8 +53,8 @@ public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
mx.setOpenProgress(peekAmount);
if (player.sneakingChanged()) {
shulker.setPeekAmount((int)(peekAmount / 0.01F));
} else if (peekAmount > 0.2 && shulker.getPeekAmount() == 0) {
mx.callSetPeekAmount((int)(peekAmount / 0.01F));
} else if (peekAmount > 0.2 && mx.callGetPeekAmount() == 0) {
if (shulker.isAlive() && shulker.world.random.nextInt(1000) < shulker.ambientSoundChance++) {
shulker.ambientSoundChance = -shulker.getMinAmbientSoundDelay();
shulker.playSound(SoundEvents.ENTITY_SHULKER_AMBIENT, 1, 1);

View file

@ -9,6 +9,14 @@ public class SpellcastingIllagerBehaviour extends EntityBehaviour<SpellcastingIl
@Override
public void update(Pony player, SpellcastingIllagerEntity entity, DisguiseSpell s) {
if (player.sneakingChanged()) {
SpellCastAccess.setSpell(player, entity, s);
}
}
private static abstract class SpellCastAccess extends SpellcastingIllagerEntity {
SpellCastAccess() {super(null, null);}
static void setSpell(Pony player, SpellcastingIllagerEntity entity, DisguiseSpell s) {
if (player.getMaster().isSneaking()) {
SpellcastingIllagerEntity.Spell[] spells = SpellcastingIllagerEntity.Spell.values();
SpellcastingIllagerEntity.Spell spell = spells[entity.world.random.nextInt(spells.length - 1) + 1];

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.entity.effect;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.magic.Caster;

View file

@ -1,7 +1,8 @@
package com.minelittlepony.unicopia.entity.player;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.MathHelper;
public class ManaContainer implements MagicReserves, Tickable {

View file

@ -5,6 +5,7 @@ import java.util.List;
import java.util.UUID;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.util.Tickable;
import net.minecraft.entity.attribute.ClampedEntityAttribute;
import net.minecraft.entity.attribute.EntityAttribute;
@ -13,7 +14,6 @@ import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributeModifier.Operation;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Tickable;
import net.minecraft.util.registry.Registry;
public class PlayerAttributes implements Tickable {

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.entity.player;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Unicopia;

View file

@ -15,6 +15,7 @@ import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.Tickable;
import com.minelittlepony.unicopia.util.MutableVector;
import net.minecraft.block.Block;
@ -29,11 +30,10 @@ import net.minecraft.entity.attribute.EntityAttributeInstance;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
@ -121,7 +121,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
entity.setPose(EntityPose.STANDING);
}
boolean creative = entity.abilities.creativeMode || entity.isSpectator();
boolean creative = entity.getAbilities().creativeMode || entity.isSpectator();
FlightType type = getFlightType();
@ -131,12 +131,12 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
entity.world.playSound(entity.getX(), entity.getY(), entity.getZ(), entity.world.getDimension().isUltrawarm() ? SoundEvents.BLOCK_BELL_USE : SoundEvents.BLOCK_BELL_RESONATE, SoundCategory.PLAYERS, 0.1125F, 1.5F, true);
}
entity.abilities.allowFlying = type.canFlyCreative(entity);
entity.getAbilities().allowFlying = type.canFlyCreative(entity);
if (!creative) {
entity.abilities.flying |= (type.canFly() || entity.abilities.allowFlying) && isFlyingEither;
entity.getAbilities().flying |= (type.canFly() || entity.getAbilities().allowFlying) && isFlyingEither;
if (!type.canFly() && (type != lastFlightType)) {
entity.abilities.flying = false;
entity.getAbilities().flying = false;
}
if ((entity.isOnGround() && entity.isSneaking())
@ -144,28 +144,28 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|| entity.horizontalCollision
|| (entity.verticalCollision && (pony.getSpecies() != Race.BAT || velocity.y < 0))) {
if (entity.abilities.flying && entity.horizontalCollision) {
if (entity.getAbilities().flying && entity.horizontalCollision) {
handleWallCollission(entity, velocity);
entity.setVelocity(velocity.toImmutable());
entity.abilities.flying = false;
entity.getAbilities().flying = false;
return;
}
entity.abilities.flying = false;
isFlyingSurvival = entity.abilities.flying && !creative;
isFlyingEither = isFlyingSurvival || (creative && entity.abilities.flying);
entity.getAbilities().flying = false;
isFlyingSurvival = entity.getAbilities().flying && !creative;
isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying);
}
}
lastFlightType = type;
isFlyingSurvival = entity.abilities.flying && !creative;
isFlyingEither = isFlyingSurvival || (creative && entity.abilities.flying);
isFlyingSurvival = entity.getAbilities().flying && !creative;
isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying);
if (isGravityNegative()) {
if (entity.isOnGround() || (!creative && entity.horizontalCollision)) {
entity.abilities.flying = false;
entity.getAbilities().flying = false;
isFlyingEither = false;
isFlyingSurvival = false;
}
@ -219,7 +219,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
if (!getFlightType().canFly()) {
entity.world.playSoundFromEntity(null, entity, SoundEvents.ITEM_SHIELD_BREAK, SoundCategory.PLAYERS, 1, 2);
entity.abilities.flying = false;
entity.getAbilities().flying = false;
isFlyingEither = false;
isFlyingSurvival = false;
}
@ -288,7 +288,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
boolean fallingTakeOffCondition = !entity.isOnGround() && velocity.y < -1.6 * getGravitySignum();
if (takeOffCondition || fallingTakeOffCondition) {
entity.abilities.flying = true;
entity.getAbilities().flying = true;
isFlyingEither = true;
isFlyingSurvival = true;
@ -364,9 +364,9 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
// vertical drop due to gravity
forward += 0.005F;
velocity.x += - forward * MathHelper.sin(player.yaw * 0.017453292F);
velocity.x += - forward * MathHelper.sin(player.getYaw() * 0.017453292F);
velocity.y -= (0.01F / Math.max(motion * 100, 1)) * getGravityModifier();
velocity.z += forward * MathHelper.cos(player.yaw * 0.017453292F);
velocity.z += forward * MathHelper.cos(player.getYaw() * 0.017453292F);
}
protected void applyThrust(PlayerEntity player, MutableVector velocity) {
@ -426,8 +426,8 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
forward = Math.min(forward, 7);
forward /= 1 + (EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player) * 0.8F);
velocity.x += - forward * MathHelper.sin((player.yaw + glance) * 0.017453292F);
velocity.z += forward * MathHelper.cos((player.yaw + glance) * 0.017453292F);
velocity.x += - forward * MathHelper.sin((player.getYaw() + glance) * 0.017453292F);
velocity.z += forward * MathHelper.cos((player.getYaw() + glance) * 0.017453292F);
if (!player.world.isClient && player.world.isThundering() && player.world.random.nextInt(9000) == 0) {
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(player.world);
@ -438,7 +438,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
}
protected double getHorizontalMotion(Entity e) {
return Entity.squaredHorizontalLength(e.getPos().subtract(lastPos));
return e.getPos().subtract(lastPos).horizontalLengthSquared();
}
private FlightType getFlightType() {
@ -456,19 +456,19 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
public void updateFlightStat(boolean flying) {
FlightType type = getFlightType();
entity.abilities.allowFlying = type.canFlyCreative(entity);
entity.getAbilities().allowFlying = type.canFlyCreative(entity);
if (type.canFly() || entity.abilities.allowFlying) {
entity.abilities.flying |= flying;
isFlyingSurvival = entity.abilities.flying;
if (type.canFly() || entity.getAbilities().allowFlying) {
entity.getAbilities().flying |= flying;
isFlyingSurvival = entity.getAbilities().flying;
} else {
entity.abilities.flying = false;
entity.getAbilities().flying = false;
isFlyingSurvival = false;
}
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
compound.putBoolean("isFlying", isFlyingSurvival);
compound.putBoolean("isFlyingEither", isFlyingEither);
@ -476,7 +476,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
isFlyingSurvival = compound.getBoolean("isFlying");
isFlyingEither = compound.getBoolean("isFlyingEither");

View file

@ -5,7 +5,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Affinity;
import com.minelittlepony.unicopia.client.UnicopiaClient;
@ -28,6 +28,7 @@ import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
import com.minelittlepony.unicopia.network.Transmittable;
import com.minelittlepony.unicopia.util.Copieable;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.Tickable;
import com.minelittlepony.common.util.animation.LinearInterpolator;
import com.google.common.collect.Lists;
import com.google.common.collect.Streams;
@ -37,18 +38,18 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -61,7 +62,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
static final TrackedData<Float> MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
private static final TrackedData<CompoundTag> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.TAG_COMPOUND);
private final AbilityDispatcher powers = new AbilityDispatcher(this);
private final PlayerPhysics gravity = new PlayerPhysics(this);
@ -118,7 +119,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
entity.getDataTracker().set(RACE, race.ordinal());
gravity.updateFlightStat(entity.abilities.flying);
gravity.updateFlightStat(entity.getAbilities().flying);
entity.sendAbilitiesUpdate();
}
@ -262,7 +263,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
if (isHanging()) {
if (ticksHanging++ > 40) {
if (Entity.squaredHorizontalLength(entity.getVelocity()) > 0.01
if (entity.getVelocity().horizontalLengthSquared() > 0.01
|| entity.isSneaking()
|| !canHangAt(getHangingPos())) {
@ -284,7 +285,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
}
}
public Optional<Float> onImpact(float distance, float damageMultiplier) {
public Optional<Float> onImpact(float distance, float damageMultiplier, DamageSource cause) {
float g = gravity.getGravityModifier();
@ -301,11 +302,11 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
distance = Math.max(0, (distance * g) - 5);
handleFall(distance, damageMultiplier);
handleFall(distance, damageMultiplier, cause);
return Optional.of(distance);
}
handleFall(distance, damageMultiplier);
handleFall(distance, damageMultiplier, cause);
return Optional.empty();
}
@ -349,7 +350,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
protected Stream<ItemStack> getInventoryStacks() {
return Streams.concat(
super.getInventoryStacks(),
entity.inventory.main.stream()
entity.getInventory().main.stream()
);
}
@ -374,7 +375,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
}
@Override
public void toNBT(CompoundTag compound) {
public void toNBT(NbtCompound compound) {
super.toNBT(compound);
compound.putString("playerSpecies", getSpecies().name());
@ -389,7 +390,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
}
@Override
public void fromNBT(CompoundTag compound) {
public void fromNBT(NbtCompound compound) {
super.fromNBT(compound);
speciesPersisted = true;
setSpecies(Race.fromName(compound.getString("playerSpecies")));
@ -407,7 +408,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
@Override
public void copyFrom(Pony oldPlayer) {
speciesPersisted = oldPlayer.speciesPersisted;
if (!oldPlayer.getEntity().removed) {
if (!oldPlayer.getEntity().isRemoved()) {
setSpell(oldPlayer.getSpellSlot().get(true).orElse(null));
}
oldPlayer.setSpell(null);

View file

@ -1,11 +1,12 @@
package com.minelittlepony.unicopia.entity.player.dummy;
import javax.annotation.Nonnull;
import org.jetbrains.annotations.NotNull;
import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Owned;
import com.mojang.authlib.GameProfile;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayNetworkHandler;
@ -38,7 +39,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
}
@Override
@Nonnull
@NotNull
protected PlayerListEntry getPlayerListEntry() {
if (playerInfo == null) {
ClientPlayNetworkHandler connection = MinecraftClient.getInstance().getNetworkHandler();
@ -74,11 +75,13 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
}
private final class Packet extends PlayerListS2CPacket {
public Packet() { super(PacketByteBufs.empty()); }
PlayerListS2CPacket.Entry entry() {
return new PlayerListS2CPacket.Entry(
getGameProfile(),
0,
GameMode.NOT_SET,
GameMode.DEFAULT,
new LiteralText(getGameProfile().getName()));
}
}

View file

@ -7,7 +7,6 @@ import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.ServerPlayerInteractionManager;
import net.minecraft.server.world.ServerWorld;
public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned<PlayerEntity> {
@ -15,7 +14,7 @@ public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned
private PlayerEntity owner;
public DummyServerPlayerEntity(ServerWorld world, GameProfile profile) {
super(world.getServer(), world, profile, new ServerPlayerInteractionManager(world));
super(world.getServer(), world, profile);
}
@Override

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.item;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;

View file

@ -1,13 +1,14 @@
package com.minelittlepony.unicopia.item;
import java.util.List;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.entity.IItemEntity;
import com.minelittlepony.unicopia.entity.ItemImpl;
import com.minelittlepony.unicopia.item.toxin.Toxicity;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.Item;
@ -29,10 +30,10 @@ public class AppleItem extends Item implements ItemImpl.TickableItem {
public ActionResult onGroundTick(IItemEntity item) {
ItemEntity entity = item.get().getMaster();
if (!entity.removed && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) {
if (!entity.isRemoved() && item.getPickupDelay() == 0 && item.getAge() > 2030 && entity.world.random.nextInt(150) < 10) {
if (!entity.world.isClient) {
entity.remove();
entity.remove(RemovalReason.KILLED);
ItemEntity neu = EntityType.ITEM.create(entity.world);
neu.copyPositionAndRotation(entity);
@ -48,7 +49,7 @@ public class AppleItem extends Item implements ItemImpl.TickableItem {
entity.world.spawnEntity(copy);
}
float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 0.1F + 0.1F;
float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.uniqueOffset) * 0.1F + 0.1F;
for (int i = 0; i < 3; i++) {
entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(),

View file

@ -101,7 +101,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art
List<LivingEntity> inputs = new ArrayList<>();
List<LivingEntity> outputs = new ArrayList<>();
VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> !e.removed && (e instanceof PlayerEntity || e instanceof MobEntity))).forEach(e -> {
VecHelper.findInRange(entity, entity.world, entity.getPos(), 20, EntityPredicates.EXCEPT_CREATIVE_OR_SPECTATOR.and(e -> !e.isRemoved() && (e instanceof PlayerEntity || e instanceof MobEntity))).forEach(e -> {
LivingEntity living = (LivingEntity)e;
if (e instanceof PlayerEntity

View file

@ -23,7 +23,7 @@ public class DrinkableItem extends Item {
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
}
if (user instanceof PlayerEntity && !((PlayerEntity)user).abilities.creativeMode) {
if (user instanceof PlayerEntity && !((PlayerEntity)user).getAbilities().creativeMode) {
stack.decrement(1);
}

View file

@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
import java.util.List;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.ability.magic.Caster;
@ -42,7 +42,7 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem,
result.setCount(1);
result.getOrCreateTag().putString("issuer", player.getName().asString());
if (!player.abilities.creativeMode) {
if (!player.getAbilities().creativeMode) {
stack.decrement(1);
}

View file

@ -4,7 +4,7 @@ import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.Affinity;
import com.minelittlepony.unicopia.Unicopia;

View file

@ -1,11 +1,11 @@
package com.minelittlepony.unicopia.item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
public interface GlowableItem {
default boolean isGlowing(ItemStack stack) {
CompoundTag tag = stack.getSubTag("display");
NbtCompound tag = stack.getSubTag("display");
return tag != null && tag.getBoolean("glowing");
}

View file

@ -13,6 +13,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -47,20 +48,20 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab
world.playSound(null, player.getX(), player.getY(), player.getZ(),
SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL,
0.5F,
0.4F / (RANDOM.nextFloat() * 0.4F + 0.8F));
0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
if (!world.isClient) {
MagicProjectileEntity projectile = new MagicProjectileEntity(world, player);
projectile.setItem(stack);
projectile.setThrowDamage(getProjectileDamage(stack));
projectile.setProperties(player, player.pitch, player.yaw, 0, 1.5F, 1);
projectile.setProperties(player, player.getPitch(), player.getYaw(), 0, 1.5F, 1);
world.spawnEntity(projectile);
}
player.incrementStat(Stats.USED.getOrCreateStat(this));
if (!player.abilities.creativeMode) {
if (!player.getAbilities().creativeMode) {
stack.decrement(1);
}
@ -79,15 +80,15 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab
if (!lightning
&& !entity.world.isClient
&& !entity.removed
&& entity.getAge() > 100
&& !entity.isRemoved()
&& entity.getItemAge() > 100
&& entity.world.isThundering()
&& entity.world.isSkyVisible(entity.getBlockPos())
&& entity.world.random.nextInt(130) == 0) {
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world);
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
entity.remove();
entity.remove(RemovalReason.DISCARDED);
entity.world.spawnEntity(lightning);
ItemEntity neu = EntityType.ITEM.create(entity.world);

View file

@ -78,7 +78,7 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
e.onStruckByLightning((ServerWorld)e.world, lightning);
}
if (!player.abilities.creativeMode) {
if (!player.getAbilities().creativeMode) {
stack.decrement(1);
}

View file

@ -10,7 +10,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.enchantment.EnchantmentTarget;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
public class GemFindingEnchantment extends SimpleEnchantment {
@ -24,14 +23,16 @@ public class GemFindingEnchantment extends SimpleEnchantment {
BlockPos origin = user.getOrigin();
float volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getWorld().getBlockState(pos).isIn(UTags.INTERESTING))
double volume = BlockPos.findClosest(origin, radius, radius, pos -> user.getWorld().getBlockState(pos).isIn(UTags.INTERESTING))
.map(p -> user.getOriginVector().squaredDistanceTo(p.getX(), p.getY(), p.getZ()))
.map(find -> (1 - (MathHelper.sqrt(find) / radius)))
.orElse(-1F);
.map(find -> (1 - (Math.sqrt(find) / radius)))
.orElse(-1D);
volume = Math.max(volume, 0.04F);
user.getEnchants().computeIfAbsent(this, Data::new).level = volume * (1.3F + level * 0.3F);
user.getEnchants().computeIfAbsent(this, Data::new).level = (float)volume * (1.3F + level * 0.3F);
}
@Environment(EnvType.CLIENT)

Some files were not shown because too many files have changed in this diff Show more