mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 08:18:00 +01:00
1.16.5 -> 1.17
This commit is contained in:
parent
8bfa54b408
commit
55e990882e
133 changed files with 688 additions and 629 deletions
71
build.gradle
71
build.gradle
|
@ -1,32 +1,43 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'fabric-loom' version '0.8-SNAPSHOT'
|
id 'fabric-loom' version '0.8-SNAPSHOT'
|
||||||
|
id 'org.ajoberstar.reckon' version '0.13.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'fabric-loom'
|
java {
|
||||||
|
toolchain {
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
languageVersion = JavaLanguageVersion.of(16)
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
}
|
||||||
|
|
||||||
version = "${project.minecraft_version}-${project.version}"
|
|
||||||
|
|
||||||
if (project.release != 'RELEASE') {
|
|
||||||
version += "-${project.release}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = project.group
|
group = project.group
|
||||||
description = project.displayname
|
description = project.displayname
|
||||||
archivesBaseName = project.name
|
archivesBaseName = project.name
|
||||||
|
|
||||||
// check for updates every build when on CI
|
|
||||||
if (System.env.CI) {
|
|
||||||
configurations.all {
|
|
||||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
refmapName = 'unicopia.mixin.refmap.json'
|
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 {
|
dependencies {
|
||||||
|
@ -34,23 +45,20 @@ dependencies {
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
modApi "net.fabricmc:fabric-loader:${project.loader_version}"
|
modApi "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_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}"
|
modApi "com.minelittlepony:kirin:${project.kirin_version}"
|
||||||
include "com.minelittlepony:Kirin:${project.kirin_version}"
|
include "com.minelittlepony:kirin:${project.kirin_version}"
|
||||||
|
|
||||||
modCompileOnly("io.github.prospector:modmenu:${project.modmenu_version}") {
|
modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
|
||||||
transitive = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version.toString()
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
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"
|
classifier = "sources"
|
||||||
from sourceSets.main.allSource
|
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'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,18 @@ org.gradle.daemon=false
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.16.5
|
minecraft_version=1.17
|
||||||
yarn_mappings=1.16.5+build.4
|
yarn_mappings=1.17+build.5
|
||||||
loader_version=0.11.1
|
loader_version=0.11.3
|
||||||
fabric_version=0.30.3+1.16
|
fabric_version=0.34.9+1.17
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
group=com.minelittlepony
|
group=com.minelittlepony
|
||||||
displayname=Unicopia
|
displayname=Unicopia
|
||||||
authors=Sollace
|
authors=Sollace
|
||||||
description=Magical Abilities for Mine Little Pony!
|
description=Magical Abilities for Mine Little Pony!
|
||||||
version=9
|
|
||||||
release=BETA
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
modmenu_version=1.14.+
|
modmenu_version=2.0.0-beta.7
|
||||||
minelp_version=4.2.2-1.16.5-1.16-SNAPSHOT
|
minelp_version=4.3.4
|
||||||
kirin_version=1.7.1-1.16.2-SNAPSHOT
|
kirin_version=1.9.1
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
|
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_BAT = IS_PLAYER.and(ofRace(Race.BAT));
|
||||||
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(raceMatches(Race::canCast));
|
Predicate<Entity> PLAYER_UNICORN = IS_PLAYER.and(raceMatches(Race::canCast));
|
||||||
Predicate<Entity> PLAYER_CHANGELING = IS_PLAYER.and(ofRace(Race.CHANGELING));
|
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;
|
Predicate<LivingEntity> HAS_WANT_IT_NEED_IT = e -> EnchantmentHelper.getEquipmentLevel(UEnchantments.WANT_IT_NEED_IT, e) > 0;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
|
import com.minelittlepony.unicopia.entity.player.dummy.DummyPlayerEntity;
|
||||||
import com.minelittlepony.unicopia.entity.player.dummy.DummyServerPlayerEntity;
|
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.
|
* Returns an implementation of PlayerEntity appropriate to the side being called on.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NotNull
|
||||||
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
||||||
if (observer.world instanceof ServerWorld) {
|
if (observer.world instanceof ServerWorld) {
|
||||||
return new DummyServerPlayerEntity((ServerWorld)observer.world, profile);
|
return new DummyServerPlayerEntity((ServerWorld)observer.world, profile);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
|
||||||
|
@ -107,7 +107,7 @@ public enum Race implements Affine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPermitted(@Nullable PlayerEntity sender) {
|
public boolean isPermitted(@Nullable PlayerEntity sender) {
|
||||||
if (isOp() && (sender == null || !sender.abilities.creativeMode)) {
|
if (isOp() && (sender == null || !sender.getAbilities().creativeMode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia;
|
package com.minelittlepony.unicopia;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.world.PersistentState;
|
import net.minecraft.world.PersistentState;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
@ -9,8 +9,10 @@ public class WorldTribeManager extends PersistentState {
|
||||||
|
|
||||||
private Race defaultRace = Unicopia.getConfig().preferredRace.get();
|
private Race defaultRace = Unicopia.getConfig().preferredRace.get();
|
||||||
|
|
||||||
public WorldTribeManager(ServerWorld world) {
|
public WorldTribeManager() {}
|
||||||
super(nameFor(world.getDimension()));
|
|
||||||
|
public WorldTribeManager(NbtCompound nbt) {
|
||||||
|
defaultRace = Race.fromName(nbt.getString("defaultRace"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Race getDefaultRace() {
|
public Race getDefaultRace() {
|
||||||
|
@ -22,12 +24,7 @@ public class WorldTribeManager extends PersistentState {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromTag(CompoundTag tag) {
|
public NbtCompound writeNbt(NbtCompound tag) {
|
||||||
defaultRace = Race.fromName(tag.getString("defaultRace"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag toTag(CompoundTag tag) {
|
|
||||||
tag.putString("defaultRace", defaultRace.name());
|
tag.putString("defaultRace", defaultRace.name());
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +34,6 @@ public class WorldTribeManager extends PersistentState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WorldTribeManager forWorld(ServerWorld world) {
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
import com.minelittlepony.unicopia.ability.data.Hit;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
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.MsgPlayerAbility;
|
||||||
import com.minelittlepony.unicopia.network.Channel;
|
import com.minelittlepony.unicopia.network.Channel;
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
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.sound.SoundEvents;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
|
|
||||||
public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
if (compound.contains("stats")) {
|
if (compound.contains("stats")) {
|
||||||
stats.clear();
|
stats.clear();
|
||||||
CompoundTag li = compound.getCompound("stats");
|
NbtCompound li = compound.getCompound("stats");
|
||||||
li.getKeys().forEach(key -> {
|
li.getKeys().forEach(key -> {
|
||||||
getStat(AbilitySlot.valueOf(key)).fromNBT(li.getCompound(key));
|
getStat(AbilitySlot.valueOf(key)).fromNBT(li.getCompound(key));
|
||||||
});
|
});
|
||||||
|
@ -89,8 +89,8 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
CompoundTag li = new CompoundTag();
|
NbtCompound li = new NbtCompound();
|
||||||
stats.forEach((key, value) -> li.put(key.name(), value.toNBT()));
|
stats.forEach((key, value) -> li.put(key.name(), value.toNBT()));
|
||||||
compound.put("stats", li);
|
compound.put("stats", li);
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
compound.putInt("warmup", warmup);
|
compound.putInt("warmup", warmup);
|
||||||
compound.putInt("cooldown", cooldown);
|
compound.putInt("cooldown", cooldown);
|
||||||
compound.putInt("maxWarmup", maxWarmup);
|
compound.putInt("maxWarmup", maxWarmup);
|
||||||
|
@ -263,7 +263,7 @@ public class AbilityDispatcher implements Tickable, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
warmup = compound.getInt("warmup");
|
warmup = compound.getInt("warmup");
|
||||||
cooldown = compound.getInt("cooldown");
|
cooldown = compound.getInt("cooldown");
|
||||||
maxWarmup = compound.getInt("maxWarmup");
|
maxWarmup = compound.getInt("maxWarmup");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
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.data.Hit;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
import com.minelittlepony.unicopia.ability.data.Hit;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.ability;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.minelittlepony.unicopia.BlockDestructionManager;
|
import com.minelittlepony.unicopia.BlockDestructionManager;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.BlockDestructionManager;
|
import com.minelittlepony.unicopia.BlockDestructionManager;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
@ -58,7 +58,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Hit tryActivate(Pony player) {
|
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);
|
thrustDownwards(player);
|
||||||
return Hit.INSTANCE;
|
return Hit.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
import com.minelittlepony.unicopia.ability.data.Hit;
|
||||||
|
@ -73,7 +73,7 @@ public class PegasusCaptureStormAbility implements Ability<Hit> {
|
||||||
} else if (player.getOrigin().getY() < 120) {
|
} else if (player.getOrigin().getY() < 120) {
|
||||||
tell(player, "ability.unicopia.too_low");
|
tell(player, "ability.unicopia.too_low");
|
||||||
} else {
|
} else {
|
||||||
if (!player.getMaster().abilities.creativeMode) {
|
if (!player.getMaster().getAbilities().creativeMode) {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
import com.minelittlepony.unicopia.ability.data.Hit;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability;
|
package com.minelittlepony.unicopia.ability;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.Optional;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.Owned;
|
import com.minelittlepony.unicopia.Owned;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.SpellPredicate;
|
import com.minelittlepony.unicopia.ability.magic.spell.SpellPredicate;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability.magic;
|
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.GemstoneItem;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
|
@ -83,7 +83,7 @@ public interface Thrown extends Spell, ProjectileDelegate {
|
||||||
projectile.setThrowDamage(getThrowDamage(caster));
|
projectile.setThrowDamage(getThrowDamage(caster));
|
||||||
projectile.setSpell(this);
|
projectile.setSpell(this);
|
||||||
projectile.setHydrophobic();
|
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);
|
world.spawnEntity(projectile);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability.magic.spell;
|
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.UEntities;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Attached;
|
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.ParticleHandle;
|
||||||
import com.minelittlepony.unicopia.particle.UParticles;
|
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.Identifier;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
|
|
||||||
if (dimension != null) {
|
if (dimension != null) {
|
||||||
|
@ -84,7 +84,7 @@ public abstract class AbstractPlacedSpell extends AbstractSpell implements Attac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
if (compound.contains("dimension")) {
|
if (compound.contains("dimension")) {
|
||||||
dimension = new Identifier(compound.getString("dimension"));
|
dimension = new Identifier(compound.getString("dimension"));
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.minelittlepony.unicopia.Affinity;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Spell;
|
import com.minelittlepony.unicopia.ability.magic.Spell;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
|
||||||
public abstract class AbstractSpell implements Spell {
|
public abstract class AbstractSpell implements Spell {
|
||||||
|
|
||||||
|
@ -69,13 +69,13 @@ public abstract class AbstractSpell implements Spell {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
compound.putBoolean("dead", isDead);
|
compound.putBoolean("dead", isDead);
|
||||||
compound.putUuid("uuid", uuid);
|
compound.putUuid("uuid", uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
isDirty = false;
|
isDirty = false;
|
||||||
if (compound.contains("uuid")) {
|
if (compound.contains("uuid")) {
|
||||||
uuid = compound.getUuid("uuid");
|
uuid = compound.getUuid("uuid");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.ability.magic.spell;
|
package com.minelittlepony.unicopia.ability.magic.spell;
|
||||||
|
|
||||||
import java.util.List;
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Thrown;
|
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.Entity;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtHelper;
|
import net.minecraft.nbt.NbtHelper;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -88,7 +88,7 @@ public class AttractiveSpell extends ShieldSpell implements Thrown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
if (homingPos != null) {
|
if (homingPos != null) {
|
||||||
compound.put("homingPos", NbtHelper.fromBlockPos(homingPos));
|
compound.put("homingPos", NbtHelper.fromBlockPos(homingPos));
|
||||||
|
@ -96,7 +96,7 @@ public class AttractiveSpell extends ShieldSpell implements Thrown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
if (compound.contains("homingPos")) {
|
if (compound.contains("homingPos")) {
|
||||||
homingPos = NbtHelper.toBlockPos(compound.getCompound("homingPos"));
|
homingPos = NbtHelper.toBlockPos(compound.getCompound("homingPos"));
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.ability.magic.spell;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.FlightType;
|
import com.minelittlepony.unicopia.FlightType;
|
||||||
import com.minelittlepony.unicopia.Owned;
|
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.mob.MobEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
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 {
|
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
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
|
|
||||||
compound.putInt("suppressionCounter", suppressionCounter);
|
compound.putInt("suppressionCounter", suppressionCounter);
|
||||||
|
@ -186,7 +186,7 @@ public class DisguiseSpell extends AbstractSpell implements Attached, Suppressab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
|
|
||||||
suppressionCounter = compound.getInt("suppressionCounter");
|
suppressionCounter = compound.getInt("suppressionCounter");
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.block.PlantBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.TntEntity;
|
import net.minecraft.entity.TntEntity;
|
||||||
|
import net.minecraft.entity.Entity.RemovalReason;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
import net.minecraft.util.math.BlockPos;
|
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) {
|
protected boolean applyEntitySingle(LivingEntity owner, Entity e) {
|
||||||
if (e instanceof TntEntity) {
|
if (e instanceof TntEntity) {
|
||||||
e.remove();
|
e.remove(RemovalReason.DISCARDED);
|
||||||
e.getEntityWorld().setBlockState(e.getBlockPos(), Blocks.TNT.getDefaultState());
|
e.getEntityWorld().setBlockState(e.getBlockPos(), Blocks.TNT.getDefaultState());
|
||||||
} else if (e.isOnFire()) {
|
} else if (e.isOnFire()) {
|
||||||
e.extinguish();
|
e.extinguish();
|
||||||
|
|
|
@ -15,7 +15,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
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.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.GameRules;
|
import net.minecraft.world.GameRules;
|
||||||
|
@ -72,7 +72,7 @@ public class JoustingSpell extends AbstractSpell implements Attached {
|
||||||
((Pony)source).getMagicalReserves().getEnergy().multiply(0.2F);
|
((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) {
|
private boolean canBreak(BlockPos pos, LivingEntity entity) {
|
||||||
|
@ -85,13 +85,13 @@ public class JoustingSpell extends AbstractSpell implements Attached {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
compound.putInt("age", age);
|
compound.putInt("age", age);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
age = compound.getInt("age");
|
age = compound.getInt("age");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.mob.ZombieEntity;
|
import net.minecraft.entity.mob.ZombieEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.NbtList;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
@ -89,7 +89,7 @@ public class NecromancySpell extends AbstractPlacedSpell {
|
||||||
summonedEntities.forEach(ref -> {
|
summonedEntities.forEach(ref -> {
|
||||||
ref.ifPresent(caster.getWorld(), e -> {
|
ref.ifPresent(caster.getWorld(), e -> {
|
||||||
if (master != null) {
|
if (master != null) {
|
||||||
master.dealDamage(master, e);
|
master.applyDamageEffects(master, e);
|
||||||
}
|
}
|
||||||
if (caster.getWorld().random.nextInt(2000) != 0) {
|
if (caster.getWorld().random.nextInt(2000) != 0) {
|
||||||
e.setHealth(0);
|
e.setHealth(0);
|
||||||
|
@ -117,23 +117,23 @@ public class NecromancySpell extends AbstractPlacedSpell {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
if (summonedEntities.size() > 0) {
|
if (summonedEntities.size() > 0) {
|
||||||
ListTag list = new ListTag();
|
NbtList list = new NbtList();
|
||||||
summonedEntities.forEach(ref -> list.add(ref.toNBT()));
|
summonedEntities.forEach(ref -> list.add(ref.toNBT()));
|
||||||
compound.put("summonedEntities", list);
|
compound.put("summonedEntities", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
summonedEntities.clear();
|
summonedEntities.clear();
|
||||||
if (compound.contains("summonedEntities")) {
|
if (compound.contains("summonedEntities")) {
|
||||||
compound.getList("summonedEntities", 10).forEach(tag -> {
|
compound.getList("summonedEntities", 10).forEach(tag -> {
|
||||||
EntityReference<LivingEntity> ref = new EntityReference<>();
|
EntityReference<LivingEntity> ref = new EntityReference<>();
|
||||||
ref.fromNBT((CompoundTag)tag);
|
ref.fromNBT((NbtCompound)tag);
|
||||||
summonedEntities.add(ref);
|
summonedEntities.add(ref);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.ability.magic.spell;
|
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.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.block.state.StateMaps;
|
import com.minelittlepony.unicopia.block.state.StateMaps;
|
||||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.entity.EyeOfEnderEntity;
|
||||||
import net.minecraft.entity.FallingBlockEntity;
|
import net.minecraft.entity.FallingBlockEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.TntEntity;
|
import net.minecraft.entity.TntEntity;
|
||||||
|
import net.minecraft.entity.Entity.RemovalReason;
|
||||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
|
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 (!ProjectileUtil.isProjectileThrownBy(target, source.getMaster())) {
|
||||||
if (distance < 1) {
|
if (distance < 1) {
|
||||||
target.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 0.1F, 1);
|
target.playSound(SoundEvents.ENTITY_ZOMBIE_VILLAGER_CURE, 0.1F, 1);
|
||||||
target.remove();
|
target.remove(RemovalReason.DISCARDED);
|
||||||
} else {
|
} else {
|
||||||
ProjectileUtil.ricochet(target, pos, 0.9F);
|
ProjectileUtil.ricochet(target, pos, 0.9F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.predicate.entity.EntityPredicates;
|
import net.minecraft.predicate.entity.EntityPredicates;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -71,7 +71,7 @@ public class SiphoningSpell extends AbstractPlacedSpell {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Stream<LivingEntity> getTargets(Caster<?> source) {
|
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()
|
.stream()
|
||||||
.map(e -> (LivingEntity)e);
|
.map(e -> (LivingEntity)e);
|
||||||
}
|
}
|
||||||
|
@ -147,13 +147,13 @@ public class SiphoningSpell extends AbstractPlacedSpell {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
compound.putInt("upset", ticksUpset);
|
compound.putInt("upset", ticksUpset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
ticksUpset = compound.getInt("upset");
|
ticksUpset = compound.getInt("upset");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,14 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Affine;
|
import com.minelittlepony.unicopia.ability.magic.Affine;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Spell;
|
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.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -168,7 +168,7 @@ public final class SpellType<T extends Spell> implements Affine, SpellPredicate<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Spell fromNBT(@Nullable CompoundTag compound) {
|
public static Spell fromNBT(@Nullable NbtCompound compound) {
|
||||||
if (compound != null && compound.contains("effect_id")) {
|
if (compound != null && compound.contains("effect_id")) {
|
||||||
Spell effect = getKey(new Identifier(compound.getString("effect_id"))).create();
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CompoundTag toNBT(Spell effect) {
|
public static NbtCompound toNBT(Spell effect) {
|
||||||
CompoundTag compound = effect.toNBT();
|
NbtCompound compound = effect.toNBT();
|
||||||
|
|
||||||
compound.putString("effect_id", effect.getType().getId().toString());
|
compound.putString("effect_id", effect.getType().getId().toString());
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.block.state;
|
package com.minelittlepony.unicopia.block.state;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.enums.DoubleBlockHalf;
|
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
|
* @return The converted state if there is one, otherwise the original state is returned
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NotNull
|
||||||
BlockState getConverted(World world, @Nonnull BlockState state);
|
BlockState getConverted(World world, @NotNull BlockState state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert a block state at a position.
|
* Attempts to convert a block state at a position.
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
@ -31,8 +31,8 @@ class BlockStateMap implements BlockStateConverter {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@NotNull
|
||||||
public BlockState getConverted(World world, @Nonnull BlockState state) {
|
public BlockState getConverted(World world, @NotNull BlockState state) {
|
||||||
for (StateMapping i : mappings) {
|
for (StateMapping i : mappings) {
|
||||||
if (i.test(state)) {
|
if (i.test(state)) {
|
||||||
return i.apply(world, state);
|
return i.apply(world, state);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
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
|
* @return True if the state can be converted
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
boolean test(@Nonnull BlockState state);
|
boolean test(@NotNull BlockState state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the given state based on this mapping
|
* Converts the given state based on this mapping
|
||||||
|
@ -133,13 +133,13 @@ interface StateMapping extends Predicate<BlockState>, BiFunction<World, BlockSta
|
||||||
*
|
*
|
||||||
* @return The converted state
|
* @return The converted state
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NotNull
|
||||||
@Override
|
@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.
|
* Gets the inverse of this mapping if one exists. Otherwise returns itself.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@NotNull
|
||||||
StateMapping inverse();
|
StateMapping inverse();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.unicopia.client;
|
package com.minelittlepony.unicopia.client;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
@ -15,7 +15,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
public class ClientInteractionManager extends InteractionManager {
|
public class ClientInteractionManager extends InteractionManager {
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@NotNull
|
||||||
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
||||||
if (observer.world instanceof ClientWorld) {
|
if (observer.world instanceof ClientWorld) {
|
||||||
return new DummyClientPlayerEntity((ClientWorld)observer.world, profile);
|
return new DummyClientPlayerEntity((ClientWorld)observer.world, profile);
|
||||||
|
|
|
@ -15,7 +15,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.minecraft.client.MinecraftClient;
|
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.client.sound.PositionedSoundInstance;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.minelittlepony.unicopia.entity.Equine;
|
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.attribute.EntityAttributeModifier.Operation;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
@ -152,7 +152,7 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
return stack.getEnchantments()
|
return stack.getEnchantments()
|
||||||
.stream()
|
.stream()
|
||||||
.map(t -> (CompoundTag)t)
|
.map(t -> (NbtCompound)t)
|
||||||
.map(tag -> Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(tag.getString("id")))
|
.map(tag -> Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(tag.getString("id")))
|
||||||
.map(ench -> new Pair<>(tag.getInt("lvl"), ench)))
|
.map(ench -> new Pair<>(tag.getInt("lvl"), ench)))
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
|
|
|
@ -60,7 +60,7 @@ public interface URenderers {
|
||||||
AccessoryFeatureRenderer.register(AmuletFeatureRenderer::new);
|
AccessoryFeatureRenderer.register(AmuletFeatureRenderer::new);
|
||||||
AccessoryFeatureRenderer.register(WingsFeatureRenderer::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.FLOATING_ARTEFACT, FloatingArtefactEntityRenderer::new);
|
||||||
EntityRendererRegistry.INSTANCE.register(UEntities.CAST_SPELL, CastSpellEntityRenderer::new);
|
EntityRendererRegistry.INSTANCE.register(UEntities.CAST_SPELL, CastSpellEntityRenderer::new);
|
||||||
|
|
||||||
|
@ -84,10 +84,10 @@ public interface URenderers {
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.scale(0.5F, 0.5F, 0.5F);
|
matrices.scale(0.5F, 0.5F, 0.5F);
|
||||||
matrices.translate(0.0125, 0.1, 0);
|
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();
|
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();
|
immediate.draw();
|
||||||
|
|
||||||
if (mode == ModelTransformation.Mode.GUI) {
|
if (mode == ModelTransformation.Mode.GUI) {
|
||||||
|
@ -96,7 +96,7 @@ public interface URenderers {
|
||||||
matrices.push();
|
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;
|
return GemstoneItem.isEnchanted(stack) ? 1 + GemstoneItem.getSpellKey(stack).getAffinity().ordinal() : 0;
|
||||||
});
|
});
|
||||||
ColorProviderRegistry.ITEM.register((stack, i) -> {
|
ColorProviderRegistry.ITEM.register((stack, i) -> {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class UnicopiaClient implements ClientModInitializer {
|
||||||
|
|
||||||
private void onScreenInit(Screen screen, ButtonList buttons) {
|
private void onScreenInit(Screen screen, ButtonList buttons) {
|
||||||
if (screen instanceof CreateWorldScreen) {
|
if (screen instanceof CreateWorldScreen) {
|
||||||
buttons.add(SettingsScreen.createRaceSelector(screen));
|
buttons.addButton(SettingsScreen.createRaceSelector(screen));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.BufferRenderer;
|
import net.minecraft.client.render.BufferRenderer;
|
||||||
import net.minecraft.client.render.Tessellator;
|
import net.minecraft.client.render.Tessellator;
|
||||||
|
import net.minecraft.client.render.VertexFormat;
|
||||||
import net.minecraft.client.render.VertexFormats;
|
import net.minecraft.client.render.VertexFormats;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -110,7 +111,7 @@ class ManaRingSlot extends Slot {
|
||||||
RenderSystem.disableTexture();
|
RenderSystem.disableTexture();
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
||||||
|
|
||||||
bufferBuilder.begin(7, VertexFormats.POSITION_COLOR);
|
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
|
||||||
|
|
||||||
Matrix4f model = matrices.peek().getModel();
|
Matrix4f model = matrices.peek().getModel();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.client.gui;
|
||||||
|
|
||||||
import java.util.Set;
|
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.GameGui;
|
||||||
import com.minelittlepony.common.client.gui.ScrollContainer;
|
import com.minelittlepony.common.client.gui.ScrollContainer;
|
||||||
|
@ -54,9 +54,9 @@ public class SettingsScreen extends GameGui {
|
||||||
super(new TranslatableText("unicopia.options.title"), parent);
|
super(new TranslatableText("unicopia.options.title"), parent);
|
||||||
|
|
||||||
content.margin.setVertical(30);
|
content.margin.setVertical(30);
|
||||||
content.padding.setHorizontal(10);
|
content.getContentPadding().setHorizontal(10);
|
||||||
content.padding.top = 10;
|
content.getContentPadding().top = 10;
|
||||||
content.padding.bottom = 20;
|
content.getContentPadding().bottom = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,7 +89,7 @@ public class SettingsScreen extends GameGui {
|
||||||
RIGHT = LEFT;
|
RIGHT = LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
children().add(content);
|
getChildElements().add(content);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public class SettingsScreen extends GameGui {
|
||||||
|
|
||||||
content.addButton(new EnumSlider<>(LEFT, row += 25, config.preferredRace.get()))
|
content.addButton(new EnumSlider<>(LEFT, row += 25, config.preferredRace.get()))
|
||||||
.onChange(config.preferredRace::set)
|
.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) {
|
if (server != null) {
|
||||||
row += 20;
|
row += 20;
|
||||||
|
@ -125,7 +125,7 @@ public class SettingsScreen extends GameGui {
|
||||||
|
|
||||||
content.addButton(new EnumSlider<>(LEFT, row += 20, tribes.getDefaultRace()))
|
content.addButton(new EnumSlider<>(LEFT, row += 20, tribes.getDefaultRace()))
|
||||||
.onChange(tribes::setDefaultRace)
|
.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());
|
.setEnabled(client.isInSingleplayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,6 @@ class Slot {
|
||||||
|
|
||||||
// progress
|
// progress
|
||||||
UHud.fill(matrices, slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF);
|
UHud.fill(matrices, slotPadding, progressTop, size - slotPadding, progressBottom, 0xCFFFFFFF);
|
||||||
RenderSystem.enableAlphaTest();
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.client.gui;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
import com.minelittlepony.unicopia.ability.AbilityDispatcher;
|
||||||
|
@ -25,6 +25,7 @@ import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Arm;
|
import net.minecraft.util.Arm;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
|
import net.minecraft.util.math.Quaternion;
|
||||||
|
|
||||||
public class UHud extends DrawableHelper {
|
public class UHud extends DrawableHelper {
|
||||||
|
|
||||||
|
@ -73,10 +74,9 @@ public class UHud extends DrawableHelper {
|
||||||
renderMessage(matrices, tickDelta);
|
renderMessage(matrices, tickDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.enableAlphaTest();
|
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
|
|
||||||
client.getTextureManager().bindTexture(HUD_TEXTURE);
|
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
|
||||||
|
|
||||||
boolean swap = client.options.keySneak.isPressed();
|
boolean swap = client.options.keySneak.isPressed();
|
||||||
|
|
||||||
|
@ -84,7 +84,6 @@ public class UHud extends DrawableHelper {
|
||||||
slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta));
|
slots.forEach(slot -> slot.renderLabel(matrices, abilities, tickDelta));
|
||||||
|
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
RenderSystem.disableAlphaTest();
|
|
||||||
|
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
|
|
||||||
|
@ -100,13 +99,17 @@ public class UHud extends DrawableHelper {
|
||||||
int x = scaledWidth / 2 + 67;
|
int x = scaledWidth / 2 + 67;
|
||||||
int y = scaledHeight - 25;
|
int y = scaledHeight - 25;
|
||||||
|
|
||||||
RenderSystem.pushMatrix();
|
MatrixStack view = RenderSystem.getModelViewStack();
|
||||||
RenderSystem.translatef(x, y, 0);
|
|
||||||
RenderSystem.rotatef(45, -0.2F, 1, 0);
|
view.push();
|
||||||
|
view.translate(x, y, 0);
|
||||||
|
view.multiply(new Quaternion(-9, 45, 0, true));
|
||||||
InventoryScreen.drawEntity(0, 0, scale, 0, -20, client.player);
|
InventoryScreen.drawEntity(0, 0, scale, 0, -20, client.player);
|
||||||
RenderSystem.popMatrix();
|
view.pop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderMessage(MatrixStack matrices, float tickDelta) {
|
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) {
|
void renderAbilityIcon(MatrixStack matrices, AbilityDispatcher.Stat stat, int x, int y, int u, int v, int frameWidth, int frameHeight) {
|
||||||
stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> {
|
stat.getAbility(KeyBindingsHandler.INSTANCE.page).ifPresent(ability -> {
|
||||||
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);
|
drawTexture(matrices, x, y, 0, 0, frameWidth, frameHeight, u, v);
|
||||||
client.getTextureManager().bindTexture(HUD_TEXTURE);
|
RenderSystem.setShaderTexture(0, HUD_TEXTURE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.minelittlepony.unicopia.client.minelittlepony;
|
package com.minelittlepony.unicopia.client.minelittlepony;
|
||||||
|
|
||||||
import com.minelittlepony.client.render.EquineRenderManager;
|
import com.minelittlepony.api.model.IModel;
|
||||||
import com.minelittlepony.model.IModel;
|
import com.minelittlepony.api.model.ModelAttributes;
|
||||||
import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback;
|
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class Main implements ClientModInitializer {
|
||||||
PonyModelPrepareCallback.EVENT.register(this::onPonyModelPrepared);
|
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;
|
if (hookErroring) return;
|
||||||
try {
|
try {
|
||||||
if (entity instanceof PlayerEntity) {
|
if (entity instanceof PlayerEntity) {
|
||||||
|
|
|
@ -10,8 +10,9 @@ import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
import net.minecraft.client.render.Tessellator;
|
import net.minecraft.client.render.Tessellator;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
import net.minecraft.client.render.VertexFormat;
|
||||||
import net.minecraft.client.render.VertexFormats;
|
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.client.world.ClientWorld;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
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.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA,
|
||||||
GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA
|
GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA
|
||||||
);
|
);
|
||||||
RenderSystem.alphaFunc(516, 0.003921569F);
|
|
||||||
|
|
||||||
|
|
||||||
Vec3d cam = camera.getPos();
|
Vec3d cam = camera.getPos();
|
||||||
|
|
||||||
|
@ -55,7 +54,6 @@ public abstract class AbstractBillboardParticle extends Particle {
|
||||||
renderQuads(te, buffer, renderX, renderY, renderZ, tickDelta);
|
renderQuads(te, buffer, renderX, renderY, renderZ, tickDelta);
|
||||||
|
|
||||||
RenderSystem.enableCull();
|
RenderSystem.enableCull();
|
||||||
RenderSystem.defaultAlphaFunc();
|
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +63,10 @@ public abstract class AbstractBillboardParticle extends Particle {
|
||||||
MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
|
MinecraftClient.getInstance().getTextureManager().bindTexture(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderQuad(Tessellator te, BufferBuilder buffer, Vector3f[] corners, float alpha, float tickDelta) {
|
protected void renderQuad(Tessellator te, BufferBuilder buffer, Vec3f[] corners, float alpha, float tickDelta) {
|
||||||
int light = getColorMultiplier(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[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[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();
|
buffer.vertex(corners[2].getX(), corners[2].getY(), corners[2].getZ()).texture(1, 1).color(colorRed, colorGreen, colorBlue, alpha).light(light).next();
|
||||||
|
|
|
@ -64,8 +64,8 @@ public class MagicParticle extends SpriteBillboardParticle {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColorMultiplier(float tint) {
|
public int getBrightness(float tint) {
|
||||||
int light = super.getColorMultiplier(tint);
|
int light = super.getBrightness(tint);
|
||||||
float timer = (float)age / (float)maxAge;
|
float timer = (float)age / (float)maxAge;
|
||||||
|
|
||||||
int v = light >> 16 & 255;
|
int v = light >> 16 & 255;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
import net.minecraft.client.render.Tessellator;
|
import net.minecraft.client.render.Tessellator;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
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.client.world.ClientWorld;
|
||||||
import net.minecraft.util.math.Quaternion;
|
import net.minecraft.util.math.Quaternion;
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl
|
||||||
|
|
||||||
fixed = effect.isAngleFixed();
|
fixed = effect.isAngleFixed();
|
||||||
if (fixed) {
|
if (fixed) {
|
||||||
rotation.hamiltonProduct(Vector3f.POSITIVE_X.getDegreesQuaternion(180 - effect.getYaw()));
|
rotation.hamiltonProduct(Vec3f.POSITIVE_X.getDegreesQuaternion(180 - effect.getYaw()));
|
||||||
rotation.hamiltonProduct(Vector3f.POSITIVE_Y.getDegreesQuaternion(effect.getPitch()));
|
rotation.hamiltonProduct(Vec3f.POSITIVE_Y.getDegreesQuaternion(effect.getPitch()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,16 +35,16 @@ public abstract class OrientedBillboardParticle extends AbstractBillboardParticl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
|
protected void renderQuads(Tessellator te, BufferBuilder buffer, float x, float y, float z, float tickDelta) {
|
||||||
Vector3f[] corners = new Vector3f[]{
|
Vec3f[] corners = new Vec3f[]{
|
||||||
new Vector3f(-1, -1, 0),
|
new Vec3f(-1, -1, 0),
|
||||||
new Vector3f(-1, 1, 0),
|
new Vec3f(-1, 1, 0),
|
||||||
new Vector3f( 1, 1, 0),
|
new Vec3f( 1, 1, 0),
|
||||||
new Vector3f( 1, -1, 0)
|
new Vec3f( 1, -1, 0)
|
||||||
};
|
};
|
||||||
float scale = getScale(tickDelta);
|
float scale = getScale(tickDelta);
|
||||||
|
|
||||||
for(int k = 0; k < 4; ++k) {
|
for(int k = 0; k < 4; ++k) {
|
||||||
Vector3f corner = corners[k];
|
Vec3f corner = corners[k];
|
||||||
corner.rotate(rotation);
|
corner.rotate(rotation);
|
||||||
corner.scale(scale);
|
corner.scale(scale);
|
||||||
corner.add(x, y, z);
|
corner.add(x, y, z);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.minelittlepony.unicopia.particle.ParticleHandle.Link;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.Tessellator;
|
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.client.world.ClientWorld;
|
||||||
import net.minecraft.particle.DefaultParticleType;
|
import net.minecraft.particle.DefaultParticleType;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -60,11 +60,11 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
float alpha = 1 - (float)age / maxAge;
|
float alpha = 1 - (float)age / maxAge;
|
||||||
|
|
||||||
for (int i = 0; i < segments.size() - 1; i++) {
|
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);
|
float scale = getScale(tickDelta);
|
||||||
|
|
||||||
for (int k = 0; k < 4; ++k) {
|
for (int k = 0; k < 4; ++k) {
|
||||||
Vector3f corner = corners[k];
|
Vec3f corner = corners[k];
|
||||||
corner.scale(scale);
|
corner.scale(scale);
|
||||||
corner.add(x, y, z);
|
corner.add(x, y, z);
|
||||||
}
|
}
|
||||||
|
@ -107,14 +107,14 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
|
|
||||||
private final class Segment {
|
private final class Segment {
|
||||||
Vec3d position;
|
Vec3d position;
|
||||||
Vector3f offset;
|
Vec3f offset;
|
||||||
|
|
||||||
int age;
|
int age;
|
||||||
int maxAge;
|
int maxAge;
|
||||||
|
|
||||||
Segment(Vec3d position) {
|
Segment(Vec3d position) {
|
||||||
this.position = 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;
|
this.maxAge = 90;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public class RainbowTrailParticle extends AbstractBillboardParticle implements A
|
||||||
return segments.indexOf(this) < segments.size() - 1 && age++ >= maxAge;
|
return segments.indexOf(this) < segments.size() - 1 && age++ >= maxAge;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3f[] getPlane(Segment to) {
|
Vec3f[] getPlane(Segment to) {
|
||||||
float fromX = offset.getX();
|
float fromX = offset.getX();
|
||||||
float toX = to.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 toTopY = to.offset.getY() + 1;
|
||||||
float toBottomY = to.offset.getY();
|
float toBottomY = to.offset.getY();
|
||||||
|
|
||||||
return new Vector3f[]{
|
return new Vec3f[]{
|
||||||
new Vector3f(fromX, fromBottomY, fromZ), // bottom left
|
new Vec3f(fromX, fromBottomY, fromZ), // bottom left
|
||||||
new Vector3f(fromX, fromTopY, fromZ), // top left
|
new Vec3f(fromX, fromTopY, fromZ), // top left
|
||||||
new Vector3f(toX, toTopY, toZ), // top right
|
new Vec3f(toX, toTopY, toZ), // top right
|
||||||
new Vector3f(toX, toBottomY, toZ) // bottom right
|
new Vec3f(toX, toBottomY, toZ) // bottom right
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.Tessellator;
|
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.client.world.ClientWorld;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -91,7 +91,7 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getColorMultiplier(float tint) {
|
protected int getBrightness(float tint) {
|
||||||
return 0xF000F0;
|
return 0xF000F0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,22 +105,22 @@ public class RunesParticle extends OrientedBillboardParticle implements Attachme
|
||||||
for (int i = 0; i < TEXTURES.length; i++) {
|
for (int i = 0; i < TEXTURES.length; i++) {
|
||||||
bindTexture(TEXTURES[i]);
|
bindTexture(TEXTURES[i]);
|
||||||
|
|
||||||
RenderSystem.color3f(colorRed, colorGreen, colorBlue);
|
RenderSystem.setShaderColor(colorRed, colorGreen, colorBlue, alpha);
|
||||||
|
|
||||||
Vector3f[] corners = new Vector3f[]{
|
Vec3f[] corners = new Vec3f[]{
|
||||||
new Vector3f(-1, -1, 0),
|
new Vec3f(-1, -1, 0),
|
||||||
new Vector3f(-1, 1, 0),
|
new Vec3f(-1, 1, 0),
|
||||||
new Vector3f( 1, 1, 0),
|
new Vec3f( 1, 1, 0),
|
||||||
new Vector3f( 1, -1, 0)
|
new Vec3f( 1, -1, 0)
|
||||||
};
|
};
|
||||||
float scale = getScale(tickDelta);
|
float scale = getScale(tickDelta);
|
||||||
|
|
||||||
float ringSpeed = (i % 2 == 0 ? i : -1) * i;
|
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) {
|
for(int k = 0; k < 4; ++k) {
|
||||||
Vector3f corner = corners[k];
|
Vec3f corner = corners[k];
|
||||||
corner.rotate(ringAngle);
|
corner.rotate(ringAngle);
|
||||||
corner.rotate(rotation);
|
corner.rotate(rotation);
|
||||||
corner.scale(scale);
|
corner.scale(scale);
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.client.particle;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.util.math.Vec3f;
|
||||||
import net.minecraft.client.util.math.Vector4f;
|
import net.minecraft.util.math.Vector4f;
|
||||||
import net.minecraft.util.math.Quaternion;
|
import net.minecraft.util.math.Quaternion;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ public class SphereModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(float x, float y, float z) {
|
public void setRotation(float x, float y, float z) {
|
||||||
rotX = Vector3f.POSITIVE_X.getDegreesQuaternion(x);
|
rotX = Vec3f.POSITIVE_X.getDegreesQuaternion(x);
|
||||||
rotY = Vector3f.POSITIVE_Y.getDegreesQuaternion(y);
|
rotY = Vec3f.POSITIVE_Y.getDegreesQuaternion(y);
|
||||||
rotZ = Vector3f.POSITIVE_Z.getDegreesQuaternion(z);
|
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) {
|
public void render(MatrixStack matrices, float scale, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
|
||||||
|
|
|
@ -4,8 +4,15 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.item.AmuletItem;
|
import com.minelittlepony.unicopia.item.AmuletItem;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.Dilation;
|
||||||
import net.minecraft.client.model.Model;
|
import net.minecraft.client.model.Model;
|
||||||
|
import net.minecraft.client.model.ModelData;
|
||||||
import net.minecraft.client.model.ModelPart;
|
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.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
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> {
|
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<>();
|
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) {
|
public AmuletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.model = new AmuletModel(AmuletModel.getData(new Dilation(0.3F)).createModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,22 +57,29 @@ public class AmuletFeatureRenderer<E extends LivingEntity> implements AccessoryF
|
||||||
|
|
||||||
static class AmuletModel extends Model {
|
static class AmuletModel extends Model {
|
||||||
|
|
||||||
private final ModelPart torso;
|
private final ModelPart amulet;
|
||||||
|
|
||||||
public AmuletModel(float dilate) {
|
public AmuletModel(ModelPart tree) {
|
||||||
super(RenderLayer::getEntityTranslucent);
|
super(RenderLayer::getEntityTranslucent);
|
||||||
torso = new ModelPart(this, 0, 0);
|
amulet = tree.getChild("amulet");
|
||||||
torso.addCuboid(-4, 0, -2, 8, 12, 4, dilate);
|
}
|
||||||
torso.setPivot(0, 0, 0);
|
|
||||||
|
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) {
|
public void setAngles(LivingEntity entity, BipedEntityModel<?> biped) {
|
||||||
torso.copyPositionAndRotation(biped.torso);
|
amulet.copyTransform(biped.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int i, int j, float f, float g, float h, float k) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,14 @@ import com.minelittlepony.common.util.Color;
|
||||||
import com.minelittlepony.unicopia.item.FriendshipBraceletItem;
|
import com.minelittlepony.unicopia.item.FriendshipBraceletItem;
|
||||||
import com.minelittlepony.unicopia.item.GlowableItem;
|
import com.minelittlepony.unicopia.item.GlowableItem;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.Dilation;
|
||||||
import net.minecraft.client.model.Model;
|
import net.minecraft.client.model.Model;
|
||||||
|
import net.minecraft.client.model.ModelData;
|
||||||
import net.minecraft.client.model.ModelPart;
|
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.network.ClientPlayerEntity;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
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.VertexConsumerProvider;
|
||||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
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.render.item.ItemRenderer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
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 static final Identifier TEXTURE = new Identifier("unicopia", "textures/models/armor/bracelet.png");
|
||||||
|
|
||||||
private final BraceletModel steveModel = new BraceletModel(0.3F, false);
|
private final BraceletModel steveModel;
|
||||||
private final BraceletModel alexModel = new BraceletModel(0.3F, true);
|
private final BraceletModel alexModel;
|
||||||
|
|
||||||
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
|
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
|
||||||
|
|
||||||
public BraceletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
public BraceletFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
||||||
this.context = 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
|
@Override
|
||||||
|
@ -74,19 +84,26 @@ public class BraceletFeatureRenderer<E extends LivingEntity> implements Accessor
|
||||||
|
|
||||||
private final boolean alex;
|
private final boolean alex;
|
||||||
|
|
||||||
public BraceletModel(float dilate, boolean alex) {
|
public BraceletModel(ModelPart tree, boolean alex) {
|
||||||
super(RenderLayer::getEntityTranslucent);
|
super(RenderLayer::getEntityTranslucent);
|
||||||
this.alex = alex;
|
this.alex = alex;
|
||||||
rightArm = new ModelPart(this, 0, alex ? 6 : 0);
|
this.leftArm = tree.getChild(EntityModelPartNames.LEFT_ARM);
|
||||||
rightArm.addCuboid(-3, 7, -2, alex ? 3 : 4, 2, 4, dilate);
|
this.rightArm = tree.getChild(EntityModelPartNames.RIGHT_ARM);
|
||||||
leftArm = new ModelPart(this, 0, alex ? 6 : 0);
|
}
|
||||||
leftArm.mirror = true;
|
|
||||||
leftArm.addCuboid(-1, 7, -2, alex ? 3 : 4, 2, 4, dilate);
|
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) {
|
public void setAngles(BipedEntityModel<?> biped) {
|
||||||
leftArm.copyPositionAndRotation(biped.leftArm);
|
leftArm.copyTransform(biped.leftArm);
|
||||||
rightArm.copyPositionAndRotation(biped.rightArm);
|
rightArm.copyTransform(biped.rightArm);
|
||||||
if (alex) {
|
if (alex) {
|
||||||
rightArm.pivotX++;
|
rightArm.pivotX++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,15 @@ package com.minelittlepony.unicopia.client.render;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.CastSpellEntity;
|
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.EntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public class CastSpellEntityRenderer extends EntityRenderer<CastSpellEntity> {
|
public class CastSpellEntityRenderer extends EntityRenderer<CastSpellEntity> {
|
||||||
|
|
||||||
public CastSpellEntityRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
|
public CastSpellEntityRenderer(EntityRendererFactory.Context ctx) {
|
||||||
super(dispatcher);
|
super(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,27 +3,26 @@ package com.minelittlepony.unicopia.client.render;
|
||||||
import com.minelittlepony.unicopia.entity.FloatingArtefactEntity;
|
import com.minelittlepony.unicopia.entity.FloatingArtefactEntity;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
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.OverlayTexture;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
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.EntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
import net.minecraft.client.render.item.ItemRenderer;
|
import net.minecraft.client.render.item.ItemRenderer;
|
||||||
import net.minecraft.client.render.model.BakedModel;
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.Vec3f;
|
||||||
|
|
||||||
public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtefactEntity> {
|
public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtefactEntity> {
|
||||||
|
|
||||||
private final ItemRenderer itemRenderer;
|
private final ItemRenderer itemRenderer;
|
||||||
|
|
||||||
public FloatingArtefactEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
public FloatingArtefactEntityRenderer(EntityRendererFactory.Context ctx) {
|
||||||
super(manager);
|
super(ctx);
|
||||||
itemRenderer = context.getItemRenderer();
|
itemRenderer = ctx.getItemRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +34,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtef
|
||||||
stack = UItems.EMPTY_JAR.getDefaultStack();
|
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 variance = 0.25F;
|
||||||
final float verticalOffset = entity.getVerticalOffset(timeDelta);
|
final float verticalOffset = entity.getVerticalOffset(timeDelta);
|
||||||
|
@ -46,7 +45,7 @@ public class FloatingArtefactEntityRenderer extends EntityRenderer<FloatingArtef
|
||||||
transforms.push();
|
transforms.push();
|
||||||
transforms.scale(scale, scale, scale);
|
transforms.scale(scale, scale, scale);
|
||||||
transforms.translate(0, verticalOffset + variance * modelScaleY, 0);
|
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);
|
itemRenderer.renderItem(stack, ModelTransformation.Mode.GROUND, false, transforms, renderContext, lightUv, OverlayTexture.DEFAULT_UV, model);
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,12 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.RenderPhase;
|
import net.minecraft.client.render.RenderPhase;
|
||||||
import net.minecraft.client.render.VertexFormat;
|
import net.minecraft.client.render.VertexFormat;
|
||||||
|
import net.minecraft.client.render.VertexFormat.DrawMode;
|
||||||
import net.minecraft.client.render.VertexFormats;
|
import net.minecraft.client.render.VertexFormats;
|
||||||
|
|
||||||
public final class RenderLayers extends RenderLayer {
|
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) {
|
boolean hasCrumbling, boolean translucent, Runnable startAction, Runnable endAction) {
|
||||||
super(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, startAction, 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) {
|
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))
|
.texture(new Color(red, green, blue, alpha))
|
||||||
|
.shader(EYES_SHADER)
|
||||||
.writeMaskState(COLOR_MASK)
|
.writeMaskState(COLOR_MASK)
|
||||||
.alpha(ONE_TENTH_ALPHA)
|
.depthTest(LEQUAL_DEPTH_TEST)
|
||||||
.transparency(GLOWING_TRANSPARENCY)
|
.transparency(GLOWING_TRANSPARENCY)
|
||||||
.shadeModel(SMOOTH_SHADE_MODEL)
|
|
||||||
.lightmap(DISABLE_LIGHTMAP)
|
.lightmap(DISABLE_LIGHTMAP)
|
||||||
.overlay(DISABLE_OVERLAY_COLOR)
|
.overlay(DISABLE_OVERLAY_COLOR)
|
||||||
.cull(DISABLE_CULLING)
|
.cull(DISABLE_CULLING)
|
||||||
.build(true));
|
.build(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Color extends Texture {
|
private static class Color extends TextureBase {
|
||||||
|
|
||||||
private final float red;
|
private final float red;
|
||||||
private final float green;
|
private final float green;
|
||||||
private final float blue;
|
private final float blue;
|
||||||
private final float alpha;
|
private final float alpha;
|
||||||
|
|
||||||
public Color(float red, float green, float blue, 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.red = red;
|
||||||
this.green = green;
|
this.green = green;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.alpha = alpha;
|
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
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return super.equals(other)
|
return super.equals(other)
|
||||||
|
|
|
@ -3,8 +3,14 @@ package com.minelittlepony.unicopia.client.render;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.Dilation;
|
||||||
import net.minecraft.client.model.Model;
|
import net.minecraft.client.model.Model;
|
||||||
|
import net.minecraft.client.model.ModelData;
|
||||||
import net.minecraft.client.model.ModelPart;
|
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.OverlayTexture;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
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 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 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;
|
private final FeatureRendererContext<E, ? extends BipedEntityModel<E>> context;
|
||||||
|
|
||||||
public WingsFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
public WingsFeatureRenderer(FeatureRendererContext<E, ? extends BipedEntityModel<E>> context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.model = new WingsModel(WingsModel.getData(Dilation.NONE).createModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,19 +58,24 @@ public class WingsFeatureRenderer<E extends LivingEntity> implements AccessoryFe
|
||||||
private final ModelPart root;
|
private final ModelPart root;
|
||||||
private final Wing[] wings;
|
private final Wing[] wings;
|
||||||
|
|
||||||
public WingsModel() {
|
public WingsModel(ModelPart tree) {
|
||||||
super(RenderLayer::getEntityTranslucent);
|
super(RenderLayer::getEntityTranslucent);
|
||||||
this.textureHeight = 23;
|
root = tree;
|
||||||
this.textureWidth = 24;
|
|
||||||
root = new ModelPart(this, 0, 0);
|
|
||||||
wings = new Wing[] {
|
wings = new Wing[] {
|
||||||
new Wing(this, root, -1),
|
new Wing(tree.getChild("left_wing"), -1),
|
||||||
new Wing(this, root, 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) {
|
public void setAngles(LivingEntity entity, BipedEntityModel<?> biped) {
|
||||||
root.copyPositionAndRotation(biped.torso);
|
root.copyTransform(biped.body);
|
||||||
for (Wing wing : wings) {
|
for (Wing wing : wings) {
|
||||||
wing.setAngles(entity);
|
wing.setAngles(entity);
|
||||||
}
|
}
|
||||||
|
@ -75,36 +87,36 @@ public class WingsFeatureRenderer<E extends LivingEntity> implements AccessoryFe
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Wing {
|
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;
|
this.k = k;
|
||||||
base = new ModelPart(model, 0, 0);
|
base = tree;
|
||||||
|
|
||||||
base.setPivot(k * 2, 2, 2 + k * 0.5F);
|
|
||||||
base.addCuboid(0, 0, 0, 2, 10, 2);
|
|
||||||
|
|
||||||
feathers = new ModelPart[8];
|
|
||||||
|
|
||||||
for (int i = 0; i < feathers.length; i++) {
|
for (int i = 0; i < feathers.length; i++) {
|
||||||
int texX = (i % 2) * 8;
|
feathers[i] = base.getChild("feather_" + i);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
void setAngles(LivingEntity entity) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.client.render;
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
|
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.Living;
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
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.model.Model;
|
||||||
import net.minecraft.client.render.OverlayTexture;
|
import net.minecraft.client.render.OverlayTexture;
|
||||||
import net.minecraft.client.render.VertexConsumerProvider;
|
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.block.entity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.render.entity.EntityRenderer;
|
import net.minecraft.client.render.entity.EntityRenderer;
|
||||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||||
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
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.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
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;
|
roll = pony instanceof Pony ? ((Pony)pony).getInterpolator().interpolate("g_roll", roll, 15) : roll;
|
||||||
|
|
||||||
matrices.translate(x, y + owner.getHeight() / 2, z);
|
matrices.translate(x, y + owner.getHeight() / 2, z);
|
||||||
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(roll));
|
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(roll));
|
||||||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(roll));
|
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(roll));
|
||||||
matrices.translate(-x, -y - owner.getHeight() / 2, -z);
|
matrices.translate(-x, -y - owner.getHeight() / 2, -z);
|
||||||
|
|
||||||
if (negative) {
|
if (negative) {
|
||||||
|
@ -132,9 +132,9 @@ public class WorldRenderDelegate {
|
||||||
BlockEntity blockEntity = ve.getBlockEntity();
|
BlockEntity blockEntity = ve.getBlockEntity();
|
||||||
|
|
||||||
if (blockEntity != null) {
|
if (blockEntity != null) {
|
||||||
BlockEntityRenderer<BlockEntity> r = BlockEntityRenderDispatcher.INSTANCE.get(blockEntity);
|
BlockEntityRenderer<BlockEntity> r = MinecraftClient.getInstance().getBlockEntityRenderDispatcher().get(blockEntity);
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
blockEntity.setPos(e.getBlockPos());
|
((MixinBlockEntity)blockEntity).setPos(e.getBlockPos());
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
BlockState state = blockEntity.getCachedState();
|
BlockState state = blockEntity.getCachedState();
|
||||||
|
@ -143,7 +143,7 @@ public class WorldRenderDelegate {
|
||||||
matrices.translate(x, y, z);
|
matrices.translate(x, y, z);
|
||||||
|
|
||||||
matrices.multiply(direction.getRotationQuaternion());
|
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);
|
matrices.translate(-0.5, 0, -0.5);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ public class WorldRenderDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
e.setFireTicks(fireTicks);
|
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);
|
e.setFireTicks(0);
|
||||||
|
|
||||||
if (model != null) {
|
if (model != null) {
|
||||||
|
@ -184,10 +184,10 @@ public class WorldRenderDelegate {
|
||||||
private void flipAngles(Entity entity) {
|
private void flipAngles(Entity entity) {
|
||||||
if (entity instanceof PlayerEntity) {
|
if (entity instanceof PlayerEntity) {
|
||||||
entity.prevYaw *= -1;
|
entity.prevYaw *= -1;
|
||||||
entity.yaw *= -1;
|
entity.setYaw(entity.getYaw() * -1);
|
||||||
|
|
||||||
entity.prevPitch *= -1;
|
entity.prevPitch *= -1;
|
||||||
entity.pitch *= -1;
|
entity.setPitch(entity.getPitch() * -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class MagicAuraSoundInstance extends MovingSoundInstance {
|
||||||
y = pos.y;
|
y = pos.y;
|
||||||
z = pos.z;
|
z = pos.z;
|
||||||
|
|
||||||
if (!living.getEntity().removed && data.isPresent()) {
|
if (!living.getEntity().isRemoved() && data.isPresent()) {
|
||||||
float level = data.get().level;
|
float level = data.get().level;
|
||||||
if (level != targetVolume) {
|
if (level != targetVolume) {
|
||||||
setTargetVolume(level);
|
setTargetVolume(level);
|
||||||
|
|
|
@ -11,12 +11,12 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
|
|
||||||
import net.minecraft.command.argument.EntitySummonArgumentType;
|
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.command.suggestion.SuggestionProviders;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
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.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
@ -38,18 +38,18 @@ public class DisguiseCommand {
|
||||||
.executes(context -> disguise(context.getSource(),
|
.executes(context -> disguise(context.getSource(),
|
||||||
context.getSource().getPlayer(),
|
context.getSource().getPlayer(),
|
||||||
EntitySummonArgumentType.getEntitySummon(context, "entity"),
|
EntitySummonArgumentType.getEntitySummon(context, "entity"),
|
||||||
new CompoundTag(), true))
|
new NbtCompound(), true))
|
||||||
.then(CommandManager.argument("nbt", NbtCompoundTagArgumentType.nbtCompound())
|
.then(CommandManager.argument("nbt", NbtCompoundArgumentType.nbtCompound())
|
||||||
.executes(context -> disguise(context.getSource(),
|
.executes(context -> disguise(context.getSource(),
|
||||||
context.getSource().getPlayer(),
|
context.getSource().getPlayer(),
|
||||||
EntitySummonArgumentType.getEntitySummon(context, "entity"),
|
EntitySummonArgumentType.getEntitySummon(context, "entity"),
|
||||||
NbtCompoundTagArgumentType.getCompoundTag(context, "nbt"), false))
|
NbtCompoundArgumentType.getNbtCompound(context, "nbt"), false))
|
||||||
));
|
));
|
||||||
|
|
||||||
dispatcher.register(builder);
|
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 = nbt.copy();
|
||||||
nbt.putString("id", id.toString());
|
nbt.putString("id", id.toString());
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.data.DataTracker;
|
import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
|
@ -66,7 +66,7 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (removed) {
|
if (isRemoved()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +83,11 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
}
|
}
|
||||||
LivingEntity master = getMaster();
|
LivingEntity master = getMaster();
|
||||||
|
|
||||||
if (master == null || master.removed) {
|
if (master == null || master.isRemoved()) {
|
||||||
if (orphanedTicks-- > 0) {
|
if (orphanedTicks-- > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remove();
|
remove(RemovalReason.DISCARDED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,13 +104,13 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}).isPresent()) {
|
}).isPresent()) {
|
||||||
remove();
|
remove(RemovalReason.DISCARDED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove(RemovalReason reason) {
|
||||||
super.remove();
|
super.remove(reason);
|
||||||
if (world.isClient) {
|
if (world.isClient) {
|
||||||
world.getLightingProvider().checkBlock(getBlockPos());
|
world.getLightingProvider().checkBlock(getBlockPos());
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeCustomDataToTag(CompoundTag tag) {
|
protected void writeCustomDataToNbt(NbtCompound tag) {
|
||||||
tag.put("owner", owner.toNBT());
|
tag.put("owner", owner.toNBT());
|
||||||
dataTracker.get(SPELL).ifPresent(spellId -> {
|
dataTracker.get(SPELL).ifPresent(spellId -> {
|
||||||
tag.putUuid("spellId", spellId);
|
tag.putUuid("spellId", spellId);
|
||||||
|
@ -171,7 +171,7 @@ public class CastSpellEntity extends Entity implements Caster<LivingEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readCustomDataFromTag(CompoundTag tag) {
|
protected void readCustomDataFromNbt(NbtCompound tag) {
|
||||||
if (tag.contains("owner")) {
|
if (tag.contains("owner")) {
|
||||||
owner.fromNBT(tag.getCompound("owner"));
|
owner.fromNBT(tag.getCompound("owner"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,11 @@ import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
import net.minecraft.entity.mob.MobEntity;
|
import net.minecraft.entity.mob.MobEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
|
||||||
public class Creature extends Living<LivingEntity> {
|
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);
|
public static final TrackedData<Float> GRAVITY = DataTracker.registerData(LivingEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||||
|
|
||||||
private static final LevelStore LEVELS = Levelled.fixed(0);
|
private static final LevelStore LEVELS = Levelled.fixed(0);
|
||||||
|
@ -94,7 +94,7 @@ public class Creature extends Living<LivingEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
getSpellSlot().get(true).ifPresent(effect -> {
|
getSpellSlot().get(true).ifPresent(effect -> {
|
||||||
compound.put("effect", SpellType.toNBT(effect));
|
compound.put("effect", SpellType.toNBT(effect));
|
||||||
|
@ -103,7 +103,7 @@ public class Creature extends Living<LivingEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
if (compound.contains("effect")) {
|
if (compound.contains("effect")) {
|
||||||
setSpell(SpellType.fromNBT(compound.getCompound("effect")));
|
setSpell(SpellType.fromNBT(compound.getCompound("effect")));
|
||||||
|
|
|
@ -7,19 +7,19 @@ import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Supplier;
|
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.SimpleEnchantment;
|
||||||
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.NbtList;
|
||||||
import net.minecraft.nbt.StringTag;
|
import net.minecraft.nbt.NbtString;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public class Enchantments implements NbtSerialisable, Tickable {
|
public class Enchantments implements NbtSerialisable, Tickable {
|
||||||
|
@ -74,19 +74,19 @@ public class Enchantments implements NbtSerialisable, Tickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
ListTag list = new ListTag();
|
NbtList list = new NbtList();
|
||||||
equippedEnchantments.forEach(enchant -> {
|
equippedEnchantments.forEach(enchant -> {
|
||||||
Identifier id = Registry.ENCHANTMENT.getId(enchant);
|
Identifier id = Registry.ENCHANTMENT.getId(enchant);
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
list.add(StringTag.of(id.toString()));
|
list.add(NbtString.of(id.toString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
compound.put("enchants", list);
|
compound.put("enchants", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
equippedEnchantments.clear();
|
equippedEnchantments.clear();
|
||||||
if (compound.contains("enchants")) {
|
if (compound.contains("enchants")) {
|
||||||
compound.getList("enchants", 8).forEach(tag -> {
|
compound.getList("enchants", 8).forEach(tag -> {
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.entity;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.player.PlayerAttributes;
|
import com.minelittlepony.unicopia.entity.player.PlayerAttributes;
|
||||||
import com.minelittlepony.unicopia.util.Copieable;
|
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.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.FenceGateBlock;
|
import net.minecraft.block.FenceGateBlock;
|
||||||
|
@ -12,11 +12,10 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.mob.MobEntity;
|
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.BlockStateParticleEffect;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
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()) {
|
if (entity.world.getBlockState(pos).isAir()) {
|
||||||
BlockPos below = pos.down();
|
BlockPos below = pos.down();
|
||||||
Block block = entity.world.getBlockState(below).getBlock();
|
BlockState block = entity.world.getBlockState(below);
|
||||||
if (block.isIn(BlockTags.FENCES) || block.isIn(BlockTags.WALLS) || block instanceof FenceGateBlock) {
|
if (block.isIn(BlockTags.FENCES) || block.isIn(BlockTags.WALLS) || block.getBlock() instanceof FenceGateBlock) {
|
||||||
entity.setOnGround(true);
|
entity.setOnGround(true);
|
||||||
return below;
|
return below;
|
||||||
}
|
}
|
||||||
|
@ -158,12 +157,12 @@ public class EntityPhysics<T extends Entity> implements Physics, Copieable<Entit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
compound.putFloat("gravity", getBaseGravityModifier());
|
compound.putFloat("gravity", getBaseGravityModifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
setBaseGravityModifier(compound.getFloat("gravity"));
|
setBaseGravityModifier(compound.getFloat("gravity"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -24,7 +24,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
|
||||||
public void set(@Nullable T entity) {
|
public void set(@Nullable T entity) {
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
uuid = entity.getUuid();
|
uuid = entity.getUuid();
|
||||||
clientId = entity.getEntityId();
|
clientId = entity.getId();
|
||||||
pos = Optional.of(entity.getPos());
|
pos = Optional.of(entity.getPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
|
||||||
|
|
||||||
public boolean isPresent(World world) {
|
public boolean isPresent(World world) {
|
||||||
T entity = get(world);
|
T entity = get(world);
|
||||||
return entity != null && !entity.removed;
|
return entity != null && !entity.isRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ifPresent(World world, Consumer<T> consumer) {
|
public void ifPresent(World world, Consumer<T> consumer) {
|
||||||
|
@ -59,7 +59,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag tag) {
|
public void toNBT(NbtCompound tag) {
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
tag.putUuid("uuid", uuid);
|
tag.putUuid("uuid", uuid);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class EntityReference<T extends Entity> implements NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag tag) {
|
public void fromNBT(NbtCompound tag) {
|
||||||
uuid = tag.containsUuid("uuid") ? tag.getUuid("uuid") : null;
|
uuid = tag.containsUuid("uuid") ? tag.getUuid("uuid") : null;
|
||||||
pos = tag.contains("pos") ? Optional.ofNullable(NbtSerialisable.readVector(tag.getList("pos", 6))) : Optional.empty();
|
pos = tag.contains("pos") ? Optional.ofNullable(NbtSerialisable.readVector(tag.getList("pos", 6))) : Optional.empty();
|
||||||
clientId = tag.getInt("clientId");
|
clientId = tag.getInt("clientId");
|
||||||
|
|
|
@ -2,16 +2,16 @@ package com.minelittlepony.unicopia.entity;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.projectile.ProjectileImpactListener;
|
import com.minelittlepony.unicopia.projectile.ProjectileImpactListener;
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
|
|
||||||
public interface Equine<T extends Entity> extends NbtSerialisable, Tickable, ProjectileImpactListener {
|
public interface Equine<T extends Entity> extends NbtSerialisable, Tickable, ProjectileImpactListener {
|
||||||
Race getSpecies();
|
Race getSpecies();
|
||||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
@ -142,17 +142,17 @@ public class FloatingArtefactEntity extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readCustomDataFromTag(CompoundTag compound) {
|
protected void readCustomDataFromNbt(NbtCompound compound) {
|
||||||
ItemStack itemStack = ItemStack.fromTag(compound.getCompound("Item"));
|
ItemStack itemStack = ItemStack.fromNbt(compound.getCompound("Item"));
|
||||||
setStack(itemStack);
|
setStack(itemStack);
|
||||||
setState(State.valueOf(compound.getInt("State")));
|
setState(State.valueOf(compound.getInt("State")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeCustomDataToTag(CompoundTag compound) {
|
protected void writeCustomDataToNbt(NbtCompound compound) {
|
||||||
ItemStack stack = getStack();
|
ItemStack stack = getStack();
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
compound.put("Item", stack.toTag(new CompoundTag()));
|
compound.put("Item", stack.writeNbt(new NbtCompound()));
|
||||||
}
|
}
|
||||||
compound.putInt("State", getState().ordinal());
|
compound.putInt("State", getState().ordinal());
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ public class FloatingArtefactEntity extends Entity {
|
||||||
|
|
||||||
health -= amount;
|
health -= amount;
|
||||||
if (health <= 0) {
|
if (health <= 0) {
|
||||||
remove();
|
remove(RemovalReason.KILLED);
|
||||||
|
|
||||||
ItemStack stack = getStack();
|
ItemStack stack = getStack();
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.util.ActionResult;
|
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()) {
|
if (!owner.isOnGround() && Math.signum(owner.getVelocity().y) != getPhysics().getGravitySignum()) {
|
||||||
double ticks = ((Entity)owner).age;
|
double ticks = ((Entity)owner).age;
|
||||||
double shift = Math.sin(ticks / 9D) / 9D;
|
double shift = Math.sin(ticks / 9D) / 9D;
|
||||||
double rise = -Math.cos(ticks / 9D) * getPhysics().getGravitySignum();
|
double rise = -Math.cos(ticks / 9D) * getPhysics().getGravitySignum();
|
||||||
|
|
||||||
owner.prevYaw = owner.prevYaw;
|
owner.prevYaw = owner.prevYaw;
|
||||||
owner.yaw += 0.3F;
|
owner.setYaw(owner.getYaw() + 0.3F);
|
||||||
|
|
||||||
owner.setVelocity(
|
owner.setVelocity(
|
||||||
owner.getVelocity()
|
owner.getVelocity()
|
||||||
|
@ -139,13 +139,13 @@ public class ItemImpl implements Equine<ItemEntity>, Owned<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
compound.putString("owner_species", getSpecies().name());
|
compound.putString("owner_species", getSpecies().name());
|
||||||
physics.toNBT(compound);
|
physics.toNBT(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
setSpecies(Race.fromName(compound.getString("owner_species")));
|
setSpecies(Race.fromName(compound.getString("owner_species")));
|
||||||
physics.fromNBT(compound);
|
physics.fromNBT(compound);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.unicopia.entity;
|
package com.minelittlepony.unicopia.entity;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
|
||||||
class ItemPhysics extends EntityPhysics<ItemEntity> {
|
class ItemPhysics extends EntityPhysics<ItemEntity> {
|
||||||
|
@ -22,7 +21,7 @@ class ItemPhysics extends EntityPhysics<ItemEntity> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!entity.isOnGround()
|
if (!entity.isOnGround()
|
||||||
|| Entity.squaredHorizontalLength(entity.getVelocity()) > 9.999999747378752E-6D) {
|
|| entity.getVelocity().horizontalLengthSquared() > 9.999999747378752E-6D) {
|
||||||
|
|
||||||
float above = 0.98f;
|
float above = 0.98f;
|
||||||
if (entity.verticalCollision) {
|
if (entity.verticalCollision) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.entity;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.SpellContainer;
|
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.data.TrackedData;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
|
||||||
public abstract class Living<T extends LivingEntity> implements Equine<T>, Caster<T> {
|
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);
|
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.entity = entity;
|
||||||
this.effectDelegate = new EffectSync(this, effect);
|
this.effectDelegate = new EffectSync(this, effect);
|
||||||
|
|
||||||
entity.getDataTracker().startTracking(effect, new CompoundTag());
|
entity.getDataTracker().startTracking(effect, new NbtCompound());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForFall(Runnable action) {
|
public void waitForFall(Runnable action) {
|
||||||
|
@ -164,19 +164,19 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
.isPresent();
|
.isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFall(float distance, float damageMultiplier) {
|
protected void handleFall(float distance, float damageMultiplier, DamageSource cause) {
|
||||||
getSpellSlot().get(SpellType.DISGUISE, false).ifPresent(spell -> {
|
getSpellSlot().get(SpellType.DISGUISE, false).ifPresent(spell -> {
|
||||||
spell.getDisguise().onImpact(this, distance, damageMultiplier);
|
spell.getDisguise().onImpact(this, distance, damageMultiplier, cause);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
enchants.toNBT(compound);
|
enchants.toNBT(compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
enchants.fromNBT(compound);
|
enchants.fromNBT(compound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.entity;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class BreakHeartGoal extends Goal {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canTarget(Entity e) {
|
protected boolean canTarget(Entity e) {
|
||||||
return !e.removed
|
return !e.isRemoved()
|
||||||
&& e instanceof FloatingArtefactEntity
|
&& e instanceof FloatingArtefactEntity
|
||||||
&& ((FloatingArtefactEntity)e).getStack().getItem() == UItems.CRYSTAL_HEART
|
&& ((FloatingArtefactEntity)e).getStack().getItem() == UItems.CRYSTAL_HEART
|
||||||
&& mob.getVisibilityCache().canSee(e);
|
&& mob.getVisibilityCache().canSee(e);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Optional;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.util.VecHelper;
|
import com.minelittlepony.unicopia.util.VecHelper;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.particle.UParticles;
|
import com.minelittlepony.unicopia.particle.UParticles;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.Entity.RemovalReason;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
@ -18,7 +19,7 @@ import net.minecraft.util.Hand;
|
||||||
|
|
||||||
public class WantItTakeItGoal extends BreakHeartGoal {
|
public class WantItTakeItGoal extends BreakHeartGoal {
|
||||||
|
|
||||||
private final TargetPredicate predicate = new TargetPredicate()
|
private final TargetPredicate predicate = TargetPredicate.createAttackable()
|
||||||
.setBaseMaxDistance(64)
|
.setBaseMaxDistance(64)
|
||||||
.setPredicate(EquinePredicates.HAS_WANT_IT_NEED_IT);
|
.setPredicate(EquinePredicates.HAS_WANT_IT_NEED_IT);
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ public class WantItTakeItGoal extends BreakHeartGoal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canTarget(Entity e) {
|
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));
|
|| (e instanceof LivingEntity && predicate.test(mob, (LivingEntity)e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +79,11 @@ public class WantItTakeItGoal extends BreakHeartGoal {
|
||||||
ItemEntity item = (ItemEntity)target;
|
ItemEntity item = (ItemEntity)target;
|
||||||
ItemStack stack = item.getStack();
|
ItemStack stack = item.getStack();
|
||||||
|
|
||||||
if (!item.removed) {
|
if (!item.isRemoved()) {
|
||||||
mob.tryEquip(stack);
|
mob.tryEquip(stack);
|
||||||
mob.method_29499(item);
|
mob.triggerItemPickedUpByEntityCriteria(item);
|
||||||
mob.sendPickup(item, stack.getCount());
|
mob.sendPickup(item, stack.getCount());
|
||||||
item.remove();
|
item.remove(RemovalReason.DISCARDED);
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ public class ChickenBehaviour extends EntityBehaviour<ChickenEntity> {
|
||||||
if (egg.isEmpty()) {
|
if (egg.isEmpty()) {
|
||||||
egg = new ItemStack(Items.EGG);
|
egg = new ItemStack(Items.EGG);
|
||||||
|
|
||||||
int slot = player.getMaster().inventory.method_7371(egg);
|
int slot = player.getMaster().getInventory().indexOf(egg);
|
||||||
if (slot > -1) {
|
if (slot > -1) {
|
||||||
player.getMaster().inventory.removeStack(slot, 1);
|
player.getMaster().getInventory().removeStack(slot, 1);
|
||||||
entity.playSound(SoundEvents.ENTITY_CHICKEN_EGG,
|
entity.playSound(SoundEvents.ENTITY_CHICKEN_EGG,
|
||||||
1,
|
1,
|
||||||
(entity.world.random.nextFloat() - entity.world.random.nextFloat()) * 0.2F + 4
|
(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();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.FlightType;
|
import com.minelittlepony.unicopia.FlightType;
|
||||||
import com.minelittlepony.unicopia.InteractionManager;
|
import com.minelittlepony.unicopia.InteractionManager;
|
||||||
|
@ -31,6 +31,7 @@ import net.minecraft.entity.FallingBlockEntity;
|
||||||
import net.minecraft.entity.Flutterer;
|
import net.minecraft.entity.Flutterer;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
|
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.decoration.AbstractDecorationEntity;
|
import net.minecraft.entity.decoration.AbstractDecorationEntity;
|
||||||
import net.minecraft.entity.mob.AmbientEntity;
|
import net.minecraft.entity.mob.AmbientEntity;
|
||||||
import net.minecraft.entity.mob.FlyingEntity;
|
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.mob.VexEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.ShulkerBulletEntity;
|
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.function.BooleanBiFunction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
|
@ -49,7 +50,7 @@ import net.minecraft.world.WorldAccess;
|
||||||
|
|
||||||
public class Disguise implements NbtSerialisable {
|
public class Disguise implements NbtSerialisable {
|
||||||
|
|
||||||
@Nonnull
|
@NotNull
|
||||||
private String entityId = "";
|
private String entityId = "";
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -63,7 +64,7 @@ public class Disguise implements NbtSerialisable {
|
||||||
private Optional<EntityDimensions> dimensions = Optional.empty();
|
private Optional<EntityDimensions> dimensions = Optional.empty();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private CompoundTag entityNbt;
|
private NbtCompound entityNbt;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity getAppearance() {
|
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();
|
remove();
|
||||||
|
|
||||||
entity = InteractionManager.instance().createPlayer(source.getEntity(), profile);
|
entity = InteractionManager.instance().createPlayer(source.getEntity(), profile);
|
||||||
entity.setCustomName(source.getMaster().getName());
|
entity.setCustomName(source.getMaster().getName());
|
||||||
((PlayerEntity)entity).fromTag(nbt.getCompound("playerNbt"));
|
((PlayerEntity)entity).readNbt(nbt.getCompound("playerNbt"));
|
||||||
entity.setUuid(UUID.randomUUID());
|
entity.setUuid(UUID.randomUUID());
|
||||||
entity.extinguish();
|
entity.extinguish();
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ public class Disguise implements NbtSerialisable {
|
||||||
|
|
||||||
public Entity getOrCreate(Caster<?> source) {
|
public Entity getOrCreate(Caster<?> source) {
|
||||||
if (entity == null && entityNbt != null) {
|
if (entity == null && entityNbt != null) {
|
||||||
CompoundTag nbt = entityNbt;
|
NbtCompound nbt = entityNbt;
|
||||||
entityNbt = null;
|
entityNbt = null;
|
||||||
attachments.clear();
|
attachments.clear();
|
||||||
|
|
||||||
|
@ -133,16 +134,14 @@ public class Disguise implements NbtSerialisable {
|
||||||
nbt.getUuid("playerId"),
|
nbt.getUuid("playerId"),
|
||||||
nbt.getString("playerName")
|
nbt.getString("playerName")
|
||||||
), source);
|
), source);
|
||||||
new Thread(() -> createPlayer(nbt, SkullBlockEntity.loadProperties(new GameProfile(
|
|
||||||
null,
|
SkullBlockEntity.loadProperties(new GameProfile(null, nbt.getString("playerName")), profile ->{ });
|
||||||
nbt.getString("playerName")
|
|
||||||
)), source)).start();
|
|
||||||
} else {
|
} else {
|
||||||
if (source.isClient()) {
|
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) {
|
if (entity != null) {
|
||||||
try {
|
try {
|
||||||
entity.fromTag(nbt);
|
entity.readNbt(nbt);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// Mojang pls
|
// Mojang pls
|
||||||
}
|
}
|
||||||
|
@ -161,8 +160,8 @@ public class Disguise implements NbtSerialisable {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onImpact(Caster<?> pony, float distance, float damageMultiplier) {
|
public void onImpact(Caster<?> pony, float distance, float damageMultiplier, DamageSource cause) {
|
||||||
EntityBehaviour.forEntity(entity).onImpact(pony, entity, distance, damageMultiplier);
|
EntityBehaviour.forEntity(entity).onImpact(pony, entity, distance, damageMultiplier, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onEntityLoaded(Caster<?> source) {
|
private void onEntityLoaded(Caster<?> source) {
|
||||||
|
@ -251,7 +250,7 @@ public class Disguise implements NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
compound.putString("entityId", entityId);
|
compound.putString("entityId", entityId);
|
||||||
|
|
||||||
if (entityNbt != null) {
|
if (entityNbt != null) {
|
||||||
|
@ -262,7 +261,7 @@ public class Disguise implements NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
String newId = compound.getString("entityId");
|
String newId = compound.getString("entityId");
|
||||||
|
|
||||||
if (!newId.contentEquals(entityId)) {
|
if (!newId.contentEquals(entityId)) {
|
||||||
|
@ -279,7 +278,7 @@ public class Disguise implements NbtSerialisable {
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
try {
|
try {
|
||||||
entity.fromTag(entityNbt);
|
entity.readNbt(entityNbt);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// Mojang pls
|
// Mojang pls
|
||||||
}
|
}
|
||||||
|
@ -296,8 +295,8 @@ public class Disguise implements NbtSerialisable {
|
||||||
|| entity instanceof FallingBlockEntity;
|
|| entity instanceof FallingBlockEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CompoundTag encodeEntityToNBT(Entity entity) {
|
private static NbtCompound encodeEntityToNBT(Entity entity) {
|
||||||
CompoundTag entityNbt = new CompoundTag();
|
NbtCompound entityNbt = new NbtCompound();
|
||||||
|
|
||||||
if (entity instanceof PlayerEntity) {
|
if (entity instanceof PlayerEntity) {
|
||||||
GameProfile profile = ((PlayerEntity)entity).getGameProfile();
|
GameProfile profile = ((PlayerEntity)entity).getGameProfile();
|
||||||
|
@ -306,13 +305,13 @@ public class Disguise implements NbtSerialisable {
|
||||||
entityNbt.putUuid("playerId", profile.getId());
|
entityNbt.putUuid("playerId", profile.getId());
|
||||||
entityNbt.putString("playerName", profile.getName());
|
entityNbt.putString("playerName", profile.getName());
|
||||||
|
|
||||||
CompoundTag tag = new CompoundTag();
|
NbtCompound tag = new NbtCompound();
|
||||||
|
|
||||||
entity.saveToTag(tag);
|
entity.writeNbt(tag);
|
||||||
|
|
||||||
entityNbt.put("playerNbt", tag);
|
entityNbt.put("playerNbt", tag);
|
||||||
} else {
|
} else {
|
||||||
entity.saveToTag(entityNbt);
|
entity.writeNbt(entityNbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return entityNbt;
|
return entityNbt;
|
||||||
|
|
|
@ -3,21 +3,24 @@ package com.minelittlepony.unicopia.entity.behaviour;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Supplier;
|
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.Caster;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
import com.minelittlepony.unicopia.entity.ItemWielder;
|
import com.minelittlepony.unicopia.entity.ItemWielder;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
import com.minelittlepony.unicopia.mixin.MixinEntity;
|
||||||
import com.minelittlepony.unicopia.util.Registries;
|
import com.minelittlepony.unicopia.util.Registries;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.Entity.RemovalReason;
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.entity.FallingBlockEntity;
|
import net.minecraft.entity.FallingBlockEntity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.MovementType;
|
import net.minecraft.entity.MovementType;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.mob.AbstractSkeletonEntity;
|
import net.minecraft.entity.mob.AbstractSkeletonEntity;
|
||||||
import net.minecraft.entity.passive.LlamaEntity;
|
import net.minecraft.entity.passive.LlamaEntity;
|
||||||
import net.minecraft.entity.passive.SnowGolemEntity;
|
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) {
|
public void onDestroy(T entity) {
|
||||||
entity.setInvulnerable(false);
|
entity.setInvulnerable(false);
|
||||||
entity.setNoGravity(false);
|
entity.setNoGravity(false);
|
||||||
entity.remove();
|
entity.remove(RemovalReason.KILLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Double> getCameraDistance(Entity entity, Pony player) {
|
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) {
|
public void copyBaseAttributes(LivingEntity from, Entity to, Vec3d positionOffset) {
|
||||||
// Set first because position calculations rely on it
|
// Set first because position calculations rely on it
|
||||||
to.age = from.age;
|
to.age = from.age;
|
||||||
to.removed = from.removed;
|
((MixinEntity)to).setRemovalReason(from.getRemovalReason());
|
||||||
to.setOnGround(from.isOnGround());
|
to.setOnGround(from.isOnGround());
|
||||||
|
|
||||||
if (!from.world.isClient) {
|
if (!from.world.isClient) {
|
||||||
|
@ -143,10 +146,6 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
to.prevY = positionOffset.y + from.prevY;
|
to.prevY = positionOffset.y + from.prevY;
|
||||||
to.prevZ = positionOffset.z + from.prevZ;
|
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.lastRenderX = positionOffset.x + from.lastRenderX;
|
||||||
to.lastRenderY = positionOffset.y + from.lastRenderY;
|
to.lastRenderY = positionOffset.y + from.lastRenderY;
|
||||||
to.lastRenderZ = positionOffset.z + from.lastRenderZ;
|
to.lastRenderZ = positionOffset.z + from.lastRenderZ;
|
||||||
|
@ -162,9 +161,9 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
|
|
||||||
to.setVelocity(from.getVelocity());
|
to.setVelocity(from.getVelocity());
|
||||||
|
|
||||||
to.pitch = from.pitch;
|
to.setPitch(from.getPitch());
|
||||||
to.prevPitch = from.prevPitch;
|
to.prevPitch = from.prevPitch;
|
||||||
to.yaw = from.yaw;
|
to.setYaw(from.getYaw());
|
||||||
to.prevYaw = from.prevYaw;
|
to.prevYaw = from.prevYaw;
|
||||||
to.horizontalSpeed = from.horizontalSpeed;
|
to.horizontalSpeed = from.horizontalSpeed;
|
||||||
to.prevHorizontalSpeed = from.prevHorizontalSpeed;
|
to.prevHorizontalSpeed = from.prevHorizontalSpeed;
|
||||||
|
@ -245,7 +244,7 @@ public class EntityBehaviour<T extends Entity> {
|
||||||
|
|
||||||
protected boolean isSneakingOnGround(Caster<?> source) {
|
protected boolean isSneakingOnGround(Caster<?> source) {
|
||||||
Entity e = source.getEntity();
|
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) {
|
public static <T extends Entity> void register(Supplier<EntityBehaviour<T>> behaviour, EntityType<?>... types) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
|
import com.minelittlepony.unicopia.mixin.MixinBlockEntity;
|
||||||
import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
|
import com.minelittlepony.unicopia.mixin.MixinFallingBlock;
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockEntityProvider;
|
import net.minecraft.block.BlockEntityProvider;
|
||||||
|
@ -21,9 +22,9 @@ import net.minecraft.block.enums.DoubleBlockHalf;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.FallingBlockEntity;
|
import net.minecraft.entity.FallingBlockEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
|
@ -39,10 +40,10 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (source.getEntity().fallDistance > 3) {
|
||||||
entity.fallDistance = source.getEntity().fallDistance;
|
entity.fallDistance = source.getEntity().fallDistance;
|
||||||
entity.handleFallDamage(distance, damageMultiplier);
|
entity.handleFallDamage(distance, damageMultiplier, cause);
|
||||||
|
|
||||||
BlockState state = entity.getBlockState();
|
BlockState state = entity.getBlockState();
|
||||||
if (state.getBlock() instanceof FallingBlock) {
|
if (state.getBlock() instanceof FallingBlock) {
|
||||||
|
@ -77,9 +78,7 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block instanceof BlockEntityProvider) {
|
if (block instanceof BlockEntityProvider) {
|
||||||
BlockEntity b = ((BlockEntityProvider)block).createBlockEntity(entity.world);
|
context.addBlockEntity(((BlockEntityProvider)block).createBlockEntity(entity.getBlockPos(), state));
|
||||||
((MixinBlockEntity)b).setCachedState(state);
|
|
||||||
context.addBlockEntity(b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return configure(entity, block);
|
return configure(entity, block);
|
||||||
|
@ -115,9 +114,10 @@ public class FallingBlockBehaviour extends EntityBehaviour<FallingBlockEntity> {
|
||||||
be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0);
|
be.onSyncedBlockEvent(1, isSneakingOnGround(source) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
be.setLocation(entity.world, entity.getBlockPos());
|
be.setWorld(entity.world);
|
||||||
|
((MixinBlockEntity)be).setPos(entity.getBlockPos());
|
||||||
ceb.tick();
|
ceb.tick();
|
||||||
be.setLocation(null, entity.getBlockPos());
|
be.setWorld(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,12 @@ public class GhastBehaviour extends MobBehaviour<GhastEntity> {
|
||||||
|
|
||||||
Vec3d rot = player.getEntity().getRotationVec(1);
|
Vec3d rot = player.getEntity().getRotationVec(1);
|
||||||
|
|
||||||
FireballEntity proj = new FireballEntity(entity.world, entity, rot.getX(), rot.getY(), rot.getZ());
|
FireballEntity proj = new FireballEntity(entity.world, player.getMaster(),
|
||||||
proj.explosionPower = entity.getFireballStrength() * (player.getLevel().get() + 1);
|
rot.getX(),
|
||||||
proj.setOwner(player.getMaster());
|
rot.getY(),
|
||||||
|
rot.getZ(),
|
||||||
|
entity.getFireballStrength() * (player.getLevel().get() + 1)
|
||||||
|
);
|
||||||
proj.updatePosition(
|
proj.updatePosition(
|
||||||
entity.getX() + rot.x * 4,
|
entity.getX() + rot.x * 4,
|
||||||
entity.getBodyY(0.5D) + 0.5,
|
entity.getBodyY(0.5D) + 0.5,
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.entity.behaviour;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.passive.RabbitEntity;
|
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) {
|
public void update(Pony player, LivingEntity entity, DisguiseSpell spell) {
|
||||||
|
|
||||||
if (player.getEntity().isOnGround()) {
|
if (player.getEntity().isOnGround()) {
|
||||||
if (Entity.squaredHorizontalLength(player.getEntity().getVelocity()) > 0.01) {
|
if (player.getEntity().getVelocity().horizontalLengthSquared() > 0.01) {
|
||||||
player.getMaster().jump();
|
player.getMaster().jump();
|
||||||
if (entity instanceof RabbitEntity) {
|
if (entity instanceof RabbitEntity) {
|
||||||
((RabbitEntity)entity).startJump();
|
((RabbitEntity)entity).startJump();
|
||||||
|
|
|
@ -21,10 +21,10 @@ public class MinecartBehaviour extends EntityBehaviour<AbstractMinecartEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Caster<?> source, AbstractMinecartEntity entity, DisguiseSpell spell) {
|
public void update(Caster<?> source, AbstractMinecartEntity entity, DisguiseSpell spell) {
|
||||||
entity.yaw -= 90;
|
entity.setYaw(entity.getYaw() - 90);
|
||||||
entity.prevYaw -= 90;
|
entity.prevYaw -= 90;
|
||||||
|
|
||||||
entity.pitch = 0;
|
entity.setPitch(0);
|
||||||
entity.prevPitch = 0;
|
entity.prevPitch = 0;
|
||||||
|
|
||||||
if (source.getEntity() instanceof LivingEntity) {
|
if (source.getEntity() instanceof LivingEntity) {
|
||||||
|
|
|
@ -44,13 +44,14 @@ public class SheepBehaviour extends EntityBehaviour<SheepEntity> {
|
||||||
entity.setSheared(true);
|
entity.setSheared(true);
|
||||||
|
|
||||||
Random rng = entity.world.random;
|
Random rng = entity.world.random;
|
||||||
PlayerInventory inv = player.getMaster().inventory;
|
PlayerInventory inv = player.getMaster().getInventory();
|
||||||
|
|
||||||
int dropAmount = rng.nextInt(3);
|
int dropAmount = rng.nextInt(3);
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
slot = inv.method_7371(dropType);
|
slot = inv.indexOf(dropType);
|
||||||
|
|
||||||
if (slot < 0) {
|
if (slot < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.minelittlepony.unicopia.ability.magic.spell.DisguiseSpell;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.mixin.MixinShulkerEntity;
|
import com.minelittlepony.unicopia.mixin.MixinShulkerEntity;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.mob.ShulkerEntity;
|
import net.minecraft.entity.mob.ShulkerEntity;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -17,12 +16,10 @@ import net.minecraft.util.math.Vec3d;
|
||||||
public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
|
public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
|
||||||
@Override
|
@Override
|
||||||
public void update(Caster<?> source, ShulkerEntity shulker, DisguiseSpell spell) {
|
public void update(Caster<?> source, ShulkerEntity shulker, DisguiseSpell spell) {
|
||||||
shulker.yaw = 0;
|
shulker.setYaw(0);
|
||||||
shulker.prevBodyYaw = 0;
|
shulker.prevBodyYaw = 0;
|
||||||
shulker.bodyYaw = 0;
|
shulker.bodyYaw = 0;
|
||||||
|
|
||||||
shulker.setAttachedBlock(null);
|
|
||||||
|
|
||||||
super.update(source, shulker, spell);
|
super.update(source, shulker, spell);
|
||||||
|
|
||||||
Direction attachmentFace = shulker.getAttachedFace();
|
Direction attachmentFace = shulker.getAttachedFace();
|
||||||
|
@ -45,7 +42,7 @@ public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
|
||||||
float peekAmount = 30;
|
float peekAmount = 30;
|
||||||
|
|
||||||
double speed = !player.getEntity().isSneaking() ? 0.29 : 0;
|
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 = (float)MathHelper.clamp(speed, 0, 1);
|
||||||
peekAmount = player.getInterpolator().interpolate("peek", peekAmount, 5);
|
peekAmount = player.getInterpolator().interpolate("peek", peekAmount, 5);
|
||||||
|
@ -56,8 +53,8 @@ public class ShulkerBehaviour extends EntityBehaviour<ShulkerEntity> {
|
||||||
mx.setOpenProgress(peekAmount);
|
mx.setOpenProgress(peekAmount);
|
||||||
|
|
||||||
if (player.sneakingChanged()) {
|
if (player.sneakingChanged()) {
|
||||||
shulker.setPeekAmount((int)(peekAmount / 0.01F));
|
mx.callSetPeekAmount((int)(peekAmount / 0.01F));
|
||||||
} else if (peekAmount > 0.2 && shulker.getPeekAmount() == 0) {
|
} else if (peekAmount > 0.2 && mx.callGetPeekAmount() == 0) {
|
||||||
if (shulker.isAlive() && shulker.world.random.nextInt(1000) < shulker.ambientSoundChance++) {
|
if (shulker.isAlive() && shulker.world.random.nextInt(1000) < shulker.ambientSoundChance++) {
|
||||||
shulker.ambientSoundChance = -shulker.getMinAmbientSoundDelay();
|
shulker.ambientSoundChance = -shulker.getMinAmbientSoundDelay();
|
||||||
shulker.playSound(SoundEvents.ENTITY_SHULKER_AMBIENT, 1, 1);
|
shulker.playSound(SoundEvents.ENTITY_SHULKER_AMBIENT, 1, 1);
|
||||||
|
|
|
@ -9,6 +9,14 @@ public class SpellcastingIllagerBehaviour extends EntityBehaviour<SpellcastingIl
|
||||||
@Override
|
@Override
|
||||||
public void update(Pony player, SpellcastingIllagerEntity entity, DisguiseSpell s) {
|
public void update(Pony player, SpellcastingIllagerEntity entity, DisguiseSpell s) {
|
||||||
if (player.sneakingChanged()) {
|
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()) {
|
if (player.getMaster().isSneaking()) {
|
||||||
SpellcastingIllagerEntity.Spell[] spells = SpellcastingIllagerEntity.Spell.values();
|
SpellcastingIllagerEntity.Spell[] spells = SpellcastingIllagerEntity.Spell.values();
|
||||||
SpellcastingIllagerEntity.Spell spell = spells[entity.world.random.nextInt(spells.length - 1) + 1];
|
SpellcastingIllagerEntity.Spell spell = spells[entity.world.random.nextInt(spells.length - 1) + 1];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.minelittlepony.unicopia.entity.effect;
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.minelittlepony.unicopia.entity.player;
|
package com.minelittlepony.unicopia.entity.player;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class ManaContainer implements MagicReserves, Tickable {
|
public class ManaContainer implements MagicReserves, Tickable {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Race;
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
|
|
||||||
import net.minecraft.entity.attribute.ClampedEntityAttribute;
|
import net.minecraft.entity.attribute.ClampedEntityAttribute;
|
||||||
import net.minecraft.entity.attribute.EntityAttribute;
|
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.EntityAttributeModifier.Operation;
|
||||||
import net.minecraft.entity.attribute.EntityAttributes;
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public class PlayerAttributes implements Tickable {
|
public class PlayerAttributes implements Tickable {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.entity.player;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
||||||
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
|
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
import com.minelittlepony.unicopia.util.MutableVector;
|
import com.minelittlepony.unicopia.util.MutableVector;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
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.damage.DamageSource;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.particle.ParticleTypes;
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
@ -121,7 +121,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
entity.setPose(EntityPose.STANDING);
|
entity.setPose(EntityPose.STANDING);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean creative = entity.abilities.creativeMode || entity.isSpectator();
|
boolean creative = entity.getAbilities().creativeMode || entity.isSpectator();
|
||||||
|
|
||||||
FlightType type = getFlightType();
|
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.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) {
|
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)) {
|
if (!type.canFly() && (type != lastFlightType)) {
|
||||||
entity.abilities.flying = false;
|
entity.getAbilities().flying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((entity.isOnGround() && entity.isSneaking())
|
if ((entity.isOnGround() && entity.isSneaking())
|
||||||
|
@ -144,28 +144,28 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
|| entity.horizontalCollision
|
|| entity.horizontalCollision
|
||||||
|| (entity.verticalCollision && (pony.getSpecies() != Race.BAT || velocity.y < 0))) {
|
|| (entity.verticalCollision && (pony.getSpecies() != Race.BAT || velocity.y < 0))) {
|
||||||
|
|
||||||
if (entity.abilities.flying && entity.horizontalCollision) {
|
if (entity.getAbilities().flying && entity.horizontalCollision) {
|
||||||
handleWallCollission(entity, velocity);
|
handleWallCollission(entity, velocity);
|
||||||
|
|
||||||
entity.setVelocity(velocity.toImmutable());
|
entity.setVelocity(velocity.toImmutable());
|
||||||
entity.abilities.flying = false;
|
entity.getAbilities().flying = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.abilities.flying = false;
|
entity.getAbilities().flying = false;
|
||||||
isFlyingSurvival = entity.abilities.flying && !creative;
|
isFlyingSurvival = entity.getAbilities().flying && !creative;
|
||||||
isFlyingEither = isFlyingSurvival || (creative && entity.abilities.flying);
|
isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastFlightType = type;
|
lastFlightType = type;
|
||||||
|
|
||||||
isFlyingSurvival = entity.abilities.flying && !creative;
|
isFlyingSurvival = entity.getAbilities().flying && !creative;
|
||||||
isFlyingEither = isFlyingSurvival || (creative && entity.abilities.flying);
|
isFlyingEither = isFlyingSurvival || (creative && entity.getAbilities().flying);
|
||||||
|
|
||||||
if (isGravityNegative()) {
|
if (isGravityNegative()) {
|
||||||
if (entity.isOnGround() || (!creative && entity.horizontalCollision)) {
|
if (entity.isOnGround() || (!creative && entity.horizontalCollision)) {
|
||||||
entity.abilities.flying = false;
|
entity.getAbilities().flying = false;
|
||||||
isFlyingEither = false;
|
isFlyingEither = false;
|
||||||
isFlyingSurvival = false;
|
isFlyingSurvival = false;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
|
|
||||||
if (!getFlightType().canFly()) {
|
if (!getFlightType().canFly()) {
|
||||||
entity.world.playSoundFromEntity(null, entity, SoundEvents.ITEM_SHIELD_BREAK, SoundCategory.PLAYERS, 1, 2);
|
entity.world.playSoundFromEntity(null, entity, SoundEvents.ITEM_SHIELD_BREAK, SoundCategory.PLAYERS, 1, 2);
|
||||||
entity.abilities.flying = false;
|
entity.getAbilities().flying = false;
|
||||||
isFlyingEither = false;
|
isFlyingEither = false;
|
||||||
isFlyingSurvival = false;
|
isFlyingSurvival = false;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
boolean fallingTakeOffCondition = !entity.isOnGround() && velocity.y < -1.6 * getGravitySignum();
|
boolean fallingTakeOffCondition = !entity.isOnGround() && velocity.y < -1.6 * getGravitySignum();
|
||||||
|
|
||||||
if (takeOffCondition || fallingTakeOffCondition) {
|
if (takeOffCondition || fallingTakeOffCondition) {
|
||||||
entity.abilities.flying = true;
|
entity.getAbilities().flying = true;
|
||||||
isFlyingEither = true;
|
isFlyingEither = true;
|
||||||
isFlyingSurvival = true;
|
isFlyingSurvival = true;
|
||||||
|
|
||||||
|
@ -364,9 +364,9 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
// vertical drop due to gravity
|
// vertical drop due to gravity
|
||||||
forward += 0.005F;
|
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.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) {
|
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 = Math.min(forward, 7);
|
||||||
forward /= 1 + (EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player) * 0.8F);
|
forward /= 1 + (EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, player) * 0.8F);
|
||||||
|
|
||||||
velocity.x += - forward * MathHelper.sin((player.yaw + glance) * 0.017453292F);
|
velocity.x += - forward * MathHelper.sin((player.getYaw() + glance) * 0.017453292F);
|
||||||
velocity.z += forward * MathHelper.cos((player.yaw + 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) {
|
if (!player.world.isClient && player.world.isThundering() && player.world.random.nextInt(9000) == 0) {
|
||||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(player.world);
|
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) {
|
protected double getHorizontalMotion(Entity e) {
|
||||||
return Entity.squaredHorizontalLength(e.getPos().subtract(lastPos));
|
return e.getPos().subtract(lastPos).horizontalLengthSquared();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlightType getFlightType() {
|
private FlightType getFlightType() {
|
||||||
|
@ -456,19 +456,19 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
public void updateFlightStat(boolean flying) {
|
public void updateFlightStat(boolean flying) {
|
||||||
FlightType type = getFlightType();
|
FlightType type = getFlightType();
|
||||||
|
|
||||||
entity.abilities.allowFlying = type.canFlyCreative(entity);
|
entity.getAbilities().allowFlying = type.canFlyCreative(entity);
|
||||||
|
|
||||||
if (type.canFly() || entity.abilities.allowFlying) {
|
if (type.canFly() || entity.getAbilities().allowFlying) {
|
||||||
entity.abilities.flying |= flying;
|
entity.getAbilities().flying |= flying;
|
||||||
isFlyingSurvival = entity.abilities.flying;
|
isFlyingSurvival = entity.getAbilities().flying;
|
||||||
} else {
|
} else {
|
||||||
entity.abilities.flying = false;
|
entity.getAbilities().flying = false;
|
||||||
isFlyingSurvival = false;
|
isFlyingSurvival = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
compound.putBoolean("isFlying", isFlyingSurvival);
|
compound.putBoolean("isFlying", isFlyingSurvival);
|
||||||
compound.putBoolean("isFlyingEither", isFlyingEither);
|
compound.putBoolean("isFlyingEither", isFlyingEither);
|
||||||
|
@ -476,7 +476,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
isFlyingSurvival = compound.getBoolean("isFlying");
|
isFlyingSurvival = compound.getBoolean("isFlying");
|
||||||
isFlyingEither = compound.getBoolean("isFlyingEither");
|
isFlyingEither = compound.getBoolean("isFlyingEither");
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
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.network.Transmittable;
|
||||||
import com.minelittlepony.unicopia.util.Copieable;
|
import com.minelittlepony.unicopia.util.Copieable;
|
||||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
|
import com.minelittlepony.unicopia.util.Tickable;
|
||||||
import com.minelittlepony.common.util.animation.LinearInterpolator;
|
import com.minelittlepony.common.util.animation.LinearInterpolator;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
|
@ -37,18 +38,18 @@ import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.attribute.DefaultAttributeContainer;
|
import net.minecraft.entity.attribute.DefaultAttributeContainer;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.data.DataTracker;
|
import net.minecraft.entity.data.DataTracker;
|
||||||
import net.minecraft.entity.data.TrackedData;
|
import net.minecraft.entity.data.TrackedData;
|
||||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
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.network.packet.s2c.play.EntityPassengersSetS2CPacket;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.Tickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
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> MANA = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||||
static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
static final TrackedData<Float> XP = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.FLOAT);
|
||||||
|
|
||||||
private static final TrackedData<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 AbilityDispatcher powers = new AbilityDispatcher(this);
|
||||||
private final PlayerPhysics gravity = new PlayerPhysics(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());
|
entity.getDataTracker().set(RACE, race.ordinal());
|
||||||
|
|
||||||
gravity.updateFlightStat(entity.abilities.flying);
|
gravity.updateFlightStat(entity.getAbilities().flying);
|
||||||
entity.sendAbilitiesUpdate();
|
entity.sendAbilitiesUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,7 +263,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
|
|
||||||
if (isHanging()) {
|
if (isHanging()) {
|
||||||
if (ticksHanging++ > 40) {
|
if (ticksHanging++ > 40) {
|
||||||
if (Entity.squaredHorizontalLength(entity.getVelocity()) > 0.01
|
if (entity.getVelocity().horizontalLengthSquared() > 0.01
|
||||||
|| entity.isSneaking()
|
|| entity.isSneaking()
|
||||||
|| !canHangAt(getHangingPos())) {
|
|| !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();
|
float g = gravity.getGravityModifier();
|
||||||
|
|
||||||
|
@ -301,11 +302,11 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
|
|
||||||
distance = Math.max(0, (distance * g) - 5);
|
distance = Math.max(0, (distance * g) - 5);
|
||||||
|
|
||||||
handleFall(distance, damageMultiplier);
|
handleFall(distance, damageMultiplier, cause);
|
||||||
return Optional.of(distance);
|
return Optional.of(distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFall(distance, damageMultiplier);
|
handleFall(distance, damageMultiplier, cause);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +350,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
protected Stream<ItemStack> getInventoryStacks() {
|
protected Stream<ItemStack> getInventoryStacks() {
|
||||||
return Streams.concat(
|
return Streams.concat(
|
||||||
super.getInventoryStacks(),
|
super.getInventoryStacks(),
|
||||||
entity.inventory.main.stream()
|
entity.getInventory().main.stream()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +375,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(CompoundTag compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
compound.putString("playerSpecies", getSpecies().name());
|
compound.putString("playerSpecies", getSpecies().name());
|
||||||
|
|
||||||
|
@ -389,7 +390,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromNBT(CompoundTag compound) {
|
public void fromNBT(NbtCompound compound) {
|
||||||
super.fromNBT(compound);
|
super.fromNBT(compound);
|
||||||
speciesPersisted = true;
|
speciesPersisted = true;
|
||||||
setSpecies(Race.fromName(compound.getString("playerSpecies")));
|
setSpecies(Race.fromName(compound.getString("playerSpecies")));
|
||||||
|
@ -407,7 +408,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
@Override
|
@Override
|
||||||
public void copyFrom(Pony oldPlayer) {
|
public void copyFrom(Pony oldPlayer) {
|
||||||
speciesPersisted = oldPlayer.speciesPersisted;
|
speciesPersisted = oldPlayer.speciesPersisted;
|
||||||
if (!oldPlayer.getEntity().removed) {
|
if (!oldPlayer.getEntity().isRemoved()) {
|
||||||
setSpell(oldPlayer.getSpellSlot().get(true).orElse(null));
|
setSpell(oldPlayer.getSpellSlot().get(true).orElse(null));
|
||||||
}
|
}
|
||||||
oldPlayer.setSpell(null);
|
oldPlayer.setSpell(null);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package com.minelittlepony.unicopia.entity.player.dummy;
|
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.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.Owned;
|
import com.minelittlepony.unicopia.Owned;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
|
@ -38,7 +39,7 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@NotNull
|
||||||
protected PlayerListEntry getPlayerListEntry() {
|
protected PlayerListEntry getPlayerListEntry() {
|
||||||
if (playerInfo == null) {
|
if (playerInfo == null) {
|
||||||
ClientPlayNetworkHandler connection = MinecraftClient.getInstance().getNetworkHandler();
|
ClientPlayNetworkHandler connection = MinecraftClient.getInstance().getNetworkHandler();
|
||||||
|
@ -74,11 +75,13 @@ public class DummyClientPlayerEntity extends AbstractClientPlayerEntity implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class Packet extends PlayerListS2CPacket {
|
private final class Packet extends PlayerListS2CPacket {
|
||||||
|
public Packet() { super(PacketByteBufs.empty()); }
|
||||||
|
|
||||||
PlayerListS2CPacket.Entry entry() {
|
PlayerListS2CPacket.Entry entry() {
|
||||||
return new PlayerListS2CPacket.Entry(
|
return new PlayerListS2CPacket.Entry(
|
||||||
getGameProfile(),
|
getGameProfile(),
|
||||||
0,
|
0,
|
||||||
GameMode.NOT_SET,
|
GameMode.DEFAULT,
|
||||||
new LiteralText(getGameProfile().getName()));
|
new LiteralText(getGameProfile().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.network.ServerPlayerInteractionManager;
|
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
|
||||||
public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned<PlayerEntity> {
|
public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned<PlayerEntity> {
|
||||||
|
@ -15,7 +14,7 @@ public class DummyServerPlayerEntity extends ServerPlayerEntity implements Owned
|
||||||
private PlayerEntity owner;
|
private PlayerEntity owner;
|
||||||
|
|
||||||
public DummyServerPlayerEntity(ServerWorld world, GameProfile profile) {
|
public DummyServerPlayerEntity(ServerWorld world, GameProfile profile) {
|
||||||
super(world.getServer(), world, profile, new ServerPlayerInteractionManager(world));
|
super(world.getServer(), world, profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.item;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.IItemEntity;
|
import com.minelittlepony.unicopia.entity.IItemEntity;
|
||||||
import com.minelittlepony.unicopia.entity.ItemImpl;
|
import com.minelittlepony.unicopia.entity.ItemImpl;
|
||||||
import com.minelittlepony.unicopia.item.toxin.Toxicity;
|
import com.minelittlepony.unicopia.item.toxin.Toxicity;
|
||||||
|
|
||||||
import net.minecraft.client.item.TooltipContext;
|
import net.minecraft.client.item.TooltipContext;
|
||||||
|
import net.minecraft.entity.Entity.RemovalReason;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -29,10 +30,10 @@ public class AppleItem extends Item implements ItemImpl.TickableItem {
|
||||||
public ActionResult onGroundTick(IItemEntity item) {
|
public ActionResult onGroundTick(IItemEntity item) {
|
||||||
ItemEntity entity = item.get().getMaster();
|
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) {
|
if (!entity.world.isClient) {
|
||||||
entity.remove();
|
entity.remove(RemovalReason.KILLED);
|
||||||
|
|
||||||
ItemEntity neu = EntityType.ITEM.create(entity.world);
|
ItemEntity neu = EntityType.ITEM.create(entity.world);
|
||||||
neu.copyPositionAndRotation(entity);
|
neu.copyPositionAndRotation(entity);
|
||||||
|
@ -48,7 +49,7 @@ public class AppleItem extends Item implements ItemImpl.TickableItem {
|
||||||
entity.world.spawnEntity(copy);
|
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++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(),
|
entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(),
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class CrystalHeartItem extends Item implements FloatingArtefactEntity.Art
|
||||||
List<LivingEntity> inputs = new ArrayList<>();
|
List<LivingEntity> inputs = new ArrayList<>();
|
||||||
List<LivingEntity> outputs = 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;
|
LivingEntity living = (LivingEntity)e;
|
||||||
|
|
||||||
if (e instanceof PlayerEntity
|
if (e instanceof PlayerEntity
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class DrinkableItem extends Item {
|
||||||
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
|
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);
|
stack.decrement(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.ability.magic.Caster;
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
||||||
|
@ -42,7 +42,7 @@ public class FriendshipBraceletItem extends WearableItem implements DyeableItem,
|
||||||
result.setCount(1);
|
result.setCount(1);
|
||||||
result.getOrCreateTag().putString("issuer", player.getName().asString());
|
result.getOrCreateTag().putString("issuer", player.getName().asString());
|
||||||
|
|
||||||
if (!player.abilities.creativeMode) {
|
if (!player.getAbilities().creativeMode) {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Affinity;
|
import com.minelittlepony.unicopia.Affinity;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.minelittlepony.unicopia.item;
|
package com.minelittlepony.unicopia.item;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
|
||||||
public interface GlowableItem {
|
public interface GlowableItem {
|
||||||
default boolean isGlowing(ItemStack stack) {
|
default boolean isGlowing(ItemStack stack) {
|
||||||
CompoundTag tag = stack.getSubTag("display");
|
NbtCompound tag = stack.getSubTag("display");
|
||||||
return tag != null && tag.getBoolean("glowing");
|
return tag != null && tag.getBoolean("glowing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.LightningEntity;
|
import net.minecraft.entity.LightningEntity;
|
||||||
|
import net.minecraft.entity.Entity.RemovalReason;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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(),
|
world.playSound(null, player.getX(), player.getY(), player.getZ(),
|
||||||
SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL,
|
SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL,
|
||||||
0.5F,
|
0.5F,
|
||||||
0.4F / (RANDOM.nextFloat() * 0.4F + 0.8F));
|
0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
|
||||||
|
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
MagicProjectileEntity projectile = new MagicProjectileEntity(world, player);
|
MagicProjectileEntity projectile = new MagicProjectileEntity(world, player);
|
||||||
projectile.setItem(stack);
|
projectile.setItem(stack);
|
||||||
projectile.setThrowDamage(getProjectileDamage(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);
|
world.spawnEntity(projectile);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.incrementStat(Stats.USED.getOrCreateStat(this));
|
player.incrementStat(Stats.USED.getOrCreateStat(this));
|
||||||
|
|
||||||
if (!player.abilities.creativeMode) {
|
if (!player.getAbilities().creativeMode) {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,15 +80,15 @@ public class JarItem extends Item implements ProjectileDelegate, ItemImpl.Tickab
|
||||||
|
|
||||||
if (!lightning
|
if (!lightning
|
||||||
&& !entity.world.isClient
|
&& !entity.world.isClient
|
||||||
&& !entity.removed
|
&& !entity.isRemoved()
|
||||||
&& entity.getAge() > 100
|
&& entity.getItemAge() > 100
|
||||||
&& entity.world.isThundering()
|
&& entity.world.isThundering()
|
||||||
&& entity.world.isSkyVisible(entity.getBlockPos())
|
&& entity.world.isSkyVisible(entity.getBlockPos())
|
||||||
&& entity.world.random.nextInt(130) == 0) {
|
&& entity.world.random.nextInt(130) == 0) {
|
||||||
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world);
|
LightningEntity lightning = EntityType.LIGHTNING_BOLT.create(entity.world);
|
||||||
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
|
lightning.refreshPositionAfterTeleport(entity.getX(), entity.getY(), entity.getZ());
|
||||||
|
|
||||||
entity.remove();
|
entity.remove(RemovalReason.DISCARDED);
|
||||||
entity.world.spawnEntity(lightning);
|
entity.world.spawnEntity(lightning);
|
||||||
|
|
||||||
ItemEntity neu = EntityType.ITEM.create(entity.world);
|
ItemEntity neu = EntityType.ITEM.create(entity.world);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class ZapAppleItem extends AppleItem implements ChameleonItem {
|
||||||
e.onStruckByLightning((ServerWorld)e.world, lightning);
|
e.onStruckByLightning((ServerWorld)e.world, lightning);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player.abilities.creativeMode) {
|
if (!player.getAbilities().creativeMode) {
|
||||||
stack.decrement(1);
|
stack.decrement(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.enchantment.EnchantmentTarget;
|
import net.minecraft.enchantment.EnchantmentTarget;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
|
|
||||||
public class GemFindingEnchantment extends SimpleEnchantment {
|
public class GemFindingEnchantment extends SimpleEnchantment {
|
||||||
|
|
||||||
|
@ -24,14 +23,16 @@ public class GemFindingEnchantment extends SimpleEnchantment {
|
||||||
|
|
||||||
BlockPos origin = user.getOrigin();
|
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(p -> user.getOriginVector().squaredDistanceTo(p.getX(), p.getY(), p.getZ()))
|
||||||
.map(find -> (1 - (MathHelper.sqrt(find) / radius)))
|
.map(find -> (1 - (Math.sqrt(find) / radius)))
|
||||||
.orElse(-1F);
|
.orElse(-1D);
|
||||||
|
|
||||||
volume = Math.max(volume, 0.04F);
|
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)
|
@Environment(EnvType.CLIENT)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue