Updating to 1.15

This commit is contained in:
Sollace 2020-04-22 16:28:20 +02:00
parent 25104b4d1f
commit b7c3a37bee
136 changed files with 1377 additions and 1499 deletions

View file

@ -1,10 +1,6 @@
// Fabric build script
// 03/06/2019
// https://github.com/FabricMC/fabric-example-mod/blob/master/build.gradle
plugins { plugins {
id 'java-library' id 'java-library'
id 'fabric-loom' version '0.2.5-SNAPSHOT' id 'fabric-loom' version '0.2.6-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
@ -59,7 +55,9 @@ dependencies {
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}"
modImplementation "io.github.prospector.modmenu:ModMenu:1.6.2-93" modCompileOnly("io.github.prospector:modmenu:${project.modmenu_version}") {
transitive = false
}
} }
processResources { processResources {

View file

@ -3,9 +3,9 @@ org.gradle.daemon=false
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
minecraft_version=1.14.4 minecraft_version=1.15.2
yarn_mappings=1.14.4+build.2 yarn_mappings=1.15.2+build.7:v2
loader_version=0.4.8+ loader_version=0.7.6+build.180
# Mod Properties # Mod Properties
group=com.minelittlepony group=com.minelittlepony
@ -16,5 +16,6 @@ org.gradle.daemon=false
release=SNAPSHOT release=SNAPSHOT
# Dependencies # Dependencies
fabric_version=0.3.0+ fabric_version=0.4.29+
kirin_version=1.14.4-1.4.4 modmenu_version=1.8.+
kirin_version=1.5.2-1.15.2

View file

@ -9,8 +9,8 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.InAnimate; import com.minelittlepony.unicopia.entity.InAnimate;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell; import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.particles.UParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -76,7 +76,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
} }
} }
player.getEntityWorld().playSound(null, player.getBlockPos(), SoundEvents.ENTITY_PARROT_IMITATE_POLAR_BEAR, SoundCategory.PLAYERS, 1.4F, 0.4F); player.getEntityWorld().playSound(null, player.getBlockPos(), SoundEvents.ENTITY_PARROT_IMITATE_RAVAGER, SoundCategory.PLAYERS, 1.4F, 0.4F);
iplayer.getEffect(DisguiseSpell.class).orElseGet(() -> { iplayer.getEffect(DisguiseSpell.class).orElseGet(() -> {
DisguiseSpell disc = new DisguiseSpell(); DisguiseSpell disc = new DisguiseSpell();

View file

@ -9,6 +9,8 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particles.ParticleUtils;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
@ -68,7 +70,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
} }
private boolean canFeed(Pony player) { private boolean canFeed(Pony player) {
return player.getOwner().getHealth() < player.getOwner().getHealthMaximum() || player.getOwner().canConsume(false); return player.getOwner().getHealth() < player.getOwner().getMaximumHealth() || player.getOwner().canConsume(false);
} }
private boolean canDrain(Entity e) { private boolean canDrain(Entity e) {
@ -101,7 +103,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
public void apply(Pony iplayer, Hit data) { public void apply(Pony iplayer, Hit data) {
PlayerEntity player = iplayer.getOwner(); PlayerEntity player = iplayer.getOwner();
float maximumHealthGain = player.getHealthMaximum() - player.getHealth(); float maximumHealthGain = player.getMaximumHealth() - player.getHealth();
int maximumFoodGain = player.canConsume(false) ? (20 - player.getHungerManager().getFoodLevel()) : 0; int maximumFoodGain = player.canConsume(false) ? (20 - player.getHungerManager().getFoodLevel()) : 0;
if (maximumHealthGain > 0 || maximumFoodGain > 0) { if (maximumHealthGain > 0 || maximumFoodGain > 0) {
@ -134,13 +136,12 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
living.damage(d, damage); living.damage(d, damage);
} }
// TODO: ParticleTypeRegistry ParticleUtils.spawnParticles(UParticles.CHANGELING_MAGIC, living, 7);
//ParticleTypeRegistry.spawnParticles(UParticles.CHANGELING_MAGIC, living, 7);
if (changeling.hasStatusEffect(StatusEffects.NAUSEA)) { if (changeling.hasStatusEffect(StatusEffects.NAUSEA)) {
living.addPotionEffect(changeling.removePotionEffect(StatusEffects.NAUSEA)); living.addStatusEffect(changeling.removeStatusEffectInternal(StatusEffects.NAUSEA));
} else if (changeling.getEntityWorld().random.nextInt(2300) == 0) { } else if (changeling.getEntityWorld().random.nextInt(2300) == 0) {
living.addPotionEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1)); living.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1));
} }
if (living instanceof PlayerEntity) { if (living instanceof PlayerEntity) {
@ -148,7 +149,7 @@ public class ChangelingFeedAbility implements Ability<Ability.Hit> {
damage *= 1.6F; damage *= 1.6F;
if (!changeling.hasStatusEffect(StatusEffects.HEALTH_BOOST)) { if (!changeling.hasStatusEffect(StatusEffects.HEALTH_BOOST)) {
changeling.addPotionEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1)); changeling.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1));
} }
} }

View file

@ -4,8 +4,8 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.particles.UParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.BoneMealItem; import net.minecraft.item.BoneMealItem;
@ -95,7 +95,7 @@ public class EarthPonyGrowAbility implements Ability<Ability.Pos> {
player.addExertion(3); player.addExertion(3);
if (player.getWorld().isClient()) { if (player.getWorld().isClient()) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 1); player.spawnParticles(MagicParticleEffect.UNICORN, 1);
} }
} }

View file

@ -133,9 +133,9 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
if (dist <= rad + 3) { if (dist <= rad + 3) {
double force = dist / 5; double force = dist / 5;
i.addVelocity( i.addVelocity(
-(player.x - i.x) / force, -(player.getX() - i.getX()) / force,
-(player.y - i.y - 2) / force + (dist < 1 ? dist : 0), -(player.getY() - i.getY() - 2) / force + (dist < 1 ? dist : 0),
-(player.z - i.z) / force); -(player.getZ() - i.getZ()) / force);
DamageSource damage = MagicalDamageSource.causePlayerDamage("smash", player); DamageSource damage = MagicalDamageSource.causePlayerDamage("smash", player);
@ -157,7 +157,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
}); });
BlockPos.iterate(pos.add(-rad, -rad, -rad), pos.add(rad, rad, rad)).forEach(i -> { BlockPos.iterate(pos.add(-rad, -rad, -rad), pos.add(rad, rad, rad)).forEach(i -> {
if (i.getSquaredDistance(player.x, player.y, player.z, true) <= rad*rad) { if (i.getSquaredDistance(player.getX(), player.getY(), player.getZ(), true) <= rad*rad) {
spawnEffect(player.world, i); spawnEffect(player.world, i);
} }
}); });
@ -169,7 +169,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
iplayer.subtractEnergyCost(rad); iplayer.subtractEnergyCost(rad);
} else if (data.hitType == 1) { } else if (data.hitType == 1) {
boolean harmed = player.getHealth() < player.getHealthMaximum(); boolean harmed = player.getHealth() < player.getMaximumHealth();
if (harmed && player.world.random.nextInt(30) == 0) { if (harmed && player.world.random.nextInt(30) == 0) {
iplayer.subtractEnergyCost(3); iplayer.subtractEnergyCost(3);
@ -230,11 +230,11 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
yVel *= y * 5; yVel *= y * 5;
for (int i = 0; i < shape.getVolumeOfSpawnableSpace(); i++) { for (int i = 0; i < shape.getVolumeOfSpawnableSpace(); i++) {
Vec3d point = shape.computePoint(player.getEntityWorld().random); Vec3d point = shape.computePoint(player.getEntityWorld().random).add(player.getPos());
player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.DIRT.getDefaultState()), player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.DIRT.getDefaultState()),
player.x + point.x, point.x,
player.y + y + point.y, point.y + y,
player.z + point.z, point.z,
0, yVel, 0 0, yVel, 0
); );
} }
@ -350,7 +350,7 @@ public class EarthPonyStompAbility implements Ability<EarthPonyStompAbility.Data
WorldEvent.DESTROY_BLOCK.play(w, pos, state); WorldEvent.DESTROY_BLOCK.play(w, pos, state);
ItemEntity item = new ItemEntity(EntityType.ITEM, w); ItemEntity item = new ItemEntity(EntityType.ITEM, w);
item.setPosition(pos.getX() + w.random.nextFloat(), pos.getY() - 0.5, pos.getZ() + w.random.nextFloat()); item.setPos(pos.getX() + w.random.nextFloat(), pos.getY() - 0.5, pos.getZ() + w.random.nextFloat());
item.setStack(getApple(w, log)); item.setStack(getApple(w, log));
drops.add(item); drops.add(item);

View file

@ -6,8 +6,9 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.particles.UParticles;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -76,7 +77,7 @@ public class PegasusCloudInteractionAbility implements Ability<Ability.Numeric>
@Override @Override
public void preApply(Pony player) { public void preApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 10); player.spawnParticles(MagicParticleEffect.UNICORN, 10);
} }
@Override @Override

View file

