remove note block tes

This commit is contained in:
Sen 2025-05-31 19:57:32 +02:00
parent 493230c4a6
commit 821a46b720
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
4 changed files with 28 additions and 188 deletions

View file

@ -1,126 +1,46 @@
package common.block.tech; package common.block.tech;
import common.block.Block; import common.block.Block;
import common.block.BlockContainer;
import common.block.Material; import common.block.Material;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.init.Blocks;
import common.init.SoundEvent; import common.init.SoundEvent;
import common.item.CheatTab; import common.item.CheatTab;
import common.model.ParticleType; import common.model.ParticleType;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityNote;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.State; import common.world.State;
import common.world.World; import common.world.World;
public class BlockNote extends BlockContainer public class BlockNote extends Block {
{ public BlockNote() {
// private static final List<String> INSTRUMENTS = Lists.newArrayList("harp", "bd", "snare", "hat", "bassattack");
public BlockNote()
{
super(Material.WOOD); super(Material.WOOD);
this.setTab(CheatTab.TECHNOLOGY); this.setTab(CheatTab.TECHNOLOGY);
} }
/** public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock) {
* Called when a neighboring block changes. if(worldIn.isBlockPowered(pos))
*/ worldIn.addBlockEvent(pos, Blocks.noteblock, 0, 0);
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
boolean flag = worldIn.isBlockPowered(pos);
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityNote)
{
TileEntityNote tileentitynote = (TileEntityNote)tileentity;
if (tileentitynote.previousRedstoneState != flag)
{
if (flag)
{
tileentitynote.triggerNote(worldIn, pos);
} }
tileentitynote.previousRedstoneState = flag; public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ) {
} if(!worldIn.client)
} worldIn.addBlockEvent(pos, Blocks.noteblock, 0, 0);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, State state, EntityNPC playerIn, Facing side, float hitX, float hitY, float hitZ)
{
if (worldIn.client)
{
return true; return true;
} }
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityNote) public void onBlockClicked(World worldIn, BlockPos pos, EntityNPC playerIn) {
{ if(!worldIn.client)
TileEntityNote tileentitynote = (TileEntityNote)tileentity; worldIn.addBlockEvent(pos, Blocks.noteblock, 0, 0);
tileentitynote.changePitch();
tileentitynote.triggerNote(worldIn, pos);
// playerIn.triggerAchievement(StatRegistry.noteblockTuneStat);
} }
return true; public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam) {
}
}
public void onBlockClicked(World worldIn, BlockPos pos, EntityNPC playerIn)
{
if (!worldIn.client)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityNote)
{
((TileEntityNote)tileentity).triggerNote(worldIn, pos);
// playerIn.triggerAchievement(StatRegistry.noteblockPlayStat);
}
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn)
{
return new TileEntityNote();
}
// private String getInstrument(int id)
// {
// if (id < 0 || id >= INSTRUMENTS.size())
// {
// id = 0;
// }
//
// return (String)INSTRUMENTS.get(id);
// }
/**
* Called on both Client and Server when World#addBlockEvent is called
*/
public boolean onBlockEventReceived(World worldIn, BlockPos pos, State state, int eventID, int eventParam)
{
float f = (float)Math.pow(2.0D, (double)(eventParam - 12) / 12.0D);
worldIn.playSound(SoundEvent.NOTE, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 3.0F); worldIn.playSound(SoundEvent.NOTE, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 3.0F);
worldIn.spawnParticle(ParticleType.NOTE, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.2D, (double)pos.getZ() + 0.5D, (double)eventParam / 24.0D, 0.0D, 0.0D); worldIn.spawnParticle(ParticleType.NOTE, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.2D, (double)pos.getZ() + 0.5D,
(double)eventParam / 24.0D, 0.0D, 0.0D);
return true; return true;
} }
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
public boolean isMagnetic() { public boolean isMagnetic() {
return true; return true;
} }

View file

@ -16,7 +16,6 @@ import common.tileentity.TileEntityEnchantmentTable;
import common.tileentity.TileEntityFurnace; import common.tileentity.TileEntityFurnace;
import common.tileentity.TileEntityHopper; import common.tileentity.TileEntityHopper;
import common.tileentity.TileEntityMobSpawner; import common.tileentity.TileEntityMobSpawner;
import common.tileentity.TileEntityNote;
import common.tileentity.TileEntityPiston; import common.tileentity.TileEntityPiston;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.tileentity.TileEntitySkull; import common.tileentity.TileEntitySkull;
@ -44,7 +43,6 @@ public abstract class TileRegistry {
addMapping(TileEntityDropper.class, "Dropper"); addMapping(TileEntityDropper.class, "Dropper");
addMapping(TileEntitySign.class, "Sign"); addMapping(TileEntitySign.class, "Sign");
addMapping(TileEntityMobSpawner.class, "MobSpawner"); addMapping(TileEntityMobSpawner.class, "MobSpawner");
addMapping(TileEntityNote.class, "Music");
addMapping(TileEntityPiston.class, "Piston"); addMapping(TileEntityPiston.class, "Piston");
addMapping(TileEntityBrewingStand.class, "Cauldron"); addMapping(TileEntityBrewingStand.class, "Cauldron");
addMapping(TileEntityEnchantmentTable.class, "EnchantTable"); addMapping(TileEntityEnchantmentTable.class, "EnchantTable");

View file

@ -1,73 +0,0 @@
package common.tileentity;
import common.init.Blocks;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.ExtMath;
import common.world.World;
public class TileEntityNote extends TileEntity
{
/** Note to play */
public byte note;
/** stores the latest redstone state */
public boolean previousRedstoneState;
public void writeTags(TagObject compound)
{
super.writeTags(compound);
compound.setByte("note", this.note);
}
public void readTags(TagObject compound)
{
super.readTags(compound);
this.note = compound.getByte("note");
this.note = (byte)ExtMath.clampi(this.note, 0, 24);
}
/**
* change pitch by -> (currentPitch + 1) % 25
*/
public void changePitch()
{
this.note = (byte)((this.note + 1) % 25);
this.markDirty();
}
public void triggerNote(World worldIn, BlockPos p_175108_2_)
{
if (worldIn.getState(p_175108_2_.up()).getBlock() == Blocks.air)
{
// Material material = worldIn.getBlockState(p_175108_2_.down()).getBlock().getMaterial();
// int i = 0;
//
// if (material == Material.rock)
// {
// i = 1;
// }
//
// if (material == Material.sand)
// {
// i = 2;
// }
//
// if (material == Material.glass)
// {
// i = 3;
// }
//
// if (material == Material.wood)
// {
// i = 4;
// }
worldIn.addBlockEvent(p_175108_2_, Blocks.noteblock, 0, this.note);
}
}
public int getColor() {
return 0x80ff00;
}
}

View file

@ -81,7 +81,6 @@ import common.tileentity.TileEntityEnchantmentTable;
import common.tileentity.TileEntityFurnace; import common.tileentity.TileEntityFurnace;
import common.tileentity.TileEntityHopper; import common.tileentity.TileEntityHopper;
import common.tileentity.TileEntityMobSpawner; import common.tileentity.TileEntityMobSpawner;
import common.tileentity.TileEntityNote;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.tileentity.TileEntitySkull; import common.tileentity.TileEntitySkull;
import common.util.Facing; import common.util.Facing;
@ -349,7 +348,6 @@ public abstract class Converter {
mapTile(TileEntityDropper.class, "Dropper", "dropper"); mapTile(TileEntityDropper.class, "Dropper", "dropper");
mapTile(TileEntitySign.class, "Sign", "sign"); mapTile(TileEntitySign.class, "Sign", "sign");
mapTile(TileEntityMobSpawner.class, "MobSpawner", "mob_spawner"); mapTile(TileEntityMobSpawner.class, "MobSpawner", "mob_spawner");
mapTile(TileEntityNote.class, "Music", "noteblock");
// mapTile(TileEntityPiston.class, "Piston", "piston"); // mapTile(TileEntityPiston.class, "Piston", "piston");
mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table"); mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table");
mapTile(TileEntityBeacon.class, "Beacon", "beacon"); mapTile(TileEntityBeacon.class, "Beacon", "beacon");
@ -974,9 +972,6 @@ public abstract class Converter {
else if("Comparator".equals(id)) { else if("Comparator".equals(id)) {
nent.setInt("OutputSignal", ent.getInt("OutputSignal")); nent.setInt("OutputSignal", ent.getInt("OutputSignal"));
} }
else if("Music".equals(id)) {
nent.setByte("note", ent.getByte("note"));
}
else if("Skull".equals(id)) { else if("Skull".equals(id)) {
nent.setByte("Rot", ent.getByte("Rot")); nent.setByte("Rot", ent.getByte("Rot"));
} }