Minor code improvements
This commit is contained in:
parent
93e149be13
commit
78f9b80861
11 changed files with 96 additions and 172 deletions
|
@ -4,7 +4,6 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.BucketItem;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
|
@ -13,7 +12,6 @@ import net.minecraft.state.property.BooleanProperty;
|
|||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -56,7 +54,7 @@ public class BoundaryMarkerBlock extends Block implements Waterloggable {
|
|||
player.getInventory().getMainHandStack().decrement(1);
|
||||
}
|
||||
world.setBlockState(pos, state.with(COLOUR, id));
|
||||
world.playSound((PlayerEntity)null, pos, SoundEvents.ITEM_DYE_USE, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
world.playSound(null, pos, SoundEvents.ITEM_DYE_USE, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.enums.Thickness;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
|
@ -16,8 +15,6 @@ import net.minecraft.util.shape.VoxelShape;
|
|||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ConcreteWithBarsBlock extends HorizontalFacingBlock implements Waterloggable {
|
||||
public static final DirectionProperty VERTICAL_DIRECTION;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package su.a71.new_soviet.blocks;
|
||||
|
||||
import com.mojang.authlib.minecraft.client.MinecraftClient;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
|
@ -67,9 +66,9 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
|
|||
if (bl) {
|
||||
world.scheduleBlockTick(pos, this, 4);
|
||||
} else {
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).getSound(), SoundCategory.NEUTRAL, getSirenVolume(world, pos), 1f);
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).sound(), SoundCategory.NEUTRAL, getSirenVolume(world, pos), 1f);
|
||||
world.setBlockState(pos, state.cycle(ON), 2);
|
||||
world.scheduleBlockTick(pos, this, SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).getDuration());
|
||||
world.scheduleBlockTick(pos, this, SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).duration());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
|
|||
if (!world.isClient) {
|
||||
incrementSoundIndex(world, pos);
|
||||
}
|
||||
player.sendMessage(Text.translatable("block.new_soviet.siren.set", SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).getName()), true);
|
||||
player.sendMessage(Text.translatable("block.new_soviet.siren.set", SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).name()), true);
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return super.onUse(state, world, pos, player, hand, hit);
|
||||
|
@ -119,8 +118,8 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
|
|||
if (state.get(ON) && !world.isReceivingRedstonePower(pos)) {
|
||||
world.setBlockState(pos, state.cycle(ON), 2);
|
||||
} else {
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).getSound(), SoundCategory.NEUTRAL, getSirenVolume(world, pos), 1f);
|
||||
world.scheduleBlockTick(pos, this, SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).getDuration());
|
||||
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).sound(), SoundCategory.NEUTRAL, getSirenVolume(world, pos), 1f);
|
||||
world.scheduleBlockTick(pos, this, SIREN_SOUNDS.get(world.getBlockState(pos).get(SOUND_INDEX)).duration());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,27 +165,6 @@ public class SirenBlock extends HorizontalFacingBlock implements Waterloggable {
|
|||
WATERLOGGED = Properties.WATERLOGGED;
|
||||
}
|
||||
|
||||
public class SirenSound {
|
||||
private final SoundEvent sound;
|
||||
private final int duration;
|
||||
private final String name;
|
||||
|
||||
public SirenSound( String name, SoundEvent sound, int duration) {
|
||||
this.sound = sound;
|
||||
this.duration = duration;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SoundEvent getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public record SirenSound(String name, SoundEvent sound, int duration) {
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.enums.WallMountLocation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.particle.DustParticleEffect;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
|
@ -14,10 +13,10 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.event.GameEvent;
|
||||
|
||||
import su.a71.new_soviet.registration.NSE_Sounds;
|
||||
|
@ -77,14 +76,8 @@ public class SwitchBlock extends LeverBlock {
|
|||
return ActionResult.CONSUME;
|
||||
}
|
||||
|
||||
private static void spawnParticles(BlockState state, WorldAccess world, BlockPos pos, float alpha) {
|
||||
Direction direction = state.get(FACING).getOpposite();
|
||||
Direction direction2 = SwitchBlock.getDirection(state).getOpposite();
|
||||
double d = (double)pos.getX() + 0.5 + 0.1 * (double)direction.getOffsetX() + 0.2 * (double)direction2.getOffsetX();
|
||||
double e = (double)pos.getY() + 0.5 + 0.1 * (double)direction.getOffsetY() + 0.2 * (double)direction2.getOffsetY();
|
||||
double f = (double)pos.getZ() + 0.5 + 0.1 * (double)direction.getOffsetZ() + 0.2 * (double)direction2.getOffsetZ();
|
||||
world.addParticle(new DustParticleEffect(DustParticleEffect.RED, alpha), d, e, f, 0.0, 0.0, 0.0);
|
||||
}
|
||||
// Remove those annoying redstone particles
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {}
|
||||
|
||||
@Override
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue