-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bazke
committed
Oct 13, 2024
1 parent
50ef8b7
commit 523c1d5
Showing
13 changed files
with
912 additions
and
0 deletions.
There are no files selected for viewing
769 changes: 769 additions & 0 deletions
769
src/generated/resources/assets/ltextras/blockstates/launchpad.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/generated/resources/assets/ltextras/models/block/launchpad.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"parent": "minecraft:block/slab", | ||
"textures": { | ||
"bottom": "ltextras:block/launchpad_top", | ||
"particle": "ltextras:block/launchpad_side", | ||
"side": "ltextras:block/launchpad_side", | ||
"top": "ltextras:block/launchpad_top" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/generated/resources/assets/ltextras/models/block/launchpad_nohoriz.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"parent": "minecraft:block/slab", | ||
"textures": { | ||
"bottom": "ltextras:block/launchpad_bottom", | ||
"particle": "ltextras:block/launchpad_side", | ||
"side": "ltextras:block/launchpad_side", | ||
"top": "ltextras:block/launchpad_top_nohoriz" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/generated/resources/assets/ltextras/models/item/launchpad.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"parent": "ltextras:block/launchpad" | ||
} |
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/ltextras/loot_table/blocks/launchpad.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "ltextras:launchpad" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "ltextras:blocks/launchpad" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/com/lovetropics/extras/block/LaunchpadBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.lovetropics.extras.block; | ||
|
||
import com.mojang.serialization.MapCodec; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.item.context.BlockPlaceContext; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.HorizontalDirectionalBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.IntegerProperty; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
|
||
public class LaunchpadBlock extends HorizontalDirectionalBlock { | ||
|
||
public static final MapCodec<LaunchpadBlock> CODEC = simpleCodec(LaunchpadBlock::new); | ||
private static final VoxelShape AABB = Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0); | ||
//Power is divided by 10 since there is no FloatProperty | ||
public static final IntegerProperty VERTICAL_POWER = IntegerProperty.create("vertical_power", 0, 50); | ||
public static final IntegerProperty HORIZONTAL_POWER = IntegerProperty.create("horizontal_power", 0, 50); | ||
|
||
public LaunchpadBlock(final Properties properties) { | ||
super(properties); | ||
registerDefaultState(defaultBlockState().setValue(VERTICAL_POWER, 10).setValue(HORIZONTAL_POWER, 10)); | ||
} | ||
|
||
@Override | ||
public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { | ||
final double verticalPower = (double) state.getValue(VERTICAL_POWER) / 10; | ||
final double horizontalPower = (double) state.getValue(HORIZONTAL_POWER) / 10; | ||
final Direction facing = state.getValue(FACING); | ||
|
||
final Vec3 upwards = new Vec3(0, verticalPower, 0); | ||
final Vec3 forward = new Vec3(facing.getStepX(), 0, facing.getStepZ()).scale(horizontalPower); | ||
|
||
entity.addDeltaMovement(forward.add(upwards)); | ||
super.stepOn(level, pos, state, entity); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForPlacement(BlockPlaceContext context) { | ||
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); | ||
} | ||
|
||
@Override | ||
protected VoxelShape getShape(final BlockState state, final BlockGetter level, final BlockPos pos, final CollisionContext context) { | ||
return AABB; | ||
} | ||
|
||
@Override | ||
protected MapCodec<? extends HorizontalDirectionalBlock> codec() { | ||
return CODEC; | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
builder.add(FACING, VERTICAL_POWER, HORIZONTAL_POWER); | ||
} | ||
} |
Binary file added
BIN
+824 Bytes
src/main/resources/assets/ltextras/textures/block/launchpad_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+822 Bytes
src/main/resources/assets/ltextras/textures/block/launchpad_side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+881 Bytes
src/main/resources/assets/ltextras/textures/block/launchpad_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+824 Bytes
src/main/resources/assets/ltextras/textures/block/launchpad_top_nohoriz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.