-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 parent
6c48122
commit 02a2c84
Showing
14 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
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
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
90 changes: 90 additions & 0 deletions
90
src/main/java/com/github/elenterius/biomancy/block/orifice/OrificeBlock.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,90 @@ | ||
package com.github.elenterius.biomancy.block.orifice; | ||
|
||
import com.github.elenterius.biomancy.init.ModParticleTypes; | ||
import com.github.elenterius.biomancy.init.ModPlantTypes; | ||
import com.github.elenterius.biomancy.util.EnhancedIntegerProperty; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
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.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.BlockStateProperties; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraftforge.common.IPlantable; | ||
import net.minecraftforge.common.PlantType; | ||
|
||
public class OrificeBlock extends Block { | ||
|
||
public static final EnhancedIntegerProperty AGE = EnhancedIntegerProperty.wrap(BlockStateProperties.AGE_2); | ||
|
||
public OrificeBlock(Properties properties) { | ||
super(properties); | ||
registerDefaultState(defaultBlockState().setValue(AGE.get(), AGE.getMin())); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
super.createBlockStateDefinition(builder); | ||
builder.add(AGE.get()); | ||
} | ||
|
||
@Override | ||
public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable) { | ||
PlantType type = plantable.getPlantType(world, pos.relative(facing)); | ||
return type == ModPlantTypes.FLESH_PLANT_TYPE; | ||
} | ||
|
||
@Override | ||
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { | ||
if (!level.isAreaLoaded(pos, 1)) return; | ||
|
||
if (random.nextFloat() < 0.3f) { | ||
int age = AGE.getValue(state); | ||
if (age < AGE.getMax()) { | ||
level.setBlock(pos, AGE.addValue(state, 1), Block.UPDATE_CLIENTS); | ||
} | ||
else { | ||
if (random.nextFloat() < 0.5f) { | ||
level.setBlock(pos, AGE.setValue(state, AGE.getMin()), Block.UPDATE_CLIENTS); | ||
} | ||
//TODO: accumulate acid below the block on the floor, | ||
// drop a acid blob entity/projectile? | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { | ||
//TODO: allow players to harvest acid from full orifices? | ||
return super.use(state, level, pos, player, hand, hit); | ||
} | ||
|
||
@Override | ||
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { | ||
if (random.nextInt(5) == 0 && AGE.getValue(state) == AGE.getMax()) { | ||
Direction direction = Direction.getRandom(random); | ||
|
||
if (direction == Direction.UP) { | ||
return; | ||
} | ||
|
||
BlockPos neighborPos = pos.relative(direction); | ||
BlockState neighborState = level.getBlockState(neighborPos); | ||
|
||
if (!state.canOcclude() || !neighborState.isFaceSturdy(level, neighborPos, direction.getOpposite())) { | ||
double x = direction.getStepX() == 0 ? random.nextDouble() : 0.5d + direction.getStepX() * 0.6d; | ||
double y = direction.getStepY() == 0 ? random.nextDouble() : 0.5d + direction.getStepY() * 0.6d; | ||
double z = direction.getStepZ() == 0 ? random.nextDouble() : 0.5d + direction.getStepZ() * 0.6d; | ||
// TODO: implement acid particle | ||
level.addParticle(ModParticleTypes.FALLING_BLOOD.get(), pos.getX() + x, pos.getY() + y, pos.getZ() + z, 0, 0, 0); | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/github/elenterius/biomancy/block/orifice/package-info.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,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package com.github.elenterius.biomancy.block.orifice; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
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
43 changes: 43 additions & 0 deletions
43
src/main/resources/assets/biomancy/models/block/primal_orifice.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,43 @@ | ||
{ | ||
"credit": "Made by Elenterius", | ||
"parent": "block/block", | ||
"render_type": "minecraft:solid", | ||
"textures": { | ||
"0": "biomancy:block/primal_orifice", | ||
"1": "biomancy:block/primal_flesh", | ||
"2": "biomancy:block/primal_orifice_2", | ||
"particle": "biomancy:block/primal_orifice" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [ 0, 0, 0 ], | ||
"to": [ 16, 16, 16 ], | ||
"faces": { | ||
"north": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#0" | ||
}, | ||
"east": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#0" | ||
}, | ||
"south": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#0" | ||
}, | ||
"west": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#0" | ||
}, | ||
"up": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#1" | ||
}, | ||
"down": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#2" | ||
} | ||
} | ||
} | ||
] | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/resources/assets/biomancy/models/block/primal_orifice_leaking.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,43 @@ | ||
{ | ||
"credit": "Made by Elenterius", | ||
"parent": "block/block", | ||
"render_type": "minecraft:solid", | ||
"textures": { | ||
"1": "biomancy:block/primal_flesh", | ||
"3": "biomancy:block/primal_orifice_leaking", | ||
"4": "biomancy:block/primal_orifice_2_full", | ||
"particle": "biomancy:block/primal_orifice" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [ 0, 0, 0 ], | ||
"to": [ 16, 16, 16 ], | ||
"faces": { | ||
"north": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#3" | ||
}, | ||
"east": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#3" | ||
}, | ||
"south": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#3" | ||
}, | ||
"west": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#3" | ||
}, | ||
"up": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#1" | ||
}, | ||
"down": { | ||
"uv": [ 0, 0, 16, 16 ], | ||
"texture": "#4" | ||
} | ||
} | ||
} | ||
] | ||
} |
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
+3.22 KB
src/main/resources/assets/biomancy/textures/block/primal_orifice_2.png
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
+662 Bytes
src/main/resources/assets/biomancy/textures/block/primal_orifice_2_full.png
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
+623 Bytes
src/main/resources/assets/biomancy/textures/block/primal_orifice_leaking.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.