@ -5,7 +5,7 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.ShieldSpell; import com.minelittlepony.unicopia.magic.spell.ShieldSpell;
import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
/** /**
* A magic casting ability for unicorns. * A magic casting ability for unicorns.
@ -60,11 +60,11 @@ public class UnicornCastingAbility implements Ability<Ability.Hit> {
@Override @Override
public void preApply(Pony player) { public void preApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(MagicParticleEffect.UNICORN, 5);
} }
@Override @Override
public void postApply(Pony player) { public void postApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(MagicParticleEffect.UNICORN, 5);
} }
} }

View file

@ -4,8 +4,8 @@ import org.lwjgl.glfw.GLFW;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.particles.UParticles;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -131,10 +131,10 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
} }
} }
player.setPosition( player.setPos(
data.x + (player.x - Math.floor(player.x)), data.x + (player.getX() - Math.floor(player.getX())),
data.y, data.y,
data.z + (player.z - Math.floor(player.z))); data.z + (player.getZ() - Math.floor(player.getZ())));
iplayer.subtractEnergyCost(distance); iplayer.subtractEnergyCost(distance);
player.fallDistance /= distance; player.fallDistance /= distance;
@ -166,11 +166,11 @@ public class UnicornTeleportAbility implements Ability<Ability.Pos> {
@Override @Override
public void preApply(Pony player) { public void preApply(Pony player) {
player.addExertion(3); player.addExertion(3);
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(MagicParticleEffect.UNICORN, 5);
} }
@Override @Override
public void postApply(Pony player) { public void postApply(Pony player) {
player.spawnParticles(UParticles.UNICORN_MAGIC, 5); player.spawnParticles(MagicParticleEffect.UNICORN, 5);
} }
} }

View file

@ -24,7 +24,7 @@ class AdvancementPredicate {
} }
public boolean test(ServerWorld world, PlayerAdvancementTracker tracker) { public boolean test(ServerWorld world, PlayerAdvancementTracker tracker) {
Advancement advancement = world.getServer().getAdvancementManager().get(id); Advancement advancement = world.getServer().getAdvancementLoader().get(id);
return advancement != null && tracker.getProgress(advancement).isDone(); return advancement != null && tracker.getProgress(advancement).isDone();
} }

View file

@ -36,7 +36,7 @@ public class BOHDeathCriterion extends AbstractCriterion<BOHDeathCriterion.Entry
} }
public void trigger(ServerPlayerEntity player) { public void trigger(ServerPlayerEntity player) {
PlayerAdvancementTracker key = player.getAdvancementManager(); PlayerAdvancementTracker key = player.getAdvancementTracker();
Optional.ofNullable(listeners.get(key)).ifPresent(e -> { Optional.ofNullable(listeners.get(key)).ifPresent(e -> {
e.trigger((ServerWorld)player.world, key); e.trigger((ServerWorld)player.world, key);
@ -68,7 +68,7 @@ public class BOHDeathCriterion extends AbstractCriterion<BOHDeathCriterion.Entry
public void trigger(ServerWorld world, PlayerAdvancementTracker tracker) { public void trigger(ServerWorld world, PlayerAdvancementTracker tracker) {
listeners.stream() listeners.stream()
.filter(listener -> listener.getConditions().test(world, tracker)) .filter(listener -> listener.getConditions().test(world, tracker))
.forEach(winner -> winner.apply(advancement)); .forEach(winner -> winner.grant(advancement));
} }
} }
} }

View file

@ -10,6 +10,7 @@ import net.minecraft.block.DoorBlock;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.enums.DoubleBlockHalf; import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -31,7 +32,7 @@ public abstract class AbstractDoorBlock extends DoorBlock {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return toggleDoor(world, pos, false, true, player); return toggleDoor(world, pos, false, true, player);
} }
@ -52,15 +53,15 @@ public abstract class AbstractDoorBlock extends DoorBlock {
return player == null || material != Material.METAL; return player == null || material != Material.METAL;
} }
protected boolean toggleDoor(World world, BlockPos pos, boolean open, boolean force, @Nullable PlayerEntity player) { protected ActionResult toggleDoor(World world, BlockPos pos, boolean open, boolean force, @Nullable PlayerEntity player) {
if (!canOpen(player)) { if (!canOpen(player)) {
return false; return ActionResult.PASS;
} }
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.getBlock() != this) { if (state.getBlock() != this) {
return false; return ActionResult.PASS;
} }
BlockPos lower = getPrimaryDoorPos(state, pos); BlockPos lower = getPrimaryDoorPos(state, pos);
@ -68,11 +69,11 @@ public abstract class AbstractDoorBlock extends DoorBlock {
BlockState mainDoor = pos == lower ? state : world.getBlockState(lower); BlockState mainDoor = pos == lower ? state : world.getBlockState(lower);
if (mainDoor.getBlock() != this) { if (mainDoor.getBlock() != this) {
return false; return ActionResult.PASS;
} }
if (!force && mainDoor.get(OPEN) == open) { if (!force && mainDoor.get(OPEN) == open) {
return false; return ActionResult.FAIL;
} }
state = mainDoor.cycle(OPEN); state = mainDoor.cycle(OPEN);
@ -83,7 +84,7 @@ public abstract class AbstractDoorBlock extends DoorBlock {
world.playLevelEvent(player, sound.getId(), pos, 0); world.playLevelEvent(player, sound.getId(), pos, 0);
return true; return ActionResult.SUCCESS;
} }
protected BlockPos getPrimaryDoorPos(BlockState state, BlockPos pos) { protected BlockPos getPrimaryDoorPos(BlockState state, BlockPos pos) {

View file

@ -8,8 +8,8 @@ import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper; import com.minelittlepony.unicopia.util.PosHelper;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tools.FabricToolTags;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityContext; import net.minecraft.entity.EntityContext;
@ -18,22 +18,23 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.IntProperty;
import net.minecraft.util.StringIdentifiable; import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.TagHelper;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
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.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.ViewableWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class BlockGrowingCuccoon extends Block { public class BlockGrowingCuccoon extends Block {
@ -53,7 +54,6 @@ public class BlockGrowingCuccoon extends Block {
Block.createCuboidShape(2, 0, 2, 14, 12, 14), Block.createCuboidShape(2, 0, 2, 14, 12, 14),
}; };
@SuppressWarnings("deprecation")
public BlockGrowingCuccoon() { public BlockGrowingCuccoon() {
super(FabricBlockSettings.of(UMaterials.HIVE) super(FabricBlockSettings.of(UMaterials.HIVE)
.ticksRandomly() .ticksRandomly()
@ -61,11 +61,11 @@ public class BlockGrowingCuccoon extends Block {
.lightLevel(9) .lightLevel(9)
.slipperiness(0.5F) .slipperiness(0.5F)
.sounds(BlockSoundGroup.SLIME) .sounds(BlockSoundGroup.SLIME)
.breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.SHOVELS, 2) .breakByTool(FabricToolTags.SHOVELS, 2)
.build() .build()
); );
setDefaultState(stateFactory.getDefaultState() setDefaultState(stateManager.getDefaultState()
.with(AGE, 0) .with(AGE, 0)
.with(SHAPE, Shape.BULB)); .with(SHAPE, Shape.BULB));
} }
@ -87,18 +87,13 @@ public class BlockGrowingCuccoon extends Block {
return true; return true;
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public Block.OffsetType getOffsetType() { public Block.OffsetType getOffsetType() {
return Block.OffsetType.XZ; return Block.OffsetType.XZ;
} }
@Override @Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
if (!checkSupport(world, pos)) { if (!checkSupport(world, pos)) {
breakConnected(world, pos); breakConnected(world, pos);
return; return;
@ -108,7 +103,7 @@ public class BlockGrowingCuccoon extends Block {
BlockPos below = pos.down(); BlockPos below = pos.down();
if (world.isBlockLoaded(below)) { if (world.isChunkLoaded(below)) {
boolean spaceBelow = world.isAir(below); boolean spaceBelow = world.isAir(below);
Shape shape = state.get(SHAPE); Shape shape = state.get(SHAPE);
@ -163,7 +158,7 @@ public class BlockGrowingCuccoon extends Block {
} }
@Override @Override
public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return super.canPlaceAt(state, world, pos) && checkSupport(world, pos); return super.canPlaceAt(state, world, pos) && checkSupport(world, pos);
} }
@ -200,7 +195,7 @@ public class BlockGrowingCuccoon extends Block {
PlayerEntity player = (PlayerEntity)living; PlayerEntity player = (PlayerEntity)living;
skull.setTag(new CompoundTag()); skull.setTag(new CompoundTag());
skull.getTag().put("SkullOwner", TagHelper.serializeProfile(new CompoundTag(), player.getGameProfile())); skull.getTag().put("SkullOwner", NbtHelper.fromGameProfile(new CompoundTag(), player.getGameProfile()));
player.dropItem(skull, true); player.dropItem(skull, true);
} else { } else {
living.dropItem(Items.SKELETON_SKULL, 1); living.dropItem(Items.SKELETON_SKULL, 1);
@ -244,7 +239,7 @@ public class BlockGrowingCuccoon extends Block {
@Override @Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(AGE, SHAPE); builder.add(AGE, SHAPE);
} }
@ -264,9 +259,9 @@ public class BlockGrowingCuccoon extends Block {
.offset(offset.x, offset.y, offset.z) .offset(offset.x, offset.y, offset.z)
.getBoundingBox(); .getBoundingBox();
double x = bounds.minX + (bounds.maxX - bounds.minX) * rand.nextFloat(); double x = bounds.x1 + (bounds.x2 - bounds.x1) * rand.nextFloat();
double y = bounds.minY; double y = bounds.y1;
double z = bounds.minZ + (bounds.maxZ - bounds.minZ) * rand.nextFloat(); double z = bounds.z1 + (bounds.z2 - bounds.z1) * rand.nextFloat();
world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0);
} }

View file

@ -11,7 +11,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation; import net.minecraft.util.BlockRotation;
@ -27,7 +27,7 @@ public class ChiselledChitinBlock extends Block {
.materialColor(MaterialColor.BLACK) .materialColor(MaterialColor.BLACK)
.build() .build()
); );
setDefaultState(stateFactory.getDefaultState() setDefaultState(stateManager.getDefaultState()
.with(Properties.FACING, Direction.UP) .with(Properties.FACING, Direction.UP)
); );
} }
@ -49,7 +49,7 @@ public class ChiselledChitinBlock extends Block {
} }
@Override @Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.FACING); builder.add(Properties.FACING);
} }

View file

@ -10,7 +10,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
import net.minecraft.entity.EntityContext; import net.minecraft.entity.EntityContext;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.StringIdentifiable; import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -29,7 +29,7 @@ public class ChitinBlock extends Block {
.materialColor(MaterialColor.BLACK) .materialColor(MaterialColor.BLACK)
.build() .build()
); );
setDefaultState(stateFactory.getDefaultState().with(COVERING, Covering.UNCOVERED)); setDefaultState(stateManager.getDefaultState().with(COVERING, Covering.UNCOVERED));
// TODO: drops: // TODO: drops:
// UItems.chitin_shell x 3 // UItems.chitin_shell x 3
@ -72,7 +72,7 @@ public class ChitinBlock extends Block {
} }
@Override @Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(COVERING); builder.add(COVERING);
} }

View file

@ -16,11 +16,13 @@ import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.DyeItem; import net.minecraft.item.DyeItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DyeColor; import net.minecraft.util.DyeColor;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
@ -48,13 +50,19 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
.build() .build()
); );
setDefaultState(stateFactory.getDefaultState() setDefaultState(stateManager.getDefaultState()
.with(HEAVY, false) .with(HEAVY, false)
.with(DISTANCE, 7) .with(DISTANCE, 7)
.with(PERSISTENT, false) .with(PERSISTENT, false)
); );
} }
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(HEAVY);
}
public FruitLeavesBlock hardy(boolean value) { public FruitLeavesBlock hardy(boolean value) {
hardy = value; hardy = value;
return this; return this;
@ -81,7 +89,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack stack = player.getStackInHand(hand); ItemStack stack = player.getStackInHand(hand);
if (Pony.of(player).getSpecies().canUseEarth()) { if (Pony.of(player).getSpecies().canUseEarth()) {
@ -104,15 +112,15 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
} }
} }
return true; return ActionResult.SUCCESS;
} }
return false; return ActionResult.PASS;
} }
@Override @Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
if (!world.isClient && world.isBlockLoaded(pos) && !state.get(PERSISTENT)) { if (!world.isClient && world.isChunkLoaded(pos) && !state.get(PERSISTENT)) {
int growthChance = getGrowthChance(world, pos, state); int growthChance = getGrowthChance(world, pos, state);
if (!state.get(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) { if (!state.get(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) {
@ -123,7 +131,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
if (state.get(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) { if (state.get(HEAVY) && (growthChance <= 0 || rand.nextInt(growthChance) == 0)) {
dropContents(world, pos, state, 0); dropContents(world, pos, state, 0);
} else { } else {
super.onScheduledTick(state, world, pos, rand); super.scheduledTick(state, world, pos, rand);
} }
} }
} }
@ -132,7 +140,7 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
protected int getGrowthChance(World world, BlockPos pos, BlockState state) { protected int getGrowthChance(World world, BlockPos pos, BlockState state) {
int chance = baseGrowthChance; int chance = baseGrowthChance;
if (!hardy && !world.isDaylight()) { if (!hardy && !world.isDay()) {
chance *= 40; chance *= 40;
} }
@ -169,10 +177,4 @@ public class FruitLeavesBlock extends LeavesBlock implements Colourful {
world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_PLACE, SoundCategory.BLOCKS, 0.3F, 1); world.playSound(null, pos, SoundEvents.ENTITY_ITEM_FRAME_PLACE, SoundCategory.BLOCKS, 0.3F, 1);
world.setBlockState(pos, state.with(HEAVY, false)); world.setBlockState(pos, state.with(HEAVY, false));
} }
@Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(HEAVY);
}
} }

View file

@ -4,7 +4,7 @@ import java.util.Random;
import com.minelittlepony.unicopia.gas.CloudType; import com.minelittlepony.unicopia.gas.CloudType;
import com.minelittlepony.unicopia.gas.Gas; import com.minelittlepony.unicopia.gas.Gas;
import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -16,12 +16,14 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -65,12 +67,17 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
.sounds(BlockSoundGroup.GLASS) .sounds(BlockSoundGroup.GLASS)
.build() .build()
); );
setDefaultState(stateFactory.getDefaultState() setDefaultState(stateManager.getDefaultState()
.with(Properties.FACING, Direction.UP) .with(Properties.FACING, Direction.UP)
.with(ON, true) .with(ON, true)
); );
} }
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(Properties.FACING).add(ON);
}
@Override @Override
public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) {
switch (state.get(Properties.FACING)) { switch (state.get(Properties.FACING)) {
@ -83,7 +90,7 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!state.get(ON)) { if (!state.get(ON)) {
ItemStack held = player.getStackInHand(hand); ItemStack held = player.getStackInHand(hand);
@ -99,10 +106,10 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
} }
} }
return true; return ActionResult.SUCCESS;
} }
return false; return ActionResult.PASS;
} }
@Override @Override
@ -126,7 +133,7 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
if (state.get(ON)) { if (state.get(ON)) {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
world.addParticle(UParticles.UNICORN_MAGIC, world.addParticle(MagicParticleEffect.UNICORN,
x - 0.3, y - 0.3, z - 0.3, x - 0.3, y - 0.3, z - 0.3,
rand.nextFloat(), rand.nextFloat(), rand.nextFloat()); rand.nextFloat(), rand.nextFloat(), rand.nextFloat());
} }
@ -136,7 +143,7 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
} }
@Override @Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random random) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (world.hasRain(pos)) { if (world.hasRain(pos)) {
if (state.get(ON)) { if (state.get(ON)) {
world.playSound(null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); world.playSound(null, pos, SoundEvents.BLOCK_REDSTONE_TORCH_BURNOUT, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
@ -188,9 +195,4 @@ public class GlowingGemBlock extends TorchBlock implements Gas {
return 0; return 0;
} }
@Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
builder.add(Properties.FACING).add(ON);
}
} }

View file

@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.util.shape.Shape;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tools.FabricToolTags;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -22,18 +23,20 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.BlockStateParticleEffect;
import net.minecraft.particle.ParticleTypes; import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.StringIdentifiable; import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.ViewableWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class HiveWallBlock extends FallingBlock { public class HiveWallBlock extends FallingBlock {
@ -42,7 +45,6 @@ public class HiveWallBlock extends FallingBlock {
private static final Shape shape = new Sphere(false, 1.5); private static final Shape shape = new Sphere(false, 1.5);
@SuppressWarnings("deprecation")
public HiveWallBlock() { public HiveWallBlock() {
super(FabricBlockSettings.of(UMaterials.HIVE) super(FabricBlockSettings.of(UMaterials.HIVE)
.noCollision() .noCollision()
@ -51,16 +53,21 @@ public class HiveWallBlock extends FallingBlock {
.ticksRandomly() .ticksRandomly()
.lightLevel(1) .lightLevel(1)
.sounds(BlockSoundGroup.SAND) .sounds(BlockSoundGroup.SAND)
.breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.PICKAXES, 1) .breakByTool(FabricToolTags.PICKAXES, 1)
.build() .build()
); );
setDefaultState(stateFactory.getDefaultState() setDefaultState(stateManager.getDefaultState()
.with(STATE, State.GROWING).with(AXIS, Axis.Y) .with(STATE, State.GROWING).with(AXIS, Axis.Y)
); );
} }
@Override @Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(STATE).add(AXIS);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
if (rand.nextInt(300) == 0) { if (rand.nextInt(300) == 0) {
world.playSound(null, pos, USounds.INSECT, SoundCategory.BLOCKS, 1, 1); world.playSound(null, pos, USounds.INSECT, SoundCategory.BLOCKS, 1, 1);
@ -137,7 +144,7 @@ public class HiveWallBlock extends FallingBlock {
} }
@Override @Override
public int getTickRate(ViewableWorld view) { public int getTickRate(WorldView view) {
return 10; return 10;
} }
@ -200,7 +207,7 @@ public class HiveWallBlock extends FallingBlock {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (hand == Hand.MAIN_HAND && player.getStackInHand(hand).isEmpty()) { if (hand == Hand.MAIN_HAND && player.getStackInHand(hand).isEmpty()) {
Pony iplayer = Pony.of(player); Pony iplayer = Pony.of(player);
@ -214,11 +221,11 @@ public class HiveWallBlock extends FallingBlock {
} }
}); });
return true; return ActionResult.SUCCESS;
} }
} }
return false; return ActionResult.PASS;
} }
@Override @Override
@ -257,7 +264,7 @@ public class HiveWallBlock extends FallingBlock {
} }
protected boolean canSpreadInto(World world, BlockPos pos, Axis axis) { protected boolean canSpreadInto(World world, BlockPos pos, Axis axis) {
if (world.isBlockLoaded(pos) && isEmptySpace(world, pos)) { if (world.isChunkLoaded(pos) && isEmptySpace(world, pos)) {
boolean one = false; boolean one = false;
for (Direction facing : axis.getFacings()) { for (Direction facing : axis.getFacings()) {
@ -277,11 +284,6 @@ public class HiveWallBlock extends FallingBlock {
return false; return false;
} }
@Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
builder.add(STATE).add(AXIS);
}
public enum State implements StringIdentifiable { public enum State implements StringIdentifiable {
GROWING, GROWING,
STABLE, STABLE,

View file

@ -1,7 +1,6 @@
package com.minelittlepony.unicopia.block; package com.minelittlepony.unicopia.block;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
@ -23,11 +22,6 @@ public class SlimeLayerBlock extends SnowBlock {
// TODO: drops Items.SLIME_BALL x1 // TODO: drops Items.SLIME_BALL x1
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public void onSteppedOn(World world, BlockPos pos, Entity entity) { public void onSteppedOn(World world, BlockPos pos, Entity entity) {
float factor = getMotionFactor(world.getBlockState(pos)); float factor = getMotionFactor(world.getBlockState(pos));

View file

@ -2,7 +2,6 @@ package com.minelittlepony.unicopia.block;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock; import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.Material; import net.minecraft.block.Material;
@ -12,6 +11,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.item.LeadItem; import net.minecraft.item.LeadItem;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -20,8 +20,8 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.ViewableWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class StickBlock extends Block { public class StickBlock extends Block {
@ -43,11 +43,6 @@ public class StickBlock extends Block {
// TODO: drops Items.STICK x1 // TODO: drops Items.STICK x1
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Deprecated @Deprecated
@Override @Override
public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) {
@ -61,18 +56,21 @@ public class StickBlock extends Block {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient) { if (!world.isClient) {
return LeadItem.attachHeldMobsToBlock(player, world, pos); return LeadItem.attachHeldMobsToBlock(player, world, pos);
} }
ItemStack stack = player.getStackInHand(hand); ItemStack stack = player.getStackInHand(hand);
return stack.getItem() == Items.LEAD || stack.isEmpty(); if (stack.getItem() == Items.LEAD || stack.isEmpty()) {
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
} }
@Override @Override
public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Block block = state.getBlock(); Block block = state.getBlock();
return block instanceof StickBlock || block instanceof FarmlandBlock; return block instanceof StickBlock || block instanceof FarmlandBlock;

View file

@ -12,7 +12,8 @@ import net.minecraft.block.CropBlock;
import net.minecraft.entity.EntityContext; import net.minecraft.entity.EntityContext;
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.state.StateFactory; import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.IntProperty; import net.minecraft.state.property.IntProperty;
import net.minecraft.util.StringIdentifiable; import net.minecraft.util.StringIdentifiable;
@ -21,8 +22,8 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes; import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.ViewableWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class TallCropBlock extends CropBlock { public class TallCropBlock extends CropBlock {
@ -53,6 +54,11 @@ public class TallCropBlock extends CropBlock {
setDefaultState(getDefaultState().with(HALF, Half.BOTTOM)); setDefaultState(getDefaultState().with(HALF, Half.BOTTOM));
} }
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(AGE, HALF);
}
@Override @Override
public OffsetType getOffsetType() { public OffsetType getOffsetType() {
return OffsetType.XZ; return OffsetType.XZ;
@ -74,8 +80,8 @@ public class TallCropBlock extends CropBlock {
} }
@Override @Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
if (rand.nextInt(10) != 0 && world.isBlockLoaded(pos) && world.getLightLevel(pos.up()) >= 9) { if (rand.nextInt(10) != 0 && world.isChunkLoaded(pos) && world.getLightLevel(pos.up()) >= 9) {
if (canGrow(world, rand, pos, state)) { if (canGrow(world, rand, pos, state)) {
growUpwards(world, pos, state, 1); growUpwards(world, pos, state, 1);
} }
@ -123,7 +129,7 @@ public class TallCropBlock extends CropBlock {
} }
@Override @Override
public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return getHalf(state) != Half.BOTTOM || super.canPlaceAt(state, world, pos); return getHalf(state) != Half.BOTTOM || super.canPlaceAt(state, world, pos);
} }
@ -160,11 +166,6 @@ public class TallCropBlock extends CropBlock {
return super.getGrowthAmount(world) / 2; return super.getGrowthAmount(world) / 2;
} }
@Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
builder.add(AGE, HALF);
}
@Override @Override
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
if (getHalf(state) != Half.MIDDLE) { if (getHalf(state) != Half.MIDDLE) {

View file

@ -15,10 +15,12 @@ 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.item.Items; import net.minecraft.item.Items;
import net.minecraft.loot.context.LootContext;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateFactory; import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.StringIdentifiable; import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
@ -26,9 +28,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.ViewableWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.loot.context.LootContext; import net.minecraft.world.WorldView;
public class TomatoPlantBlock extends CropBlock { public class TomatoPlantBlock extends CropBlock {
@ -49,6 +50,12 @@ public class TomatoPlantBlock extends CropBlock {
// if mature: UItems.tomato // if mature: UItems.tomato
} }
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(TYPE);
}
@Deprecated @Deprecated
@Override @Override
public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) { public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) {
@ -56,12 +63,6 @@ public class TomatoPlantBlock extends CropBlock {
return StickBlock.BOUNDING_BOX.offset(off.x, off.y, off.z); return StickBlock.BOUNDING_BOX.offset(off.x, off.y, off.z);
} }
@Override
protected void appendProperties(StateFactory.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(TYPE);
}
@Override @Override
public Block.OffsetType getOffsetType() { public Block.OffsetType getOffsetType() {
return Block.OffsetType.XZ; return Block.OffsetType.XZ;
@ -73,7 +74,7 @@ public class TomatoPlantBlock extends CropBlock {
} }
@Override @Override
public boolean canPlaceAt(BlockState state, ViewableWorld world, BlockPos pos) { public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (world.getBlockState(pos.down()).getBlock() instanceof TomatoPlantBlock) { if (world.getBlockState(pos.down()).getBlock() instanceof TomatoPlantBlock) {
return true; return true;
} }
@ -106,7 +107,7 @@ public class TomatoPlantBlock extends CropBlock {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (hand == Hand.MAIN_HAND && isMature(state)) { if (hand == Hand.MAIN_HAND && isMature(state)) {
if (player.getStackInHand(hand).isEmpty()) { if (player.getStackInHand(hand).isEmpty()) {
@ -126,11 +127,11 @@ public class TomatoPlantBlock extends CropBlock {
world.setBlockState(pos, state.with(getAgeProperty(), 0)); world.setBlockState(pos, state.with(getAgeProperty(), 0));
return true; return ActionResult.SUCCESS;
} }
} }
return false; return ActionResult.PASS;
} }
@Override @Override

View file

@ -24,9 +24,9 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
public interface UBlocks { public interface UBlocks {
CloudBlock normal_cloud = register(new CloudBlock(UMaterials.CLOUD, CloudType.NORMAL), "cloud_block"); CloudBlock normal_cloud = register(new CloudBlock(CloudType.NORMAL), "cloud_block");
CloudBlock enchanted_cloud = register(new CloudBlock(UMaterials.CLOUD, CloudType.ENCHANTED), "enchanted_cloud_block"); CloudBlock enchanted_cloud = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block");
CloudBlock packed_cloud = register(new CloudBlock(UMaterials.CLOUD, CloudType.PACKED), "packed_cloud_block"); CloudBlock packed_cloud = register(new CloudBlock(CloudType.PACKED), "packed_cloud_block");
CloudStairsBlock cloud_stairs = register(new CloudStairsBlock(normal_cloud.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs"); CloudStairsBlock cloud_stairs = register(new CloudStairsBlock(normal_cloud.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs");
@ -43,7 +43,7 @@ public interface UBlocks {
CloudAnvilBlock anvil = register(new CloudAnvilBlock(), "anvil"); CloudAnvilBlock anvil = register(new CloudAnvilBlock(), "anvil");
CloudFenceBlock cloud_fence = register(new CloudFenceBlock(UMaterials.CLOUD, CloudType.NORMAL), "cloud_fence"); CloudFenceBlock cloud_fence = register(new CloudFenceBlock(CloudType.NORMAL), "cloud_fence");
TallCropBlock alfalfa = register(new TallCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).build()), "alfalfa"); TallCropBlock alfalfa = register(new TallCropBlock(FabricBlockSettings.of(Material.PLANT).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).build()), "alfalfa");

View file

@ -3,12 +3,12 @@ package com.minelittlepony.unicopia.block;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SlabBlock; import net.minecraft.block.SlabBlock;
import net.minecraft.block.enums.SlabType; import net.minecraft.block.enums.SlabType;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -37,20 +37,9 @@ public abstract class USlab<T extends Block> extends SlabBlock {
return state.get(TYPE) == SlabType.DOUBLE; return state.get(TYPE) == SlabType.DOUBLE;
} }
@Deprecated
@Override @Override
public boolean isOpaque(BlockState state) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
return isDouble(state) && modelBlock != null && modelBlock.isOpaque(state); modelBlock.scheduledTick(state, world, pos, rand);
}
@Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) {
modelBlock.onScheduledTick(state, world, pos, rand);
}
@Override
public BlockRenderLayer getRenderLayer() {
return modelBlock.getRenderLayer();
} }
@Override @Override

View file

@ -1,39 +1,39 @@
package com.minelittlepony.unicopia.client; package com.minelittlepony.unicopia.client;
import com.minelittlepony.unicopia.client.particle.ChangelingMagicParticle;
import com.minelittlepony.unicopia.client.particle.DiskParticle;
import com.minelittlepony.unicopia.client.particle.MagicParticle;
import com.minelittlepony.unicopia.client.particle.RaindropsParticle;
import com.minelittlepony.unicopia.client.particle.SphereParticle;
import com.minelittlepony.unicopia.client.render.ButterflyEntityRenderer; import com.minelittlepony.unicopia.client.render.ButterflyEntityRenderer;
import com.minelittlepony.unicopia.client.render.CloudEntityRenderer; import com.minelittlepony.unicopia.client.render.CloudEntityRenderer;
import com.minelittlepony.unicopia.client.render.CuccoonEntityRenderer; import com.minelittlepony.unicopia.client.render.CuccoonEntityRenderer;
import com.minelittlepony.unicopia.client.render.RainbowEntityRenderer; import com.minelittlepony.unicopia.client.render.RainbowEntityRenderer;
import com.minelittlepony.unicopia.client.render.SpearEntityRenderer; import com.minelittlepony.unicopia.client.render.SpearEntityRenderer;
import com.minelittlepony.unicopia.client.render.RenderSpellbook; import com.minelittlepony.unicopia.client.render.SpellbookEntityRender;
import com.minelittlepony.unicopia.client.render.SpellcastEntityRenderer; import com.minelittlepony.unicopia.client.render.SpellcastEntityRenderer;
import com.minelittlepony.unicopia.entity.ButterflyEntity; import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.entity.CloudEntity; import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.entity.CuccoonEntity;
import com.minelittlepony.unicopia.entity.ProjectileEntity; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import com.minelittlepony.unicopia.entity.RainbowEntity; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import com.minelittlepony.unicopia.entity.SpearEntity;
import com.minelittlepony.unicopia.entity.SpellbookEntity;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
import net.minecraft.client.render.entity.FlyingItemEntityRenderer; import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
public interface URenderers { public interface URenderers {
static void bootstrap() { static void bootstrap() {
EntityRendererRegistry.INSTANCE.register(CloudEntity.class, CloudEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.CLOUD, CloudEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(SpellcastEntity.class, SpellcastEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.MAGIC_SPELL, SpellcastEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(ProjectileEntity.class, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer())); EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer()));
EntityRendererRegistry.INSTANCE.register(SpellbookEntity.class, RenderSpellbook::new); EntityRendererRegistry.INSTANCE.register(UEntities.SPELLBOOK, SpellbookEntityRender::new);
EntityRendererRegistry.INSTANCE.register(RainbowEntity.class, RainbowEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.RAINBOW, RainbowEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(ButterflyEntity.class, ButterflyEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.BUTTERFLY, ButterflyEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(CuccoonEntity.class, CuccoonEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.CUCCOON, CuccoonEntityRenderer::new);
EntityRendererRegistry.INSTANCE.register(SpearEntity.class, SpearEntityRenderer::new); EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_SPEAR, SpearEntityRenderer::new);
// TODO: ParticleFactoryRegistry ParticleFactoryRegistry.getInstance().register(UParticles.UNICORN_MAGIC, MagicParticle.Factory::new);
//ParticleFactoryRegistry.instance().register(UParticles.UNICORN_MAGIC, MagicParticle::new); ParticleFactoryRegistry.getInstance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle.Factory::new);
//ParticleFactoryRegistry.instance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle::new); ParticleFactoryRegistry.getInstance().register(UParticles.RAIN_DROPS, RaindropsParticle.Factory::new);
//ParticleFactoryRegistry.instance().register(UParticles.RAIN_DROPS, RaindropsParticle::new); ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle.Factory::new);
//ParticleFactoryRegistry.instance().register(UParticles.SPHERE, SphereParticle::new); ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle.Factory::new);
//ParticleFactoryRegistry.instance().register(UParticles.DISK, DiskParticle::new);
} }
} }

View file

@ -13,7 +13,6 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.ability.Abilities; import com.minelittlepony.unicopia.ability.Abilities;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.client.render.DisguiseRenderer;
import com.minelittlepony.unicopia.ducks.Colourful; import com.minelittlepony.unicopia.ducks.Colourful;
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;
@ -21,10 +20,8 @@ import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.minelittlepony.unicopia.network.MsgRequestCapabilities; import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity; import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.blaze3d.platform.GlStateManager;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.render.ColorProviderRegistry; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.event.client.ClientTickCallback; import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -36,7 +33,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ExtendedBlockView; import net.minecraft.world.BlockRenderView;
public class UnicopiaClient extends InteractionManager implements ClientModInitializer { public class UnicopiaClient extends InteractionManager implements ClientModInitializer {
@ -52,6 +49,45 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
*/ */
private static Race clientPlayerRace = getclientPlayerRace(); private static Race clientPlayerRace = getclientPlayerRace();
@Override
public void onInitializeClient() {
clientPlayerRace = getclientPlayerRace();
InteractionManager.instance = this;
ClientTickCallback.EVENT.register(this::tick);
ClientReadyCallback.EVENT.register(client -> {
Abilities.getInstance().getValues().forEach(keyboard::addKeybind);
});
//BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem"));
ColorProviderRegistry.ITEM.register((stack, tint) -> {
return getLeavesColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tint);
}, UItems.apple_leaves);
ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.apple_leaves);
ColorProviderRegistry.ITEM.register((stack, tint) -> {
if (MAGI.test(MinecraftClient.getInstance().player)) {
return SpellRegistry.instance().getSpellTintFromStack(stack);
}
return 0xFFFFFF;
}, UItems.spell, UItems.curse);
}
private void tick(MinecraftClient client) {
PlayerEntity player = client.player;
if (player != null && !player.removed) {
Race newRace = getclientPlayerRace();
if (newRace != clientPlayerRace) {
clientPlayerRace = newRace;
Unicopia.getConnection().send(new MsgRequestCapabilities(player, clientPlayerRace), Target.SERVER);
}
}
keyboard.onKeyInput();
}
private static Race getclientPlayerRace() { private static Race getclientPlayerRace() {
if (!Config.getInstance().ignoresMineLittlePony() if (!Config.getInstance().ignoresMineLittlePony()
&& MinecraftClient.getInstance().player != null) { && MinecraftClient.getInstance().player != null) {
@ -93,72 +129,7 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
return MinecraftClient.getInstance().options.perspective; return MinecraftClient.getInstance().options.perspective;
} }
public void postRenderEntity(Entity entity) { private static int getLeavesColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tint) {
if (entity instanceof PlayerEntity) {
Pony iplayer = Pony.of((PlayerEntity)entity);
if (iplayer.getGravity().getGravitationConstant() < 0) {
GlStateManager.translated(0, entity.getDimensions(entity.getPose()).height, 0);
GlStateManager.scalef(1, -1, 1);
entity.prevPitch *= -1;
entity.pitch *= -1;
}
}
}
public boolean renderEntity(Entity entity, float renderPartialTicks) {
if (DisguiseRenderer.getInstance().renderDisguise(entity, renderPartialTicks)) {
return true;
}
if (entity instanceof PlayerEntity) {
Pony iplayer = Pony.of((PlayerEntity)entity);
if (iplayer.getGravity().getGravitationConstant() < 0) {
GlStateManager.scalef(1, -1, 1);
GlStateManager.translated(0, -entity.getDimensions(entity.getPose()).height, 0);
entity.prevPitch *= -1;
entity.pitch *= -1;
}
if (DisguiseRenderer.getInstance().renderDisguiseToGui(iplayer)) {
return true;
}
if (iplayer.isInvisible()) {
return true;
}
}
return false;
}
@Override
public void onInitializeClient() {
clientPlayerRace = getclientPlayerRace();
InteractionManager.instance = this;
ClientTickCallback.EVENT.register(this::tick);
ClientReadyCallback.EVENT.register(client -> {
Abilities.getInstance().getValues().forEach(keyboard::addKeybind);
});
//BuildInTexturesBakery.getBuiltInTextures().add(new Identifier(Unicopia.MODID, "items/empty_slot_gem"));
ColorProviderRegistry.ITEM.register((stack, tint) -> {
return getLeavesColor(((BlockItem)stack.getItem()).getBlock().getDefaultState(), null, null, tint);
}, UItems.apple_leaves);
ColorProviderRegistry.BLOCK.register(UnicopiaClient::getLeavesColor, UBlocks.apple_leaves);
ColorProviderRegistry.ITEM.register((stack, tint) -> {
if (MAGI.test(MinecraftClient.getInstance().player)) {
return SpellRegistry.instance().getSpellTintFromStack(stack);
}
return 0xFFFFFF;
}, UItems.spell, UItems.curse);
}
private static int getLeavesColor(BlockState state, @Nullable ExtendedBlockView world, @Nullable BlockPos pos, int tint) {
Block block = state.getBlock(); Block block = state.getBlock();
if (block instanceof Colourful) { if (block instanceof Colourful) {
@ -172,19 +143,4 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
return GrassColors.getColor(0.5D, 1); return GrassColors.getColor(0.5D, 1);
} }
private void tick(MinecraftClient client) {
PlayerEntity player = client.player;
if (player != null && !player.removed) {
Race newRace = getclientPlayerRace();
if (newRace != clientPlayerRace) {
clientPlayerRace = newRace;
Unicopia.getConnection().send(new MsgRequestCapabilities(player, clientPlayerRace), Target.SERVER);
}
}
keyboard.onKeyInput();
}
} }

View file

@ -2,20 +2,16 @@ package com.minelittlepony.unicopia.client.gui;
import com.minelittlepony.unicopia.client.gui.UHud; import com.minelittlepony.unicopia.client.gui.UHud;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@Deprecated @Deprecated
// TODO: forge events // TODO: forge events
class ClientHooks { class ClientHooks {
public static void beforePreRenderHud() { public static void beforePreRenderHud() {
GlStateManager.pushMatrix();
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.world != null) { if (client.player != null && client.world != null) {
UHud.instance.repositionElements(Pony.of(client.player), client.window, true); UHud.instance.repositionElements(Pony.of(client.player), client.getWindow(), true);
} }
} }
@ -24,9 +20,7 @@ class ClientHooks {
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null && client.world != null) { if (client.player != null && client.world != null) {
UHud.instance.renderHud(Pony.of(client.player), client.window); UHud.instance.renderHud(Pony.of(client.player), client.getWindow());
} }
GlStateManager.popMatrix();
} }
} }

