made void kill, added death message, laguage lines
This commit is contained in:
parent
068feb0d4d
commit
ca55f5a503
@ -10,6 +10,9 @@ public class ModCriteria {
|
|||||||
public static final PortalDestroyedTrigger PORTAL_DESTROYED =
|
public static final PortalDestroyedTrigger PORTAL_DESTROYED =
|
||||||
Criteria.register(new PortalDestroyedTrigger());
|
Criteria.register(new PortalDestroyedTrigger());
|
||||||
|
|
||||||
|
public static final VoidConsumedTrigger VOID_CONSUMED_TRIGGER =
|
||||||
|
Criteria.register(new VoidConsumedTrigger());
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
// classload trigger
|
// classload trigger
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,40 @@
|
|||||||
|
package net.Chipperfluff.chipi.advancement;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.advancement.criterion.AbstractCriterion;
|
||||||
|
import net.minecraft.advancement.criterion.AbstractCriterionConditions;
|
||||||
|
import net.minecraft.predicate.entity.AdvancementEntityPredicateDeserializer;
|
||||||
|
import net.minecraft.predicate.entity.LootContextPredicate;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class VoidConsumedTrigger
|
||||||
|
extends AbstractCriterion<VoidConsumedTrigger.Conditions> {
|
||||||
|
|
||||||
|
public static final Identifier ID =
|
||||||
|
new Identifier("chipi", "void_consumed");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Conditions conditionsFromJson(
|
||||||
|
JsonObject json,
|
||||||
|
LootContextPredicate player,
|
||||||
|
AdvancementEntityPredicateDeserializer deserializer
|
||||||
|
) {
|
||||||
|
return new Conditions(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trigger(ServerPlayerEntity player) {
|
||||||
|
this.trigger(player, conditions -> true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Conditions extends AbstractCriterionConditions {
|
||||||
|
public Conditions(LootContextPredicate player) {
|
||||||
|
super(ID, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -38,10 +38,8 @@ public class ChipperFrameBlock extends PillarBlock {
|
|||||||
boolean moved
|
boolean moved
|
||||||
) {
|
) {
|
||||||
if (!world.isClient && state.getBlock() != newState.getBlock()) {
|
if (!world.isClient && state.getBlock() != newState.getBlock()) {
|
||||||
// destroy portal
|
|
||||||
ChipperPortalShape.destroyNearby(world, pos);
|
ChipperPortalShape.destroyNearby(world, pos);
|
||||||
|
|
||||||
// advancement trigger
|
|
||||||
if (world.getClosestPlayer(
|
if (world.getClosestPlayer(
|
||||||
pos.getX(), pos.getY(), pos.getZ(),
|
pos.getX(), pos.getY(), pos.getZ(),
|
||||||
10, false
|
10, false
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class ChipperPortalBlock extends Block {
|
|||||||
@Override
|
@Override
|
||||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||||
if (!player.isCreative()) {
|
if (!player.isCreative()) {
|
||||||
return 0.0F; // impossible to break
|
return 0.0F;
|
||||||
}
|
}
|
||||||
return super.calcBlockBreakingDelta(state, player, world, pos);
|
return super.calcBlockBreakingDelta(state, player, world, pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ public class ChipperPortalShape {
|
|||||||
if (shape.isValid()) {
|
if (shape.isValid()) {
|
||||||
shape.placePortal();
|
shape.placePortal();
|
||||||
|
|
||||||
// 🔥 PORTAL CREATED TRIGGER
|
|
||||||
if (serverWorld.getClosestPlayer(
|
if (serverWorld.getClosestPlayer(
|
||||||
placedPos.getX(),
|
placedPos.getX(),
|
||||||
placedPos.getY(),
|
placedPos.getY(),
|
||||||
@ -47,11 +46,9 @@ public class ChipperPortalShape {
|
|||||||
|
|
||||||
|
|
||||||
private boolean isValid() {
|
private boolean isValid() {
|
||||||
// find bottom-left corner
|
|
||||||
BlockPos base = findBottomLeft();
|
BlockPos base = findBottomLeft();
|
||||||
if (base == null) return false;
|
if (base == null) return false;
|
||||||
|
|
||||||
// check frame
|
|
||||||
for (int x = 0; x < 4; x++) {
|
for (int x = 0; x < 4; x++) {
|
||||||
for (int y = 0; y < 5; y++) {
|
for (int y = 0; y < 5; y++) {
|
||||||
|
|
||||||
|
|||||||
@ -9,58 +9,59 @@ import net.minecraft.registry.Registry;
|
|||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
import net.Chipperfluff.chipi.ChipiMod;
|
import net.Chipperfluff.chipi.ChipiMod;
|
||||||
|
import net.minecraft.block.piston.PistonBehavior;
|
||||||
|
|
||||||
public class ModBlocks {
|
public class ModBlocks {
|
||||||
|
|
||||||
public static final Block VOID_BLOCK = Registry.register(
|
public static final Block VOID_BLOCK = Registry.register(
|
||||||
Registries.BLOCK,
|
Registries.BLOCK,
|
||||||
new Identifier(ChipiMod.MOD_ID, "void_block"),
|
new Identifier(ChipiMod.MOD_ID, "void_block"),
|
||||||
new VoidBlock(
|
new VoidBlock(
|
||||||
AbstractBlock.Settings.create()
|
AbstractBlock.Settings.create()
|
||||||
.strength(-1.0F, 3600000.0F)
|
.strength(-1.0F, 3600000.0F)
|
||||||
.mapColor(MapColor.BLACK)
|
.mapColor(MapColor.BLACK)
|
||||||
.noCollision()
|
.dropsNothing()
|
||||||
.dropsNothing()
|
.pistonBehavior(PistonBehavior.BLOCK)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final Block CHIPPER_FRAME = Registry.register(
|
public static final Block CHIPPER_FRAME = Registry.register(
|
||||||
Registries.BLOCK,
|
Registries.BLOCK,
|
||||||
new Identifier(ChipiMod.MOD_ID, "chipper_frame"),
|
new Identifier(ChipiMod.MOD_ID, "chipper_frame"),
|
||||||
new ChipperFrameBlock(
|
new ChipperFrameBlock(
|
||||||
FabricBlockSettings.create()
|
FabricBlockSettings.create()
|
||||||
.strength(3.0f)
|
.strength(3.0f)
|
||||||
.requiresTool()
|
.requiresTool()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final Block CHIPPER_PORTAL = Registry.register(
|
public static final Block CHIPPER_PORTAL = Registry.register(
|
||||||
Registries.BLOCK,
|
Registries.BLOCK,
|
||||||
new Identifier(ChipiMod.MOD_ID, "chipper_portal"),
|
new Identifier(ChipiMod.MOD_ID, "chipper_portal"),
|
||||||
new ChipperPortalBlock(
|
new ChipperPortalBlock(
|
||||||
FabricBlockSettings.create()
|
FabricBlockSettings.create()
|
||||||
.noCollision()
|
.noCollision()
|
||||||
.luminance(3)
|
.luminance(3)
|
||||||
.strength(-1.0f)
|
.strength(-1.0f)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final Block CHIPPER_ORE = Registry.register(
|
public static final Block CHIPPER_ORE = Registry.register(
|
||||||
Registries.BLOCK,
|
Registries.BLOCK,
|
||||||
new Identifier(ChipiMod.MOD_ID, "chipper_ore"),
|
new Identifier(ChipiMod.MOD_ID, "chipper_ore"),
|
||||||
new Block(AbstractBlock.Settings
|
new Block(AbstractBlock.Settings
|
||||||
.copy(Blocks.IRON_ORE)
|
.copy(Blocks.IRON_ORE)
|
||||||
.requiresTool()
|
.requiresTool()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final Block CHIPPER_ALLOY_BLOCK = Registry.register(
|
public static final Block CHIPPER_ALLOY_BLOCK = Registry.register(
|
||||||
Registries.BLOCK,
|
Registries.BLOCK,
|
||||||
new Identifier(ChipiMod.MOD_ID, "chipper_alloy_block"),
|
new Identifier(ChipiMod.MOD_ID, "chipper_alloy_block"),
|
||||||
new Block(AbstractBlock.Settings
|
new Block(AbstractBlock.Settings
|
||||||
.copy(Blocks.IRON_BLOCK)
|
.copy(Blocks.IRON_BLOCK)
|
||||||
.requiresTool()
|
.requiresTool()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static void register() {}
|
public static void register() {}
|
||||||
|
|||||||
@ -2,10 +2,21 @@ package net.Chipperfluff.chipi.block;
|
|||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
import net.minecraft.entity.damage.DamageType;
|
||||||
|
import net.minecraft.registry.RegistryKey;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.explosion.Explosion;
|
import net.Chipperfluff.chipi.advancement.ModCriteria;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
|
||||||
public class VoidBlock extends Block {
|
public class VoidBlock extends Block {
|
||||||
|
|
||||||
@ -13,16 +24,59 @@ public class VoidBlock extends Block {
|
|||||||
super(settings);
|
super(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void voidKill(World world, Entity entity) {
|
||||||
public float calcBlockBreakingDelta(
|
if (world.isClient) return;
|
||||||
BlockState state,
|
|
||||||
PlayerEntity player,
|
if (entity instanceof ItemEntity) {
|
||||||
BlockView world,
|
entity.kill();
|
||||||
BlockPos pos
|
return;
|
||||||
) {
|
|
||||||
if (!player.isCreative()) {
|
|
||||||
return 0.0F;
|
|
||||||
}
|
}
|
||||||
return super.calcBlockBreakingDelta(state, player, world, pos);
|
|
||||||
|
if (entity instanceof LivingEntity living) {
|
||||||
|
|
||||||
|
if (living instanceof PlayerEntity player) {
|
||||||
|
if (player.isCreative() || player.isSpectator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegistryEntry<DamageType> voidType = world
|
||||||
|
.getRegistryManager()
|
||||||
|
.get(RegistryKeys.DAMAGE_TYPE)
|
||||||
|
.entryOf(
|
||||||
|
RegistryKey.of(
|
||||||
|
RegistryKeys.DAMAGE_TYPE,
|
||||||
|
new Identifier("chipi", "void_block")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
DamageSource voidSource = new DamageSource(voidType);
|
||||||
|
|
||||||
|
if (living instanceof ServerPlayerEntity serverPlayer) {
|
||||||
|
ModCriteria.VOID_CONSUMED_TRIGGER.trigger(serverPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
living.damage(voidSource, Float.MAX_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityCollision(
|
||||||
|
BlockState state,
|
||||||
|
World world,
|
||||||
|
BlockPos pos,
|
||||||
|
Entity entity
|
||||||
|
) {
|
||||||
|
voidKill(world, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSteppedOn(
|
||||||
|
World world,
|
||||||
|
BlockPos pos,
|
||||||
|
BlockState state,
|
||||||
|
Entity entity
|
||||||
|
) {
|
||||||
|
voidKill(world, entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/main/resources/assets/chipi/lang/en_us.json
Normal file
19
src/main/resources/assets/chipi/lang/en_us.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"death.attack.void_block": "%1$s stepped beyond safety and the Outside took them",
|
||||||
|
|
||||||
|
"block.chipi.void_block": "Void Block",
|
||||||
|
"block.chipi.chipper_frame": "Chipper Frame",
|
||||||
|
"block.chipi.chipper_portal": "Chipper Portal",
|
||||||
|
"block.chipi.chipper_ore": "Chipper Ore",
|
||||||
|
"block.chipi.chipper_alloy_block": "Chipper Alloy Block",
|
||||||
|
|
||||||
|
"item.chipi.void_block": "Void Block",
|
||||||
|
"item.chipi.chipper_frame": "Chipper Frame",
|
||||||
|
"item.chipi.chipper_portal": "Chipper Portal",
|
||||||
|
"item.chipi.chipper_ore": "Chipper Ore",
|
||||||
|
"item.chipi.chipper_alloy_block": "Chipper Alloy Block",
|
||||||
|
"item.chipi.nut": "Nut",
|
||||||
|
"item.chipi.raw_chipper_ore": "Raw Chipper Ore",
|
||||||
|
"item.chipi.chipper_ingot": "Chipper Ingot",
|
||||||
|
"item.chipi.chipper_alloy": "Chipper Alloy"
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"parent": "chipi:root",
|
||||||
|
"display": {
|
||||||
|
"icon": { "item": "chipi:void_block" },
|
||||||
|
"title": "Consumed by the Void",
|
||||||
|
"description": "Some knowledge was never meant to be obtained.",
|
||||||
|
"frame": "challenge",
|
||||||
|
"hidden": true,
|
||||||
|
"show_toast": true,
|
||||||
|
"announce_to_chat": false
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"void": {
|
||||||
|
"trigger": "chipi:void_consumed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"message_id": "void_block",
|
||||||
|
"scaling": "never",
|
||||||
|
"exhaustion": 0.0,
|
||||||
|
"effects": "hurt"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user