new sounds, who dis

This commit is contained in:
oitsjustjose 2022-10-18 14:48:04 -05:00
commit 93c6d4ba89
5 changed files with 15 additions and 8 deletions

View file

@ -1,6 +1,10 @@
package com.oitsjustjose.charged_explosives.common;
import com.oitsjustjose.charged_explosives.common.network.*;
import com.oitsjustjose.charged_explosives.common.network.ExplosionParticlePacket;
import com.oitsjustjose.charged_explosives.common.network.NetworkManager;
import com.oitsjustjose.charged_explosives.common.network.OpenGuiPacket;
import com.oitsjustjose.charged_explosives.common.network.PreviewExplosionPacket;
import com.oitsjustjose.charged_explosives.common.network.UpdateNbtPacket;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Tuple;
@ -13,7 +17,7 @@ import java.util.Optional;
public class CommonProxy {
public static NetworkManager netMgr = new NetworkManager("server");
public static NetworkManager netMgr = new NetworkManager();
public static int disc = 0;

View file

@ -168,7 +168,7 @@ public class ChargedExplosiveBlock extends FaceAttachedHorizontalDirectionalBloc
for (int i = 0; i < CommonConfig.NUM_BEEPS.get(); i++) {
cebe.addScheduledTask(ChargedExplosives.getInstance().SCHEDULER.addTask(new TickScheduler.ScheduledTask(() -> {
if (level.getBlockEntity(pos) instanceof ChargedExplosiveBlockEntity) { // check that it's still there
level.playSound(null, pos, ChargedExplosives.getInstance().REGISTRY.BeepBoop.get(), SoundSource.BLOCKS, 0.5F, 1.0F);
level.playSound(null, pos, ChargedExplosives.getInstance().REGISTRY.BeepSound.get(), SoundSource.BLOCKS, 0.75F, 1.0F);
}
}, (CommonConfig.EXPLOSION_COUNTDOWN_TIME.get() / CommonConfig.NUM_BEEPS.get()) * i)));
}

View file

@ -13,6 +13,7 @@ import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
@ -29,7 +30,7 @@ import java.util.Objects;
public class ChargedExplosiveItem extends BlockItem {
public ChargedExplosiveItem(Block block) {
super(block, new Item.Properties());
super(block, new Item.Properties().tab(CreativeModeTab.TAB_REDSTONE));
}
@Override
@ -65,13 +66,14 @@ public class ChargedExplosiveItem extends BlockItem {
@Override
public @NotNull InteractionResult place(BlockPlaceContext context) {
ItemStack stack = context.getItemInHand();
// TODO: noises
if (!isNbtInitialized(stack)) {
Objects.requireNonNull(context.getPlayer()).displayClientMessage(Util.translateOrFallback(ChargedExplosives.MODID + ".needs_init"), true);
context.getPlayer().playSound(ChargedExplosives.getInstance().REGISTRY.FailureSound.get(), 0.75F, 0.9F);
return InteractionResult.FAIL;
}
if (!isNbtValid(stack)) {
Objects.requireNonNull(context.getPlayer()).displayClientMessage(Util.translateOrFallback(ChargedExplosives.MODID + ".invalid_config"), true);
context.getPlayer().playSound(ChargedExplosives.getInstance().REGISTRY.FailureSound.get(), 0.75F, 0.9F);
return InteractionResult.FAIL;
}
return super.place(context);

View file

@ -9,7 +9,7 @@ public class NetworkManager {
public SimpleChannel networkWrapper;
private static final String PROTOCOL_VERSION = "1";
public NetworkManager(String nm) {
this.networkWrapper = NetworkRegistry.newSimpleChannel(new ResourceLocation(ChargedExplosives.MODID, nm), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
public NetworkManager() {
this.networkWrapper = NetworkRegistry.newSimpleChannel(new ResourceLocation(ChargedExplosives.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
}
}

View file

@ -23,5 +23,6 @@ public class Registry {
public final RegistryObject<Block> CeBlock = BlockRegistry.register("charged_explosive", ChargedExplosiveBlock::new);
public final RegistryObject<Item> CeItem = ItemRegistry.register("charged_explosive", () -> new ChargedExplosiveItem(CeBlock.get()));
public final RegistryObject<BlockEntityType<ChargedExplosiveBlockEntity>> CeBlockEntityType = BlockEntityTypeRegistry.register("charged_explosive", () -> BlockEntityType.Builder.of(ChargedExplosiveBlockEntity::new, Blocks.AIR).build(null));
public final RegistryObject<SoundEvent> BeepBoop = SoundEventRegistry.register("shapedchargebeep", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "shapedchargebeep")));
public final RegistryObject<SoundEvent> BeepSound = SoundEventRegistry.register("beep", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "beep")));
public final RegistryObject<SoundEvent> FailureSound = SoundEventRegistry.register("fail", () -> new SoundEvent(new ResourceLocation(ChargedExplosives.MODID, "fail")));
}