Add in-world zone visualizer, note particles, scenario shuffle, and step editor
This commit is contained in:
@@ -20,14 +20,17 @@
|
||||
*/
|
||||
package com.example.soundmod.gameplay.block;
|
||||
|
||||
import com.example.soundmod.client.audio.AudioPlaybackService;
|
||||
import com.example.soundmod.gameplay.tile.SoundPlayerTileEntity;
|
||||
import com.example.soundmod.registry.ModTileEntities;
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
@@ -36,23 +39,27 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
public class SoundPlayerBlock
|
||||
extends Block {
|
||||
public class SoundPlayerBlock extends Block {
|
||||
public SoundPlayerBlock(AbstractBlock.Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return ((TileEntityType)ModTileEntities.SOUND_PLAYER_TILE.get()).create();
|
||||
}
|
||||
|
||||
public ActionResultType func_225533_a_(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
@Override
|
||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
TileEntity te = world.getBlockEntity(pos);
|
||||
if (!world.isClientSide && te instanceof SoundPlayerTileEntity && player instanceof ServerPlayerEntity) {
|
||||
SoundPlayerTileEntity soundTe = (SoundPlayerTileEntity)te;
|
||||
@@ -62,14 +69,27 @@ extends Block {
|
||||
NetworkHooks.openGui((ServerPlayerEntity)((ServerPlayerEntity)player), (INamedContainerProvider)soundTe, (BlockPos)pos);
|
||||
}
|
||||
}
|
||||
return ActionResultType.sidedSuccess((boolean)world.isClientSide);
|
||||
return ActionResultType.sidedSuccess(world.isClientSide);
|
||||
}
|
||||
|
||||
public void func_220069_a(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean moving) {
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean moving) {
|
||||
TileEntity te = world.getBlockEntity(pos);
|
||||
if (te instanceof SoundPlayerTileEntity) {
|
||||
((SoundPlayerTileEntity)te).onRedstoneChanged(world.hasNeighborSignal(pos));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
|
||||
if (world.isClientSide && AudioPlaybackService.get().isPlaying("sound_player:" + pos.asLong())) {
|
||||
double px = (double) pos.getX() + 0.5 + (rand.nextDouble() - 0.5) * 0.5;
|
||||
double py = (double) pos.getY() + 1.05 + rand.nextDouble() * 0.25;
|
||||
double pz = (double) pos.getZ() + 0.5 + (rand.nextDouble() - 0.5) * 0.5;
|
||||
double noteColor = (double) rand.nextInt(25) / 24.0;
|
||||
world.addParticle(ParticleTypes.NOTE, px, py, pz, noteColor, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user