View file

@ -5,7 +5,7 @@ import net.fabricmc.api.Environment;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.SpriteProvider; import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.particle.DustParticleEffect; import net.minecraft.particle.DefaultParticleType;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ChangelingMagicParticle extends MagicParticle { public class ChangelingMagicParticle extends MagicParticle {
@ -31,7 +31,7 @@ public class ChangelingMagicParticle extends MagicParticle {
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DustParticleEffect> { public static class Factory implements ParticleFactory<DefaultParticleType> {
private final SpriteProvider provider; private final SpriteProvider provider;
public Factory(SpriteProvider provider) { public Factory(SpriteProvider provider) {
@ -39,7 +39,7 @@ public class ChangelingMagicParticle extends MagicParticle {
} }
@Override @Override
public Particle createParticle(DustParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) { public Particle createParticle(DefaultParticleType effect, World world, double x, double y, double z, double dx, double dy, double dz) {
MagicParticle particle = new MagicParticle(world, x, y, z, dx, dy, dz); MagicParticle particle = new MagicParticle(world, x, y, z, dx, dy, dz);
particle.setSprite(provider); particle.setSprite(provider);
return particle; return particle;

View file

@ -1,28 +1,28 @@
package com.minelittlepony.unicopia.client.particle; package com.minelittlepony.unicopia.client.particle;
import net.minecraft.client.render.BufferBuilder; import com.minelittlepony.unicopia.client.render.model.DiskModel;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera; import net.minecraft.client.render.Camera;
import net.minecraft.particle.ParticleEffect; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.lwjgl.opengl.GL14;
import com.minelittlepony.unicopia.client.render.DiskModel;
import com.mojang.blaze3d.platform.GlStateManager;
public class DiskParticle extends SphereParticle { public class DiskParticle extends SphereParticle {
private static final DiskModel model = new DiskModel(); private static final DiskModel model = new DiskModel();
protected double rotX; protected float rotX;
protected double rotY; protected float rotY;
protected double rotZ; protected float rotZ;
public DiskParticle(ParticleEffect type, World w, public DiskParticle(World w,
double x, double y, double z, double x, double y, double z,
float radius, float radius,
int red, int green, int blue, float alpha, int red, int green, int blue, float alpha,
double rX, double rY, double rZ) { float rX, float rY, float rZ) {
super(w, x, y, z, radius, red, green, blue, alpha); super(w, x, y, z, radius, red, green, blue, alpha);
rotX = rX; rotX = rX;
@ -31,17 +31,17 @@ public class DiskParticle extends SphereParticle {
} }
@Override @Override
public void buildGeometry(BufferBuilder buffer, Camera viewer, float partialTicks, float x, float z, float yz, float xy, float xz) { public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
if (alpha <= 0) { if (alpha <= 0) {
return; return;
} }
GL14.glBlendColor(red, green, blue, alpha); MatrixStack matrices = new MatrixStack();
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
model.setPosition(this.x, this.y, this.z); model.setPosition(x, y, z);
model.render(radius); model.setRotation(rotX, rotY, rotZ);
model.render(matrices, radius, immediate.getBuffer(RenderLayer.getTranslucent()), 1, 1, red, green, blue, alpha);
GlStateManager.color4f(1, 1, 1, 1); immediate.draw();
} }
} }

View file

@ -1,13 +1,14 @@
package com.minelittlepony.unicopia.client.particle; package com.minelittlepony.unicopia.client.particle;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.particle.v1.FabricSpriteProvider;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.particle.SpriteBillboardParticle; import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.particle.DustParticleEffect;
import net.minecraft.world.World; import net.minecraft.world.World;
public class MagicParticle extends SpriteBillboardParticle { public class MagicParticle extends SpriteBillboardParticle {
@ -96,16 +97,16 @@ public class MagicParticle extends SpriteBillboardParticle {
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DustParticleEffect> { public static class Factory implements ParticleFactory<MagicParticleEffect> {
private final SpriteProvider provider; private final FabricSpriteProvider provider;
public Factory(SpriteProvider provider) { public Factory(FabricSpriteProvider provider) {
this.provider = provider; this.provider = provider;
} }
@Override @Override
public Particle createParticle(DustParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) { public Particle createParticle(MagicParticleEffect effect, World world, double x, double y, double z, double dx, double dy, double dz) {
MagicParticle particle = effect.getAlpha() > 0 ? MagicParticle particle = effect.hasTint() ?
new MagicParticle(world, x, y, z, dx, dy, dz, effect.getRed(), effect.getGreen(), effect.getBlue()) new MagicParticle(world, x, y, z, dx, dy, dz, effect.getRed(), effect.getGreen(), effect.getBlue())
: new MagicParticle(world, x, y, z, dx, dy, dz); : new MagicParticle(world, x, y, z, dx, dy, dz);
particle.setSprite(provider); particle.setSprite(provider);

View file

@ -5,20 +5,18 @@ import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory; import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.ParticleTextureSheet; import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.particle.SpriteProvider; import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Camera; import net.minecraft.client.render.Camera;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType; import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.lwjgl.opengl.GL11; import com.minelittlepony.unicopia.client.render.model.SphereModel;
import org.lwjgl.opengl.GL14;
import com.minelittlepony.unicopia.client.render.SphereModel;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.particles.ParticleConnection.AttachableParticle; import com.minelittlepony.unicopia.particles.ParticleConnection.AttachableParticle;
import com.mojang.blaze3d.platform.GlStateManager;
public class SphereParticle extends Particle implements AttachableParticle { public class SphereParticle extends Particle implements AttachableParticle {
@ -33,11 +31,7 @@ public class SphereParticle extends Particle implements AttachableParticle {
private static final SphereModel model = new SphereModel(); private static final SphereModel model = new SphereModel();
public SphereParticle(ParticleEffect type, World w, public SphereParticle(World w, double x, double y, double z, float radius, int red, int green, int blue, float alpha, double vX, double vY, double vZ) {
double x, double y, double z,
float radius,
int red, int green, int blue, float alpha,
double vX, double vY, double vZ) {
this(w, x, y, z, radius, red, green, blue, alpha); this(w, x, y, z, radius, red, green, blue, alpha);
this.velocityX = vX; this.velocityX = vX;
@ -68,66 +62,6 @@ public class SphereParticle extends Particle implements AttachableParticle {
this.caster = caster; this.caster = caster;
} }
@Override
public ParticleTextureSheet getType() {
// TODO Auto-generated method stub
return null;
}
@Override
public void tick() {
super.tick();
if (caster != null) {
if (!caster.hasEffect() || caster.getEffect().isDead() || caster.getEntity().removed) {
markDead();
} else {
Entity e = caster.getEntity();
if (caster.getWorld().getEntityById(e.getEntityId()) == null) {
markDead();
}
setPos(e.x, e.y, e.z);
}
} else {
radius *= 0.9998281;
}
}
@Override
public void buildGeometry(BufferBuilder buffer, Camera viewer, float partialTicks, float x, float z, float yz, float xy, float xz) {
if (alpha <= 0 || radius <= 0) {
return;
}
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GlStateManager.depthMask(false);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.enableAlphaTest();
GlStateManager.enableBlend();
MinecraftClient.getInstance().gameRenderer.disableLightmap();
GlStateManager.enableLighting();
GL14.glBlendColor(red, green, blue, alpha);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.disableTexture();
model.setPosition(this.x, this.y, this.z);
model.render(radius);
GlStateManager.enableTexture();
GlStateManager.disableLighting();
MinecraftClient.getInstance().gameRenderer.enableLightmap();
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.color4f(1, 1, 1, 1);
GL11.glPopAttrib();
}
@Override @Override
public void setAttribute(int key, Object value) { public void setAttribute(int key, Object value) {
if (key == 0) { if (key == 0) {
@ -147,6 +81,45 @@ public class SphereParticle extends Particle implements AttachableParticle {
} }
} }
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.CUSTOM;
}
@Override
public void tick() {
super.tick();
if (caster != null) {
if (!caster.hasEffect() || caster.getEffect().isDead() || caster.getEntity().removed) {
markDead();
} else {
Entity e = caster.getEntity();
if (caster.getWorld().getEntityById(e.getEntityId()) == null) {
markDead();
}
setPos(e.getX(), e.getY(), e.getZ());
}
} else {
radius *= 0.9998281;
}
}
@Override
public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float tickDelta) {
if (alpha <= 0 || radius <= 0) {
return;
}
MatrixStack matrices = new MatrixStack();
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
model.setPosition(x, y, z);
model.render(matrices, radius, immediate.getBuffer(RenderLayer.getTranslucent()), 1, 1, red, green, blue, alpha);
immediate.draw();
}
public static class Factory implements ParticleFactory<DefaultParticleType> { public static class Factory implements ParticleFactory<DefaultParticleType> {
private final SpriteProvider provider; private final SpriteProvider provider;
@ -155,7 +128,7 @@ public class SphereParticle extends Particle implements AttachableParticle {
} }
@Override @Override
public Particle createParticle(DefaultParticleType defaultParticleType_1, World world, double x, double y, double z, double dx, double dy, double dz) { public Particle createParticle(DefaultParticleType type, World world, double x, double y, double z, double dx, double dy, double dz) {
RaindropsParticle particle = new RaindropsParticle(world, x, y, z, dx, dy, dz); RaindropsParticle particle = new RaindropsParticle(world, x, y, z, dx, dy, dz);
particle.setSprite(provider); particle.setSprite(provider);
return particle; return particle;

View file

@ -2,11 +2,11 @@ package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.client.render.model.ButterflyEntityModel; import com.minelittlepony.unicopia.client.render.model.ButterflyEntityModel;
import com.minelittlepony.unicopia.entity.ButterflyEntity; import com.minelittlepony.unicopia.entity.ButterflyEntity;
import com.mojang.blaze3d.platform.GlStateManager;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -17,22 +17,22 @@ public class ButterflyEntityRenderer extends LivingEntityRenderer<ButterflyEntit
} }
@Override @Override
protected Identifier getTexture(ButterflyEntity entity) { public Identifier getTexture(ButterflyEntity entity) {
return entity.getVariety().getSkin(); return entity.getVariety().getSkin();
} }
@Override @Override
protected void scale(ButterflyEntity entity, float ticks) { protected void scale(ButterflyEntity entity, MatrixStack matrixStack, float ticks) {
GlStateManager.scalef(0.35F, 0.35F, 0.35F); matrixStack.scale(0.35F, 0.35F, 0.35F);
} }
@Override @Override
protected void setupTransforms(ButterflyEntity entity, float age, float yaw, float ticks) { protected void setupTransforms(ButterflyEntity entity, MatrixStack matrixStack, float age, float yaw, float ticks) {
if (!entity.isResting()) { if (!entity.isResting()) {
GlStateManager.translated(0, MathHelper.cos(age / 3F) / 10F, 0); matrixStack.translate(0, MathHelper.cos(age / 3F) / 10F, 0);
} }
super.setupTransforms(entity, age, yaw, ticks); super.setupTransforms(entity, matrixStack, age, yaw, ticks);
} }
} }

View file

@ -1,8 +1,10 @@
package com.minelittlepony.unicopia.client.render; package com.minelittlepony.unicopia.client.render;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -21,18 +23,18 @@ public class CloudEntityRenderer extends LivingEntityRenderer<CloudEntity, Cloud
} }
@Override @Override
public void scale(CloudEntity entity, float par2) { public void scale(CloudEntity entity, MatrixStack matrixStack, float par2) {
float scale = entity.getCloudSize(); float scale = entity.getCloudSize();
GL11.glScalef(scale, scale, scale); matrixStack.scale(scale, scale, scale);
} }
@Override @Override
protected void render(CloudEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) { public void render(CloudEntity entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
if (!entity.removed) { if (!entity.removed) {
GlStateManager.pushMatrix(); matrixStack.push();
GlStateManager.translatef(0, -entity.getHeight()/entity.getCloudSize() + 0.3F, 0); matrixStack.translate(0, -entity.getHeight()/entity.getCloudSize() + 0.3F, 0);
GlStateManager.disableLighting(); GlStateManager.disableLighting();
GlStateManager.enableBlend(); GlStateManager.enableBlend();
@ -43,18 +45,18 @@ public class CloudEntityRenderer extends LivingEntityRenderer<CloudEntity, Cloud
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor); super.render(entity, f, g, matrixStack, vertexConsumerProvider, i);
GlStateManager.disableBlend(); GlStateManager.disableBlend();
GlStateManager.enableLighting(); GlStateManager.enableLighting();
GlStateManager.color4f(1, 1, 1, 1); GlStateManager.color4f(1, 1, 1, 1);
GlStateManager.popMatrix(); matrixStack.pop();
} }
} }
@Override @Override
protected Identifier getTexture(CloudEntity entity) { public Identifier getTexture(CloudEntity entity) {
if (entity.getIsRaining() && entity.getIsThundering()) { if (entity.getIsRaining() && entity.getIsThundering()) {
return rainCloud; return rainCloud;
} }

View file

@ -4,12 +4,14 @@ import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.client.render.model.CuccoonEntityModel; import com.minelittlepony.unicopia.client.render.model.CuccoonEntityModel;
import com.minelittlepony.unicopia.entity.CuccoonEntity; import com.minelittlepony.unicopia.entity.CuccoonEntity;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -22,7 +24,7 @@ public class CuccoonEntityRenderer extends LivingEntityRenderer<CuccoonEntity, C
} }
@Override @Override
protected Identifier getTexture(CuccoonEntity entity) { public Identifier getTexture(CuccoonEntity entity) {
return TEXTURE; return TEXTURE;
} }
@ -32,22 +34,21 @@ public class CuccoonEntityRenderer extends LivingEntityRenderer<CuccoonEntity, C
} }
@Override @Override
public void render(CuccoonEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { public void render(CuccoonEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) {
if (entity.hasPassengers()) { if (entity.hasPassengers()) {
Entity rider = entity.getPrimaryPassenger(); Entity rider = entity.getPrimaryPassenger();
if (!(rider == MinecraftClient.getInstance().player) || InteractionManager.instance().getViewMode() != 0) { if (!(rider == MinecraftClient.getInstance().player) || InteractionManager.instance().getViewMode() != 0) {
GlStateManager.enableAlphaTest(); RenderSystem.enableAlphaTest();
GlStateManager.enableBlend(); RenderSystem.enableBlend();
renderManager.render(rider, x, y + rider.getMountedHeightOffset(), z, entityYaw, partialTicks, true); renderManager.render(rider, rider.getX(), rider.getY() + rider.getMountedHeightOffset(), rider.getZ(), rider.yaw, tickDelta, matrices, vertices, light);
GlStateManager.disableBlend(); RenderSystem.disableBlend();
GlStateManager.disableAlphaTest(); RenderSystem.disableAlphaTest();
} }
} }
super.render(entity, x, y, z, entityYaw, partialTicks); super.render(entity, yaw, tickDelta, matrices, vertices, light);
} }
} }

View file

@ -1,83 +0,0 @@
package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.spell.DisguiseSpell;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.entity.Entity;
public class DisguiseRenderer {
private static final DisguiseRenderer INSTANCE = new DisguiseRenderer();
public static DisguiseRenderer getInstance() {
return INSTANCE;
}
private final MinecraftClient mc = MinecraftClient.getInstance();
private boolean rendering;
public boolean renderDisguise(Entity entity, float usedPartialTick) {
EntityRenderDispatcher renderMan = mc.getEntityRenderManager();
if (rendering) {
renderMan.setRenderShadows(true);
renderStaticDisguise(renderMan, entity);
renderMan.setRenderShadows(false);
return true;
} else {
renderMan.setRenderShadows(renderMan.shouldRenderShadows() || usedPartialTick != 1);
}
return false;
}
protected void renderStaticDisguise(EntityRenderDispatcher renderMan, Entity entity) {
Entity observer = mc.getCameraEntity();
double x = entity.x - observer.x;
double y = entity.y - observer.y;
double z = entity.z - observer.z;
renderDisguise(renderMan, entity, x, y, z);
}
public boolean renderDisguiseToGui(Pony player) {
DisguiseSpell effect = player.getEffect(DisguiseSpell.class, false);
if (effect == null || effect.isDead()) {
return false;
}
EntityRenderDispatcher renderMan = mc.getEntityRenderManager();
if (renderMan.shouldRenderShadows()) {
return false;
}
Entity e = effect.getDisguise();
// Check for a disguise and render it in our place.
if (e != null) {
effect.update(player);
e.setCustomNameVisible(false);
e.setInvisible(false);
e.y = player.getOwner().y;
renderDisguise(renderMan, e, 0, 0, 0);
}
return true;
}
protected void renderDisguise(EntityRenderDispatcher renderMan, Entity entity, double x, double y, double z) {
rendering = false;
renderMan.render(entity, x, y, z, 0, 1, false);
rendering = true;
}
}

View file

@ -1,14 +0,0 @@
package com.minelittlepony.unicopia.client.render;
public class DiskModel extends SphereModel {
@Override
protected void drawShape() {
/* Disk sphere = new Disk();
sphere.setDrawStyle(GLU.GLU_FILL);
sphere.setNormals(GL.GLU_SMOOTH);
sphere.draw(0, 1, 32, 32);*/
// TODO: GLU Disk
}
}

View file

@ -1,32 +0,0 @@
package com.minelittlepony.unicopia.client.render;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.model.Box;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.model.Quad;
import net.minecraft.client.model.Vertex;
import net.minecraft.client.render.BufferBuilder;
public class ModelQuads extends Box {
public ModelQuads(Cuboid renderer) {
super(renderer, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}
protected List<Quad> quadList = new ArrayList<>();
public ModelQuads addFace(Vertex... vertices) {
quadList.add(new TexturedShape2d(vertices));
return this;
}
@Override
public void render(BufferBuilder renderer, float scale) {
for (Quad i : quadList) {
i.render(renderer, scale);
}
}
}

View file

@ -4,9 +4,11 @@ import org.lwjgl.opengl.GL11;
import com.minelittlepony.unicopia.entity.RainbowEntity; import com.minelittlepony.unicopia.entity.RainbowEntity;
import com.minelittlepony.unicopia.util.WorldHelper; import com.minelittlepony.unicopia.util.WorldHelper;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.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;
@ -23,7 +25,12 @@ public class RainbowEntityRenderer extends EntityRenderer<RainbowEntity> {
private static final Identifier TEXTURE = new Identifier("unicopia", "textures/environment/rainbow.png"); private static final Identifier TEXTURE = new Identifier("unicopia", "textures/environment/rainbow.png");
public void doRender(RainbowEntity entity, double x, double y, double z, float entityYaw, float partialTicks) { @Override
public Identifier getTexture(RainbowEntity entity) {
return TEXTURE;
}
public void render(RainbowEntity entity, double x, double y, double z, float entityYaw, float partialTicks) {
float distance = MinecraftClient.getInstance().getCameraEntity().distanceTo(entity); float distance = MinecraftClient.getInstance().getCameraEntity().distanceTo(entity);
float maxDistance = 16 * MinecraftClient.getInstance().options.viewDistance; float maxDistance = 16 * MinecraftClient.getInstance().options.viewDistance;
double r = entity.getRadius(); double r = entity.getRadius();
@ -37,39 +44,31 @@ public class RainbowEntityRenderer extends EntityRenderer<RainbowEntity> {
return; return;
} }
bindEntityTexture(entity); RenderSystem.pushMatrix();
RenderSystem.disableLighting();
RenderSystem.disableCull();
RenderSystem.enableBlend();
RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.pushMatrix(); RenderSystem.translated(x, y, z);
GlStateManager.disableLighting(); RenderSystem.rotatef(entityYaw, 0, 1, 0);
GlStateManager.disableCull();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.translated(x, y, z); RenderSystem.color4f(1, 1, 1, opacity);
GlStateManager.rotatef(entityYaw, 0, 1, 0);
GlStateManager.color4f(1, 1, 1, opacity);
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBufferBuilder(); BufferBuilder bufferbuilder = tessellator.getBuffer();
bufferbuilder.begin(GL11.GL_QUADS, VertexFormats.POSITION_UV); bufferbuilder.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE);
bufferbuilder.vertex(-r, r, 0).texture(1, 0).end(); bufferbuilder.vertex(-r, r, 0).texture(1, 0).next();
bufferbuilder.vertex( r, r, 0).texture(0, 0).end(); bufferbuilder.vertex( r, r, 0).texture(0, 0).next();
bufferbuilder.vertex( r, 0, 0).texture(0, 1).end(); bufferbuilder.vertex( r, 0, 0).texture(0, 1).next();
bufferbuilder.vertex(-r, 0, 0).texture(1, 1).end(); bufferbuilder.vertex(-r, 0, 0).texture(1, 1).next();
tessellator.draw(); tessellator.draw();
GlStateManager.disableBlend(); RenderSystem.disableBlend();
GlStateManager.enableCull(); RenderSystem.enableCull();
GlStateManager.enableLighting(); RenderSystem.enableLighting();
GlStateManager.popMatrix(); RenderSystem.popMatrix();
} }
@Override
protected Identifier getTexture(RainbowEntity entity) {
return TEXTURE;
}
} }

View file

@ -1,78 +0,0 @@
package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.client.render.model.SpellbookModel;
import com.minelittlepony.unicopia.entity.SpellbookEntity;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.util.math.MathHelper;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.util.Identifier;
public class RenderSpellbook extends LivingEntityRenderer<SpellbookEntity, SpellbookModel> {
private static final Identifier BLUE = new Identifier("unicopia", "textures/entity/enchanting_table_book_blue.png");
private static final Identifier NORMAL = new Identifier("unicopia", "textures/entity/enchanting_table_book.png");
public RenderSpellbook(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, new SpellbookModel(), 0);
}
@Override
protected Identifier getTexture(SpellbookEntity entity) {
return entity.getIsAltered() ? BLUE : NORMAL;
}
@Override
protected float getLyingAngle(SpellbookEntity entity) {
return 0;
}
@Override
protected void render(SpellbookEntity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float increment) {
float breath = MathHelper.sin((entity.age + stutter) / 20) * 0.01F + 0.1F;
float first_page_rot = walkSpeed + (breath * 10);
float second_page_rot = 1 - first_page_rot;
float open_angle = 0.9f - walkSpeed;
if (first_page_rot > 1) first_page_rot = 1;
if (second_page_rot > 1) second_page_rot = 1;
if (!entity.getIsOpen()) {
GlStateManager.translatef(0, 1.44f, 0);
} else {
GlStateManager.translatef(0, 1.2f + breath, 0);
}
GlStateManager.pushMatrix();
if (!entity.getIsOpen()) {
first_page_rot = second_page_rot = open_angle = 0;
GlStateManager.rotatef(90.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotatef(90.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.translatef(-0.25f, 0, 0);
} else {
GlStateManager.rotatef(-60.0F, 0.0F, 0.0F, 1.0F);
}
GlStateManager.enableCull();
super.render(entity, 0, first_page_rot, second_page_rot, open_angle, 0, 0.0625F);
GlStateManager.popMatrix();
}
@Override
protected void setupTransforms(SpellbookEntity entity, float p_77043_2_, float p_77043_3_, float partialTicks) {
GlStateManager.rotatef(-MathHelper.lerp(entity.prevYaw, entity.yaw, partialTicks), 0, 1, 0);
}
@Override
protected boolean hasLabel(SpellbookEntity targetEntity) {
return super.hasLabel(targetEntity)
&& (targetEntity.isCustomNameVisible()
|| targetEntity.hasCustomName()
&& targetEntity == renderManager.targetedEntity);
}
}

View file

@ -3,7 +3,7 @@ package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.SpearEntity; import com.minelittlepony.unicopia.entity.SpearEntity;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.ProjectileEntityRenderer; import net.minecraft.client.render.entity.ProjectileEntityRenderer;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@ -16,7 +16,7 @@ public class SpearEntityRenderer extends ProjectileEntityRenderer<SpearEntity> {
} }
@Override @Override
protected Identifier getTexture(SpearEntity entity) { public Identifier getTexture(SpearEntity entity) {
return TEXTURE; return TEXTURE;
} }
} }

View file

@ -0,0 +1,59 @@
package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.client.render.model.SpellbookModel;
import com.minelittlepony.unicopia.entity.SpellbookEntity;
import net.minecraft.util.math.MathHelper;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.Identifier;
public class SpellbookEntityRender extends LivingEntityRenderer<SpellbookEntity, SpellbookModel> {
private static final Identifier BLUE = new Identifier("unicopia", "textures/entity/enchanting_table_book_blue.png");
private static final Identifier NORMAL = new Identifier("unicopia", "textures/entity/enchanting_table_book.png");
public SpellbookEntityRender(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, new SpellbookModel(), 0);
}
@Override
public Identifier getTexture(SpellbookEntity entity) {
return entity.getIsAltered() ? BLUE : NORMAL;
}
@Override
protected float getLyingAngle(SpellbookEntity entity) {
return 0;
}
@Override
protected void setupTransforms(SpellbookEntity entity, MatrixStack matrices, float p_77043_2_, float p_77043_3_, float partialTicks) {
if (!entity.getIsOpen()) {
matrices.translate(0, 1.44f, 0);
} else {
matrices.translate(0, 1.2f + MathHelper.sin((entity.age + partialTicks) / 20) * 0.01F + 0.1F, 0);
}
if (!entity.getIsOpen()) {
matrices.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90));
matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(90));
matrices.translate(-0.25f, 0, 0);
} else {
matrices.multiply(Vector3f.NEGATIVE_Z.getDegreesQuaternion(60));
}
matrices.multiply(Vector3f.NEGATIVE_Y.getDegreesQuaternion(MathHelper.lerp(entity.prevYaw, entity.yaw, partialTicks)));
}
@Override
protected boolean hasLabel(SpellbookEntity targetEntity) {
return super.hasLabel(targetEntity)
&& (targetEntity.isCustomNameVisible()
|| targetEntity.hasCustomName()
&& targetEntity == renderManager.targetedEntity);
}
}

View file

@ -2,39 +2,86 @@ package com.minelittlepony.unicopia.client.render;
import com.minelittlepony.unicopia.client.render.model.GemEntityModel; import com.minelittlepony.unicopia.client.render.model.GemEntityModel;
import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.mojang.blaze3d.platform.GlStateManager;
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.VisibleRegion; import net.minecraft.client.render.Frustum;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer; import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class SpellcastEntityRenderer extends LivingEntityRenderer<SpellcastEntity, GemEntityModel> { public class SpellcastEntityRenderer extends LivingEntityRenderer<SpellcastEntity, GemEntityModel> {
private static final Identifier gem = new Identifier("unicopia", "textures/entity/gem.png"); private static final Identifier TEXTURE = new Identifier("unicopia", "textures/entity/gem.png");
public SpellcastEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) { public SpellcastEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
super(manager, new GemEntityModel(), 0); super(manager, new GemEntityModel(), 0);
addFeature(new TierFeature(this));
} }
@Override @Override
protected Identifier getTexture(SpellcastEntity entity) { public Identifier getTexture(SpellcastEntity entity) {
return gem; return TEXTURE;
} }
@Override @Override
public boolean isVisible(SpellcastEntity livingEntity, VisibleRegion camera, double camX, double camY, double camZ) { public boolean shouldRender(SpellcastEntity entity, Frustum visibleRegion, double cameraX, double cameraY, double cameraZ) {
return true; return true;
} }
@Override @Override
protected float getLyingAngle(SpellcastEntity entity) { protected float getLyingAngle(SpellcastEntity entity) {
return 0; return 0;
} }
@Override
public void render(SpellcastEntity livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
super.render(livingEntity, f, g, matrixStack, vertexConsumerProvider, i);
}
@Override @Override
protected boolean hasLabel(SpellcastEntity targetEntity) { protected boolean hasLabel(SpellcastEntity targetEntity) {
return super.hasLabel(targetEntity) && (targetEntity.isCustomNameVisible() return super.hasLabel(targetEntity) && (targetEntity.isCustomNameVisible()
|| targetEntity.hasCustomName() && targetEntity == renderManager.targetedEntity); || targetEntity.hasCustomName() && targetEntity == renderManager.targetedEntity);
} }
class TierFeature extends FeatureRenderer<SpellcastEntity, GemEntityModel> {
public TierFeature(FeatureRendererContext<SpellcastEntity, GemEntityModel> context) {
super(context);
}
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, SpellcastEntity entity, float limbAngle, float limbDistance, float tickDelta, float customAngle, float headYaw, float headPitch) {
int tiers = Math.min(entity.getCurrentLevel(), 5);
for (int i = 0; i <= tiers; i++) {
float grow = (1 + i) * 0.2F;
matrices.scale(1 + grow, 1 + grow, 1 + grow);
matrices.translate(0, -grow, 0);
if (i == 5) {
matrices.push();
matrices.translate(0.6F, 0.8F, 0);
matrices.scale(0.4F, 0.4F, 0.4F);
FeatureRenderer.render(model, model, TEXTURE, matrices, vertexConsumers, light, entity, limbAngle, limbDistance, entity.age, headYaw, headPitch, 1, 1, 1, 1);
matrices.pop();
}
}
for (int i = entity.getCurrentLevel(); i > 0; i--) {
matrices.push();
GlStateManager.translatef(0.6F, 0, 0);
FeatureRenderer.render(model, model, TEXTURE, matrices, vertexConsumers, light, entity, limbAngle, limbDistance, entity.age, headYaw, headPitch, 1, 1, 1, 1);
matrices.pop();
}
}
}
} }

