Skip to content

Commit

Permalink
smaller song cube
Browse files Browse the repository at this point in the history
  • Loading branch information
IAFEnvoy committed Jan 9, 2025
1 parent 58d9f23 commit 49d43e3
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public AbstractSongPower<?> getPower(ItemStack stack) {

@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return VoxelShapes.cuboid(0.25, 0, 0.25, 0.75, 0.5, 0.75);
return VoxelShapes.cuboid(0.375, 0, 0.375, 0.625, 0.25, 0.625);
}

@Override
public VoxelShape getRaycastShape(BlockState state, BlockView world, BlockPos pos) {
return VoxelShapes.cuboid(0.25, 0, 0.25, 0.75, 0.5, 0.75);
return VoxelShapes.cuboid(0.375, 0, 0.375, 0.625, 0.25, 0.625);
}

@Override
Expand Down Expand Up @@ -92,7 +92,7 @@ public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return (world1, pos, state1, blockEntity) -> {
if (blockEntity instanceof AbstractSongCubeBlockEntity songCubeBlockEntity)
Proxies.songCubeSoundManager.startPlaying(pos, songCubeBlockEntity.getCategory());
Proxies.songCubeSoundManager.startPlaying(songCubeBlockEntity.getPos(), songCubeBlockEntity.getCategory());
};
}
}
19 changes: 14 additions & 5 deletions common/src/main/java/com/iafenvoy/sow/power/PowerCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@
import com.iafenvoy.neptune.util.RandomHelper;
import com.iafenvoy.sow.power.type.AbstractSongPower;
import com.iafenvoy.sow.power.type.DummySongPower;
import com.iafenvoy.sow.registry.SowSounds;
import net.minecraft.sound.SoundEvent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Style;

import java.util.*;
import java.util.function.Supplier;

public enum PowerCategory {
AGGRESSIUM("aggressium", new Color4i(237, 28, 36, 255), 231),
MOBILIUM("mobilium", new Color4i(255, 242, 0, 255), 9035),
PROTISIUM("protisium", new Color4i(115, 251, 253, 255), 4290),
SUPPORTIUM("supportium", new Color4i(117, 249, 77, 255), 10);
AGGRESSIUM("aggressium", new Color4i(237, 28, 36, 255), 231,SowSounds.AGGRESSIUM),
MOBILIUM("mobilium", new Color4i(255, 242, 0, 255), 9035,SowSounds.MOBILIUM),
PROTISIUM("protisium", new Color4i(115, 251, 253, 255), 4290,SowSounds.PROTISIUM),
SUPPORTIUM("supportium", new Color4i(117, 249, 77, 255), 10,SowSounds.SUPPORTIUM);
private final String id;
private final Color4i color;
private final long randomOffset;
private final Supplier<SoundEvent> sound;
private final List<AbstractSongPower<?>> powers = new ArrayList<>();
private final Map<String, AbstractSongPower<?>> byId = new HashMap<>();

PowerCategory(String id, Color4i color, long randomOffset) {
PowerCategory(String id, Color4i color, long randomOffset, Supplier<SoundEvent> sound) {
this.id = id;
this.color = color;
this.randomOffset = randomOffset;
this.sound = sound;
}

public String getId() {
Expand All @@ -38,6 +43,10 @@ public long getRandomOffset() {
return this.randomOffset;
}

public SoundEvent getSound() {
return this.sound.get();
}

public MutableText appendColor(MutableText text) {
return text.fillStyle(Style.EMPTY.withColor(this.getColor().getIntValue()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected SongCubeBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) {
@Override
public void render(T entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
matrices.push();
matrices.translate(0.5, 0.25, 0.5);
matrices.translate(0.5, 0.125, 0.5);
this.itemRenderer.renderItem(this.getStack(), ModelTransformationMode.FIXED, light, overlay, matrices, vertexConsumers, entity.getWorld(), 0);
matrices.pop();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.iafenvoy.sow.world.sound;

import com.iafenvoy.sow.power.PowerCategory;
import com.iafenvoy.sow.registry.SowSounds;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -56,12 +55,7 @@ private static class SongCubeSoundInstance extends AbstractSoundInstance impleme
private boolean playing;

public SongCubeSoundInstance(BlockPos pos, PowerCategory category) {
super(switch (category) {
case AGGRESSIUM -> SowSounds.AGGRESSIUM.get();
case MOBILIUM -> SowSounds.MOBILIUM.get();
case PROTISIUM -> SowSounds.PROTISIUM.get();
case SUPPORTIUM -> SowSounds.SUPPORTIUM.get();
}, SoundCategory.BLOCKS, new LocalRandom(0));
super(category.getSound(), SoundCategory.BLOCKS, new LocalRandom(0));
this.repeat = true;
this.x = pos.getX();
this.y = pos.getY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,40 @@
"parent": "block/cube_all",
"textures": {
"all": "sow:block/aggressium_song"
},
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.3, 0.3, 0.3]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.3, 0.3, 0.3]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"head": {
"translation": [0, 9.5, 0],
"scale": [0.4, 0.4, 0.4]
},
"fixed": {
"scale": [0.25, 0.25, 0.25]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,40 @@
"parent": "block/cube_all",
"textures": {
"all": "sow:block/mobilium_song"
},
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.3, 0.3, 0.3]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.3, 0.3, 0.3]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"head": {
"translation": [0, 9.5, 0],
"scale": [0.4, 0.4, 0.4]
},
"fixed": {
"scale": [0.25, 0.25, 0.25]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,40 @@
"parent": "block/cube_all",
"textures": {
"all": "sow:block/protisium_song"
},
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.3, 0.3, 0.3]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.3, 0.3, 0.3]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"head": {
"translation": [0, 9.5, 0],
"scale": [0.4, 0.4, 0.4]
},
"fixed": {
"scale": [0.25, 0.25, 0.25]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,40 @@
"parent": "block/cube_all",
"textures": {
"all": "sow:block/supportium_song"
},
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.275, 0.275, 0.275]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.3, 0.3, 0.3]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.3, 0.3, 0.3]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"head": {
"translation": [0, 9.5, 0],
"scale": [0.4, 0.4, 0.4]
},
"fixed": {
"scale": [0.25, 0.25, 0.25]
}
}
}

0 comments on commit 49d43e3

Please sign in to comment.