This commit is contained in:
2026-02-12 10:33:16 +01:00
parent 4a817f8c21
commit be82e6eed1
122 changed files with 480 additions and 901 deletions

View File

@@ -11,6 +11,8 @@ import net.minecraft.world.World;
public class AtomEntity extends Entity {
private static final int NUKE_RADIUS = 100;
private boolean armed = false;
private boolean wasFallingFast = false;
public AtomEntity(EntityType<?> type, World world) {
super(type, world);
}
@@ -26,14 +28,31 @@ public class AtomEntity extends Entity {
this.setVelocity(this.getVelocity().add(0, -0.08, 0));
}
// Track if it was falling fast enough to count as impact
if (this.getVelocity().y < -0.5) {
wasFallingFast = true;
}
this.move(MovementType.SELF, this.getVelocity());
if (!getWorld().isClient && this.isOnGround()) {
explode();
this.discard();
if (!getWorld().isClient) {
// 🔥 If on fire, arm it
if (this.isOnFire()) {
armed = true;
}
// 💥 Explode only if:
// 1. It was falling fast OR
// 2. It is armed
if (this.isOnGround() && (wasFallingFast || armed)) {
explode();
this.discard();
}
}
}
private void explode() {
ServerWorld world = (ServerWorld) this.getWorld();

View File

@@ -0,0 +1,45 @@
package dev.tggamesyt.szar;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class AtomItem extends Item {
public AtomItem(Settings settings) {
super(settings);
}
@Override
public ActionResult useOnBlock(ItemUsageContext context) {
World world = context.getWorld();
if (world.isClient()) return ActionResult.SUCCESS;
ServerWorld serverWorld = (ServerWorld) world;
BlockPos pos = context.getBlockPos(); // The block the player clicked
Vec3d spawnPos = Vec3d.ofCenter(pos).add(0, 1, 0); // Spawn 1 block above clicked block
// Create entity
AtomEntity atom = new AtomEntity(Szar.AtomEntityType, serverWorld);
atom.setPosition(spawnPos.x, spawnPos.y, spawnPos.z);
// Spawn it
serverWorld.spawnEntity(atom);
// Damage the item or set cooldown if desired
ItemStack stack = context.getStack();
stack.damage(1, context.getPlayer(), p -> p.sendToolBreakStatus(context.getHand()));
return ActionResult.CONSUME;
}
}

View File

@@ -3,6 +3,7 @@ package dev.tggamesyt.szar;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
@@ -50,13 +51,29 @@ public class AtomSummonerItem extends Item {
}
BlockPos hitPos = hit.getBlockPos();
Vec3d spawnPos = Vec3d.ofCenter(hitPos).add(0, 100, 0);
// Get highest solid block at that X/Z
int topY = serverWorld.getTopY(
net.minecraft.world.Heightmap.Type.WORLD_SURFACE,
hitPos.getX(),
hitPos.getZ()
);
BlockPos topPos = new BlockPos(hitPos.getX(), topY, hitPos.getZ());
Vec3d spawnPos = Vec3d.ofCenter(topPos).add(0, 100, 0);
AtomEntity atom = new AtomEntity(Szar.AtomEntityType, serverWorld);
atom.setPosition(spawnPos.x, spawnPos.y, spawnPos.z);
// 🔴 Set armed via NBT
atom.readCustomDataFromNbt(new NbtCompound() {{
putBoolean("Armed", true);
}});
serverWorld.spawnEntity(atom);
// Cooldown + durability
player.getItemCooldownManager().set(this, COOLDOWN_TICKS);
stack.damage(1, player, p -> p.sendToolBreakStatus(hand));

View File

@@ -93,8 +93,7 @@ public class Szar implements ModInitializer {
public static final Block URANIUM_BLOCK =
new Block(
FabricBlockSettings.create()
.strength(7.0f, 1200.0f) // very hard, bedrock-tier vibe
.requiresTool()
.strength(20.0f, 1200.0f).requiresTool()
);
// ConfiguredFeature Key
public static final RegistryKey<ConfiguredFeature<?, ?>> URANIUM_ORE_KEY =
@@ -258,6 +257,10 @@ public class Szar implements ModInitializer {
entries.add(Szar.EPSTEIN_SPAWNEGG);
entries.add(Szar.ATOM_DETONATOR);
entries.add(Szar.URANIUM_ORE);
entries.add(Szar.URANIUM);
entries.add(Szar.URANIUM_ROD);
entries.add(Szar.ATOM_CORE);
entries.add(Szar.ATOM);
})
.build()
);
@@ -636,6 +639,21 @@ public class Szar implements ModInitializer {
new Item.Settings()
)
);
public static final Item URANIUM = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "uranium"),
new Item(new Item.Settings())
);
public static final Item URANIUM_ROD = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "uranium_rod"),
new Item(new Item.Settings())
);
public static final Item ATOM_CORE = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "nuke_core"),
new Item(new Item.Settings())
);
public static final Item KEY_ITEM = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "police_key"),
@@ -818,6 +836,13 @@ public class Szar implements ModInitializer {
new Item.Settings()
)
);
public static final Item ATOM = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "atom"),
new AtomItem(
new Item.Settings()
)
);
public static final Item NAZI_SPAWNEGG = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "nazi_spawn_egg"),
@@ -951,7 +976,7 @@ public class Szar implements ModInitializer {
static {
ANIMATION_TIMINGS_SECONDS.put(PlaneAnimation.START_ENGINE, 2.2917f); // 2.2917s * 20 ticks
ANIMATION_TIMINGS_SECONDS.put(PlaneAnimation.STOP_ENGINE, 20f); // 2.0s * 20 ticks
ANIMATION_TIMINGS_SECONDS.put(PlaneAnimation.STOP_ENGINE, 2f); // 2.0s * 20 ticks
ANIMATION_TIMINGS_SECONDS.put(PlaneAnimation.FLYING, -1f); // looping
ANIMATION_TIMINGS_SECONDS.put(PlaneAnimation.LANDING, 2f); // 2.0s * 20 ticks
ANIMATION_TIMINGS_SECONDS.put(PlaneAnimation.LAND_STARTED, -1f); // looping

View File

@@ -57,5 +57,9 @@
"item.szar.detonator": "Detonator",
"entity.szar.atom": "Atom",
"block.szar.uranium_ore": "Uranium Ore"
"block.szar.uranium_ore": "Uranium Ore",
"item.szar.uranium": "Uranium",
"item.szar.uranium_rod": "Uranium Rod",
"item.szar.nuke_core": "Nuke Core",
"item.szar.atom": "Nuke"
}

View File

@@ -0,0 +1,179 @@
{
"format_version": "1.21.11",
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"0": "szar:item/nuke"
},
"elements": [
{
"from": [6, 17, 6],
"to": [10, 19, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 17, 8]},
"faces": {
"north": {"uv": [9, 4.75, 10, 5.25], "texture": "#0"},
"east": {"uv": [8, 4.75, 9, 5.25], "texture": "#0"},
"south": {"uv": [11, 4.75, 12, 5.25], "texture": "#0"},
"west": {"uv": [10, 4.75, 11, 5.25], "texture": "#0"},
"up": {"uv": [10, 4.75, 9, 3.75], "texture": "#0"},
"down": {"uv": [11, 3.75, 10, 4.75], "texture": "#0"}
}
},
{
"from": [5, 15, 5],
"to": [11, 17, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 15, 8]},
"faces": {
"north": {"uv": [1.5, 9, 3, 9.5], "texture": "#0"},
"east": {"uv": [0, 9, 1.5, 9.5], "texture": "#0"},
"south": {"uv": [4.5, 9, 6, 9.5], "texture": "#0"},
"west": {"uv": [3, 9, 4.5, 9.5], "texture": "#0"},
"up": {"uv": [3, 9, 1.5, 7.5], "texture": "#0"},
"down": {"uv": [4.5, 7.5, 3, 9], "texture": "#0"}
}
},
{
"from": [4, 9, 4],
"to": [12, 16, 12],
"rotation": {"x": 0, "y": 0, "z": -180, "origin": [8, 12, 8]},
"faces": {
"north": {"uv": [2, 5.75, 4, 7.5], "texture": "#0"},
"east": {"uv": [0, 5.75, 2, 7.5], "texture": "#0"},
"south": {"uv": [6, 5.75, 8, 7.5], "texture": "#0"},
"west": {"uv": [4, 5.75, 6, 7.5], "texture": "#0"},
"up": {"uv": [4, 5.75, 2, 3.75], "texture": "#0"},
"down": {"uv": [6, 3.75, 4, 5.75], "texture": "#0"}
}
},
{
"from": [7, 19, 7],
"to": [9, 20, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 19, 8]},
"faces": {
"north": {"uv": [9.5, 10.75, 10, 11], "texture": "#0"},
"east": {"uv": [9, 10.75, 9.5, 11], "texture": "#0"},
"south": {"uv": [10.5, 10.75, 11, 11], "texture": "#0"},
"west": {"uv": [10, 10.75, 10.5, 11], "texture": "#0"},
"up": {"uv": [10, 10.75, 9.5, 10.25], "texture": "#0"},
"down": {"uv": [10.5, 10.25, 10, 10.75], "texture": "#0"}
}
},
{
"from": [5, 7, 5],
"to": [11, 9, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 7, 8]},
"faces": {
"north": {"uv": [7.5, 9, 9, 9.5], "texture": "#0"},
"east": {"uv": [6, 9, 7.5, 9.5], "texture": "#0"},
"south": {"uv": [10.5, 9, 12, 9.5], "texture": "#0"},
"west": {"uv": [9, 9, 10.5, 9.5], "texture": "#0"},
"up": {"uv": [9, 9, 7.5, 7.5], "texture": "#0"},
"down": {"uv": [10.5, 7.5, 9, 9], "texture": "#0"}
}
},
{
"from": [6, 5, 6],
"to": [10, 7, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 5, 8]},
"faces": {
"north": {"uv": [9, 6.25, 10, 6.75], "texture": "#0"},
"east": {"uv": [8, 6.25, 9, 6.75], "texture": "#0"},
"south": {"uv": [11, 6.25, 12, 6.75], "texture": "#0"},
"west": {"uv": [10, 6.25, 11, 6.75], "texture": "#0"},
"up": {"uv": [10, 6.25, 9, 5.25], "texture": "#0"},
"down": {"uv": [11, 5.25, 10, 6.25], "texture": "#0"}
}
},
{
"from": [7, 4, 7],
"to": [9, 5, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 4, 8]},
"faces": {
"north": {"uv": [11, 7.25, 11.5, 7.5], "texture": "#0"},
"east": {"uv": [10.5, 7.25, 11, 7.5], "texture": "#0"},
"south": {"uv": [12, 7.25, 12.5, 7.5], "texture": "#0"},
"west": {"uv": [11.5, 7.25, 12, 7.5], "texture": "#0"},
"up": {"uv": [11.5, 7.25, 11, 6.75], "texture": "#0"},
"down": {"uv": [12, 6.75, 11.5, 7.25], "texture": "#0"}
}
},
{
"from": [5, 3, 5],
"to": [6, 7, 6],
"rotation": {"angle": 0, "axis": "y", "origin": [5, 3, 6]},
"faces": {
"north": {"uv": [0.25, 11, 0.5, 12], "texture": "#0"},
"east": {"uv": [0, 11, 0.25, 12], "texture": "#0"},
"south": {"uv": [0.75, 11, 1, 12], "texture": "#0"},
"west": {"uv": [0.5, 11, 0.75, 12], "texture": "#0"},
"up": {"uv": [0.5, 11, 0.25, 10.75], "texture": "#0"},
"down": {"uv": [0.75, 10.75, 0.5, 11], "texture": "#0"}
}
},
{
"from": [10, 3, 10],
"to": [11, 7, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [10, 3, 11]},
"faces": {
"north": {"uv": [2.25, 11, 2.5, 12], "texture": "#0"},
"east": {"uv": [2, 11, 2.25, 12], "texture": "#0"},
"south": {"uv": [2.75, 11, 3, 12], "texture": "#0"},
"west": {"uv": [2.5, 11, 2.75, 12], "texture": "#0"},
"up": {"uv": [2.5, 11, 2.25, 10.75], "texture": "#0"},
"down": {"uv": [2.75, 10.75, 2.5, 11], "texture": "#0"}
}
},
{
"from": [10, 3, 5],
"to": [11, 7, 6],
"rotation": {"angle": 0, "axis": "y", "origin": [10, 3, 6]},
"faces": {
"north": {"uv": [1.25, 11, 1.5, 12], "texture": "#0"},
"east": {"uv": [1, 11, 1.25, 12], "texture": "#0"},
"south": {"uv": [1.75, 11, 2, 12], "texture": "#0"},
"west": {"uv": [1.5, 11, 1.75, 12], "texture": "#0"},
"up": {"uv": [1.5, 11, 1.25, 10.75], "texture": "#0"},
"down": {"uv": [1.75, 10.75, 1.5, 11], "texture": "#0"}
}
},
{
"from": [5, 3, 10],
"to": [6, 7, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [5, 3, 11]},
"faces": {
"north": {"uv": [3.25, 11, 3.5, 12], "texture": "#0"},
"east": {"uv": [3, 11, 3.25, 12], "texture": "#0"},
"south": {"uv": [3.75, 11, 4, 12], "texture": "#0"},
"west": {"uv": [3.5, 11, 3.75, 12], "texture": "#0"},
"up": {"uv": [3.5, 11, 3.25, 10.75], "texture": "#0"},
"down": {"uv": [3.75, 10.75, 3.5, 11], "texture": "#0"}
}
},
{
"from": [2, 0, 2],
"to": [14, 3, 14],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 1, 8]},
"faces": {
"north": {"uv": [3, 3, 6, 3.75], "texture": "#0"},
"east": {"uv": [0, 3, 3, 3.75], "texture": "#0"},
"south": {"uv": [9, 3, 12, 3.75], "texture": "#0"},
"west": {"uv": [6, 3, 9, 3.75], "texture": "#0"},
"up": {"uv": [6, 3, 3, 0], "texture": "#0"},
"down": {"uv": [9, 0, 6, 3], "texture": "#0"}
}
},
{
"from": [6, 3, 6],
"to": [10, 4, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 3, 8]},
"faces": {
"north": {"uv": [1, 10.5, 2, 10.75], "texture": "#0"},
"east": {"uv": [0, 10.5, 1, 10.75], "texture": "#0"},
"south": {"uv": [3, 10.5, 4, 10.75], "texture": "#0"},
"west": {"uv": [2, 10.5, 3, 10.75], "texture": "#0"},
"up": {"uv": [2, 10.5, 1, 9.5], "texture": "#0"},
"down": {"uv": [3, 9.5, 2, 10.5], "texture": "#0"}
}
}
]
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "szar:item/nuke_core"
}
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "szar:item/uranium"
}
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "szar:item/uranium_rod"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