View file

@ -1,87 +0,0 @@
package com.minelittlepony.unicopia.client.render;
import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.util.GlAllocationUtils;
public class SphereModel {
private int displayList;
private boolean baked;
protected double posX;
protected double posY;
protected double posZ;
protected float rotX;
protected float rotY;
protected float rotZ;
public void setPosition(double x, double y, double z) {
posX = x - BlockEntityRenderDispatcher.renderOffsetX;
posY = y - BlockEntityRenderDispatcher.renderOffsetY;
posZ = z - BlockEntityRenderDispatcher.renderOffsetZ;
}
public void setRotation(float x, float y, float z) {
rotX = x;
rotY = y;
rotZ = z;
}
public void render(float scale) {
if (scale == 0) {
return;
}
if (!baked) {
baked = true;
bake();
}
GlStateManager.pushMatrix();
if (posX != 0 && posY != 9 && posZ != 0) {
GlStateManager.translated(posX, posY, posZ);
}
glRotate(rotX, 1, 0, 0);
glRotate(rotY, 0, 1, 0);
glRotate(rotZ, 0, 0, 1);
GlStateManager.scalef(scale, scale, scale);
GlStateManager.callList(displayList);
GlStateManager.popMatrix();
}
private void bake() {
displayList = GlAllocationUtils.genLists(1);
GlStateManager.newList(displayList, GL11.GL_COMPILE);
drawShape();
GlStateManager.endList();
}
protected void drawShape() {
/*Sphere sphere = new Sphere();
sphere.setDrawStyle(GLU.GLU_FILL);
sphere.setNormals(GLU.GLU_SMOOTH);
sphere.draw(1, 32, 32);*/
// TODO: GLU Sphere
}
static void glRotate(float angle, float x, float y, float z) {
if (angle != 0) {
GlStateManager.rotatef(angle, x, y, z);
}
}
}

View file

@ -1,55 +0,0 @@
package com.minelittlepony.unicopia.client.render;
import net.minecraft.client.model.Quad;
import net.minecraft.client.model.Vertex;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.util.math.Vec3d;
public class TexturedShape2d extends Quad {
protected boolean invertNormal;
public TexturedShape2d(Vertex... vertices) {
super(vertices);
}
public TexturedShape2d(Vertex[] vertices, int texcoordU1, int texcoordV1, int texcoordU2, int texcoordV2, float textureWidth, float textureHeight) {
super(vertices, texcoordU1, texcoordV1, texcoordU2, texcoordV2, textureWidth, textureHeight);
}
public TexturedShape2d setInvertNormal() {
invertNormal = true;
return this;
}
@Override
public void render(BufferBuilder renderer, float scale) {
Vec3d vec3d = vertices[1].pos.reverseSubtract(vertices[0].pos);
Vec3d vec3d1 = vertices[1].pos.reverseSubtract(vertices[2].pos);
Vec3d vec3d2 = vec3d1.crossProduct(vec3d).normalize();
float f = (float)vec3d2.x;
float f1 = (float)vec3d2.y;
float f2 = (float)vec3d2.z;
if (invertNormal) {
f = -f;
f1 = -f1;
f2 = -f2;
}
renderer.begin(7, VertexFormats.POSITION_UV_NORMAL);
for (int i = 0; i < vertexCount; ++i) {
Vertex positiontexturevertex = vertices[i];
renderer
.vertex(positiontexturevertex.pos.x * scale, positiontexturevertex.pos.y * scale, positiontexturevertex.pos.z * scale)
.texture(positiontexturevertex.u, positiontexturevertex.v)
.normal(f, f1, f2)
.end();
}
Tessellator.getInstance().draw();
}
}

View file

