made void kill, added death message, laguage lines

This commit is contained in:
Chipperfluff 2025-12-17 12:10:10 +01:00
parent 068feb0d4d
commit ca55f5a503
10 changed files with 189 additions and 54 deletions

View File

@ -10,6 +10,9 @@ public class ModCriteria {
public static final PortalDestroyedTrigger PORTAL_DESTROYED =
Criteria.register(new PortalDestroyedTrigger());
public static final VoidConsumedTrigger VOID_CONSUMED_TRIGGER =
Criteria.register(new VoidConsumedTrigger());
public static void register() {
// classload trigger
}

View File

@ -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);
}
}
}

View File

@ -38,10 +38,8 @@ public class ChipperFrameBlock extends PillarBlock {
boolean moved
) {
if (!world.isClient && state.getBlock() != newState.getBlock()) {
// destroy portal
ChipperPortalShape.destroyNearby(world, pos);
// advancement trigger
if (world.getClosestPlayer(
pos.getX(), pos.getY(), pos.getZ(),
10, false

View File

@ -75,7 +75,7 @@ public class ChipperPortalBlock extends Block {
@Override
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
if (!player.isCreative()) {
return 0.0F; // impossible to break
return 0.0F;
}
return super.calcBlockBreakingDelta(state, player, world, pos);
}

View File

@ -27,7 +27,6 @@ public class ChipperPortalShape {
if (shape.isValid()) {
shape.placePortal();
// 🔥 PORTAL CREATED TRIGGER
if (serverWorld.getClosestPlayer(
placedPos.getX(),
placedPos.getY(),
@ -47,11 +46,9 @@ public class ChipperPortalShape {
private boolean isValid() {
// find bottom-left corner
BlockPos base = findBottomLeft();
if (base == null) return false;
// check frame
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 5; y++) {

View File

@ -9,6 +9,7 @@ import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.Chipperfluff.chipi.ChipiMod;
import net.minecraft.block.piston.PistonBehavior;
public class ModBlocks {
@ -19,8 +20,8 @@ public class ModBlocks {
AbstractBlock.Settings.create()
.strength(-1.0F, 3600000.0F)
.mapColor(MapColor.BLACK)
.noCollision()
.dropsNothing()
.pistonBehavior(PistonBehavior.BLOCK)
)
);

View File

@ -2,10 +2,21 @@ package net.Chipperfluff.chipi.block;
import net.minecraft.block.Block;
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.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.world.BlockView;
import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.World;
import net.Chipperfluff.chipi.advancement.ModCriteria;
import net.minecraft.server.network.ServerPlayerEntity;
public class VoidBlock extends Block {
@ -13,16 +24,59 @@ public class VoidBlock extends Block {
super(settings);
}
@Override
public float calcBlockBreakingDelta(
BlockState state,
PlayerEntity player,
BlockView world,
BlockPos pos
) {
if (!player.isCreative()) {
return 0.0F;
private void voidKill(World world, Entity entity) {
if (world.isClient) return;
if (entity instanceof ItemEntity) {
entity.kill();
return;
}
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);
}
}

View 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"
}

View File

@ -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"
}
}
}

View File

@ -0,0 +1,6 @@
{
"message_id": "void_block",
"scaling": "never",
"exhaustion": 0.0,
"effects": "hurt"
}