Various fixes

This commit is contained in:
Sollace 2020-05-03 19:20:51 +02:00
parent 42f8e4d1e7
commit 2afe31c706
21 changed files with 179 additions and 72 deletions

View file

@ -44,9 +44,7 @@ public class ChitinBlock extends Block {
@Override
@Nullable
public BlockState getPlacementState(ItemPlacementContext context) {
Direction side = context.getSide();
return getDefaultState().with(Covering.PROPERTY, Covering.getCovering(context.getWorld(), context.getBlockPos().offset(side)));
return getDefaultState().with(Covering.PROPERTY, Covering.getCovering(context.getWorld(), context.getBlockPos().up()));
}
@Override

View file

@ -15,6 +15,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FallingBlock;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.FallingBlockEntity;
import net.minecraft.entity.player.PlayerEntity;
@ -126,7 +127,7 @@ public class HiveWallBlock extends FallingBlock {
@Override
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean uuuuh) {
if (state.get(STATE) != State.STABLE) {
if (getState(state) != State.STABLE) {
super.onBlockAdded(state, world, pos, oldState, uuuuh);
}
}
@ -218,7 +219,7 @@ public class HiveWallBlock extends FallingBlock {
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
return getDefaultState().with(AXIS, Axis.fromVanilla(context.getPlayerFacing().getAxis()));
return getDefaultState().with(AXIS, Axis.fromVanilla(context.getSide().getAxis()));
}
@Override
@ -257,8 +258,9 @@ public class HiveWallBlock extends FallingBlock {
for (Direction facing : axis.getFacings()) {
BlockPos op = pos.offset(facing);
Material m = world.getBlockState(op).getMaterial();
if (world.getBlockState(op).getMaterial() == UMaterials.HIVE) {
if (m == UMaterials.HIVE || m == UMaterials.CHITIN) {
if (one) {
return true;
}
@ -266,7 +268,6 @@ public class HiveWallBlock extends FallingBlock {
one = true;
}
}
}
return false;

View file

@ -102,11 +102,10 @@ public interface UBlocks {
.build()));
HiveWallBlock HIVE_WALL_BLOCK = register("hive_wall_block", new HiveWallBlock(FabricBlockSettings.of(UMaterials.HIVE)
.noCollision()
.strength(10, 10)
.hardness(2)
.ticksRandomly()
.lightLevel(1)
.lightLevel(3)
.sounds(BlockSoundGroup.SAND)
.breakByTool(FabricToolTags.SHOVELS, 1)
.build()));

View file

@ -41,6 +41,7 @@ class KeyBindingsHandler {
int code = Abilities.KEYS_CODES.get(id);
FabricKeyBinding b = FabricKeyBinding.Builder.create(id, InputUtil.Type.KEYSYM, code, KEY_CATEGORY).build();
KeyBindingRegistry.INSTANCE.register(b);
getKeyCodePool(b).add(p);
bindings.add(b);

View file

@ -39,8 +39,8 @@ public interface URenderers {
ParticleFactoryRegistry.getInstance().register(UParticles.UNICORN_MAGIC, MagicParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.CHANGELING_MAGIC, ChangelingMagicParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.RAIN_DROPS, RaindropsParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle.Factory::new);
ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle::new);
ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle::new);
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), UBlocks.ENCHANTED_TORCH, UBlocks.ENCHANTED_WALL_TORCH,
UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR);

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.client.particle;
import com.minelittlepony.unicopia.client.render.model.DiskModel;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
@ -18,16 +19,12 @@ public class DiskParticle extends SphereParticle {
protected float rotY;
protected float rotZ;
public DiskParticle(World w,
double x, double y, double z,
float radius,
int red, int green, int blue, float alpha,
float rX, float rY, float rZ) {
super(w, x, y, z, radius, red, green, blue, alpha);
public DiskParticle(SphereParticleEffect effect, World w, double x, double y, double z, double rX, double rY, double rZ) {
super(effect, w, x, y, z, 0, 0, 0);
rotX = rX;
rotY = rY;
rotZ = rZ;
rotX = (float)rX;
rotY = (float)rY;
rotZ = (float)rZ;
}
@Override

View file

@ -2,21 +2,19 @@ package com.minelittlepony.unicopia.client.particle;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleFactory;
import net.minecraft.client.particle.ParticleTextureSheet;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.world.World;
import com.minelittlepony.unicopia.client.render.model.SphereModel;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.particles.ParticleHandle.Attachment;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import com.minelittlepony.util.Color;
public class SphereParticle extends Particle implements Attachment {
@ -32,22 +30,22 @@ public class SphereParticle extends Particle implements Attachment {
private static final SphereModel model = new SphereModel();
public SphereParticle(World w, double x, double y, double z, float radius, int red, int green, int blue, float alpha, double vX, double vY, double vZ) {
this(w, x, y, z, radius, red, green, blue, alpha);
public SphereParticle(SphereParticleEffect effect, World w, double x, double y, double z, double vX, double vY, double vZ) {
this(effect, w, x, y, z);
this.velocityX = vX;
this.velocityY = vY;
this.velocityZ = vZ;
}
public SphereParticle(World w, double x, double y, double z, float radius, int red, int green, int blue, float alpha) {
public SphereParticle(SphereParticleEffect effect, World w, double x, double y, double z) {
super(w, x, y, z);
this.radius = radius;
this.red = red/255F;
this.green = green/255F;
this.blue = blue/255F;
this.alpha = alpha;
this.radius = effect.getRadius();
this.red = effect.getRed()/255F;
this.green = effect.getGreen()/255F;
this.blue = effect.getBlue()/255F;
this.alpha = effect.getAlpha();
setMaxAge(10);
}
@ -73,7 +71,6 @@ public class SphereParticle extends Particle implements Attachment {
red = Color.r(tint);
green = Color.g(tint);
blue = Color.b(tint);
alpha = Color.a(tint);
}
}
@ -112,18 +109,9 @@ public class SphereParticle extends Particle implements Attachment {
MatrixStack matrices = new MatrixStack();
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
model.setPosition(x, y, z);
model.setRotation(0, 0, 0);
model.render(matrices, radius, immediate.getBuffer(RenderLayer.getTranslucent()), 1, 1, red, green, blue, alpha);
immediate.draw();
}
public static class Factory implements ParticleFactory<DefaultParticleType> {
public Factory(SpriteProvider provider) {
}
@Override
public Particle createParticle(DefaultParticleType type, World world, double x, double y, double z, double dx, double dy, double dz) {
return new RaindropsParticle(world, x, y, z, dx, dy, dz);
}
}
}

View file

@ -13,9 +13,9 @@ public class SphereModel {
protected Vec3d pos;
protected Quaternion rotX;
protected Quaternion rotY;
protected Quaternion rotZ;
protected Quaternion rotX = Quaternion.IDENTITY;
protected Quaternion rotY = Quaternion.IDENTITY;
protected Quaternion rotZ = Quaternion.IDENTITY;
public void setPosition(double x, double y, double z) {
pos = new Vec3d(x, y, z).subtract(BlockEntityRenderDispatcher.INSTANCE.camera.getPos());

View file

@ -414,7 +414,7 @@ public class PlayerImpl implements Pony, MagicReserves {
gravity.fromNBT(compound.getCompound("gravity"));
if (compound.contains("effect")) {
setEffect(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
effectDelegate.set(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
}
pageStates.fromNBT(compound);

View file

@ -22,9 +22,7 @@ public class CoverableCloudBlock extends CloudBlock {
@Override
@Nullable
public BlockState getPlacementState(ItemPlacementContext context) {
Direction side = context.getSide();
return getDefaultState().with(Covering.PROPERTY, Covering.getCovering(context.getWorld(), context.getBlockPos().offset(side)));
return getDefaultState().with(Covering.PROPERTY, Covering.getCovering(context.getWorld(), context.getBlockPos().up()));
}
@Override

View file

@ -50,9 +50,8 @@ public interface Castable extends MagicalItem, Dispensable {
spell.setAffinity(getAffinity(stack));
spell.updatePositionAndAngles(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0);
spell.setEffect(effect);
world.spawnEntity(spell);
spell.setEffect(effect);
return spell;
}

View file

@ -6,7 +6,7 @@ import java.util.function.Consumer;
import com.minelittlepony.unicopia.entity.SpellcastEntity;
import com.minelittlepony.unicopia.magic.Affinity;
import com.minelittlepony.unicopia.magic.CasterUtils;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.util.MagicalDamageSource;
import com.minelittlepony.unicopia.util.PosHelper;
@ -236,9 +236,9 @@ public class DarknessSpell extends AbstractAttachableSpell {
double vX = (source.getWorld().random.nextFloat() - 0.5) * particleSpeed;
double vZ = (source.getWorld().random.nextFloat() - 0.5) * particleSpeed;
source.getWorld().addParticle(UParticles.SPHERE,
source.getWorld().addParticle(new SphereParticleEffect(tint, 0.3F, (int)(size * 1000)),
pos.x, pos.y, pos.z,
vX, 0, vZ);//(int)(size * 1000), tint, 30
vX, 0, vZ);
}
}

View file

@ -116,11 +116,11 @@ public class PortalSpell extends AbstractSpell.RangedAreaSpell implements Useabl
if (other != null) {
other.getActualInstance().setDestinationPortal(this);
if (!world.isClient) {
if (!context.getWorld().isClient) {
prop.setEffect(null);
}
} else {
if (!world.isClient) {
if (!context.getWorld().isClient) {
bridge = (PortalSpell)copy();
prop.setEffect(bridge);

View file

@ -10,7 +10,7 @@ import com.minelittlepony.unicopia.magic.AttachedMagicEffect;
import com.minelittlepony.unicopia.magic.Caster;
import com.minelittlepony.unicopia.particles.MagicParticleEffect;
import com.minelittlepony.unicopia.particles.ParticleHandle;
import com.minelittlepony.unicopia.particles.UParticles;
import com.minelittlepony.unicopia.particles.SphereParticleEffect;
import com.minelittlepony.unicopia.util.projectile.ProjectileUtil;
import com.minelittlepony.unicopia.util.shape.Sphere;
@ -53,7 +53,7 @@ public class ShieldSpell extends AbstractSpell.RangedAreaSpell implements Attach
});
particlEffect.ifAbsent(source, spawner -> {
spawner.addParticle(UParticles.SPHERE, source.getOriginVector(), Vec3d.ZERO);
spawner.addParticle(new SphereParticleEffect(getTint(), 0.3F, radius), source.getOriginVector(), Vec3d.ZERO);
}).ifPresent(p -> {
p.attach(source);
p.setAttribute(0, radius);
@ -69,7 +69,6 @@ public class ShieldSpell extends AbstractSpell.RangedAreaSpell implements Attach
double cost = 4 + (source.getCurrentLevel() * 2);
cost *= costMultiplier / 5F;
System.out.println("Taking " + cost);
if (!source.subtractEnergyCost(cost)) {
setDead();

View file

@ -0,0 +1,41 @@
package com.minelittlepony.unicopia.particles;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.util.PacketByteBuf;
public class DiskParticleEffect extends SphereParticleEffect {
public static final ParticleEffect.Factory<DiskParticleEffect> FACTORY = new ParticleEffect.Factory<DiskParticleEffect>() {
@Override
public DiskParticleEffect read(ParticleType<DiskParticleEffect> particleType, StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float g = (float)reader.readDouble();
reader.expect(' ');
float h = (float)reader.readDouble();
reader.expect(' ');
float i = (float)reader.readDouble();
reader.expect(' ');
float j = (float)reader.readDouble();
reader.expect(' ');
float k = (float)reader.readDouble();
return new DiskParticleEffect(g, h, i, j, k);
}
@Override
public DiskParticleEffect read(ParticleType<DiskParticleEffect> particleType, PacketByteBuf buf) {
return new DiskParticleEffect(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat());
}
};
public DiskParticleEffect(float red, float green, float blue, float alpha, float rad) {
super(red, green, blue, alpha, rad);
}
@Override
public ParticleType<?> getType() {
return UParticles.DISK;
}
}

View file

@ -56,7 +56,7 @@ public class MagicParticleEffect implements ParticleEffect {
public boolean hasTint() {
return false;
return tinted;
}
public float getRed() {

View file

@ -0,0 +1,94 @@
package com.minelittlepony.unicopia.particles;
import java.util.Locale;
import com.minelittlepony.util.Color;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.registry.Registry;
public class SphereParticleEffect implements ParticleEffect {
public static final ParticleEffect.Factory<SphereParticleEffect> FACTORY = new ParticleEffect.Factory<SphereParticleEffect>() {
@Override
public SphereParticleEffect read(ParticleType<SphereParticleEffect> particleType, StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float g = (float)reader.readDouble();
reader.expect(' ');
float h = (float)reader.readDouble();
reader.expect(' ');
float i = (float)reader.readDouble();
reader.expect(' ');
float j = (float)reader.readDouble();
reader.expect(' ');
float k = (float)reader.readDouble();
return new SphereParticleEffect(g, h, i, j, k);
}
@Override
public SphereParticleEffect read(ParticleType<SphereParticleEffect> particleType, PacketByteBuf buf) {
return new SphereParticleEffect(buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat(), buf.readFloat());
}
};
private final float red;
private final float green;
private final float blue;
private final float alpha;
private final float radius;
public SphereParticleEffect(int tint, float alpha, float rad) {
this(Color.r(tint), Color.g(tint), Color.b(tint), alpha, rad);
}
public SphereParticleEffect(float red, float green, float blue, float alpha, float rad) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
this.radius = rad;
}
public float getRed() {
return red;
}
public float getGreen() {
return green;
}
public float getBlue() {
return blue;
}
public float getAlpha() {
return alpha;
}
public float getRadius() {
return radius;
}
@Override
public ParticleType<?> getType() {
return UParticles.SPHERE;
}
@Override
public void write(PacketByteBuf buf) {
buf.writeFloat(red);
buf.writeFloat(green);
buf.writeFloat(blue);
buf.writeFloat(alpha);
buf.writeFloat(radius);
}
@Override
public String asString() {
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getId(getType()), red, green, blue, alpha, radius);
}
}

View file

@ -13,8 +13,8 @@ public interface UParticles {
DefaultParticleType RAIN_DROPS = register("rain_drops", FabricParticleTypes.simple());
DefaultParticleType SPHERE = register("sphere", FabricParticleTypes.simple(true));
DefaultParticleType DISK = register("disk", FabricParticleTypes.simple());
ParticleType<SphereParticleEffect> SPHERE = register("sphere", FabricParticleTypes.complex(true, SphereParticleEffect.FACTORY));
ParticleType<DiskParticleEffect> DISK = register("disk", FabricParticleTypes.complex(true, DiskParticleEffect.FACTORY));
static <T extends ParticleType<?>> T register(String name, T type) {
return Registry.register(Registry.PARTICLE_TYPE, new Identifier("unicopia", name), type);

View file

@ -59,18 +59,12 @@ public interface VecHelper {
}
static Stream<Entity> findAllEntitiesInRange(@Nullable Entity origin, World w, BlockPos pos, double radius) {
BlockPos begin = pos.add(-radius, -radius, -radius);
BlockPos end = pos.add(radius, radius, radius);
Box bb = new Box(begin, end);
return w.getEntities(origin, bb, null).stream().filter(e -> {
return w.getEntities(origin, new Box(pos).expand(radius), e -> {
double dist = e.squaredDistanceTo(pos.getX(), pos.getY(), pos.getZ());
double dist2 = e.squaredDistanceTo(pos.getX(), pos.getY() - e.getStandingEyeHeight(), pos.getZ());
return dist <= radius || dist2 <= radius;
});
}).stream();
}
/**

View file

@ -1,3 +1,2 @@
{
"textures": []
}

View file

@ -1,3 +1,2 @@
{
"textures": []
}