-
Notifications
You must be signed in to change notification settings - Fork 54
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
49a45af
commit f289bb6
Showing
28 changed files
with
563 additions
and
1 deletion.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/generated/resources/assets/vampirism/blockstates/fog_diffuser.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,7 @@ | ||
{ | ||
"variants": { | ||
"": { | ||
"model": "vampirism:block/fog_diffuser_normal" | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/generated/resources/assets/vampirism/models/block/fog_diffuser_normal.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,4 @@ | ||
{ | ||
"parent": "vampirism:block/fog_diffuser", | ||
"render_type": "minecraft:cutout" | ||
} |
3 changes: 3 additions & 0 deletions
3
src/generated/resources/assets/vampirism/models/item/fog_diffuser.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": "vampirism:block/fog_diffuser" | ||
} |
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
59 changes: 59 additions & 0 deletions
59
...rated/resources/data/vampirism/advancements/recipes/decorations/vampire/fog_diffuser.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,59 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_cursed_plank": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"vampirism:cursed_spruce_planks" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_diamond": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"tag": "forge:gems/diamond" | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_mother_core": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"vampirism:mother_core" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_the_recipe": { | ||
"conditions": { | ||
"recipe": "vampirism:vampire/fog_diffuser" | ||
}, | ||
"trigger": "minecraft:recipe_unlocked" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_diamond", | ||
"has_cursed_plank", | ||
"has_mother_core", | ||
"has_the_recipe" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"vampirism:vampire/fog_diffuser" | ||
] | ||
}, | ||
"sends_telemetry_event": false | ||
} |
21 changes: 21 additions & 0 deletions
21
src/generated/resources/data/vampirism/loot_tables/blocks/fog_diffuser.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": "vampirism:fog_diffuser" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
], | ||
"random_sequence": "vampirism:blocks/fog_diffuser" | ||
} |
27 changes: 27 additions & 0 deletions
27
src/generated/resources/data/vampirism/recipes/vampire/fog_diffuser.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,27 @@ | ||
{ | ||
"type": "minecraft:crafting_shaped", | ||
"category": "misc", | ||
"key": { | ||
"O": { | ||
"tag": "forge:obsidian" | ||
}, | ||
"X": { | ||
"item": "vampirism:cursed_spruce_planks" | ||
}, | ||
"Y": { | ||
"tag": "forge:gems/diamond" | ||
}, | ||
"Z": { | ||
"item": "vampirism:mother_core" | ||
} | ||
}, | ||
"pattern": [ | ||
"XYX", | ||
"YZY", | ||
"OOO" | ||
], | ||
"result": { | ||
"item": "vampirism:fog_diffuser" | ||
}, | ||
"show_notification": true | ||
} |
105 changes: 105 additions & 0 deletions
105
src/main/java/de/teamlapen/vampirism/blockentity/FogDiffuserBlockEntity.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,105 @@ | ||
package de.teamlapen.vampirism.blockentity; | ||
|
||
import de.teamlapen.vampirism.core.ModTags; | ||
import de.teamlapen.vampirism.core.ModTiles; | ||
import de.teamlapen.vampirism.world.VampirismWorld; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.AABB; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
|
||
public class FogDiffuserBlockEntity extends BlockEntity { | ||
|
||
@NotNull | ||
private State state = State.IDLE; | ||
private boolean activated = false; | ||
private float bootProgress = 0; | ||
|
||
public FogDiffuserBlockEntity(BlockPos pPos, BlockState pBlockState) { | ||
super(ModTiles.FOG_DIFFUSER.get(), pPos, pBlockState); | ||
} | ||
|
||
@Override | ||
protected void saveAdditional(@NotNull CompoundTag pTag) { | ||
super.saveAdditional(pTag); | ||
pTag.putString("state", this.state.name()); | ||
pTag.putFloat("bootProgress", this.bootProgress); | ||
pTag.putBoolean("activated", this.activated); | ||
} | ||
|
||
@Override | ||
public void load(@NotNull CompoundTag pTag) { | ||
super.load(pTag); | ||
this.state = State.valueOf(pTag.getString("state")); | ||
this.bootProgress = pTag.getFloat("bootProgress"); | ||
this.activated = pTag.getBoolean("activated"); | ||
} | ||
|
||
protected int getRange() { | ||
return (int) (2.5 * 16); | ||
} | ||
|
||
public @NotNull State getState() { | ||
return state; | ||
} | ||
|
||
public float getBootProgress() { | ||
return bootProgress; | ||
} | ||
|
||
protected AABB getArea() { | ||
return getArea(this.getRange()); | ||
} | ||
|
||
protected AABB getArea(int range) { | ||
return new AABB(this.worldPosition.offset(-range, -range, -range), this.worldPosition.offset(range, range, range)); | ||
} | ||
|
||
public static void tick(Level level, BlockPos pos, BlockState state, FogDiffuserBlockEntity blockEntity) { | ||
switch (blockEntity.state) { | ||
case IDLE -> { | ||
if (blockEntity.activated) { | ||
blockEntity.state = State.BOOTING; | ||
blockEntity.bootProgress = 0; | ||
} | ||
} | ||
case BOOTING -> { | ||
if (level.getGameTime() % 128 == 0) { | ||
blockEntity.bootProgress += 0.1; | ||
if (blockEntity.bootProgress >= 1) { | ||
blockEntity.state = State.ACTIVE; | ||
} | ||
blockEntity.updateFogArea(level); | ||
} | ||
} | ||
case ACTIVE -> { | ||
} | ||
} | ||
} | ||
|
||
public void updateFogArea(Level level) { | ||
VampirismWorld.getOpt(level).ifPresent(w -> w.updateTemporaryArtificialFog(this.worldPosition, switch (this.state) { | ||
case BOOTING -> getArea((int) (this.getRange() * this.bootProgress)); | ||
case ACTIVE -> getArea(); | ||
default -> null; | ||
})); | ||
} | ||
|
||
public void interact(ItemStack itemInHand) { | ||
if (!this.activated && itemInHand.is(ModTags.Items.PURE_BLOOD)) { | ||
this.activated = true; | ||
itemInHand.shrink(1); | ||
} | ||
} | ||
|
||
public enum State { | ||
IDLE, | ||
BOOTING, | ||
ACTIVE | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/main/java/de/teamlapen/vampirism/blocks/FogDiffuserBlock.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 de.teamlapen.vampirism.blocks; | ||
|
||
import de.teamlapen.vampirism.VampirismMod; | ||
import de.teamlapen.vampirism.blockentity.FogDiffuserBlockEntity; | ||
import de.teamlapen.vampirism.core.ModTiles; | ||
import de.teamlapen.vampirism.world.VampirismWorld; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
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.RenderShape; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.entity.BlockEntityTicker; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraft.world.phys.shapes.CollisionContext; | ||
import net.minecraft.world.phys.shapes.Shapes; | ||
import net.minecraft.world.phys.shapes.VoxelShape; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Optional; | ||
|
||
public class FogDiffuserBlock extends VampirismBlockContainer { | ||
|
||
private static final VoxelShape shape = makeShape(); | ||
|
||
private static @NotNull VoxelShape makeShape() { | ||
VoxelShape a = Block.box(1, 0, 1, 15, 2, 15); | ||
VoxelShape b = Block.box(3, 2, 3, 13, 12, 13); | ||
return Shapes.or(a, b); | ||
} | ||
|
||
public FogDiffuserBlock(@NotNull Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Override | ||
public @NotNull InteractionResult use(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull Player pPlayer, @NotNull InteractionHand pHand, @NotNull BlockHitResult pHit) { | ||
ItemStack itemInHand = pPlayer.getItemInHand(pHand); | ||
getBlockEntity(pLevel, pPos).ifPresent(blockEntity -> { | ||
blockEntity.interact(itemInHand); | ||
VampirismMod.proxy.displayFogDiffuserScreen(blockEntity, getName()); | ||
}); | ||
return InteractionResult.sidedSuccess(pLevel.isClientSide); | ||
} | ||
|
||
@NotNull | ||
protected Optional<FogDiffuserBlockEntity> getBlockEntity(@NotNull Level level, BlockPos pos) { | ||
BlockEntity blockEntity = level.getBlockEntity(pos); | ||
if (blockEntity instanceof FogDiffuserBlockEntity) { | ||
return Optional.of((FogDiffuserBlockEntity) blockEntity); | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pState) { | ||
return new FogDiffuserBlockEntity(pPos, pState); | ||
} | ||
|
||
@Override | ||
public @NotNull RenderShape getRenderShape(@NotNull BlockState pState) { | ||
return RenderShape.MODEL; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter worldIn, @NotNull BlockPos pos, @NotNull CollisionContext context) { | ||
return shape; | ||
} | ||
|
||
@Override | ||
public void onRemove(@NotNull BlockState state, @NotNull Level worldIn, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { | ||
super.onRemove(state, worldIn, pos, newState, isMoving); | ||
VampirismWorld.getOpt(worldIn).ifPresent(vampirismWorld -> vampirismWorld.updateTemporaryArtificialFog(pos, null)); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level pLevel, @NotNull BlockState pState, @NotNull BlockEntityType<T> pBlockEntityType) { | ||
return createTickerHelper(pBlockEntityType, ModTiles.FOG_DIFFUSER.get(), FogDiffuserBlockEntity::tick); | ||
} | ||
} |
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
Oops, something went wrong.