View File

@@ -5,20 +5,48 @@
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "szar:uranium_ore"
}
],
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:netherite_pickaxe"
]
}
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"name": "szar:uranium_ore",
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
],
"items": [
"minecraft:diamond_pickaxe",
"minecraft:netherite_pickaxe"
]
}
}
]
},
{
"type": "minecraft:item",
"name": "szar:uranium",
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:netherite_pickaxe"
]
}
}
]
}
]
}
]
}
]
}
}

View File

@@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"III",
"NNN",
"III"
],
"key": {
"I": {
"item": "minecraft:iron_block"
},
"N": {
"item": "szar:nuke_core"
}
},
"result": {
"item": "szar:atom",
"count": 1
}
}

View File

@@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"RRR",
"AAI",
"III"
],
"key": {
"R": {
"item": "minecraft:redstone"
},
"A": {
"item": "szar:atom"
},
"I": {
"item": "minecraft:iron_ingot"
}
},
"result": {
"item": "szar:detonator",
"count": 1
}
}

View File

@@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"TUT",
"UTU",
"TUT"
],
"key": {
"U": {
"item": "szar:uranium_rod"
},
"T": {
"item": "minecraft:tnt"
}
},
"result": {
"item": "szar:nuke_core",
"count": 1
}
}

View File

@@ -0,0 +1,9 @@
{
"type": "minecraft:smelting",
"ingredient": {
"item": "szar:uranium_ore"
},
"result": "szar:uranium",
"experience": 2.67,
"cookingtime": 200
}

View File

@@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
" U",
" U ",
"U "
],
"key": {
"U": {
"item": "szar:uranium"
}
},
"result": {
"item": "szar:uranium_rod",
"count": 1
}
}

View File

@@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"U",
"U",
"U"
],
"key": {
"U": {
"item": "szar:uranium"
}
},
"result": {
"item": "szar:uranium_rod",
"count": 1
}
}

View File

@@ -0,0 +1,17 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"U ",
" U ",
" U"
],
"key": {
"U": {
"item": "szar:uranium"
}
},
"result": {
"item": "szar:uranium_rod",
"count": 1
}
}