mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Sounds in the right places and no stacking
This commit is contained in:
parent
9ddc520652
commit
5a7a35b3cc
8 changed files with 35 additions and 22 deletions
|
@ -232,6 +232,7 @@ public class AllItems {
|
|||
|
||||
public static final ItemEntry<PotatoCannonItem> POTATO_CANNON =
|
||||
REGISTRATE.item("potato_cannon", PotatoCannonItem::new)
|
||||
.properties(p -> p.maxStackSize(1))
|
||||
.transform(CreateRegistrate.customRenderedItem(() -> PotatoCannonModel::new))
|
||||
.model(AssetLookup.itemModelWithPartials())
|
||||
.register();
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.minecraft.util.SoundCategory;
|
|||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
@ -231,7 +232,7 @@ public class AllSoundEvents {
|
|||
// return;
|
||||
// if (soundLocation.getPath().contains("_compounded_")
|
||||
// event.setResultSound();
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
private static class SoundEntryProvider implements IDataProvider {
|
||||
|
@ -377,10 +378,18 @@ public class AllSoundEvents {
|
|||
play(world, entity, pos.getX(), pos.getY(), pos.getZ(), volume, pitch);
|
||||
}
|
||||
|
||||
abstract void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch);
|
||||
public void play(World world, PlayerEntity entity, Vector3d pos, float volume, float pitch) {
|
||||
play(world, entity, pos.getX(), pos.getY(), pos.getZ(), volume, pitch);
|
||||
}
|
||||
|
||||
public abstract void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch);
|
||||
|
||||
public void playAt(World world, BlockPos pos, float volume, float pitch, boolean fade) {
|
||||
playAt(world, pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, volume, pitch, fade);
|
||||
playAt(world, pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5, volume, pitch, fade);
|
||||
}
|
||||
|
||||
public void playAt(World world, Vector3d pos, float volume, float pitch, boolean fade) {
|
||||
playAt(world, pos.getX(), pos.getY(), pos.getZ(), volume, pitch, fade);
|
||||
}
|
||||
|
||||
public abstract void playAt(World world, double x, double y, double z, float volume, float pitch, boolean fade);
|
||||
|
@ -445,7 +454,7 @@ public class AllSoundEvents {
|
|||
}
|
||||
|
||||
@Override
|
||||
void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch) {
|
||||
public void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch) {
|
||||
for (Pair<SoundEvent, Couple<Float>> pair : compiledEvents) {
|
||||
Couple<Float> volPitch = pair.getSecond();
|
||||
world.playSound(entity, x, y, z, pair.getFirst(), category, volPitch.getFirst() * volume,
|
||||
|
@ -498,7 +507,7 @@ public class AllSoundEvents {
|
|||
}
|
||||
|
||||
@Override
|
||||
void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch) {
|
||||
public void play(World world, PlayerEntity entity, double x, double y, double z, float volume, float pitch) {
|
||||
world.playSound(entity, x, y, z, event, category, volume, pitch);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class PotatoCannonRenderHandler extends ShootableGadgetRenderHandler {
|
|||
private float nextPitch;
|
||||
|
||||
@Override
|
||||
protected void playSound(Hand hand, BlockPos position) {
|
||||
protected void playSound(Hand hand, Vector3d position) {
|
||||
PotatoProjectileEntity.playLaunchSound(Minecraft.getInstance().world, position, nextPitch);
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ public class PotatoProjectileEntity extends DamagingProjectileEntity implements
|
|||
AllSoundEvents.POTATO_HIT.playOnServer(world, new BlockPos(location));
|
||||
}
|
||||
|
||||
public static void playLaunchSound(World world, BlockPos location, float pitch) {
|
||||
public static void playLaunchSound(World world, Vector3d location, float pitch) {
|
||||
AllSoundEvents.FWOOMP.playAt(world, location, 1, pitch, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.foundation.utility.AngleHelper;
|
|||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -41,8 +42,8 @@ public abstract class PotatoProjectileRenderMode {
|
|||
public void transform(MatrixStack ms, PotatoProjectileEntity entity, float pt) {
|
||||
super.transform(ms, entity, pt);
|
||||
MatrixStacker.of(ms)
|
||||
.rotateZ((entity.ticksExisted + pt) * 2 * (entity.getEntityId() % 16))
|
||||
.rotateX((entity.ticksExisted + pt) * (entity.getEntityId() % 32));
|
||||
.rotateZ((entity.ticksExisted + pt) * 2 * entityRandom(entity, 16))
|
||||
.rotateX((entity.ticksExisted + pt) * entityRandom(entity, 32));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,10 +66,14 @@ public abstract class PotatoProjectileRenderMode {
|
|||
.rotateX(270
|
||||
+ AngleHelper.deg(MathHelper.atan2(diff.y, -MathHelper.sqrt(diff.x * diff.x + diff.z * diff.z))));
|
||||
MatrixStacker.of(ms)
|
||||
.rotateY((entity.ticksExisted + pt) * 20 * spin)
|
||||
.rotateY((entity.ticksExisted + pt) * 20 * spin + entityRandom(entity, 360))
|
||||
.rotateZ(-spriteAngleOffset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int entityRandom(Entity entity, int maxValue) {
|
||||
return (System.identityHashCode(entity) * 31) % maxValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -45,13 +44,13 @@ public abstract class ShootGadgetPacket extends SimplePacketBase {
|
|||
protected abstract void readAdditional(PacketBuffer buffer);
|
||||
|
||||
protected abstract void writeAdditional(PacketBuffer buffer);
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
protected abstract void handleAdditional();
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
protected abstract ShootableGadgetRenderHandler getHandler();
|
||||
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final void handle(Supplier<Context> context) {
|
||||
|
@ -64,13 +63,13 @@ public abstract class ShootGadgetPacket extends SimplePacketBase {
|
|||
if (renderViewEntity.getPositionVec()
|
||||
.distanceTo(location) > 100)
|
||||
return;
|
||||
|
||||
|
||||
ShootableGadgetRenderHandler handler = getHandler();
|
||||
handleAdditional();
|
||||
if (self)
|
||||
handler.shoot(hand);
|
||||
handler.shoot(hand, location);
|
||||
else
|
||||
handler.playSound(hand, new BlockPos(location));
|
||||
handler.playSound(hand, location);
|
||||
});
|
||||
context.get()
|
||||
.setPacketHandled(true);
|
||||
|
|
|
@ -13,8 +13,8 @@ import net.minecraft.client.renderer.texture.TextureManager;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.HandSide;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
@ -44,7 +44,7 @@ public abstract class ShootableGadgetRenderHandler {
|
|||
return 0.8f;
|
||||
}
|
||||
|
||||
public void shoot(Hand hand) {
|
||||
public void shoot(Hand hand, Vector3d location) {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
boolean rightHand = hand == Hand.MAIN_HAND ^ player.getPrimaryHand() == HandSide.LEFT;
|
||||
if (rightHand) {
|
||||
|
@ -54,10 +54,10 @@ public abstract class ShootableGadgetRenderHandler {
|
|||
leftHandAnimation = .2f;
|
||||
dontReequipLeft = false;
|
||||
}
|
||||
playSound(hand, player.getBlockPos());
|
||||
playSound(hand, location);
|
||||
}
|
||||
|
||||
protected abstract void playSound(Hand hand, BlockPos position);
|
||||
protected abstract void playSound(Hand hand, Vector3d position);
|
||||
|
||||
protected abstract boolean appliesTo(ItemStack stack);
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.client.world.ClientWorld;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
||||
|
@ -58,7 +57,7 @@ public class ZapperRenderHandler extends ShootableGadgetRenderHandler {
|
|||
protected void transformHand(MatrixStack ms, float flip, float equipProgress, float recoil, float pt) {}
|
||||
|
||||
@Override
|
||||
protected void playSound(Hand hand, BlockPos position) {
|
||||
protected void playSound(Hand hand, Vector3d position) {
|
||||
float pitch = hand == Hand.MAIN_HAND ? 0.1f : 0.9f;
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
AllSoundEvents.WORLDSHAPER_PLACE.play(mc.world, mc.player, position, 0.1f, pitch);
|
||||
|
|
Loading…
Reference in a new issue