@ -1,73 +1,70 @@
package com.minelittlepony.unicopia.client.render.model; package com.minelittlepony.unicopia.client.render.model;
import com.minelittlepony.unicopia.entity.ButterflyEntity; import com.minelittlepony.unicopia.entity.ButterflyEntity;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.model.Cuboid; import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class ButterflyEntityModel extends EntityModel<ButterflyEntity> { public class ButterflyEntityModel extends EntityModel<ButterflyEntity> {
private Cuboid body; private ModelPart body;
private Cuboid leftWingInner; private ModelPart leftWingInner;
private Cuboid leftWingOuter; private ModelPart leftWingOuter;
private Cuboid rightWingInner; private ModelPart rightWingInner;
private Cuboid rightWingOuter; private ModelPart rightWingOuter;
public ButterflyEntityModel() { public ButterflyEntityModel() {
textureWidth = 64; textureWidth = 64;
textureHeight = 64; textureHeight = 64;
body = new Cuboid(this, 0, 0); body = new ModelPart(this, 0, 0);
body.rotationPointZ = -10; body.pivotX = -10;
body.rotationPointY = 12; body.pivotY = 12;
rightWingInner = new Cuboid(this, 42, 0); rightWingInner = new ModelPart(this, 42, 0);
rightWingInner.roll = -0.2F; rightWingInner.roll = -0.2F;
rightWingInner.addBox(-13, -5, 0, 10, 19, 1); rightWingInner.addCuboid(-13, -5, 0, 10, 19, 1);
body.addChild(rightWingInner); body.addChild(rightWingInner);
rightWingOuter = new Cuboid(this, 24, 16); rightWingOuter = new ModelPart(this, 24, 16);
rightWingOuter.setRotationPoint(-13, 10, 0.1F); rightWingOuter.setPivot(-13, 10, 0.1F);
rightWingOuter.roll = -0.2F; rightWingOuter.roll = -0.2F;
rightWingOuter.addBox(0, 0, 0, 10, 12, 1); rightWingOuter.addCuboid(0, 0, 0, 10, 12, 1);
rightWingInner.addChild(rightWingOuter); rightWingInner.addChild(rightWingOuter);
leftWingInner = new Cuboid(this, 42, 0); leftWingInner = new ModelPart(this, 42, 0);
leftWingInner.mirror = true; leftWingInner.mirror = true;
leftWingInner.roll = 0.2F; leftWingInner.roll = 0.2F;
leftWingInner.addBox(2, -5, 0, 10, 19, 1); leftWingInner.addCuboid(2, -5, 0, 10, 19, 1);
body.addChild(leftWingInner); body.addChild(leftWingInner);
leftWingOuter = new Cuboid(this, 24, 16); leftWingOuter = new ModelPart(this, 24, 16);
leftWingOuter.mirror = true; leftWingOuter.mirror = true;
leftWingOuter.roll = -0.2F; leftWingOuter.roll = -0.2F;
leftWingOuter.setRotationPoint(2, 10, 0.1F); leftWingOuter.setPivot(2, 10, 0.1F);
leftWingOuter.addBox(0, 0, 0, 10, 12, 1); leftWingOuter.addCuboid(0, 0, 0, 10, 12, 1);
leftWingInner.addChild(leftWingOuter); leftWingInner.addChild(leftWingOuter);
} }
@Override @Override
public void render(ButterflyEntity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
RenderSystem.disableLighting();
setAngles(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
RenderSystem.enableLighting();
GlStateManager.disableLighting();
body.render(scale);
GlStateManager.enableLighting();
} }
@Override @Override
public void setAngles(ButterflyEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor) { public void setAngles(ButterflyEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float headYaw, float headPitch) {
float flap = MathHelper.cos(ageInTicks) * (float)Math.PI / 4; float flap = MathHelper.cos(ageInTicks) * (float)Math.PI / 4;

View file

@ -1,32 +1,37 @@
package com.minelittlepony.unicopia.client.render.model; package com.minelittlepony.unicopia.client.render.model;
import com.google.common.collect.ImmutableList;
import com.minelittlepony.unicopia.entity.CloudEntity; import com.minelittlepony.unicopia.entity.CloudEntity;
import net.minecraft.client.model.Cuboid; import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.CompositeEntityModel;
public class CloudEntityModel extends EntityModel<CloudEntity> { public class CloudEntityModel extends CompositeEntityModel<CloudEntity> {
private final Cuboid body; private final ModelPart body;
public CloudEntityModel() { public CloudEntityModel() {
body = new Cuboid(this, 0, 0); body = new ModelPart(this, 0, 0);
body.setTextureSize(250, 90); body.setTextureSize(250, 90);
body.setTextureOffset(0, 0); body.setTextureOffset(0, 0);
body.addBox(-24, 5, -24, 48, 10, 48); body.addCuboid(-24, 5, -24, 48, 10, 48);
body.setTextureOffset(0, 58); body.setTextureOffset(0, 58);
body.addBox(-10, 14.999F, -10, 30, 2, 30); body.addCuboid(-10, 14.999F, -10, 30, 2, 30);
body.setTextureOffset(120, 58); body.setTextureOffset(120, 58);
body.addBox(-10, 3.001F, -10, 30, 2, 30); body.addCuboid(-10, 3.001F, -10, 30, 2, 30);
body.rotationPointY += 4.2; body.pivotY += 4.2;
} }
@Override @Override
public void render(CloudEntity cloud, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { public Iterable<ModelPart> getParts() {
body.render(scale); return ImmutableList.of(body);
}
@Override
public void setAngles(CloudEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
} }
} }

View file

@ -1,68 +1,65 @@
package com.minelittlepony.unicopia.client.render.model; package com.minelittlepony.unicopia.client.render.model;
import com.minelittlepony.unicopia.entity.CuccoonEntity; import com.minelittlepony.unicopia.entity.CuccoonEntity;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager.DstFactor;
import com.mojang.blaze3d.platform.GlStateManager.DestFactor; import com.mojang.blaze3d.platform.GlStateManager.SrcFactor;
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.model.Cuboid; import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
public class CuccoonEntityModel extends EntityModel<CuccoonEntity> { public class CuccoonEntityModel extends EntityModel<CuccoonEntity> {
private final Cuboid body; private final ModelPart body;
private float breatheAmount;
public CuccoonEntityModel() { public CuccoonEntityModel() {
body = new Cuboid(this, 0, 0); body = new ModelPart(this, 0, 0);
body.setTextureSize(250, 250); body.setTextureSize(250, 250);
body.setTextureOffset(0, 0); body.setTextureOffset(0, 0);
// cuccoon shape // cuccoon shape
body.addBox(-4, -2, -4, 8, 2, 8); body.addCuboid(-4, -2, -4, 8, 2, 8);
body.addBox(-7.5F, 0, -7.5F, 15, 6, 15); body.addCuboid(-7.5F, 0, -7.5F, 15, 6, 15);
body.addBox(-10, 4, -10, 20, 6, 20); body.addCuboid(-10, 4, -10, 20, 6, 20);
body.addBox(-11.5F, 10, -11.5F, 23, 8, 23); body.addCuboid(-11.5F, 10, -11.5F, 23, 8, 23);
body.addBox(-10, 17, -10, 20, 6, 20); body.addCuboid(-10, 17, -10, 20, 6, 20);
body.addBox(-11.5F, 22, -11.5F, 23, 2, 23); body.addCuboid(-11.5F, 22, -11.5F, 23, 2, 23);
// pile of blocks
// body.addBox(-10, offsetY + 10, -10, 12, 12, 12);
// body.addBox(-14, offsetY + 14, 4, 10, 10, 10);
// body.addBox(-17, offsetY + 17, 3, 8, 8, 8);
// body.addBox(0, offsetY + 10, 0, 12, 12, 12);
// body.addBox(-7, offsetY + 6, -7, 16, 16, 16);
// body.addBox(-7, offsetY + 0, -7, 12, 12, 12);
} }
@Override @Override
public void render(CuccoonEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
matrices.push();
float breatheAmount = entity.getBreatheAmount(ageInTicks) / 8; RenderSystem.enableBlend();
RenderSystem.enableAlphaTest();
RenderSystem.enableRescaleNormal();
GlStateManager.pushMatrix(); RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableBlend(); matrices.scale(1 - breatheAmount, 1 + breatheAmount, 1 - breatheAmount);
GlStateManager.enableAlphaTest(); matrices.translate(0, -breatheAmount * 1.3F, 0);
GlStateManager.enableNormalize();
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA); body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
GlStateManager.scalef(1 - breatheAmount, 1 + breatheAmount, 1 - breatheAmount); matrices.scale(0.9F, 0.9F, 0.9F);
GlStateManager.translatef(0, -breatheAmount * 1.3F, 0); matrices.translate(0, 0.2F, 0);
body.render(scale); body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
GlStateManager.scalef(0.9F, 0.9F, 0.9F); RenderSystem.disableRescaleNormal();
GlStateManager.translatef(0, 0.2F, 0); RenderSystem.disableAlphaTest();
RenderSystem.disableBlend();
body.render(scale); matrices.pop();
}
GlStateManager.disableNormalize(); @Override
GlStateManager.disableAlphaTest(); public void setAngles(CuccoonEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
GlStateManager.disableBlend(); breatheAmount = entity.getBreatheAmount(customAngle) / 8;
GlStateManager.popMatrix();
} }
} }

View file

@ -0,0 +1,23 @@
package com.minelittlepony.unicopia.client.render.model;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.Matrix4f;
import net.minecraft.client.util.math.MatrixStack;
public class DiskModel extends SphereModel {
@Override
public void render(MatrixStack.Entry matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
Matrix4f model = matrices.getModel();
final double num_rings = 30;
final double zenithIncrement = Math.PI / num_rings;
double radius = 1;
for(double zenith = 0; zenith < Math.PI; zenith += zenithIncrement) {
drawVertex(model, vertexWriter, radius, zenith, Math.PI, light, overlay, r, g, b, a);
}
}
}

View file

@ -1,82 +1,42 @@
package com.minelittlepony.unicopia.client.render.model; package com.minelittlepony.unicopia.client.render.model;
import com.minelittlepony.unicopia.client.render.ModelQuads;
import com.minelittlepony.unicopia.entity.SpellcastEntity; import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.util.Color; import com.minelittlepony.unicopia.util.Color;
import com.mojang.blaze3d.platform.GLX; import net.minecraft.client.model.ModelPart;
import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.model.Cuboid;
import net.minecraft.client.model.Vertex;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityPose;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class GemEntityModel extends EntityModel<SpellcastEntity> { public class GemEntityModel extends EntityModel<SpellcastEntity> {
private Cuboid body; private ModelPart body;
private int tint;
public GemEntityModel() { public GemEntityModel() {
textureWidth = 256; textureWidth = 256;
textureHeight = 256; textureHeight = 256;
body = new Cuboid(this); body = new ModelPart(this);
body.y = 1.2f; body.pivotY = 1.2f;
int size = 1;
body.boxes.add(new ModelQuads(body).addFace(
new Vertex( size, 0, size, 0, 0.5f),
new Vertex(-size, 0, size, 0.25f, 0.25f),
new Vertex( 0, size * 2, 0, 0, 0.25f),
new Vertex( 0, size * 2, 0, 0, 0.25f)
).addFace(
new Vertex( size, 0, size, 0, 0.25f),
new Vertex(-size, 0, size, 0.25f, 0),
new Vertex( 0, -size * 2, 0, 0.25f, 0.25f),
new Vertex( 0, -size * 2, 0, 0.25f, 0.25f)
).addFace(
new Vertex(size, 0, -size, 0.25f, 0.5f),
new Vertex(size, 0, size, 0.5f, 0.25f),
new Vertex(0, size * 2, 0, 0.25f, 0.25f),
new Vertex(0, size * 2, 0, 0.25f, 0.25f)
).addFace(
new Vertex(size, 0, -size, 0.25f, 0.25f),
new Vertex(size, 0, size, 0.5f, 0),
new Vertex(0, -size * 2, 0, 0.5f, 0.25f),
new Vertex(0, -size * 2, 0, 0.5f, 0.25f)
).addFace(
new Vertex(-size, 0, -size, 0.5f, 0.5f),
new Vertex( size, 0, -size, 0.75f, 0.25f),
new Vertex( 0, size * 2, 0, 0.5f, 0.25f),
new Vertex( 0, size * 2, 0, 0.5f, 0.25f)
).addFace(
new Vertex(-size, 0, -size, 0.5f, 0.25f),
new Vertex( size, 0, -size, 0.75f, 0),
new Vertex( 0, -size * 2, 0, 0.75f, 0.25f),
new Vertex( 0, -size * 2, 0, 0.75f, 0.25f)
).addFace(
new Vertex(-size, 0, size, 0.75f, 0.5f),
new Vertex(-size, 0, -size, 1, 0.25f),
new Vertex( 0, size * 2, 0, 0.75f, 0.25f),
new Vertex( 0, size * 2, 0, 0.75f, 0.25f)
).addFace(
new Vertex(-size, 0, size, 0.75f, 0.25f),
new Vertex(-size, 0, -size, 1, 0),
new Vertex( 0, -size * 2, 0, 1, 0.25f),
new Vertex( 0, -size * 2, 0, 1, 0.25f)
));
} }
@Override @Override
public void render(SpellcastEntity entity, float time, float walkSpeed, float stutter, float yaw, float pitch, float scale) { public void setAngles(SpellcastEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
tint = entity.hasEffect() ? entity.getEffect().getTint() : -1;
GlStateManager.pushMatrix(); float floatOffset = MathHelper.sin((entity.age + customAngle) / 10 + entity.hoverStart) / 10 + 0.1F;
float floatOffset = MathHelper.sin((entity.age + stutter) / 10 + entity.hoverStart) / 10 + 0.1F; boolean unstable = entity.overLevelCap();
GlStateManager.translated(0, floatOffset - entity.getEyeHeight(EntityPose.STANDING), 0);
floatOffset = (entity.age + stutter) / 20; body.pivotX = unstable ? (float)Math.sin(customAngle) / 5F : 0;
body.pivotY = 1.2F + floatOffset - entity.getEyeHeight(EntityPose.STANDING);
body.pivotZ = unstable ? (float)Math.cos(customAngle) / 5F : 0;
body.pitch = unstable ? (float)Math.sin(customAngle) : 0;
floatOffset = (entity.age + customAngle) / 20;
if (entity.getCurrentLevel() > 0) { if (entity.getCurrentLevel() > 0) {
floatOffset *= entity.getCurrentLevel() + 1; floatOffset *= entity.getCurrentLevel() + 1;
} }
@ -84,74 +44,19 @@ public class GemEntityModel extends EntityModel<SpellcastEntity> {
floatOffset += entity.hoverStart; floatOffset += entity.hoverStart;
floatOffset *= 180 / (float)Math.PI; floatOffset *= 180 / (float)Math.PI;
GlStateManager.pushMatrix(); body.yaw = floatOffset;
if (entity.overLevelCap()) {
GlStateManager.translated(Math.sin(stutter) / 5, 0, Math.cos(stutter) / 5);
GlStateManager.rotatef((float)Math.sin(stutter), 0, 1, 0);
} }
GlStateManager.rotated(floatOffset, 0, 1, 0); @Override
public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
body.render(scale); if (tint != -1) {
red = Color.r(tint);
GlStateManager.enableBlend(); green = Color.g(tint);
GlStateManager.disableAlphaTest(); blue = Color.b(tint);
GlStateManager.blendFunc(1, 1);
setLightingConditionsBrightness(0xF0F0);
if (entity.hasEffect()) {
int tint = entity.getEffect().getTint();
GlStateManager.color4f(Color.r(tint), Color.g(tint), Color.b(tint), 1);
} }
int tiers = Math.min(entity.getCurrentLevel(), 5); body.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
for (int i = 0; i <= tiers; i++) {
float grow = (1 + i) * 0.2F;
GlStateManager.scalef(1 + grow, 1 + grow, 1 + grow);
GlStateManager.translatef(0, -grow, 0);
renderOverlay(grow, scale);
if (i == 5) {
GlStateManager.pushMatrix();
GlStateManager.rotatef(-floatOffset * 0.9F, 0, 1, 0);
GlStateManager.translatef(0.6F, 0.8F, 0);
GlStateManager.scalef(0.4F, 0.4F, 0.4F);
renderOverlay(grow, scale);
GlStateManager.popMatrix();
} }
} }
GlStateManager.popMatrix();
for (int i = entity.getCurrentLevel(); i > 0; i--) {
GlStateManager.pushMatrix();
GlStateManager.rotatef(floatOffset / i, 0, 1, 0);
GlStateManager.translatef(0.6F, 0, 0);
renderOverlay(0.6F, scale);
GlStateManager.popMatrix();
}
setLightingConditionsBrightness(entity.getLightmapCoordinates());
GlStateManager.disableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.popMatrix();
}
protected void renderOverlay(float grow, float scale) {
body.render(scale);
}
private void setLightingConditionsBrightness(int brightness) {
int texX = brightness % 0x10000;
int texY = brightness / 0x10000;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, texX, texY);
}
}

View file

@ -1,49 +1,69 @@
package com.minelittlepony.unicopia.client.render.model; package com.minelittlepony.unicopia.client.render.model;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.minelittlepony.unicopia.entity.SpellbookEntity; import com.minelittlepony.unicopia.entity.SpellbookEntity;
import net.minecraft.client.model.Cuboid; import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class SpellbookModel extends EntityModel<SpellbookEntity> { public class SpellbookModel extends EntityModel<SpellbookEntity> {
private final Cuboid leftCover = (new Cuboid(this)).setTextureOffset(0, 0).addBox(-6.0F, -5.0F, 0.0F, 6, 10, 0); private final ModelPart leftCover = (new ModelPart(64, 32, 0, 0)).addCuboid(-6, -5, -0.005F, 6, 10, 0.005F);
private final Cuboid rightCover = (new Cuboid(this)).setTextureOffset(16, 0).addBox(0.0F, -5.0F, 0.0F, 6, 10, 0); private final ModelPart rightCover = (new ModelPart(64, 32, 16, 0)).addCuboid(0, -5, -0.005F, 6, 10, 0.005F);
private final Cuboid leftBlock = (new Cuboid(this)).setTextureOffset(0, 10).addBox(0.0F, -4.0F, -0.99F, 5, 8, 1); private final ModelPart leftBlock = (new ModelPart(64, 32, 0, 10)).addCuboid(0, -4, -0.99F, 5, 8, 1);
private final Cuboid rightBlock = (new Cuboid(this)).setTextureOffset(12, 10).addBox(0.0F, -4.0F, -0.01F, 5, 8, 1); private final ModelPart rightBlock = (new ModelPart(64, 32, 12, 10)).addCuboid(0, -4, -0.01F, 5, 8, 1);
private final Cuboid leftPage = (new Cuboid(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0); private final ModelPart leftPage = (new ModelPart(64, 32, 24, 10)).addCuboid(0, -4, 0, 5, 8, 0.005F);
private final Cuboid rightPage = (new Cuboid(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0); private final ModelPart rightPage = (new ModelPart(64, 32, 24, 10)).addCuboid(0, -4, 0, 5, 8, 0.005F);
private final Cuboid spine = (new Cuboid(this)).setTextureOffset(12, 0).addBox(-1.0F, -5.0F, 0.0F, 2, 10, 0); private final ModelPart spine = (new ModelPart(64, 32, 12, 0)).addCuboid(-1, -5, 0, 2, 10, 0.005F);
private final List<ModelPart> parts = ImmutableList.of(leftCover, rightCover, spine, leftBlock, rightBlock, leftPage, rightPage);
public SpellbookModel() { public SpellbookModel() {
this.leftCover.setRotationPoint(0.0F, 0.0F, -1.0F); leftCover.setPivot(0, 0, -1);
this.rightCover.setRotationPoint(0.0F, 0.0F, 1.0F); rightCover.setPivot(0, 0, 1);
this.spine.yaw = 1.5707964F; spine.yaw = 1.5707964F;
} }
@Override @Override
public void render(SpellbookEntity entity, float float_1, float float_2, float float_3, float float_4, float float_5, float float_6) { public void render(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) {
this.leftCover.render(float_6); parts.forEach(modelPart -> {
this.rightCover.render(float_6); modelPart.render(matrices, vertexConsumer, light, overlay, red, green, blue, alpha);
this.spine.render(float_6); });
this.leftBlock.render(float_6); }
this.rightBlock.render(float_6);
this.leftPage.render(float_6); public void setPageAngles(float breath, float leftPageRot, float rightPageRot, float openAngle) {
this.rightPage.render(float_6); float j = (MathHelper.sin(breath * 0.02F) * 0.1F + 1.25F) * openAngle;
leftCover.yaw = 3.1415927F + j;
rightCover.yaw = -j;
leftBlock.yaw = j;
rightBlock.yaw = -j;
leftPage.yaw = j - j * 2 * leftPageRot;
rightPage.yaw = j - j * 2 * rightPageRot;
leftBlock.pivotX = MathHelper.sin(j);
rightBlock.pivotX = MathHelper.sin(j);
leftPage.pivotX = MathHelper.sin(j);
rightPage.pivotX = MathHelper.sin(j);
} }
@Override @Override
public void setAngles(SpellbookEntity entity, float float_1, float float_2, float float_3, float float_4, float float_5, float float_6) { public void setAngles(SpellbookEntity entity, float limbAngle, float limbDistance, float customAngle, float headYaw, float headPitch) {
float float_7 = (MathHelper.sin(float_1 * 0.02F) * 0.1F + 1.25F) * float_4; float breath = MathHelper.sin((entity.age + customAngle) / 20) * 0.01F + 0.1F;
this.leftCover.yaw = 3.1415927F + float_7;
this.rightCover.yaw = -float_7; float first_page_rot = limbDistance + (breath * 10);
this.leftBlock.yaw = float_7; float second_page_rot = 1 - first_page_rot;
this.rightBlock.yaw = -float_7; float open_angle = 0.9f - limbDistance;
this.leftPage.yaw = float_7 - float_7 * 2.0F * float_2;
this.rightPage.yaw = float_7 - float_7 * 2.0F * float_3; if (first_page_rot > 1) first_page_rot = 1;
this.leftBlock.rotationPointX = MathHelper.sin(float_7); if (second_page_rot > 1) second_page_rot = 1;
this.rightBlock.rotationPointX = MathHelper.sin(float_7);
this.leftPage.rotationPointX = MathHelper.sin(float_7); if (!entity.getIsOpen()) {
this.rightPage.rotationPointX = MathHelper.sin(float_7); first_page_rot = second_page_rot = open_angle = 0;
}
setPageAngles(breath, first_page_rot, second_page_rot, open_angle);
} }
} }

View file

@ -0,0 +1,99 @@
package com.minelittlepony.unicopia.client.render.model;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.util.math.Matrix4f;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.client.util.math.Vector4f;
import net.minecraft.util.math.Quaternion;
import net.minecraft.util.math.Vec3d;
public class SphereModel {
protected Vec3d pos;
protected Quaternion rotX;
protected Quaternion rotY;
protected Quaternion rotZ;
public void setPosition(double x, double y, double z) {
pos = new Vec3d(x, y, z).subtract(BlockEntityRenderDispatcher.INSTANCE.camera.getPos());
}
public void setRotation(float x, float y, float z) {
rotX = Vector3f.POSITIVE_X.getDegreesQuaternion(x);
rotY = Vector3f.POSITIVE_Y.getDegreesQuaternion(y);
rotZ = Vector3f.POSITIVE_Z.getDegreesQuaternion(z);
}
public void render(MatrixStack matrices, float scale, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
if (scale == 0) {
return;
}
matrices.push();
matrices.translate(pos.x, pos.y, pos.z);
matrices.multiply(rotX);
matrices.multiply(rotY);
matrices.multiply(rotZ);
matrices.scale(scale, scale, scale);
render(matrices.peek(), vertexWriter, light, overlay, r, g, b, a);
matrices.pop();
}
public void render(MatrixStack.Entry matrices, VertexConsumer vertexWriter, int light, int overlay, float r, float g, float b, float a) {
Matrix4f model = matrices.getModel();
final double num_rings = 30;
final double num_sectors = 30;
final double two_pi = Math.PI * 2;
final double zenithIncrement = Math.PI / num_rings;
final double azimuthIncrement = two_pi / num_sectors;
double radius = 1;
for(double zenith = 0; zenith < Math.PI; zenith += zenithIncrement) {
for(double azimuth = 0; azimuth < two_pi; azimuth += azimuthIncrement) {
drawVertex(model, vertexWriter, radius, zenith, azimuth, light, overlay, r, g, b, a); // top left
drawVertex(model, vertexWriter, radius, zenith + zenithIncrement, azimuth, light, overlay, r, g, b, a); // top right
drawVertex(model, vertexWriter, radius, zenith + zenithIncrement, azimuth + azimuthIncrement, light, overlay, r, g, b, a); // bottom right
drawVertex(model, vertexWriter, radius, zenith, azimuth + azimuthIncrement, light, overlay, r, g, b, a); // bottom left
}
}
}
protected void drawQuad(Matrix4f model, VertexConsumer vertexWriter,
double radius, double zenith, double azimuth,
double zenithIncrement, double azimuthIncrement,
int light, int overlay, float r, float g, float b, float a) {
}
protected void drawVertex(Matrix4f model, VertexConsumer vertexWriter,
double radius, double zenith, double azimuth,
int light, int overlay, float r, float g, float b, float a) {
Vector4f position = convertToCartesianCoord(radius, zenith, azimuth);
position.transform(model);
vertexWriter.vertex(position.getX(), position.getY(), position.getZ(),
r, g, b, a,
0, 0, overlay, light, 0, 0, 0);
}
protected Vector4f convertToCartesianCoord(double radius, double zenith, double azimuth) {
double tanq = Math.tan(zenith);
double x = Math.pow(radius, 2) / (2 * tanq) - (tanq / 2);
double y = x * tanq;
double z = radius / Math.tan(azimuth);
return new Vector4f((float)x, (float)y, (float)z, 1);
}
}

View file

@ -49,7 +49,7 @@ public class DisguiseCommand {
} }
static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, CompoundTag nbt, boolean isSelf) throws CommandSyntaxException { static int disguise(ServerCommandSource source, PlayerEntity player, Identifier id, CompoundTag nbt, boolean isSelf) throws CommandSyntaxException {
nbt = nbt.method_10553(); nbt = nbt.copy();
nbt.putString("id", id.toString()); nbt.putString("id", id.toString());
Pony iplayer = Pony.of(player); Pony iplayer = Pony.of(player);

View file

@ -67,14 +67,14 @@ public class BagOfHoldingContainer extends Container {
@Override @Override
public ItemStack transferSlot(PlayerEntity playerIn, int index) { public ItemStack transferSlot(PlayerEntity playerIn, int index) {
ItemStack resultingStack = ItemStack.EMPTY; ItemStack resultingStack = ItemStack.EMPTY;
Slot slot = slotList.get(index); Slot slot = slots.get(index);
if (slot != null && slot.hasStack()) { if (slot != null && slot.hasStack()) {
ItemStack originalStack = slot.getStack(); ItemStack originalStack = slot.getStack();
resultingStack = originalStack.copy(); resultingStack = originalStack.copy();
if (index < inventory.getInvSize()) { if (index < inventory.getInvSize()) {
if (!insertItem(originalStack, inventory.getInvSize(), slotList.size(), true)) { if (!insertItem(originalStack, inventory.getInvSize(), slots.size(), true)) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} else if (!insertItem(originalStack, 0, inventory.getInvSize(), false)) { } else if (!insertItem(originalStack, 0, inventory.getInvSize(), false)) {

View file

@ -20,6 +20,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.BasicInventory; import net.minecraft.inventory.BasicInventory;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@ -30,8 +32,6 @@ import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion.DestructionType; import net.minecraft.world.explosion.Explosion.DestructionType;
import net.minecraft.world.loot.context.LootContext;
import net.minecraft.world.loot.context.LootContextParameters;
public class BagOfHoldingInventory extends BasicInventory implements NbtSerialisable { public class BagOfHoldingInventory extends BasicInventory implements NbtSerialisable {
@ -54,14 +54,14 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis
} }
public static void iterateContents(ItemStack stack, BiFunction<Integer, ItemStack, Boolean> itemConsumer) { public static void iterateContents(ItemStack stack, BiFunction<Integer, ItemStack, Boolean> itemConsumer) {
if (stack.hasTag() && stack.getTag().containsKey("inventory")) { if (stack.hasTag() && stack.getTag().contains("inventory")) {
CompoundTag compound = stack.getSubTag("inventory"); CompoundTag compound = stack.getSubTag("inventory");
if (compound.containsKey("items")) { if (compound.contains("items")) {
ListTag list = compound.getList("items", NBT_COMPOUND); ListTag list = compound.getList("items", NBT_COMPOUND);
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
ItemStack item = ItemStack.fromTag(list.getCompoundTag(i)); ItemStack item = ItemStack.fromTag(list.getCompound(i));
if (!item.isEmpty() && !itemConsumer.apply(i, item)) { if (!item.isEmpty() && !itemConsumer.apply(i, item)) {
break; break;
} }
@ -135,7 +135,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis
BOHDeathCriterion.INSTANCE.trigger((ServerPlayerEntity)player); BOHDeathCriterion.INSTANCE.trigger((ServerPlayerEntity)player);
} }
player.damage(MagicalDamageSource.create("paradox"), 1000); player.damage(MagicalDamageSource.create("paradox"), 1000);
player.world.createExplosion(player, player.x, player.y, player.z, 5, DestructionType.DESTROY); player.world.createExplosion(player, player.getX(), player.getY(), player.getZ(), 5, DestructionType.DESTROY);
} }
} }
@ -154,7 +154,7 @@ public class BagOfHoldingInventory extends BasicInventory implements NbtSerialis
return isIllegalBlock(Block.getBlockFromItem(stack.getItem())) return isIllegalBlock(Block.getBlockFromItem(stack.getItem()))
|| stack.getItem().isIn(UTags.HAMMERPACE_IMMUNE) || stack.getItem().isIn(UTags.HAMMERPACE_IMMUNE)
|| (compound != null && compound.containsKey("invalid")); || (compound != null && compound.contains("invalid"));
} }
protected boolean isIllegalBlock(Block block) { protected boolean isIllegalBlock(Block block) {

View file

@ -4,12 +4,12 @@ import com.minelittlepony.common.client.gui.element.Scrollbar;
import com.minelittlepony.unicopia.item.BagOfHoldingItem; import com.minelittlepony.unicopia.item.BagOfHoldingItem;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; import net.minecraft.client.gui.screen.ingame.ContainerScreen;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class BagOfHoldingScreen extends AbstractContainerScreen<BagOfHoldingContainer> { public class BagOfHoldingScreen extends ContainerScreen<BagOfHoldingContainer> {
private static final Identifier CHEST_GUI_TEXTURE = new Identifier("textures/gui/container/generic_54.png"); private static final Identifier CHEST_GUI_TEXTURE = new Identifier("textures/gui/container/generic_54.png");
private final int inventoryRows; private final int inventoryRows;
@ -21,15 +21,16 @@ public class BagOfHoldingScreen extends AbstractContainerScreen<BagOfHoldingCont
super(provider.createMenu(0, player.inventory, player), player.inventory, provider.getDisplayName()); super(provider.createMenu(0, player.inventory, player), player.inventory, provider.getDisplayName());
playerRows = playerInventory.getInvSize() / 9; playerRows = playerInventory.getInvSize() / 9;
inventoryRows = (container.slotList.size() / 9) - 1; inventoryRows = (container.slots.size() / 9) - 1;
} }
@Override @Override
public void init() { public void init() {
super.init(); super.init();
scrollbar.reposition( scrollbar.reposition(
left + containerWidth, x + containerWidth,
top, y,
containerHeight, containerHeight,
(inventoryRows + 1) * 18 + 17); (inventoryRows + 1) * 18 + 17);
children.add(scrollbar); children.add(scrollbar);

View file

@ -55,7 +55,7 @@ public class HeavyInventory {
CompoundTag bet = stack.getSubTag("BlockEntityTag"); CompoundTag bet = stack.getSubTag("BlockEntityTag");
CompoundTag compound = stack.getSubTag("inventory"); CompoundTag compound = stack.getSubTag("inventory");
boolean hasWeight = compound != null && compound.containsKey("weight"); boolean hasWeight = compound != null && compound.contains("weight");
if (deep) { if (deep) {
if (!hasWeight && bet != null) { if (!hasWeight && bet != null) {
@ -76,7 +76,7 @@ public class HeavyInventory {
} }
} }
if (hasWeight && (deep || !compound.containsKey("deep"))) { if (hasWeight && (deep || !compound.contains("deep"))) {
return compound.getDouble("weight"); return compound.getDouble("weight");
} }
} }

View file

@ -90,9 +90,9 @@ public class SpellBookContainer extends Container {
player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_SNARE, 1, 1); player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_SNARE, 1, 1);
worldObj.createExplosion(null, player.x, player.y, player.z, 0, DestructionType.NONE); worldObj.createExplosion(null, player.getX(), player.getY(), player.getZ(), 0, DestructionType.NONE);
worldObj.createExplosion(null, player.x, player.y, player.z, 0, DestructionType.NONE); worldObj.createExplosion(null, player.getX(), player.getY(), player.getZ(), 0, DestructionType.NONE);
worldObj.addParticle(ParticleTypes.EXPLOSION, player.x, player.y, player.z, 1, 0, 0); worldObj.addParticle(ParticleTypes.EXPLOSION, player.getX(), player.getY(), player.getZ(), 1, 0, 0);
AwaitTickQueue.enqueueTask(w -> player.container.close(player)); AwaitTickQueue.enqueueTask(w -> player.container.close(player));
@ -116,7 +116,7 @@ public class SpellBookContainer extends Container {
@Override @Override
public ItemStack transferSlot(PlayerEntity player, int index) { public ItemStack transferSlot(PlayerEntity player, int index) {
ItemStack stack = ItemStack.EMPTY; ItemStack stack = ItemStack.EMPTY;
Slot slot = slotList.get(index); Slot slot = slots.get(index);
if (slot != null && slot.hasStack()) { if (slot != null && slot.hasStack()) {
ItemStack slotStack = slot.getStack(); ItemStack slotStack = slot.getStack();

View file

@ -1,10 +1,9 @@
package com.minelittlepony.unicopia.client.gui; package com.minelittlepony.unicopia.container;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.minelittlepony.common.client.gui.element.Button; import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.container.SpellBookContainer;
import com.minelittlepony.unicopia.container.SpellBookContainer.SpellbookSlot; import com.minelittlepony.unicopia.container.SpellBookContainer.SpellbookSlot;
import com.minelittlepony.unicopia.enchanting.IPageUnlockListener; import com.minelittlepony.unicopia.enchanting.IPageUnlockListener;
import com.minelittlepony.unicopia.enchanting.Page; import com.minelittlepony.unicopia.enchanting.Page;
@ -13,14 +12,14 @@ import com.minelittlepony.unicopia.enchanting.Pages;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; import net.minecraft.client.gui.screen.ingame.ContainerScreen;
import net.minecraft.client.texture.MissingSprite; import net.minecraft.client.texture.MissingSprite;
import net.minecraft.container.Slot; import net.minecraft.container.Slot;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer> implements IPageUnlockListener { public class SpellBookScreen extends ContainerScreen<SpellBookContainer> implements IPageUnlockListener {
private static Page currentPage; private static Page currentPage;
@ -48,11 +47,11 @@ public class SpellBookScreen extends AbstractContainerScreen<SpellBookContainer>
public void init() { public void init() {
super.init(); super.init();
addButton(nextPage = new PageButton(left + 360, top + 185, true)).onClick(v -> { addButton(nextPage = new PageButton(x + 360, y + 185, true)).onClick(v -> {
currentPage = currentPage.next(); currentPage = currentPage.next();
onPageChange(); onPageChange();
}); });
addButton(prevPage = new PageButton(left + 20, top + 185, false)).onClick(v -> { addButton(prevPage = new PageButton(x + 20, y + 185, false)).onClick(v -> {
currentPage = currentPage.prev(); currentPage = currentPage.prev();
onPageChange(); onPageChange();
}); });

View file

@ -5,15 +5,21 @@ import com.minelittlepony.unicopia.enchanting.SpellCraftingEvent;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.MagicGemItem; import com.minelittlepony.unicopia.item.MagicGemItem;
import com.minelittlepony.unicopia.magic.spell.SpellRegistry; import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
import com.mojang.datafixers.util.Pair;
import net.minecraft.container.PlayerContainer;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory; import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.MusicDiscItem; import net.minecraft.item.MusicDiscItem;
import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.RecipeType;
import net.minecraft.util.DefaultedList; import net.minecraft.util.DefaultedList;
import net.minecraft.util.Identifier;
public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot { public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
// TODO: need to register this
public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "empty_slot_gem");
private final Pony player; private final Pony player;
private final SpellBookInventory craftMatrix; private final SpellBookInventory craftMatrix;
@ -95,7 +101,7 @@ public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
} }
@Override @Override
public String getBackgroundSprite() { public Pair<Identifier, Identifier> getBackgroundSprite() {
return "unicopia:items/empty_slot_gem"; return Pair.of(PlayerContainer.BLOCK_ATLAS_TEXTURE, EMPTY_GEM_SLOT);
} }
} }

View file

@ -19,7 +19,7 @@ import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
import net.minecraft.resource.JsonDataLoader; import net.minecraft.resource.JsonDataLoader;
import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.SystemUtil; import net.minecraft.util.Util;
import net.minecraft.util.profiler.Profiler; import net.minecraft.util.profiler.Profiler;
public class Pages extends JsonDataLoader implements IdentifiableResourceReloadListener { public class Pages extends JsonDataLoader implements IdentifiableResourceReloadListener {
@ -38,7 +38,7 @@ public class Pages extends JsonDataLoader implements IdentifiableResourceReloadL
private final Map<Identifier, PageInstance> pages = Maps.newHashMap(); private final Map<Identifier, PageInstance> pages = Maps.newHashMap();
private List<PageInstance> pagesByIndex = Lists.newArrayList(); private List<PageInstance> pagesByIndex = Lists.newArrayList();
private final Map<String, IConditionFactory> conditionFactories = SystemUtil.consume(Maps.newHashMap(), m -> { private final Map<String, IConditionFactory> conditionFactories = Util.make(Maps.newHashMap(), m -> {
m.put("unicopia:compound_condition", CompoundCondition::new); m.put("unicopia:compound_condition", CompoundCondition::new);
m.put("unicopia:page_state", PageStateCondition::new); m.put("unicopia:page_state", PageStateCondition::new);
m.put("unicopia:spell_crafting", SpellCraftingEvent.Condition::new); m.put("unicopia:spell_crafting", SpellCraftingEvent.Condition::new);
@ -53,12 +53,6 @@ public class Pages extends JsonDataLoader implements IdentifiableResourceReloadL
return ID; return ID;
} }
@Override
protected Map<Identifier, JsonObject> prepare(ResourceManager manager, Profiler profiler) {
// TODO: broken synthetic
return super.method_20731(manager, profiler);
}
@Override @Override
protected void apply(Map<Identifier, JsonObject> data, ResourceManager manager, Profiler profiled) { protected void apply(Map<Identifier, JsonObject> data, ResourceManager manager, Profiler profiled) {
pages.clear(); pages.clear();

View file

@ -37,12 +37,6 @@ public class AffineIngredients extends JsonDataLoader implements IdentifiableRes
return ID; return ID;
} }
@Override
protected Map<Identifier, JsonObject> prepare(ResourceManager manager, Profiler profiler) {
// TODO: broken synthetic
return super.method_20731(manager, profiler);
}
@Override @Override
protected void apply(Map<Identifier, JsonObject> data, ResourceManager manager, Profiler profiled) { protected void apply(Map<Identifier, JsonObject> data, ResourceManager manager, Profiler profiled) {
storedIngredients.clear(); storedIngredients.clear();

View file

@ -10,12 +10,12 @@ import com.google.gson.JsonParseException;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.DefaultedList; import net.minecraft.util.DefaultedList;
import net.minecraft.util.PacketByteBuf; import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.SystemUtil; import net.minecraft.util.Util;
public interface SpellIngredient { public interface SpellIngredient {
SpellIngredient EMPTY = new SingleSpellIngredient(ItemStack.EMPTY, false); SpellIngredient EMPTY = new SingleSpellIngredient(ItemStack.EMPTY, false);
Map<String, Serializer<? extends SpellIngredient>> SERIALIZERS = SystemUtil.consume(new HashMap<>(), map -> { Map<String, Serializer<? extends SpellIngredient>> SERIALIZERS = Util.make(new HashMap<>(), map -> {
map.put("compound", CompoundSpellIngredient.SERIALIZER); map.put("compound", CompoundSpellIngredient.SERIALIZER);
map.put("single", SingleSpellIngredient.SERIALIZER); map.put("single", SingleSpellIngredient.SERIALIZER);
map.put("affine", AffineIngredient.SERIALIZER); map.put("affine", AffineIngredient.SERIALIZER);

View file

@ -88,7 +88,7 @@ public class ButterflyEntity extends AmbientEntity {
super.tick(); super.tick();
Vec3d vel = getVelocity(); Vec3d vel = getVelocity();
setVelocity(vel.x, y * 0.6, vel.z); setVelocity(vel.x, getY() * 0.6, vel.z);
} }
public boolean isResting() { public boolean isResting() {
@ -156,14 +156,18 @@ public class ButterflyEntity extends AmbientEntity {
// select a new hovering position // select a new hovering position
if (hoveringPosition == null || random.nextInt(30) == 0 || hoveringPosition.getSquaredDistance(pos) < 4) { if (hoveringPosition == null || random.nextInt(30) == 0 || hoveringPosition.getSquaredDistance(pos) < 4) {
hoveringPosition = new BlockPos(x + random.nextInt(7) - random.nextInt(7), y + random.nextInt(6) - 2, z + random.nextInt(7) - random.nextInt(7)); hoveringPosition = new BlockPos(
getX() + random.nextInt(7) - random.nextInt(7),
getY() + random.nextInt(6) - 2,
getZ() + random.nextInt(7) - random.nextInt(7)
);
} }
// hover casually towards the chosen position // hover casually towards the chosen position
double changedX = hoveringPosition.getX() + 0.5D - x; double changedX = hoveringPosition.getX() + 0.5D - getX();
double changedY = hoveringPosition.getY() + 0.1D - y; double changedY = hoveringPosition.getY() + 0.1D - getY();
double changedZ = hoveringPosition.getZ() + 0.5D - z; double changedZ = hoveringPosition.getZ() + 0.5D - getZ();
Vec3d vel = getVelocity(); Vec3d vel = getVelocity();
@ -185,7 +189,8 @@ public class ButterflyEntity extends AmbientEntity {
} }
@Override @Override
public void handleFallDamage(float distance, float damageMultiplier) { public boolean handleFallDamage(float distance, float damageMultiplier) {
return false;
} }
@Override @Override
@ -195,7 +200,7 @@ public class ButterflyEntity extends AmbientEntity {
@Override @Override
public boolean canSpawn(IWorld world, SpawnType type) { public boolean canSpawn(IWorld world, SpawnType type) {
if (type == SpawnType.NATURAL) { if (type == SpawnType.NATURAL) {
return y < world.getSeaLevel() && world.getLightLevel(getBlockPos()) > 7; return getY() < world.getSeaLevel() && world.getLightLevel(getBlockPos()) > 7;
} }
return true; return true;
} }

View file

@ -10,8 +10,8 @@ import com.minelittlepony.unicopia.ability.PegasusCloudInteractionAbility.ICloud
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
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 com.minelittlepony.unicopia.util.particles.ParticleEmitter; import com.minelittlepony.unicopia.particles.ParticleEmitter;
import com.minelittlepony.unicopia.util.particles.UParticles; import com.minelittlepony.unicopia.particles.UParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -102,11 +102,6 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
return false; return false;
} }
@Override
public int getLightmapCoordinates() {
return 0xF000F0;
}
@Override @Override
public float getBrightnessAtEyes() { public float getBrightnessAtEyes() {
return 0xF000F0; return 0xF000F0;
@ -149,7 +144,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
@Override @Override
protected void pushAway(Entity other) { protected void pushAway(Entity other) {
if (other instanceof CloudEntity || other instanceof PlayerEntity) { if (other instanceof CloudEntity || other instanceof PlayerEntity) {
if (other.y > y) { if (other.getY() > getY()) {
return; return;
} }
@ -175,9 +170,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
if (getIsRaining()) { if (getIsRaining()) {
if (world.isClient) { if (world.isClient) {
for (int i = 0; i < 30 * getCloudSize(); i++) { for (int i = 0; i < 30 * getCloudSize(); i++) {
double x = MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX); double x = MathHelper.nextDouble(random, boundingbox.x1, boundingbox.x2);
double y = getBoundingBox().minY + getHeight()/2; double y = getBoundingBox().y1 + getHeight()/2;
double z = MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ); double z = MathHelper.nextDouble(random, boundingbox.z1, boundingbox.z2);
ParticleEffect particleId = canSnowHere(new BlockPos(x, y, z)) ? ParticleTypes.ITEM_SNOWBALL : UParticles.RAIN_DROPS; ParticleEffect particleId = canSnowHere(new BlockPos(x, y, z)) ? ParticleTypes.ITEM_SNOWBALL : UParticles.RAIN_DROPS;
@ -186,21 +181,20 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
Box rainedArea = boundingbox Box rainedArea = boundingbox
.expand(1, 0, 1) .expand(1, 0, 1)
.expand(0, -(y - getGroundPosition(x, z).getY()), 0); .expand(0, -(getY() - getGroundPosition(getBlockPos()).getY()), 0);
for (PlayerEntity j : world.getEntities(PlayerEntity.class, rainedArea)) { for (PlayerEntity j : world.getEntities(PlayerEntity.class, rainedArea, j -> canSnowHere(j.getBlockPos()))) {
if (!canSnowHere(j.getBlockPos())) {
j.world.playSound(j, j.getBlockPos(), SoundEvents.WEATHER_RAIN, SoundCategory.AMBIENT, 0.1F, 0.6F); j.world.playSound(j, j.getBlockPos(), SoundEvents.WEATHER_RAIN, SoundCategory.AMBIENT, 0.1F, 0.6F);
} }
} }
}
double width = getDimensions(getPose()).width; double width = getDimensions(getPose()).width;
BlockPos pos = getGroundPosition( BlockPos pos = getGroundPosition(new BlockPos(
x + random.nextFloat() * width, getX() + random.nextFloat() * width,
z + random.nextFloat() * width getY(),
); getZ() + random.nextFloat() * width
));
if (getIsThundering()) { if (getIsThundering()) {
if (random.nextInt(3000) == 0) { if (random.nextInt(3000) == 0) {
@ -246,7 +240,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
} }
} }
state.getBlock().onRainTick(world, below); state.getBlock().rainTick(world, below);
} }
} }
@ -277,7 +271,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
for (Entity i : world.getEntities(this, boundingbox for (Entity i : world.getEntities(this, boundingbox
.expand(1 / (1 + getCloudSize())), EquinePredicates.ENTITY_INTERACT_WITH_CLOUDS)) { .expand(1 / (1 + getCloudSize())), EquinePredicates.ENTITY_INTERACT_WITH_CLOUDS)) {
if (i.y > y + 0.5) { if (i.getY() > getY() + 0.5) {
applyGravityCompensation(i); applyGravityCompensation(i);
} }
} }
@ -285,9 +279,9 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
if (isOnFire() && !dead) { if (isOnFire() && !dead) {
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
world.addParticle(ParticleTypes.CLOUD, world.addParticle(ParticleTypes.CLOUD,
MathHelper.nextDouble(random, boundingbox.minX, boundingbox.maxX), MathHelper.nextDouble(random, boundingbox.x1, boundingbox.x2),
MathHelper.nextDouble(random, boundingbox.minY, boundingbox.maxY), MathHelper.nextDouble(random, boundingbox.y1, boundingbox.y2),
MathHelper.nextDouble(random, boundingbox.minZ, boundingbox.maxZ), 0, 0.25, 0); MathHelper.nextDouble(random, boundingbox.z1, boundingbox.z2), 0, 0.25, 0);
} }
} }
@ -308,7 +302,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
@Override @Override
public double getMountedHeightOffset() { public double getMountedHeightOffset() {
return getBoundingBox().maxY - getBoundingBox().minY - 0.25; return getBoundingBox().y2 - getBoundingBox().y1 - 0.25;
} }
@Override @Override
@ -320,14 +314,14 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
@Override @Override
public void onPlayerCollision(PlayerEntity player) { public void onPlayerCollision(PlayerEntity player) {
if (player.y >= y) { if (player.getY() >= getY()) {
if (applyGravityCompensation(player)) { if (applyGravityCompensation(player)) {
double difX = player.x - player.prevX; double difX = player.getX() - player.prevX;
double difZ = player.z - player.prevZ; double difZ = player.getZ() - player.prevZ;
double difY = player.y - player.prevY; double difY = player.getY() - player.prevY;
player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6); player.horizontalSpeed = (float)(player.horizontalSpeed + MathHelper.sqrt(difX * difX + difZ * difZ) * 0.6);
player.distanceWalked = (float)(player.distanceWalked + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6); player.distanceTraveled = (float)(player.distanceTraveled + MathHelper.sqrt(difX * difX + difY * difY + difZ * difZ) * 0.6);
if (Pony.of(player).stepOnCloud()) { if (Pony.of(player).stepOnCloud()) {
BlockSoundGroup soundtype = BlockSoundGroup.WOOL; BlockSoundGroup soundtype = BlockSoundGroup.WOOL;
@ -343,15 +337,15 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
protected void mobTick() { protected void mobTick() {
if (!getStationary()) { if (!getStationary()) {
if (!hasVehicle()) { if (!hasVehicle()) {
double distance = targetAltitude - y; double distance = targetAltitude - getY();
if (targetAltitude < y && !world.isAir(getBlockPos())) { if (targetAltitude < getY() && !world.isAir(getBlockPos())) {
distance = 0; distance = 0;
} }
if (Math.abs(distance) < 1 && random.nextInt(7000) == 0) { if (Math.abs(distance) < 1 && random.nextInt(7000) == 0) {
targetAltitude = getRandomFlyingHeight(); targetAltitude = getRandomFlyingHeight();
distance = targetAltitude - y; distance = targetAltitude - getY();
} }
if (Math.abs(distance) < 1) { if (Math.abs(distance) < 1) {
@ -449,10 +443,10 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
} else if (stack != null && stack.getItem() instanceof ShovelItem) { } else if (stack != null && stack.getItem() instanceof ShovelItem) {
return super.damage(source, amount * 1.5f); return super.damage(source, amount * 1.5f);
} else if (canFly) { } else if (canFly) {
if (player.y < y || !world.isAir(getBlockPos())) { if (player.getY() < getY() || !world.isAir(getBlockPos())) {
targetAltitude = y + 5; targetAltitude = getY() + 5;
} else if (player.y > y) { } else if (player.getY() > getY()) {
targetAltitude = y - 5; targetAltitude = getY() - 5;
} }
} }
} }
@ -610,7 +604,7 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
} }
public void spawnThunderbolt() { public void spawnThunderbolt() {
spawnThunderbolt(getGroundPosition(x, z)); spawnThunderbolt(getGroundPosition(getBlockPos()));
} }
public void spawnThunderbolt(BlockPos pos) { public void spawnThunderbolt(BlockPos pos) {
@ -619,10 +613,10 @@ public class CloudEntity extends FlyingEntity implements ICloudEntity, InAnimate
} }
} }
private BlockPos getGroundPosition(double x, double z) { private BlockPos getGroundPosition(BlockPos inPos) {
BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(x, y, z)); BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, inPos);
if (pos.getY() >= y) { if (pos.getY() >= getY()) {
while (World.isValid(pos)) { while (World.isValid(pos)) {
pos = pos.down(); pos = pos.down();
if (world.getBlockState(pos).hasSolidTopSurface(world, pos, this)) { if (world.getBlockState(pos).hasSolidTopSurface(world, pos, this)) {

View file

@ -82,7 +82,7 @@ public class ConstructionCloudEntity extends CloudEntity {
if (hit != null) { if (hit != null) {
Direction direction = hit.getSide(); Direction direction = hit.getSide();
mc.hitResult = hit = new BlockHitResult(hit.getPos(), direction, new BlockPos(hit.getPos()), false); mc.crosshairTarget = hit = new BlockHitResult(hit.getPos(), direction, new BlockPos(hit.getPos()), false);
int oldCount = stack.getCount(); int oldCount = stack.getCount();
ActionResult result = mc.interactionManager.interactBlock(((ClientPlayerEntity)player), (ClientWorld)player.world, hand, hit); ActionResult result = mc.interactionManager.interactBlock(((ClientPlayerEntity)player), (ClientWorld)player.world, hand, hit);

View file

@ -9,8 +9,8 @@ import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds; import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.particles.UParticles;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -124,12 +124,12 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
if (passenger instanceof LivingEntity) { if (passenger instanceof LivingEntity) {
LivingEntity living = (LivingEntity)passenger; LivingEntity living = (LivingEntity)passenger;
if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getHealthMaximum()) { if (!living.hasStatusEffect(StatusEffects.REGENERATION) && living.getHealth() < living.getMaximumHealth()) {
living.addPotionEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 20, 2)); living.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 20, 2));
} }
if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getHealthMaximum()) { if (!living.hasStatusEffect(StatusEffects.SLOWNESS) && living.getHealth() < living.getMaximumHealth()) {
living.addPotionEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 2000, 4)); living.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 2000, 4));
} }
} }
} }
@ -137,9 +137,9 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
if (world.isClient) { if (world.isClient) {
EntityDimensions dims = getDimensions(getPose()); EntityDimensions dims = getDimensions(getPose());
double x = this.x + dims.width * random.nextFloat() - dims.width/2; double x = getX() + dims.width * random.nextFloat() - dims.width/2;
double y = this.y + dims.height * random.nextFloat(); double y = getY() + dims.height * random.nextFloat();
double z = this.z + dims.width * random.nextFloat() - dims.width/2; double z = getZ() + dims.width * random.nextFloat() - dims.width/2;
world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0); world.addParticle(ParticleTypes.DRIPPING_LAVA, x, y, z, 0, 0, 0);
} }
@ -153,22 +153,22 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
if (hasPassengers()) { if (hasPassengers()) {
Entity passenger = getPrimaryPassenger(); Entity passenger = getPrimaryPassenger();
if (player.canConsume(false) || player.getHealth() < player.getHealthMaximum()) { if (player.canConsume(false) || player.getHealth() < player.getMaximumHealth()) {
DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player); DamageSource d = MagicalDamageSource.causePlayerDamage("feed", player);
Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7); Pony.of(player).spawnParticles(UParticles.CHANGELING_MAGIC, 7);
if (passenger instanceof LivingEntity) { if (passenger instanceof LivingEntity) {
if (player.hasStatusEffect(StatusEffects.NAUSEA)) { if (player.hasStatusEffect(StatusEffects.NAUSEA)) {
((LivingEntity)passenger).addPotionEffect(player.removePotionEffect(StatusEffects.NAUSEA)); ((LivingEntity)passenger).addStatusEffect(player.removeStatusEffectInternal(StatusEffects.NAUSEA));
} else if (random.nextInt(2300) == 0) { } else if (random.nextInt(2300) == 0) {
((LivingEntity)passenger).addPotionEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1)); ((LivingEntity)passenger).addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 20, 1));
} }
} }
if (passenger instanceof PlayerEntity) { if (passenger instanceof PlayerEntity) {
if (!player.hasStatusEffect(StatusEffects.HEALTH_BOOST)) { if (!player.hasStatusEffect(StatusEffects.HEALTH_BOOST)) {
player.addPotionEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1)); player.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 13000, 1));
} }
} }
@ -226,9 +226,9 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
double d1 = random.nextGaussian() * 0.02; double d1 = random.nextGaussian() * 0.02;
world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.getDefaultState()), world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.SLIME_BLOCK.getDefaultState()),
x + random.nextFloat() * dims.width * 2 - dims.width, getX() + random.nextFloat() * dims.width * 2 - dims.width,
y + random.nextFloat() * dims.height, getY() + random.nextFloat() * dims.height,
z + random.nextFloat() * dims.width * 2 - dims.width, getZ() + random.nextFloat() * dims.width * 2 - dims.width,
d2, d0, d1); d2, d0, d1);
} }
} }
@ -244,7 +244,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
i -= j; i -= j;
world.spawnEntity(new ExperienceOrbEntity(world, x, y, z, j)); world.spawnEntity(new ExperienceOrbEntity(world, getX(), getY(), getZ(), j));
} }
removeAllPassengers(); removeAllPassengers();
@ -292,7 +292,7 @@ public class CuccoonEntity extends LivingEntity implements IMagicals, InAnimate
} }
@Override @Override
public void setEquippedStack(EquipmentSlot slot, ItemStack stack) { public void equipStack(EquipmentSlot slot, ItemStack stack) {
} }
@Override @Override

View file

@ -15,7 +15,7 @@ import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
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.world.ViewableWorld; import net.minecraft.world.WorldView;
public class FollowCasterGoal<T extends MobEntity> extends Goal { public class FollowCasterGoal<T extends MobEntity> extends Goal {
@ -25,7 +25,7 @@ public class FollowCasterGoal<T extends MobEntity> extends Goal {
protected LivingEntity owner; protected LivingEntity owner;
protected final ViewableWorld world; protected final WorldView world;
public final double followSpeed; public final double followSpeed;
@ -79,15 +79,15 @@ public class FollowCasterGoal<T extends MobEntity> extends Goal {
@Override @Override
public void start() { public void start() {
timeout = 0; timeout = 0;
oldWaterCost = entity.getPathNodeTypeWeight(PathNodeType.WATER); oldWaterCost = entity.getPathfindingPenalty(PathNodeType.WATER);
entity.setPathNodeTypeWeight(PathNodeType.WATER, 0); entity.setPathfindingPenalty(PathNodeType.WATER, 0);
} }
@Override @Override
public void stop() { public void stop() {
owner = null; owner = null;
navigation.stop(); navigation.stop();
entity.setPathNodeTypeWeight(PathNodeType.WATER, oldWaterCost); entity.setPathfindingPenalty(PathNodeType.WATER, oldWaterCost);
} }
@Override @Override
@ -107,15 +107,15 @@ public class FollowCasterGoal<T extends MobEntity> extends Goal {
return; return;
} }
int x = MathHelper.floor(owner.x) - 2; int x = MathHelper.floor(owner.getX()) - 2;
int y = MathHelper.floor(owner.getBoundingBox().minY); int y = MathHelper.floor(owner.getBoundingBox().y1);
int z = MathHelper.floor(owner.z) - 2; int z = MathHelper.floor(owner.getZ()) - 2;
for (int offX = 0; offX <= 4; offX++) { for (int offX = 0; offX <= 4; offX++) {
for (int offZ = 0; offZ <= 4; offZ++) { for (int offZ = 0; offZ <= 4; offZ++) {
if ((offX < 1 || offZ < 1 || offX > 3 || offZ > 3) && canMoveInto(new BlockPos(x + offX, y - 1, z + offZ))) { if ((offX < 1 || offZ < 1 || offX > 3 || offZ > 3) && canMoveInto(new BlockPos(x + offX, y - 1, z + offZ))) {
entity.setPositionAndAngles((x + offX) + 0.5F, y, (z + offZ) + 0.5F, entity.headYaw, entity.pitch); entity.updatePositionAndAngles((x + offX) + 0.5F, y, (z + offZ) + 0.5F, entity.headYaw, entity.pitch);
navigation.stop(); navigation.stop();
return; return;

View file

@ -115,7 +115,7 @@ public class LivingEntityCapabilities implements RaceContainer<LivingEntity>, Ca
@Override @Override
public void fromNBT(CompoundTag compound) { public void fromNBT(CompoundTag compound) {
if (compound.containsKey("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }
} }

View file

@ -54,14 +54,14 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
} }
public ProjectileEntity(EntityType<ProjectileEntity> type, World world, LivingEntity thrower) { public ProjectileEntity(EntityType<ProjectileEntity> type, World world, LivingEntity thrower) {
this(type, world, thrower.x, thrower.y + thrower.getStandingEyeHeight(), thrower.z); this(type, world, thrower.getX(), thrower.getY() + thrower.getStandingEyeHeight(), thrower.getZ());
setOwner(thrower); setOwner(thrower);
} }
public ProjectileEntity(EntityType<ProjectileEntity> type, World world, double x, double y, double z) { public ProjectileEntity(EntityType<ProjectileEntity> type, World world, double x, double y, double z) {
super(type, world); super(type, world);
setPosition(x, y, z); setPos(x, y, z);
} }
@Override @Override
@ -224,7 +224,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
ParticleEffect effect = getParticleParameters(); ParticleEffect effect = getParticleParameters();
for(int i = 0; i < 8; i++) { for(int i = 0; i < 8; i++) {
world.addParticle(effect, x, y, z, 0, 0, 0); world.addParticle(effect, getX(), getY(), getZ(), 0, 0, 0);
} }
} }
@ -234,7 +234,7 @@ public class ProjectileEntity extends ThrownItemEntity implements IMagicals, Adv
public void readCustomDataFromTag(CompoundTag compound) { public void readCustomDataFromTag(CompoundTag compound) {
super.readCustomDataFromTag(compound); super.readCustomDataFromTag(compound);
if (compound.containsKey("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }
} }

View file

@ -42,7 +42,7 @@ public class RainbowEntity extends Entity implements InAnimate {
float yaw = (int)MathHelper.nextDouble(random, 0, 360); float yaw = (int)MathHelper.nextDouble(random, 0, 360);
setPositionAndAngles(0, 0, 0, yaw, 0); updatePositionAndAngles(0, 0, 0, yaw, 0);
radius = MathHelper.nextDouble(random, RAINBOW_MIN_SIZE, RAINBOW_MAX_SIZE); radius = MathHelper.nextDouble(random, RAINBOW_MIN_SIZE, RAINBOW_MAX_SIZE);
ticksAlive = 10000; ticksAlive = 10000;
@ -59,10 +59,8 @@ public class RainbowEntity extends Entity implements InAnimate {
} }
@Override @Override
public void setPosition(double x, double y, double z) { public void setPos(double x, double y, double z) {
this.x = x; super.setPos(x, y, z);
this.y = y;
this.z = z;
float width = getDimensions(getPose()).width; float width = getDimensions(getPose()).width;
setBoundingBox(new Box( setBoundingBox(new Box(
@ -77,7 +75,7 @@ public class RainbowEntity extends Entity implements InAnimate {
} }
@Override @Override
public boolean shouldRenderAtDistance(double distance) { public boolean shouldRender(double distance) {
return true; return true;
} }
@ -96,8 +94,8 @@ public class RainbowEntity extends Entity implements InAnimate {
if (!removed) { if (!removed) {
Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos()); Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos());
world.getEntities(RainbowEntity.class, bounds).forEach(this::attackCompetitor); world.getEntities(RainbowEntity.class, bounds, null).forEach(this::attackCompetitor);
world.getEntities(RainbowEntity.Spawner.class, bounds).forEach(this::attackCompetitor); world.getEntities(RainbowEntity.Spawner.class, bounds, null).forEach(this::attackCompetitor);
} }
} }
@ -137,8 +135,8 @@ public class RainbowEntity extends Entity implements InAnimate {
Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos()); Box bounds = SPAWN_COLLISSION_RADIUS.offset(getPos());
return super.canSpawn(world, type) return super.canSpawn(world, type)
&& world.getEntities(RainbowEntity.class, bounds).isEmpty() && world.getEntities(RainbowEntity.class, bounds, null).isEmpty()
&& world.getEntities(RainbowEntity.Spawner.class, bounds).isEmpty(); && world.getEntities(RainbowEntity.Spawner.class, bounds, null).isEmpty();
} }
@Override @Override
@ -157,7 +155,7 @@ public class RainbowEntity extends Entity implements InAnimate {
public void trySpawnRainbow() { public void trySpawnRainbow() {
RainbowEntity rainbow = UEntities.RAINBOW.create(world); RainbowEntity rainbow = UEntities.RAINBOW.create(world);
rainbow.setPosition(x, y, z); rainbow.setPos(getX(), getY(), getZ());
world.spawnEntity(rainbow); world.spawnEntity(rainbow);
} }
} }
@ -168,7 +166,7 @@ public class RainbowEntity extends Entity implements InAnimate {
} }
@Override @Override
public void method_11188(ClientPlayPacketListener listener) { public void apply(ClientPlayPacketListener listener) {
// TODO: Packet needs to be registered, and handling separated // TODO: Packet needs to be registered, and handling separated
MinecraftClient client = MinecraftClient.getInstance(); MinecraftClient client = MinecraftClient.getInstance();

View file

@ -67,8 +67,8 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile {
} }
@Override @Override
public void method_7449(int amount) { public void setPunch(int amount) {
super.method_7449(amount); super.setPunch(amount);
getDataTracker().set(KNOCKBACK, amount); getDataTracker().set(KNOCKBACK, amount);
} }
@ -99,7 +99,7 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile {
LivingEntity target = (LivingEntity)entity; LivingEntity target = (LivingEntity)entity;
if (!world.isClient) { if (!world.isClient) {
target.setStuckArrows(target.getStuckArrows() + 1); target.setStuckArrowCount(target.getStuckArrowCount() + 1);
} }
int knockback = getDataTracker().get(KNOCKBACK); int knockback = getDataTracker().get(KNOCKBACK);
@ -171,7 +171,7 @@ public class SpearEntity extends ArrowEntity implements AdvancedProjectile {
@Override @Override
public void launch(Entity shooter, float pitch, float yaw, float pitchOffset, float velocity, float inaccuracy) { public void launch(Entity shooter, float pitch, float yaw, float pitchOffset, float velocity, float inaccuracy) {
method_7474(shooter, pitch, yaw, pitchOffset, velocity, inaccuracy); setProperties(shooter, pitch, yaw, pitchOffset, velocity, inaccuracy);
} }
@Override @Override

View file

@ -4,7 +4,7 @@ import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.UItems;
import net.minecraft.container.Container; import net.minecraft.container.Container;
import net.minecraft.container.NameableContainerProvider; import net.minecraft.container.NameableContainerFactory;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.DataTracker;
@ -24,7 +24,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules; import net.minecraft.world.GameRules;
import net.minecraft.world.World; import net.minecraft.world.World;
public class SpellbookEntity extends MobEntity implements NameableContainerProvider, IMagicals { public class SpellbookEntity extends MobEntity implements NameableContainerFactory, IMagicals {
private static final TrackedData<Boolean> OPENED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN); private static final TrackedData<Boolean> OPENED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
private static final TrackedData<Boolean> ALTERED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN); private static final TrackedData<Boolean> ALTERED = DataTracker.registerData(SpellbookEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
@ -85,7 +85,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi
@Override @Override
public void tick() { public void tick() {
boolean open = getIsOpen(); boolean open = getIsOpen();
jumping = open && isInWater(); jumping = open && isTouchingWater();
super.tick(); super.tick();
if (open && world.isClient) { if (open && world.isClient) {
@ -98,7 +98,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi
if (random.nextInt(320) == 0) { if (random.nextInt(320) == 0) {
for (int offY = 0; offY <= 1; ++offY) { for (int offY = 0; offY <= 1; ++offY) {
world.addParticle(ParticleTypes.ENCHANT, world.addParticle(ParticleTypes.ENCHANT,
x, y, z, getX(), getY(), getZ(),
offX/2F + random.nextFloat(), offX/2F + random.nextFloat(),
offY/2F - random.nextFloat() + 0.5f, offY/2F - random.nextFloat() + 0.5f,
offZ/2F + random.nextFloat() offZ/2F + random.nextFloat()
@ -110,7 +110,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi
} }
if (world.random.nextInt(30) == 0) { if (world.random.nextInt(30) == 0) {
float celest = world.getStarsBrightness(1) * 4; float celest = world.getSkyAngleRadians(1) * 4;
boolean isDay = celest > 3 || celest < 1; boolean isDay = celest > 3 || celest < 1;
@ -136,7 +136,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi
BlockSoundGroup sound = BlockSoundGroup.WOOD; BlockSoundGroup sound = BlockSoundGroup.WOOD;
world.playSound(x, y, z, sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true); world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch(), true);
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) {
dropItem(UItems.spellbook, 1); dropItem(UItems.spellbook, 1);
@ -178,7 +178,7 @@ public class SpellbookEntity extends MobEntity implements NameableContainerProvi
super.readCustomDataFromTag(compound); super.readCustomDataFromTag(compound);
setIsOpen(compound.getBoolean("open")); setIsOpen(compound.getBoolean("open"));
setUserSetState(compound.containsKey("force_open") ? compound.getBoolean("force_open") : null); setUserSetState(compound.contains("force_open") ? compound.getBoolean("force_open") : null);
} }
@Override @Override

View file

@ -79,14 +79,14 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
} }
@Override @Override
public boolean shouldRenderAtDistance(double distance) { public boolean shouldRender(double distance) {
if (getCurrentLevel() > 0) { if (getCurrentLevel() > 0) {
distance /= getCurrentLevel(); distance /= getCurrentLevel();
} }
if (distance > 0) { if (distance > 0) {
distance--; distance--;
} }
return super.shouldRenderAtDistance(distance); return super.shouldRender(distance);
} }
@Override @Override
@ -223,7 +223,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
} else if (world.random.nextInt((int)(exhaustionChance * 500)) == 0) { } else if (world.random.nextInt((int)(exhaustionChance * 500)) == 0) {
setEffect(null); setEffect(null);
} else if (world.random.nextInt((int)(exhaustionChance * 3500)) == 0) { } else if (world.random.nextInt((int)(exhaustionChance * 3500)) == 0) {
world.createExplosion(this, x, y, z, getCurrentLevel()/2, DestructionType.BREAK); world.createExplosion(this, getX(), getY(), getZ(), getCurrentLevel()/2, DestructionType.BREAK);
remove(); remove();
} }
} }
@ -266,7 +266,7 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
protected void onDeath() { protected void onDeath() {
BlockSoundGroup sound = BlockSoundGroup.STONE; BlockSoundGroup sound = BlockSoundGroup.STONE;
world.playSound(x, y, z, sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true); world.playSound(getX(), getY(), getZ(), sound.getBreakSound(), SoundCategory.NEUTRAL, sound.getVolume(), sound.getPitch(), true);
if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) { if (world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS)) {
int level = getCurrentLevel(); int level = getCurrentLevel();
@ -352,14 +352,14 @@ public class SpellcastEntity extends MobEntityWithAi implements IMagicals, Caste
@Override @Override
public void readCustomDataFromTag(CompoundTag compound) { public void readCustomDataFromTag(CompoundTag compound) {
super.readCustomDataFromTag(compound); super.readCustomDataFromTag(compound);
if (compound.containsKey("affinity")) { if (compound.contains("affinity")) {
setAffinity(Affinity.of(compound.getString("affinity"))); setAffinity(Affinity.of(compound.getString("affinity")));
} }
setOwner(compound.getUuid("owner")); setOwner(compound.getUuid("owner"));
setCurrentLevel(compound.getInt("level")); setCurrentLevel(compound.getInt("level"));
if (compound.containsKey("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }
} }

View file

@ -90,10 +90,10 @@ public class WildCloudEntity extends CloudEntity {
targetAltitude = getRandomFlyingHeight(); targetAltitude = getRandomFlyingHeight();
if (y < minSpawnHeight) { if (getY() < minSpawnHeight) {
minSpawnHeight += random.nextInt(Math.max(1, (int)getMaximumFlyingHeight() - (int)minSpawnHeight)); minSpawnHeight += random.nextInt(Math.max(1, (int)getMaximumFlyingHeight() - (int)minSpawnHeight));
setPositionAndAngles(x, minSpawnHeight - 1, z, yaw, pitch); updatePositionAndAngles(getX(), minSpawnHeight - 1, getZ(), yaw, pitch);
moveToBoundingBoxCenter(); moveToBoundingBoxCenter();
} }
@ -115,7 +115,7 @@ public class WildCloudEntity extends CloudEntity {
setIsRaining(packData.leader.getIsRaining()); setIsRaining(packData.leader.getIsRaining());
setIsThundering(packData.leader.getIsThundering()); setIsThundering(packData.leader.getIsThundering());
setPositionAndAngles(position.x, position.y, position.z, packData.leader.yaw, packData.leader.pitch); updatePositionAndAngles(position.x, position.y, position.z, packData.leader.yaw, packData.leader.pitch);
checkBlockCollision(); checkBlockCollision();
} }

View file

@ -144,7 +144,7 @@ class AbilityDelegate implements AbilityReceiver, Updatable, NbtSerialisable {
warmup = compound.getInt("warmup"); warmup = compound.getInt("warmup");
cooldown = compound.getInt("cooldown"); cooldown = compound.getInt("cooldown");
if (compound.containsKey("activeAbility")) { if (compound.contains("activeAbility")) {
Abilities.getInstance() Abilities.getInstance()
.getPowerFromName(compound.getString("activeAbility")) .getPowerFromName(compound.getString("activeAbility"))
.ifPresent(p -> activeAbility = p); .ifPresent(p -> activeAbility = p);

View file

@ -10,8 +10,8 @@ import com.minelittlepony.unicopia.entity.FlightControl;
import com.minelittlepony.unicopia.entity.Updatable; import com.minelittlepony.unicopia.entity.Updatable;
import com.minelittlepony.unicopia.magic.MagicEffect; import com.minelittlepony.unicopia.magic.MagicEffect;
import com.minelittlepony.unicopia.mixin.MixinEntity; import com.minelittlepony.unicopia.mixin.MixinEntity;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.NbtSerialisable; import com.minelittlepony.unicopia.util.NbtSerialisable;
import com.minelittlepony.unicopia.util.particles.UParticles;
import com.minelittlepony.unicopia.util.MutableVector; import com.minelittlepony.unicopia.util.MutableVector;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -134,14 +134,14 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl
rnd.nextGaussian() * entity.getWidth() rnd.nextGaussian() * entity.getWidth()
); );
player.addParticle(UParticles.UNICORN_MAGIC, pos, velocity.toImmutable()); player.addParticle(MagicParticleEffect.UNICORN, pos, velocity.toImmutable());
} }
} }
entity.abilities.allowFlying = checkCanFly(player); entity.abilities.allowFlying = checkCanFly(player);
if (!entity.abilities.creativeMode) { if (!entity.abilities.creativeMode) {
entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isInWater(); entity.abilities.flying |= entity.abilities.allowFlying && isFlying && !entity.onGround && !entity.isTouchingWater();
} }
isFlying = entity.abilities.flying && !entity.abilities.creativeMode; isFlying = entity.abilities.flying && !entity.abilities.creativeMode;
@ -153,7 +153,7 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl
} }
if (gravity < 0) { if (gravity < 0) {
entity.onGround = !entity.world.isAir(new BlockPos(entity.x, entity.y + entity.getHeight() + 0.5F, entity.z)); entity.onGround = !entity.world.isAir(new BlockPos(entity.getX(), entity.getY() + entity.getHeight() + 0.5F, entity.getZ()));
if (entity.onGround) { if (entity.onGround) {
entity.abilities.flying = false; entity.abilities.flying = false;
@ -263,8 +263,8 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl
} }
} }
lastTickPosX = entity.x; lastTickPosX = entity.getX();
lastTickPosZ = entity.z; lastTickPosZ = entity.getZ();
entity.setVelocity(velocity.toImmutable()); entity.setVelocity(velocity.toImmutable());
} }
@ -325,8 +325,8 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl
} }
protected double getHorizontalMotion(Entity e) { protected double getHorizontalMotion(Entity e) {
double motionX = e.x - lastTickPosX; double motionX = e.getX() - lastTickPosX;
double motionZ = e.z - lastTickPosZ; double motionZ = e.getZ() - lastTickPosZ;
return (motionX * motionX) return (motionX * motionX)
+ (motionZ * motionZ); + (motionZ * motionZ);
@ -382,7 +382,7 @@ public class GravityDelegate implements Updatable, FlightControl, NbtSerialisabl
isFlying = compound.getBoolean("isFlying"); isFlying = compound.getBoolean("isFlying");
isRainbooming = compound.getBoolean("isRainbooming"); isRainbooming = compound.getBoolean("isRainbooming");
if (compound.containsKey("gravity")) { if (compound.contains("gravity")) {
gravity = compound.getFloat("gravity"); gravity = compound.getFloat("gravity");
} else { } else {
gravity = 0; gravity = 0;

View file

@ -327,8 +327,8 @@ public class PlayerImpl implements Pony {
@Override @Override
public boolean stepOnCloud() { public boolean stepOnCloud() {
if (entity.fallDistance > 1 || entity.distanceWalked > nextStepDistance) { if (entity.fallDistance > 1 || entity.distanceTraveled > nextStepDistance) {
nextStepDistance = entity.distanceWalked + 2; nextStepDistance = entity.distanceTraveled + 2;
entity.fallDistance = 0; entity.fallDistance = 0;
return true; return true;
@ -372,16 +372,16 @@ public class PlayerImpl implements Pony {
player.getHungerManager().add(-health/2, -saturation/2); player.getHungerManager().add(-health/2, -saturation/2);
player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true)); player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 3, true, true));
} else { } else {
player.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true)); player.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 200, 3, true, true));
} }
if (player.world.getDifficulty() != Difficulty.PEACEFUL && player.world.random.nextInt(20) == 0) { if (player.world.getDifficulty() != Difficulty.PEACEFUL && player.world.random.nextInt(20) == 0) {
player.addPotionEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true)); player.addStatusEffect(new StatusEffectInstance(UEffects.FOOD_POISONING, 3, 2, true, true));
} }
player.addPotionEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true)); player.addStatusEffect(new StatusEffectInstance(StatusEffects.WEAKNESS, 2000, 2, true, true));
} }
} }
@ -408,7 +408,7 @@ public class PlayerImpl implements Pony {
powers.fromNBT(compound.getCompound("powers")); powers.fromNBT(compound.getCompound("powers"));
gravity.fromNBT(compound.getCompound("gravity")); gravity.fromNBT(compound.getCompound("gravity"));
if (compound.containsKey("effect")) { if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect"))); setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
} }

View file

@ -45,7 +45,7 @@ public class PlayerPageStats implements NbtSerialisable, PageOwner {
@Override @Override
public void fromNBT(CompoundTag compound) { public void fromNBT(CompoundTag compound) {
pageStates.clear(); pageStates.clear();
if (compound.containsKey("pageStates")) { if (compound.contains("pageStates")) {
CompoundTag pages = compound.getCompound("pageStates"); CompoundTag pages = compound.getCompound("pageStates");
pages.getKeys().forEach(key -> { pages.getKeys().forEach(key -> {

View file

@ -5,13 +5,15 @@ import java.util.Random;
import com.minelittlepony.unicopia.util.WorldEvent; import com.minelittlepony.unicopia.util.WorldEvent;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tools.FabricToolTags;
import net.minecraft.block.AnvilBlock; import net.minecraft.block.AnvilBlock;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -19,23 +21,17 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
public class CloudAnvilBlock extends AnvilBlock implements Gas { public class CloudAnvilBlock extends AnvilBlock implements Gas {
@SuppressWarnings("deprecation")
public CloudAnvilBlock() { public CloudAnvilBlock() {
super(FabricBlockSettings.of(Material.WOOL) super(FabricBlockSettings.of(Material.WOOL)
.strength(0.025F, 1) .strength(0.025F, 1)
.resistance(2000) .resistance(2000)
.breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.SHOVELS, 0) .breakByTool(FabricToolTags.SHOVELS, 0)
.sounds(BlockSoundGroup.WOOL) .sounds(BlockSoundGroup.WOOL)
.ticksRandomly() .ticksRandomly()
.build() .build()
); );
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public void onLandedUpon(World world, BlockPos pos, Entity entityIn, float fallDistance) { public void onLandedUpon(World world, BlockPos pos, Entity entityIn, float fallDistance) {
if (!applyLanding(entityIn, fallDistance)) { if (!applyLanding(entityIn, fallDistance)) {
@ -54,8 +50,8 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas {
} }
@Override @Override
public boolean activate(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return false; return ActionResult.PASS;
} }
@Override @Override
@ -66,7 +62,7 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas {
} }
@Override @Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
BlockState below = world.getBlockState(pos.down()); BlockState below = world.getBlockState(pos.down());
if (below.getBlock() instanceof Gas) { if (below.getBlock() instanceof Gas) {
@ -75,7 +71,7 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas {
} }
} }
super.onScheduledTick(state, world, pos, rand); super.scheduledTick(state, world, pos, rand);
} }
@Override @Override

View file

@ -7,15 +7,12 @@ import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.MossItem; import com.minelittlepony.unicopia.item.MossItem;
import com.minelittlepony.unicopia.util.HoeUtil; import com.minelittlepony.unicopia.util.HoeUtil;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ItemUsageContext;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
@ -25,10 +22,8 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
private final CloudType variant; private final CloudType variant;
public CloudBlock(Material material, CloudType variant) { public CloudBlock(CloudType variant) {
super(FabricBlockSettings.of(material) super(variant.configure()
.strength(0.5F, 1)
.sounds(BlockSoundGroup.WOOL)
.ticksRandomly() .ticksRandomly()
.build() .build()
); );
@ -42,12 +37,7 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
} }
@Override @Override
public boolean isOpaque(BlockState state) { public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
return variant != CloudType.NORMAL;
}
@Override
public void onScheduledTick(BlockState state, World world, BlockPos pos, Random rand) {
if (rand.nextInt(10) == 0) { if (rand.nextInt(10) == 0) {
pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2)); pos = pos.offset(Direction.random(rand), 1 + rand.nextInt(2));
state = world.getBlockState(pos); state = world.getBlockState(pos);
@ -60,11 +50,6 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable {
} }
} }
@Override
public BlockRenderLayer getRenderLayer() {
return variant == CloudType.NORMAL ? BlockRenderLayer.TRANSLUCENT : super.getRenderLayer();
}
@Override @Override
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
if (beside.getBlock() instanceof Gas) { if (beside.getBlock() instanceof Gas) {

View file

@ -4,11 +4,12 @@ import com.minelittlepony.unicopia.block.AbstractDoorBlock;
import com.minelittlepony.unicopia.block.UMaterials; import com.minelittlepony.unicopia.block.UMaterials;
import net.fabricmc.fabric.api.block.FabricBlockSettings; import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.BlockRenderLayer; import net.fabricmc.fabric.api.tools.FabricToolTags;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -16,20 +17,21 @@ import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
public class CloudDoorBlock extends AbstractDoorBlock implements Gas { public class CloudDoorBlock extends AbstractDoorBlock implements Gas {
@SuppressWarnings("deprecation")
public CloudDoorBlock() { public CloudDoorBlock() {
super(FabricBlockSettings.of(UMaterials.CLOUD) super(FabricBlockSettings.of(UMaterials.CLOUD)
.sounds(BlockSoundGroup.WOOL) .sounds(BlockSoundGroup.WOOL)
.hardness(3) .hardness(3)
.resistance(200) .resistance(200)
.breakByTool(net.fabricmc.fabric.api.tools.FabricToolTags.SHOVELS, 0) .breakByTool(FabricToolTags.SHOVELS, 0)
.build()); .build());
} }
@Override @Override
public boolean activate(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return getCanInteract(state, player) && super.activate(state, worldIn, pos, player, hand, hit); if (!getCanInteract(state, player)) {
return ActionResult.PASS;
}
return super.onUse(state, worldIn, pos, player, hand, hit);
} }
@Deprecated @Deprecated
@ -40,11 +42,6 @@ public class CloudDoorBlock extends AbstractDoorBlock implements Gas {
return Math.max(hardness, Math.min(60, hardness + (pos.getY() - 100))); return Math.max(hardness, Math.min(60, hardness + (pos.getY() - 100)));
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) { public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) {
if (!applyBouncyness(state, entity)) { if (!applyBouncyness(state, entity)) {

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.gas;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.ducks.Farmland; import com.minelittlepony.unicopia.ducks.Farmland;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock; import net.minecraft.block.FarmlandBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -20,11 +19,6 @@ public class CloudFarmlandBlock extends FarmlandBlock implements Farmland, Gas {
super(settings); super(settings);
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {

View file

@ -1,13 +1,9 @@
package com.minelittlepony.unicopia.gas; package com.minelittlepony.unicopia.gas;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.minecraft.block.BlockRenderLayer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock; import net.minecraft.block.FenceBlock;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -16,13 +12,8 @@ public class CloudFenceBlock extends FenceBlock implements Gas {
private final CloudType variant; private final CloudType variant;
public CloudFenceBlock(Material material, CloudType variant) { public CloudFenceBlock(CloudType variant) {
super(FabricBlockSettings.of(material) super(variant.configure().build());
.hardness(0.5F)
.resistance(1)
.sounds(BlockSoundGroup.WOOL)
.build());
this.variant = variant; this.variant = variant;
} }
@ -31,21 +22,11 @@ public class CloudFenceBlock extends FenceBlock implements Gas {
return variant == CloudType.NORMAL; return variant == CloudType.NORMAL;
} }
@Override
public boolean isOpaque(BlockState state) {
return false;
}
@Override @Override
public CloudType getCloudMaterialType(BlockState blockState) { public CloudType getCloudMaterialType(BlockState blockState) {
return variant; return variant;
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.TRANSLUCENT;
}
@Override @Override
public void onLandedUpon(World world, BlockPos pos, Entity entityIn, float fallDistance) { public void onLandedUpon(World world, BlockPos pos, Entity entityIn, float fallDistance) {
if (!applyLanding(entityIn, fallDistance)) { if (!applyLanding(entityIn, fallDistance)) {

View file

@ -1,17 +1,30 @@
package com.minelittlepony.unicopia.gas; package com.minelittlepony.unicopia.gas;
import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.EquinePredicates;
import com.minelittlepony.unicopia.block.UMaterials;
import com.minelittlepony.unicopia.entity.CloudEntity; import com.minelittlepony.unicopia.entity.CloudEntity;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
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.sound.BlockSoundGroup;
public enum CloudType { public enum CloudType {
NORMAL, NORMAL,
PACKED, PACKED,
ENCHANTED; ENCHANTED;
public FabricBlockSettings configure() {
FabricBlockSettings settings = FabricBlockSettings.of(UMaterials.CLOUD)
.strength(0.5F, 1)
.sounds(BlockSoundGroup.WOOL);
if (this != NORMAL ) {
settings.nonOpaque();
}
return settings;
}
public boolean canInteract(Entity e) { public boolean canInteract(Entity e) {
if (e == null) { if (e == null) {
return false; return false;

View file

@ -73,9 +73,9 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem
World world = entity.world; World world = entity.world;
double x = entity.x + world.random.nextFloat() - 0.5; double x = entity.getX() + world.random.nextFloat() - 0.5;
double z = entity.z + world.random.nextFloat() - 0.5; double z = entity.getY() + world.random.nextFloat() - 0.5;
double y = entity.y + world.random.nextFloat(); double y = entity.getZ() + world.random.nextFloat();
ParticleEffect particle = world.random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME; ParticleEffect particle = world.random.nextBoolean() ? ParticleTypes.LARGE_SMOKE : ParticleTypes.FLAME;
@ -138,7 +138,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem
int hideFlags = 0; int hideFlags = 0;
if (!compound.containsKey("HideFlags") || ((hideFlags = compound.getInt("HideFlags")) & 2) == 0) { if (!compound.contains("HideFlags") || ((hideFlags = compound.getInt("HideFlags")) & 2) == 0) {
compound.putInt("HideFlags", hideFlags | 2); compound.putInt("HideFlags", hideFlags | 2);
} }
@ -153,7 +153,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem
PlayerEntity player = (PlayerEntity)entity; PlayerEntity player = (PlayerEntity)entity;
if (player.getHealth() < player.getHealthMaximum()) { if (player.getHealth() < player.getMaximumHealth()) {
player.heal(0.5F); player.heal(0.5F);
} else if (player.canConsume(false)) { } else if (player.canConsume(false)) {
player.getHungerManager().add(1, 0); player.getHungerManager().add(1, 0);
@ -210,7 +210,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem
if (stack.getDamage() >= getMaxDamage() - 1) { if (stack.getDamage() >= getMaxDamage() - 1) {
stack.damage(10, player, p -> p.sendEquipmentBreakStatus(EquipmentSlot.CHEST)); stack.damage(10, player, p -> p.sendEquipmentBreakStatus(EquipmentSlot.CHEST));
player.damage(MagicalDamageSource.ALICORN_AMULET, player.getHealthMaximum() - 0.01F); player.damage(MagicalDamageSource.ALICORN_AMULET, player.getMaximumHealth() - 0.01F);
player.getHungerManager().setFoodLevel(1); player.getHungerManager().setFoodLevel(1);
Vec3d pos = player.getPos(); Vec3d pos = player.getPos();
@ -233,7 +233,7 @@ public class AlicornAmuletItem extends ArmorItem implements AddictiveMagicalItem
LocalDifficulty difficulty = player.getWorld().getLocalDifficulty(player.getOrigin()); LocalDifficulty difficulty = player.getWorld().getLocalDifficulty(player.getOrigin());
float amount = (attachedTime * (1 + needfulness)) * (1 + difficulty.getClampedLocalDifficulty()); float amount = (attachedTime * (1 + needfulness)) * (1 + difficulty.getClampedLocalDifficulty());
amount = Math.min(amount, player.getOwner().getHealthMaximum()); amount = Math.min(amount, player.getOwner().getMaximumHealth());
player.getOwner().damage(MagicalDamageSource.ALICORN_AMULET, amount); player.getOwner().damage(MagicalDamageSource.ALICORN_AMULET, amount);

View file

@ -92,7 +92,7 @@ public class AppleItem extends Item implements Toxic, ItemEntityCapabilities.Tic
float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 0.1F + 0.1F; float bob = MathHelper.sin(((float)item.getAge() + 1) / 10F + entity.hoverHeight) * 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.x, entity.y + bob, entity.z, entity.world.addParticle(ParticleTypes.AMBIENT_ENTITY_EFFECT, entity.getX(), entity.getY() + bob, entity.getZ(),
entity.world.random.nextGaussian() - 0.5F, entity.world.random.nextGaussian() - 0.5F,
entity.world.random.nextGaussian() - 0.5F, entity.world.random.nextGaussian() - 0.5F,
entity.world.random.nextGaussian() - 0.5F); entity.world.random.nextGaussian() - 0.5F);

View file

@ -16,7 +16,7 @@ import com.minelittlepony.unicopia.util.VecHelper;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry; import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.item.TooltipContext; import net.minecraft.client.item.TooltipContext;
import net.minecraft.container.NameableContainerProvider; import net.minecraft.container.NameableContainerFactory;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
@ -122,7 +122,7 @@ public class BagOfHoldingItem extends Item implements MagicalItem {
return Affinity.NEUTRAL; return Affinity.NEUTRAL;
} }
public static class ContainerProvider implements NameableContainerProvider { public static class ContainerProvider implements NameableContainerFactory {
private Text customname = null; private Text customname = null;

View file

@ -36,7 +36,7 @@ public class CloudPlacerItem extends Item implements Dispensable {
public void placeCloud(World world, BlockPos pos) { public void placeCloud(World world, BlockPos pos) {
CloudEntity cloud = cloudSupplier.create(world); CloudEntity cloud = cloudSupplier.create(world);
cloud.setPositionAndAngles(pos, 0, 0); cloud.refreshPositionAndAngles(pos, 0, 0);
world.spawnEntity(cloud); world.spawnEntity(cloud);
} }

View file

@ -54,7 +54,7 @@ public class RottenTomatoItem extends TomatoItem implements TossableItem {
duration += Math.max(0, effect.getDuration()); duration += Math.max(0, effect.getDuration());
} }
entity.addPotionEffect(new StatusEffectInstance(StatusEffects.NAUSEA, duration, 4)); entity.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, duration, 4));
} }
return entity.eatFood(world, stack); return entity.eatFood(world, stack);

View file

@ -40,8 +40,8 @@ public class SpellbookItem extends BookItem implements Dispensable {
if (!context.getWorld().isClient && EquinePredicates.MAGI.test(player)) { if (!context.getWorld().isClient && EquinePredicates.MAGI.test(player)) {
BlockPos pos = context.getBlockPos().offset(context.getSide()); BlockPos pos = context.getBlockPos().offset(context.getSide());
double diffX = player.x - (pos.getX() + 0.5); double diffX = player.getX() - (pos.getX() + 0.5);
double diffZ = player.z - (pos.getZ() + 0.5); double diffZ = player.getZ() - (pos.getZ() + 0.5);
float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX) + Math.PI); float yaw = (float)Math.toDegrees(Math.atan2(diffZ, diffX) + Math.PI);
placeBook(context.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw); placeBook(context.getWorld(), pos.getX(), pos.getY(), pos.getZ(), yaw);
@ -58,8 +58,7 @@ public class SpellbookItem extends BookItem implements Dispensable {
private static void placeBook(World world, int x, int y, int z, float yaw) { private static void placeBook(World world, int x, int y, int z, float yaw) {
SpellbookEntity book = UEntities.SPELLBOOK.create(world); SpellbookEntity book = UEntities.SPELLBOOK.create(world);
book.setPositionAndAngles(x + 0.5, y, z + 0.5, yaw, 0); book.updatePositionAndAngles(x + 0.5, y, z + 0.5, yaw, 0);
//book.renderYawOffset = 0;
book.prevYaw = yaw; book.prevYaw = yaw;
world.spawnEntity(book); world.spawnEntity(book);

View file

@ -44,9 +44,9 @@ public class StaffItem extends SwordItem {
for (int i = 0; i < 130; i++) { for (int i = 0; i < 130; i++) {
w.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.OAK_LOG.getDefaultState()), w.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.OAK_LOG.getDefaultState()),
target.x + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), target.getX() + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1),
(target.y + dims.height / 2) + (target.world.random.nextFloat() - 0.5F) * dims.height, (target.getY() + dims.height / 2) + (target.world.random.nextFloat() - 0.5F) * dims.height,
target.z + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1), target.getZ() + (target.world.random.nextFloat() - 0.5F) * (dims.width + 1),
0, 0, 0 0, 0, 0
); );
} }

View file

@ -44,7 +44,7 @@ public class StickItem extends Item {
ItemStack itemstack = context.getStack(); ItemStack itemstack = context.getStack();
if (player instanceof ServerPlayerEntity) { if (player instanceof ServerPlayerEntity) {
Criterions.PLACED_BLOCK.handle((ServerPlayerEntity)player, pos.up(), itemstack); Criterions.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack);
} }
if (player == null || !player.abilities.creativeMode) { if (player == null || !player.abilities.creativeMode) {

View file

@ -23,7 +23,7 @@ public class TomatoItem extends Item {
@Override @Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) { public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) {
stack = super.finishUsing(stack, world, entity); stack = super.finishUsing(stack, world, entity);
entity.removePotionEffect(StatusEffects.NAUSEA); entity.removeStatusEffect(StatusEffects.NAUSEA);
return stack; return stack;
} }

View file

@ -20,7 +20,7 @@ public interface UEffects {
StatusEffectInstance foodEffect = e.getStatusEffect(p); StatusEffectInstance foodEffect = e.getStatusEffect(p);
nausea = new StatusEffectInstance(StatusEffects.NAUSEA, foodEffect.getDuration(), foodEffect.getAmplifier(), foodEffect.isAmbient(), foodEffect.shouldShowParticles()); nausea = new StatusEffectInstance(StatusEffects.NAUSEA, foodEffect.getDuration(), foodEffect.getAmplifier(), foodEffect.isAmbient(), foodEffect.shouldShowParticles());
e.addPotionEffect(nausea); e.addStatusEffect(nausea);
} }
e.damage(MagicalDamageSource.FOOD_POISONING, i); e.damage(MagicalDamageSource.FOOD_POISONING, i);

View file

@ -74,7 +74,7 @@ public class ZapAppleItem extends AppleItem {
player.damage(MagicalDamageSource.ZAP_APPLE, 120); player.damage(MagicalDamageSource.ZAP_APPLE, 120);
if (w instanceof ServerWorld) { if (w instanceof ServerWorld) {
((ServerWorld) w).addLightning(new LightningEntity(w, player.x, player.y, player.z, false)); ((ServerWorld) w).addLightning(new LightningEntity(w, player.getX(), player.getY(), player.getZ(), false));
} }
return stack; return stack;
@ -87,7 +87,7 @@ public class ZapAppleItem extends AppleItem {
} }
public TypedActionResult<ItemStack> onFedTo(ItemStack stack, PlayerEntity player, Entity e) { public TypedActionResult<ItemStack> onFedTo(ItemStack stack, PlayerEntity player, Entity e) {
e.onStruckByLightning(new LightningEntity(e.world, e.x, e.y, e.z, false)); e.onStruckByLightning(new LightningEntity(e.world, e.getX(), e.getY(), e.getZ(), false));
if (!player.abilities.creativeMode) { if (!player.abilities.creativeMode) {
stack.decrement(1); stack.decrement(1);
@ -105,7 +105,7 @@ public class ZapAppleItem extends AppleItem {
} }
public Item getAppearance(ItemStack stack) { public Item getAppearance(ItemStack stack) {
if (stack.hasTag() && stack.getTag().containsKey("appearance")) { if (stack.hasTag() && stack.getTag().contains("appearance")) {
return Registry.ITEM.get(new Identifier(stack.getTag().getString("appearance"))); return Registry.ITEM.get(new Identifier(stack.getTag().getString("appearance")));
} }

View file

@ -49,7 +49,7 @@ public interface Castable extends MagicalItem, Dispensable {
SpellcastEntity spell = new SpellcastEntity(null, world); SpellcastEntity spell = new SpellcastEntity(null, world);
spell.setAffinity(getAffinity(stack)); spell.setAffinity(getAffinity(stack));
spell.setPositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0); spell.updatePositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0);
spell.setEffect(effect); spell.setEffect(effect);
world.spawnEntity(spell); world.spawnEntity(spell);

View file

@ -7,8 +7,8 @@ import java.util.stream.Stream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.minelittlepony.unicopia.entity.Owned; import com.minelittlepony.unicopia.entity.Owned;
import com.minelittlepony.unicopia.particles.ParticleSource;
import com.minelittlepony.unicopia.util.VecHelper; import com.minelittlepony.unicopia.util.VecHelper;
import com.minelittlepony.unicopia.util.particles.ParticleSource;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;

View file

@ -46,7 +46,7 @@ public interface TossedMagicEffect extends MagicEffect, Tossable<Caster<?>> {
Entity entity = caster.getOwner(); Entity entity = caster.getOwner();
world.playSound(null, entity.x, entity.y, entity.z, getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F)); world.playSound(null, entity.getX(), entity.getY(), entity.getZ(), getThrowSound(caster), SoundCategory.NEUTRAL, 0.7F, 0.4F / (world.random.nextFloat() * 0.4F + 0.8F));
if (caster.isLocal()) { if (caster.isLocal()) {
AdvancedProjectile projectile = new ProjectileEntity(null, world, caster.getOwner()); AdvancedProjectile projectile = new ProjectileEntity(null, world, caster.getOwner());

View file

@ -105,7 +105,7 @@ public abstract class AbstractAttachableSpell extends AbstractSpell {
public void fromNBT(CompoundTag compound) { public void fromNBT(CompoundTag compound) {
super.fromNBT(compound); super.fromNBT(compound);
if (compound.containsKey("target")) { if (compound.contains("target")) {
targettedEntityId = compound.getUuid("target"); targettedEntityId = compound.getUuid("target");
} }
} }

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.magic.spell;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.magic.Affinity; import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.Caster; import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.util.MagicalDamageSource; import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.particles.UParticles;
import com.minelittlepony.unicopia.util.shape.Sphere; import com.minelittlepony.unicopia.util.shape.Sphere;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -35,7 +35,7 @@ public class AttractiveSpell extends ShieldSpell {
Vec3d pos = source.getOriginVector(); Vec3d pos = source.getOriginVector();
source.spawnParticles(new Sphere(false, range), range * 9, p -> { source.spawnParticles(new Sphere(false, range), range * 9, p -> {
source.addParticle(UParticles.UNICORN_MAGIC, p, p.subtract(pos)); // getTint() source.addParticle(new MagicParticleEffect(getTint()), p, p.subtract(pos));
}); });
} }

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