Polished bells

- Fix cursed bells not rendering on contraptions
- Prevent players in spectator from creating soul pulses
- Improve and format some bell-related code
This commit is contained in:
PepperBell 2021-06-27 23:15:51 -07:00
parent 9d5eecff06
commit 7b18c658b7
24 changed files with 183 additions and 177 deletions

View file

@ -1306,26 +1306,14 @@ public class AllBlocks {
public static final BlockEntry<PeculiarBellBlock> PECULIAR_BELL =
REGISTRATE.block("peculiar_bell", PeculiarBellBlock::new)
.initialProperties(SharedProperties::softMetal)
.properties(p -> p.nonOpaque()
.sound(SoundType.ANVIL))
.addLayer(() -> RenderType::getCutoutMipped)
.tag(AllBlockTags.BRITTLE.tag)
.transform(BuilderTransformers.bell())
.onRegister(addMovementBehaviour(new BellMovementBehaviour()))
.blockstate(BlockStateGen.bell())
.item()
.transform(customItemModel())
.register();
public static final BlockEntry<CursedBellBlock> CURSED_BELL =
REGISTRATE.block("cursed_bell", CursedBellBlock::new)
.initialProperties(() -> PECULIAR_BELL.get())
.addLayer(() -> RenderType::getCutoutMipped)
.tag(AllBlockTags.BRITTLE.tag)
.transform(BuilderTransformers.bell())
.onRegister(addMovementBehaviour(new CursedBellMovementBehaviour()))
.blockstate(BlockStateGen.bell())
.item()
.transform(customItemModel())
.register();
// Materials

View file

@ -38,7 +38,7 @@ public class BellMovementBehaviour extends MovementBehaviour {
Block block = context.state.getBlock();
if (block instanceof AbstractBellBlock) {
((AbstractBellBlock) block).playSound(world, pos);
((AbstractBellBlock<?>) block).playSound(world, pos);
} else {
// Vanilla bell sound
world.playSound(null, pos, SoundEvents.BLOCK_BELL_USE,

View file

@ -52,7 +52,7 @@ public abstract class AbstractBellBlock<TE extends AbstractBellTileEntity> exten
if (direction == null)
direction = world.getBlockState(pos).get(field_220133_a);
if (!this.canRingFrom(state, direction, hit.getHitVec().y - (double)pos.getY()))
if (!this.canRingFrom(state, direction, hit.getHitVec().y - pos.getY()))
return false;
TE te = getTileEntity(world, pos);
@ -64,6 +64,7 @@ public abstract class AbstractBellBlock<TE extends AbstractBellTileEntity> exten
if (player != null)
player.addStat(Stats.BELL_RING);
}
return true;
}
@ -74,8 +75,8 @@ public abstract class AbstractBellBlock<TE extends AbstractBellTileEntity> exten
return false;
Direction direction = state.get(field_220133_a);
BellAttachment bellattachment = state.get(field_220134_b);
switch(bellattachment) {
BellAttachment bellAttachment = state.get(field_220134_b);
switch(bellAttachment) {
case FLOOR:
case CEILING:
return direction.getAxis() == hitDir.getAxis();

View file

@ -47,6 +47,6 @@ public abstract class AbstractBellTileEntity extends SmartTileEntity {
}
}
public abstract PartialModel getBellPartial();
public abstract PartialModel getBellModel();
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.foundation.data;
package com.simibubi.create.content.curiosities.bell;
import javax.annotation.ParametersAreNonnullByDefault;
@ -20,7 +20,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class BasicParticleData<T extends Particle> implements IParticleData, ICustomParticleDataWithSprite<BasicParticleData<T>> {
public abstract class BasicParticleData<T extends Particle> implements IParticleData, ICustomParticleDataWithSprite<BasicParticleData<T>> {
public BasicParticleData() { }
@ -32,6 +32,7 @@ public abstract class BasicParticleData<T extends Particle> implements IParticl
public BasicParticleData<T> deserialize(ParticleType<BasicParticleData<T>> arg0, StringReader reader) {
return data;
}
@Override
public BasicParticleData<T> read(ParticleType<BasicParticleData<T>> type, PacketBuffer buffer) {
return data;

View file

@ -29,7 +29,7 @@ public class BellRenderer<TE extends AbstractBellTileEntity> extends SafeTileEnt
Direction facing = state.get(BellBlock.field_220133_a);
BellAttachment attachment = state.get(BellBlock.field_220134_b);
SuperByteBuffer bell = PartialBufferer.get(te.getBellPartial(), state);
SuperByteBuffer bell = PartialBufferer.get(te.getBellModel(), state);
if (te.isRinging)
bell.rotateCentered(te.ringDirection.rotateYCCW(), getSwingAngle(te.ringingTicks + partialTicks));
@ -37,7 +37,7 @@ public class BellRenderer<TE extends AbstractBellTileEntity> extends SafeTileEnt
float rY = AngleHelper.horizontalAngle(facing);
if (attachment == BellAttachment.SINGLE_WALL || attachment == BellAttachment.DOUBLE_WALL)
rY += 90;
bell.rotateCentered(Direction.UP, (float) (rY / 180 * Math.PI));
bell.rotateCentered(Direction.UP, AngleHelper.rad(rY));
IVertexBuilder vb = buffer.getBuffer(RenderType.getCutout());
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), state, te.getPos());
@ -46,7 +46,7 @@ public class BellRenderer<TE extends AbstractBellTileEntity> extends SafeTileEnt
public static float getSwingAngle(float time) {
float t = time / 1.5f;
return 1.2f * MathHelper.sin(t / (float)Math.PI) / (2.5f + t / 3.0f);
return 1.2f * MathHelper.sin(t / (float) Math.PI) / (2.5f + t / 3.0f);
}
}

View file

@ -1,42 +0,0 @@
package com.simibubi.create.content.curiosities.bell;
import com.simibubi.create.AllBlocks;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.Hand;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@EventBusSubscriber
public class CursedBellItemPulser {
public static final int DISTANCE = 2;
public static final int RECHARGE_TICKS = 8;
@SubscribeEvent
public static void bellItemCreatesPulses(TickEvent.PlayerTickEvent event) {
if (event.phase != TickEvent.Phase.END)
return;
if (event.side != LogicalSide.SERVER)
return;
if (event.player.world.getGameTime() % RECHARGE_TICKS != 0)
return;
for (Hand hand : Hand.values()) {
Item held = event.player.getHeldItem(hand).getItem();
if (!(held instanceof BlockItem))
continue;
Block block = ((BlockItem) held).getBlock();
if (!block.is(AllBlocks.CURSED_BELL.get()))
continue;
SoulPulseEffectHandler.sendPulsePacket(event.player.world, event.player.getBlockPos(), DISTANCE, false);
}
}
}

View file

@ -1,12 +1,11 @@
package com.simibubi.create.content.curiosities.bell;
import com.simibubi.create.content.contraptions.components.actors.BellMovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import net.minecraft.util.math.BlockPos;
public class CursedBellMovementBehaviour extends MovementBehaviour {
public class CursedBellMovementBehaviour extends BellMovementBehaviour {
public static final int DISTANCE = 3;
@ -20,9 +19,9 @@ public class CursedBellMovementBehaviour extends MovementBehaviour {
@Override
public void visitNewPosition(MovementContext context, BlockPos pos) {
if (!context.world.isRemote && getRecharge(context) == 0) {
SoulPulseEffectHandler.sendPulsePacket(context.world, pos, DISTANCE, true);
CursedBellPulser.sendPulse(context.world, pos, DISTANCE, true);
setRecharge(context, CursedBellTileEntity.RECHARGE_TICKS);
BellMovementBehaviour.playSound(context);
playSound(context);
}
}

View file

@ -0,0 +1,42 @@
package com.simibubi.create.content.curiosities.bell;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.networking.AllPackets;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.network.PacketDistributor;
@EventBusSubscriber
public class CursedBellPulser {
public static final int DISTANCE = 2;
public static final int RECHARGE_TICKS = 8;
@SubscribeEvent
public static void cursedBellCreatesPulse(TickEvent.PlayerTickEvent event) {
if (event.phase != TickEvent.Phase.END)
return;
if (event.side != LogicalSide.SERVER)
return;
if (event.player.isSpectator())
return;
if (event.player.world.getGameTime() % RECHARGE_TICKS != 0)
return;
if (event.player.isHolding(AllBlocks.CURSED_BELL::is))
sendPulse(event.player.world, event.player.getBlockPos(), DISTANCE, false);
}
public static void sendPulse(World world, BlockPos pos, int distance, boolean canOverlap) {
Chunk chunk = world.getChunkAt(pos);
AllPackets.channel.send(PacketDistributor.TRACKING_CHUNK.with(() -> chunk), new SoulPulseEffectPacket(pos, distance, canOverlap));
}
}

View file

@ -33,7 +33,7 @@ public class CursedBellTileEntity extends AbstractBellTileEntity {
public void addBehaviours(List<TileEntityBehaviour> behaviours) { }
@Override
public PartialModel getBellPartial() {
public PartialModel getBellModel() {
return AllBlockPartials.CURSED_BELL;
}
@ -46,7 +46,7 @@ public class CursedBellTileEntity extends AbstractBellTileEntity {
return false;
if (!world.isRemote)
SoulPulseEffectHandler.sendPulsePacket(world, pos, DISTANCE, true);
CursedBellPulser.sendPulse(world, pos, DISTANCE, true);
startEffect();
@ -82,17 +82,24 @@ public class CursedBellTileEntity extends AbstractBellTileEntity {
return;
Random rand = world.getRandom();
if (rand.nextFloat() > 1/4f)
if (rand.nextFloat() > 0.25f)
return;
spawnParticle(rand);
playSound(rand);
}
protected void spawnParticle(Random rand) {
double x = pos.getX() + rand.nextDouble();
double y = pos.getY() + 0.5;
double z = pos.getZ() + rand.nextDouble();
double vx = rand.nextDouble()*0.04 - 0.02;
double vx = rand.nextDouble() * 0.04 - 0.02;
double vy = 0.1;
double vz = rand.nextDouble()*0.04 - 0.02;
this.world.addParticle(ParticleTypes.SOUL, x, y, z, vx, vy, vz);
double vz = rand.nextDouble() * 0.04 - 0.02;
world.addParticle(ParticleTypes.SOUL, x, y, z, vx, vy, vz);
}
protected void playSound(Random rand) {
float vol = rand.nextFloat() * 0.4F + rand.nextFloat() > 0.9F ? 0.6F : 0.0F;
float pitch = 0.6F + rand.nextFloat() * 0.4F;
world.playSound(null, pos, SoundEvents.PARTICLE_SOUL_ESCAPE, SoundCategory.BLOCKS, vol, pitch);

View file

@ -27,8 +27,8 @@ public class CustomRotationParticle extends SimpleAnimatedParticle {
public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) {
Quaternion quaternion = new Quaternion(camera.getRotation());
if (this.particleAngle != 0.0F) {
float angle = MathHelper.lerp(partialTicks, this.prevParticleAngle, this.particleAngle);
if (particleAngle != 0.0F) {
float angle = MathHelper.lerp(partialTicks, prevParticleAngle, particleAngle);
quaternion.multiply(Vector3f.POSITIVE_Z.getRadialQuaternion(angle));
}
return quaternion;
@ -37,12 +37,17 @@ public class CustomRotationParticle extends SimpleAnimatedParticle {
@Override
public void buildGeometry(IVertexBuilder builder, ActiveRenderInfo camera, float partialTicks) {
Vector3d cameraPos = camera.getProjectedView();
float originX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX) - cameraPos.getX());
float originY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY) - cameraPos.getY());
float originZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ) - cameraPos.getZ());
float originX = (float) (MathHelper.lerp(partialTicks, prevPosX, posX) - cameraPos.getX());
float originY = (float) (MathHelper.lerp(partialTicks, prevPosY, posY) - cameraPos.getY());
float originZ = (float) (MathHelper.lerp(partialTicks, prevPosZ, posZ) - cameraPos.getZ());
Vector3f[] vertices = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)};
float scale = this.getScale(partialTicks);
Vector3f[] vertices = new Vector3f[] {
new Vector3f(-1.0F, -1.0F, 0.0F),
new Vector3f(-1.0F, 1.0F, 0.0F),
new Vector3f(1.0F, 1.0F, 0.0F),
new Vector3f(1.0F, -1.0F, 0.0F)
};
float scale = getScale(partialTicks);
Quaternion rotation = getCustomRotation(camera, partialTicks);
for(int i = 0; i < 4; ++i) {
@ -52,14 +57,14 @@ public class CustomRotationParticle extends SimpleAnimatedParticle {
vertex.add(originX, originY, originZ);
}
float minU = mirror ? this.getMaxU() : this.getMinU();
float maxU = mirror ? this.getMinU() : this.getMaxU();
float minV = this.getMinV();
float maxV = this.getMaxV();
int brightness = this.getBrightnessForRender(partialTicks);
builder.vertex(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ()).texture(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).light(brightness).endVertex();
builder.vertex(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ()).texture(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).light(brightness).endVertex();
builder.vertex(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ()).texture(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).light(brightness).endVertex();
builder.vertex(vertices[3].getX(), vertices[3].getY(), vertices[3].getZ()).texture(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).light(brightness).endVertex();
float minU = mirror ? getMaxU() : getMinU();
float maxU = mirror ? getMinU() : getMaxU();
float minV = getMinV();
float maxV = getMaxV();
int brightness = getBrightnessForRender(partialTicks);
builder.vertex(vertices[0].getX(), vertices[0].getY(), vertices[0].getZ()).texture(maxU, maxV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex();
builder.vertex(vertices[1].getX(), vertices[1].getY(), vertices[1].getZ()).texture(maxU, minV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex();
builder.vertex(vertices[2].getX(), vertices[2].getY(), vertices[2].getZ()).texture(minU, minV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex();
builder.vertex(vertices[3].getX(), vertices[3].getY(), vertices[3].getZ()).texture(minU, maxV).color(particleRed, particleGreen, particleBlue, particleAlpha).light(brightness).endVertex();
}
}

View file

@ -6,7 +6,6 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllTileEntities;
import net.minecraft.block.BellBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -32,7 +31,9 @@ public class PeculiarBellBlock extends AbstractBellBlock<PeculiarBellTileEntity>
}
@Override
public Class<PeculiarBellTileEntity> getTileEntityClass() { return PeculiarBellTileEntity.class; }
public Class<PeculiarBellTileEntity> getTileEntityClass() {
return PeculiarBellTileEntity.class;
}
@Override
public void playSound(World world, BlockPos pos) {
@ -72,18 +73,18 @@ public class PeculiarBellBlock extends AbstractBellBlock<PeculiarBellTileEntity>
}
return AllBlocks.CURSED_BELL.getDefaultState()
.with(BellBlock.field_220133_a, state.get(BellBlock.field_220133_a))
.with(BellBlock.field_220134_b, state.get(BellBlock.field_220134_b))
.with(BellBlock.POWERED, state.get(BellBlock.POWERED));
.with(CursedBellBlock.field_220133_a, state.get(field_220133_a))
.with(CursedBellBlock.field_220134_b, state.get(field_220134_b))
.with(CursedBellBlock.POWERED, state.get(POWERED));
}
public void spawnConversionParticles(IWorld world, BlockPos blockPos) {
Random random = world.getRandom();
int num = random.nextInt(10) + 15;
for (int i = 0; i < num; i++) {
float pitch = random.nextFloat()*120 - 90;
float yaw = random.nextFloat()*360;
Vector3d vel = Vector3d.fromPitchYaw(pitch, yaw).scale(random.nextDouble()*0.1 + 0.1);
float pitch = random.nextFloat() * 120 - 90;
float yaw = random.nextFloat() * 360;
Vector3d vel = Vector3d.fromPitchYaw(pitch, yaw).scale(random.nextDouble() * 0.1 + 0.1);
Vector3d pos = Vector3d.ofCenter(blockPos);
world.addParticle(ParticleTypes.SOUL_FIRE_FLAME, pos.x, pos.y, pos.z, vel.x, vel.y, vel.z);
}

View file

@ -12,7 +12,7 @@ public class PeculiarBellTileEntity extends AbstractBellTileEntity {
}
@Override
public PartialModel getBellPartial() {
public PartialModel getBellModel() {
return AllBlockPartials.PECULIAR_BELL;
}

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.curiosities.bell;
import com.simibubi.create.AllParticleTypes;
import com.simibubi.create.foundation.data.BasicParticleData;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.renderer.ActiveRenderInfo;
@ -19,9 +18,9 @@ public class SoulBaseParticle extends CustomRotationParticle {
super(worldIn, x, y, z, spriteSet, 0);
this.animatedSprite = spriteSet;
this.particleScale = 0.5f;
this.setSize(this.particleScale,this.particleScale);
this.setSize(this.particleScale, this.particleScale);
this.loopLength = 16 + (int) (this.rand.nextFloat() * 2f - 1f);
this.maxAge = (int)(90.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.maxAge = (int) (90.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.field_21507 = true; // disable movement
}
@ -45,6 +44,7 @@ public class SoulBaseParticle extends CustomRotationParticle {
public IBasicParticleFactory<SoulBaseParticle> getBasicFactory() {
return SoulBaseParticle::new;
}
@Override
public ParticleType<?> getType() {
return AllParticleTypes.SOUL_BASE.get();

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.curiosities.bell;
import com.simibubi.create.AllParticleTypes;
import com.simibubi.create.foundation.data.BasicParticleData;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.renderer.ActiveRenderInfo;

View file

@ -38,7 +38,9 @@ public class SoulPulseEffect {
return ticks <= -WAITING_TICKS;
}
public boolean canOverlap() { return added == null; }
public boolean canOverlap() {
return added == null;
}
public List<BlockPos> tick(World world) {
if (finished())
@ -69,7 +71,7 @@ public class SoulPulseEffect {
.collect(Collectors.toList());
}
public static boolean canSpawnSoulAt(World world, BlockPos at) {
public boolean canSpawnSoulAt(World world, BlockPos at) {
EntityType<?> dummy = EntityType.ZOMBIE;
double dummyWidth = 0.2, dummyHeight = 0.75;
double w2 = dummyWidth / 2;
@ -84,7 +86,7 @@ public class SoulPulseEffect {
), (a,b) -> true).allMatch(VoxelShape::isEmpty);
}
public static void spawnParticles(World world, BlockPos at) {
public void spawnParticles(World world, BlockPos at) {
if (world == null || !world.isRemote)
return;
@ -101,10 +103,9 @@ public class SoulPulseEffect {
for (int x = 0; x < MAX_DISTANCE; x++) {
for (int y = 0; y < MAX_DISTANCE; y++) {
for (int z = 0; z < MAX_DISTANCE; z++) {
BlockPos candidate = new BlockPos(x,y,z);
BlockPos candidate = new BlockPos(x, y, z);
int dist = (int) Math.round(Math.sqrt(
candidate.distanceSq(0,0,0,false)));
int dist = (int) Math.round(Math.sqrt(candidate.distanceSq(0, 0, 0, false)));
if (dist > MAX_DISTANCE)
continue;
if (dist <= 0)

View file

@ -4,18 +4,9 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Supplier;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.fml.network.NetworkEvent;
import net.minecraftforge.fml.network.PacketDistributor;
public class SoulPulseEffectHandler {
@ -35,14 +26,14 @@ public class SoulPulseEffectHandler {
if (pulse.canOverlap()) {
for (BlockPos pos : spawns) {
SoulPulseEffect.spawnParticles(world, pos);
pulse.spawnParticles(world, pos);
}
} else {
for (BlockPos pos : spawns) {
if (occupied.contains(pos))
continue;
SoulPulseEffect.spawnParticles(world, pos);
pulse.spawnParticles(world, pos);
pulse.added.add(pos);
occupied.add(pos);
}
@ -56,52 +47,13 @@ public class SoulPulseEffectHandler {
pulses.removeIf(SoulPulseEffect::finished);
}
public void addPulse(SoulPulseEffect pulse) {
pulses.add(pulse);
}
public void refresh() {
pulses.clear();
occupied.clear();
}
public static void sendPulsePacket(World world, BlockPos at, int distance, boolean canOverlap) {
Chunk chunk = world.getChunkAt(at);
AllPackets.channel.send(PacketDistributor.TRACKING_CHUNK.with(() -> chunk), new Packet(at, distance, canOverlap));
}
private void handlePulse(BlockPos pos, int distance, boolean overlaps) {
pulses.add(new SoulPulseEffect(pos, distance, overlaps));
}
public static class Packet extends SimplePacketBase {
public BlockPos pos;
public int distance;
public boolean overlaps;
public Packet(BlockPos pos, int distance, boolean overlaps) {
this.pos = pos;
this.distance = distance;
this.overlaps = overlaps;
}
public Packet(PacketBuffer buffer) {
pos = new BlockPos(buffer.readInt(), buffer.readInt(), buffer.readInt());
distance = buffer.readInt();
overlaps = buffer.readBoolean();
}
@Override
public void write(PacketBuffer buffer) {
buffer.writeInt(pos.getX());
buffer.writeInt(pos.getY());
buffer.writeInt(pos.getZ());
buffer.writeInt(distance);
buffer.writeBoolean(overlaps);
}
@Override
public void handle(Supplier<NetworkEvent.Context> context) {
context.get().enqueueWork(() -> CreateClient.SOUL_PULSE_EFFECT_HANDLER.handlePulse(pos, distance, overlaps));
context.get().setPacketHandled(true);
}
}
}

View file

@ -0,0 +1,45 @@
package com.simibubi.create.content.curiosities.bell;
import java.util.function.Supplier;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.networking.SimplePacketBase;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.network.NetworkEvent;
public class SoulPulseEffectPacket extends SimplePacketBase {
public BlockPos pos;
public int distance;
public boolean canOverlap;
public SoulPulseEffectPacket(BlockPos pos, int distance, boolean overlaps) {
this.pos = pos;
this.distance = distance;
this.canOverlap = overlaps;
}
public SoulPulseEffectPacket(PacketBuffer buffer) {
pos = buffer.readBlockPos();
distance = buffer.readInt();
canOverlap = buffer.readBoolean();
}
@Override
public void write(PacketBuffer buffer) {
buffer.writeBlockPos(pos);
buffer.writeInt(distance);
buffer.writeBoolean(canOverlap);
}
@Override
public void handle(Supplier<NetworkEvent.Context> context) {
context.get().enqueueWork(() -> {
CreateClient.SOUL_PULSE_EFFECT_HANDLER.addPulse(new SoulPulseEffect(pos, distance, canOverlap));
});
context.get().setPacketHandled(true);
}
}

View file

@ -32,7 +32,6 @@ import com.tterrag.registrate.providers.RegistrateBlockstateProvider;
import com.tterrag.registrate.util.nullness.NonNullBiConsumer;
import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
import net.minecraft.block.BellBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.state.BooleanProperty;
@ -463,12 +462,6 @@ public class BlockStateGen {
};
}
public static <B extends BellBlock> NonNullBiConsumer<DataGenContext<Block, B>, RegistrateBlockstateProvider> bell() {
return (c, p) -> p.horizontalBlock(c.getEntry(), state ->
AssetLookup.partialBaseModel(c, p, state.get(BlockStateProperties.BELL_ATTACHMENT).getString())
);
}
private static void putPart(Map<Pair<String, Axis>, ModelFile> coreModels, MultiPartBlockStateBuilder builder,
Axis axis, String s, boolean up, boolean down, boolean left, boolean right) {
Direction positiveAxis = Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);

View file

@ -29,9 +29,11 @@ import com.tterrag.registrate.builders.BlockBuilder;
import com.tterrag.registrate.util.nullness.NonNullUnaryOperator;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Rarity;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.PistonType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
@ -216,4 +218,16 @@ public class BuilderTransformers {
.transform(ModelGen.customItemModel("crate", type, "single"));
}
public static <B extends Block, P> NonNullUnaryOperator<BlockBuilder<B, P>> bell() {
return b -> b.initialProperties(SharedProperties::softMetal)
.properties(p -> p.nonOpaque()
.sound(SoundType.ANVIL))
.addLayer(() -> RenderType::getCutoutMipped)
.tag(AllBlockTags.BRITTLE.tag)
.blockstate((c, p) -> p.horizontalBlock(c.getEntry(), state ->
AssetLookup.partialBaseModel(c, p, state.get(BlockStateProperties.BELL_ATTACHMENT).getString())))
.item()
.transform(ModelGen.customItemModel());
}
}

View file

@ -21,7 +21,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.tra
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartControllerUpdatePacket;
import com.simibubi.create.content.contraptions.fluids.actors.FluidSplashPacket;
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.ConfigureSequencedGearshiftPacket;
import com.simibubi.create.content.curiosities.bell.SoulPulseEffectHandler;
import com.simibubi.create.content.curiosities.bell.SoulPulseEffectPacket;
import com.simibubi.create.content.curiosities.projector.ConfigureProjectorPacket;
import com.simibubi.create.content.curiosities.symmetry.SymmetryEffectPacket;
import com.simibubi.create.content.curiosities.tools.BlueprintAssignCompleteRecipePacket;
@ -115,7 +115,7 @@ public enum AllPackets {
TUNNEL_FLAP(TunnelFlapPacket.class, TunnelFlapPacket::new, PLAY_TO_CLIENT),
FUNNEL_FLAP(FunnelFlapPacket.class, FunnelFlapPacket::new, PLAY_TO_CLIENT),
POTATO_CANNON(PotatoCannonPacket.class, PotatoCannonPacket::new, PLAY_TO_CLIENT),
SOUL_PULSE(SoulPulseEffectHandler.Packet.class, SoulPulseEffectHandler.Packet::new, PLAY_TO_CLIENT),
SOUL_PULSE(SoulPulseEffectPacket.class, SoulPulseEffectPacket::new, PLAY_TO_CLIENT),
PERSISTENT_DATA(ISyncPersistentData.Packet.class, ISyncPersistentData.Packet::new, PLAY_TO_CLIENT),
;

View file

@ -3,7 +3,7 @@
"textures": {
"1": "create:block/bell_frame_side",
"2": "create:block/bell_frame",
"particle": "create:block/bell"
"particle": "create:block/bell"
},
"elements": [
{

View file

@ -3,7 +3,7 @@
"textures": {
"1": "create:block/bell_frame_side",
"2": "create:block/bell_frame",
"particle": "create:block/bell"
"particle": "create:block/bell"
},
"elements": [
{

View file

@ -1,6 +1,6 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"parent": "block/block",
"textures": {
"0": "create:block/bell_anim",
"particle": "create:block/bell"