Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
WenXin20 committed Sep 4, 2024
1 parent a984901 commit f30e869
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .bbmodels/coin.bbmodel
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"meta":{"format_version":"4.10","model_format":"animated_entity_model","box_uv":false},"name":"coin","model_identifier":"coin","visible_box":[2,2.5,0.75],"variable_placeholders":"","variable_placeholder_buttons":[],"timeline_setups":[],"unhandled_root_fields":{},"resolution":{"width":16,"height":16},"elements":[{"name":"coin","box_uv":false,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-4,4,-0.5],"to":[4,12,0.5],"autouv":0,"color":6,"origin":[0,8,0],"faces":{"north":{"uv":[4,4,12,12],"texture":0},"east":{"uv":[4,4,5,12],"texture":0},"south":{"uv":[12,4,4,12],"texture":0},"west":{"uv":[11,4,12,12],"texture":0},"up":{"uv":[4,4,12,5],"rotation":180,"texture":0},"down":{"uv":[4,11,12,12],"rotation":180,"texture":0}},"type":"cube","uuid":"b3d80fb9-d94d-f2ea-eed8-9b299546f6a1"}],"outliner":[{"name":"bone","origin":[0,9,0],"color":0,"uuid":"fcdd1012-773b-0d3d-296e-ab92fb2bb5c6","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["b3d80fb9-d94d-f2ea-eed8-9b299546f6a1"]}],"textures":[{"path":"C:\\Users\\dwnew\\Documents\\Github\\Marioverse-1.21\\src\\main\\resources\\assets\\marioverse\\textures\\block\\coin.png","name":"coin.png","folder":"block","namespace":"marioverse","id":"coin","width":16,"height":16,"uv_width":16,"uv_height":16,"particle":true,"use_as_default":false,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"f88243d7-969b-3020-ad86-4de20a22c2c8","relative_path":"../src/main/resources/assets/marioverse/textures/block/coin.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAMJJREFUOE9jZKAQMFKon2EQGvD/+8H/MG/9/pyL4sMvu94wCMU8Q3E1hhdABvy4W4AaNB8g3EsnXjOYlzzBb8CvV3r//75iZri04zXcEFWJfwycCuLEGQB2wdkCsGKwRgNxBmaxvwx/bzEzbF/5lSFo8i3iXaBnIcrAIMDAwKE8geH92kiG2y+YiPTCLWaG7w9eMvC4icC9QZoLbjHDNYIMgoEDJ3kIe+HdEqn/IKcig6cPueBcgmFAatIehEmZVC8AAERvYhH1aJaWAAAAAElFTkSuQmCC"}],"animations":[{"uuid":"385d8c82-f0e8-294f-6ee9-625d2f9471f7","name":"animation.coin.rotation","loop":"loop","override":false,"length":2,"snapping":24,"selected":true,"saved":true,"path":"C:\\Users\\dwnew\\Documents\\Github\\Marioverse-1.21\\src\\main\\resources\\assets\\marioverse\\animations\\coin.animation.json","anim_time_update":"","blend_weight":"","start_delay":"","loop_delay":"","animators":{"fcdd1012-773b-0d3d-296e-ab92fb2bb5c6":{"name":"bone","type":"bone","keyframes":[{"channel":"rotation","data_points":[{"x":"0","y":"0","z":"0"}],"uuid":"162d8445-f240-4f1f-8548-61f123c4537a","time":0,"color":-1,"interpolation":"linear","easing":"linear","easingArgs":[]},{"channel":"rotation","data_points":[{"x":0,"y":-180,"z":0}],"uuid":"4710d085-0955-d1fa-7bd4-9bba2ccd5510","time":1,"color":-1,"interpolation":"linear","easing":"linear","easingArgs":[]},{"channel":"rotation","data_points":[{"x":0,"y":-360,"z":0}],"uuid":"677c461d-60cc-c78f-57a0-7edc4bee4aec","time":2,"color":-1,"interpolation":"linear","easing":"linear","easingArgs":[]}]}}}],"geckoSettings":{"formatVersion":2,"modSDK":"Forge 1.12 - 1.16","objectType":"OBJ_TYPE_ENTITY","entityType":"Entity","javaPackage":"com.example.mod","animFileNamespace":"MODID","animFilePath":"animations/ANIMATIONFILE.json"}}
{"meta":{"format_version":"4.10","model_format":"animated_entity_model","box_uv":false},"name":"coin","model_identifier":"coin - Converted","visible_box":[2,2.5,0.75],"variable_placeholders":"","variable_placeholder_buttons":[],"timeline_setups":[],"unhandled_root_fields":{},"resolution":{"width":16,"height":16},"elements":[{"name":"coin","box_uv":false,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-4,4,-0.5],"to":[4,12,0.5],"autouv":0,"color":6,"origin":[0,8,0],"faces":{"north":{"uv":[4,4,12,12],"texture":0},"east":{"uv":[4,4,5,12],"texture":0},"south":{"uv":[12,4,4,12],"texture":0},"west":{"uv":[11,4,12,12],"texture":0},"up":{"uv":[12,4,4,5],"rotation":180,"texture":0},"down":{"uv":[12,11,4,12],"rotation":180,"texture":0}},"type":"cube","uuid":"b3d80fb9-d94d-f2ea-eed8-9b299546f6a1"}],"outliner":[{"name":"bone","origin":[0,9,0],"color":0,"uuid":"fcdd1012-773b-0d3d-296e-ab92fb2bb5c6","export":true,"mirror_uv":false,"isOpen":true,"locked":false,"visibility":true,"autouv":0,"children":["b3d80fb9-d94d-f2ea-eed8-9b299546f6a1"]}],"textures":[{"path":"C:\\Users\\dwnew\\Documents\\Github\\Marioverse-1.21\\src\\main\\resources\\assets\\marioverse\\textures\\block\\coin.png","name":"coin.png","folder":"block","namespace":"marioverse","id":"coin","width":16,"height":16,"uv_width":16,"uv_height":16,"particle":true,"use_as_default":false,"layers_enabled":false,"sync_to_project":"","render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"internal":true,"saved":true,"uuid":"f88243d7-969b-3020-ad86-4de20a22c2c8","relative_path":"../src/main/resources/assets/marioverse/textures/block/coin.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAOVJREFUOE9jZKAQMFKonwHDgHdLpP7zuImgmMvKOxnOZ+S0R9FDfRf8/37wP8y6359zUVzyZdcbBqGYZ/hdADLgx90CiMYPDAwMAlCagYHh0onXDOYlT/Ab8OuV3v+/r5gZvl94Cbed00AcbBhRBsBcADKAU0Ec7AJmsb8Mf28xM2xf+ZUhaPItIlxwi5nh+4OXDGCbGRgYOJQnMLxfG8lw+wUTkV64xQy3GeYP8lygIA52CQwcOMlD2AughARyKjJ4+pALziUYBqQmbYyUuC5XDZ6QpOW/oZinKvGPcEKi2AWkGgAATphtETxuaLcAAAAASUVORK5CYII="}],"animations":[{"uuid":"385d8c82-f0e8-294f-6ee9-625d2f9471f7","name":"animation.coin.rotation","loop":"loop","override":false,"length":2,"snapping":24,"selected":true,"saved":true,"path":"C:\\Users\\dwnew\\Documents\\Github\\Marioverse-1.21\\src\\main\\resources\\assets\\marioverse\\animations\\coin.animation.json","anim_time_update":"","blend_weight":"","start_delay":"","loop_delay":"","animators":{"fcdd1012-773b-0d3d-296e-ab92fb2bb5c6":{"name":"bone","type":"bone","keyframes":[{"channel":"rotation","data_points":[{"x":"0","y":"0","z":"0"}],"uuid":"162d8445-f240-4f1f-8548-61f123c4537a","time":0,"color":-1,"interpolation":"linear","easing":"linear","easingArgs":[]},{"channel":"rotation","data_points":[{"x":0,"y":-180,"z":0}],"uuid":"4710d085-0955-d1fa-7bd4-9bba2ccd5510","time":1,"color":-1,"interpolation":"linear","easing":"linear","easingArgs":[]},{"channel":"rotation","data_points":[{"x":0,"y":-360,"z":0}],"uuid":"677c461d-60cc-c78f-57a0-7edc4bee4aec","time":2,"color":-1,"interpolation":"linear","easing":"linear","easingArgs":[]}]}}}],"geckoSettings":{"formatVersion":2,"modSDK":"Forge 1.12 - 1.16","objectType":"OBJ_TYPE_ENTITY","entityType":"Entity","javaPackage":"com.example.mod","animFileNamespace":"MODID","animFilePath":"animations/ANIMATIONFILE.json"}}
24 changes: 16 additions & 8 deletions src/main/java/com/wenxin2/marioverse/blocks/CoinBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand All @@ -33,7 +35,7 @@
public class CoinBlock extends Block implements SimpleWaterloggedBlock, EntityBlock {
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;

protected static final VoxelShape COIN_SHAPE = Block.box(4.0, 4.0, 4.0, 8.0, 8.0, 8.0).optimize();
protected static final VoxelShape COIN_SHAPE = Block.box(4.0, 4.0, 4.0, 12.0, 12.0, 12.0).optimize();

public CoinBlock(Properties properties) {
super(properties);
Expand Down Expand Up @@ -70,30 +72,36 @@ public BlockState updateShape(BlockState state, Direction direction, BlockState

@Override
protected void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
double motionX = (world.random.nextDouble() - 0.5) * 0.1;
double motionY = world.random.nextDouble() * 0.1;
double motionZ = (world.random.nextDouble() - 0.5) * 0.1;

ItemStack coinItem = new ItemStack(this.asItem());

if (entity instanceof Player player) {
world.removeBlock(pos, Boolean.TRUE);
player.addItem(coinItem);
world.playSound(player, pos, SoundRegistry.COIN_PICKUP.get(), SoundSource.BLOCKS, 1.0F, 1.0F);

if (!world.isClientSide) {
for (int i = 0; i < 5; i++) {
world.addParticle(ParticleTypes.SCRAPE, pos.getX(), pos.getY(), pos.getZ(), motionX, motionY, motionZ);
double motionX = (world.random.nextDouble() - 0.5) * 0.1;
double motionY = world.random.nextDouble() * 0.1;
double motionZ = (world.random.nextDouble() - 0.5) * 0.1;

world.addParticle(ParticleTypes.SCRAPE, player.getX() + 0.5, player.getY() + 0.5, player.getZ() + 0.5, motionX, motionY, motionZ);
}
}

world.removeBlock(pos, false);
player.addItem(coinItem);

if (!player.addItem(coinItem)) {
player.drop(coinItem, false);
}
}
super.entityInside(state, world, pos, entity);
}

@Override
public void tick(BlockState state, ServerLevel serverWorld, BlockPos pos, RandomSource random) {
super.tick(state, serverWorld, pos, random);
}

@NotNull
@Override
public FluidState getFluidState(final BlockState state)
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/marioverse/geo/coin.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"east": {"uv": [4, 4], "uv_size": [1, 8]},
"south": {"uv": [12, 4], "uv_size": [-8, 8]},
"west": {"uv": [11, 4], "uv_size": [1, 8]},
"up": {"uv": [12, 5], "uv_size": [-8, -1], "uv_rotation": 180},
"down": {"uv": [12, 12], "uv_size": [-8, -1], "uv_rotation": 180}
"up": {"uv": [4, 5], "uv_size": [8, -1], "uv_rotation": 180},
"down": {"uv": [4, 12], "uv_size": [8, -1], "uv_rotation": 180}
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/marioverse/sounds.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"block.coin_pickup": {"category": "block", "sounds": [{ "name": "block/coin_pickup", "stream": false }],
"block.coin_pickup": {"category": "block", "sounds": [{ "name": "marioverse:block/coin_pickup", "stream": false }],
"subtitle": "subtitles.marioverse.block.coin_pickup" },

"block.pipes_linked": {"category": "block", "sounds": [{ "name": "block/amethyst_cluster/break1", "stream": false },
Expand Down

0 comments on commit f30e869

Please sign in to comment.