merl and TOS

This commit is contained in:
2026-02-14 15:37:27 +01:00
parent 148aa740b6
commit c5deef7b75
15 changed files with 537 additions and 182 deletions

View File

@@ -0,0 +1,77 @@
package dev.tggamesyt.szar;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.goal.*;
import net.minecraft.entity.attribute.DefaultAttributeContainer;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.PathAwareEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtString;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
public class MerlEntity extends PathAwareEntity {
public MerlEntity(EntityType<? extends PathAwareEntity> type, World world) {
super(type, world);
}
@Override
protected void initGoals() {
// Panic when recently damaged
this.goalSelector.add(0, new EscapeDangerGoal(this, 1.4D));
// Wander normally
this.goalSelector.add(1, new WanderAroundFarGoal(this, 1.0D));
this.goalSelector.add(2, new LookAroundGoal(this));
}
public static DefaultAttributeContainer.Builder createAttributes() {
return MobEntity.createMobAttributes()
.add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0)
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.25)
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 2);
}
@Override
protected void dropLoot(DamageSource source, boolean causedByPlayer) {
ItemStack book = new ItemStack(Items.WRITTEN_BOOK);
NbtCompound nbt = book.getOrCreateNbt();
nbt.putString("title", "My answer");
nbt.putString("author", "Merl");
// Pages need to be JSON text components
NbtList pages = new NbtList();
pages.add(NbtString.of("{\"text\":\"I don't know.\"}"));
pages.add(NbtString.of("{\"text\":\"-Merl\"}"));
nbt.put("pages", pages);
this.dropStack(book);
}
@Override
public ActionResult interactMob(PlayerEntity player, Hand hand) {
if (!this.getWorld().isClient && player instanceof ServerPlayerEntity serverPlayer) {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeInt(this.getId());
ServerPlayNetworking.send(serverPlayer, Szar.OPEN_MERL_SCREEN, buf);
}
return ActionResult.SUCCESS;
}
}

View File

@@ -40,6 +40,7 @@ import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.structure.StructurePieceType;
@@ -85,6 +86,8 @@ public class Szar implements ModInitializer {
public static final String MOD_ID = "szar";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static MinecraftServer SERVER;
public static final SoundEvent MERL_SOUND =
SoundEvent.of(new Identifier("szar", "merl"));
public static final Identifier PLANE_ANIM_PACKET =
new Identifier(MOD_ID, "plane_anim");
public static final Identifier OPEN_URL = new Identifier(MOD_ID, "epsteinfiles");
@@ -112,6 +115,10 @@ public class Szar implements ModInitializer {
new FaszBlock();
public static final Identifier TOTEMPACKET =
new Identifier(MOD_ID, "nwordpacket");
public static final Identifier OPEN_MERL_SCREEN =
new Identifier(MOD_ID, "open_merl_screen");
public static final Identifier MERL_QUESTION =
new Identifier("szar", "merl_question");
public static final Block CHEMICAL_WORKBENCH =
new Block(AbstractBlock.Settings.copy(Blocks.OAK_PLANKS));
public static final RegistryKey<PointOfInterestType> CHEMICAL_WORKBENCH_POI_KEY =
@@ -172,6 +179,15 @@ public class Szar implements ModInitializer {
.dimensions(EntityDimensions.fixed(0.6F, 1.8F)) // player-sized
.build()
);
public static final EntityType<MerlEntity> MerlEntityType =
Registry.register(
Registries.ENTITY_TYPE,
new Identifier(MOD_ID, "merl"),
FabricEntityTypeBuilder
.create(SpawnGroup.CREATURE, MerlEntity::new)
.dimensions(EntityDimensions.fixed(0.6F, 1.8F)) // player-sized
.build()
);
public static final EntityType<NaziEntity> NaziEntityType =
Registry.register(
Registries.ENTITY_TYPE,
@@ -263,6 +279,7 @@ public class Szar implements ModInitializer {
entries.add(Szar.ATOM_CORE);
entries.add(Szar.ATOM);
entries.add(Szar.BAITER_DISK);
entries.add(Szar.MERL_SPAWNEGG);
})
.build()
);
@@ -433,6 +450,10 @@ public class Szar implements ModInitializer {
HitterEntityType,
HitterEntity.createAttributes()
);
FabricDefaultAttributeRegistry.register(
MerlEntityType,
MerlEntity.createAttributes()
);
FabricDefaultAttributeRegistry.register(
PoliceEntityType,
PoliceEntity.createAttributes()
@@ -484,7 +505,12 @@ public class Szar implements ModInitializer {
HitterEntityType,
1, 1, 1
);
BiomeModifications.addSpawn(
BiomeSelectors.includeByKey(BiomeKeys.PLAINS, BiomeKeys.FOREST, BiomeKeys.FLOWER_FOREST),
SpawnGroup.MONSTER,
MerlEntityType,
1, 1, 1
);
BiomeModifications.addSpawn(
BiomeSelectors.includeByKey(BiomeKeys.JUNGLE, BiomeKeys.BAMBOO_JUNGLE, BiomeKeys.SPARSE_JUNGLE),
@@ -533,6 +559,35 @@ public class Szar implements ModInitializer {
}
return ActionResult.PASS;
});
ServerPlayNetworking.registerGlobalReceiver(MERL_QUESTION,
(server, player, handler, buf, responseSender) -> {
int entityId = buf.readInt();
String question = buf.readString();
server.execute(() -> {
Entity entity = player.getWorld().getEntityById(entityId);
if (entity instanceof MerlEntity merl) {
player.sendMessage(
Text.literal("Merl whispers to you: I don't know.")
.formatted(Formatting.GRAY, Formatting.ITALIC),
false
);
merl.getWorld().playSound(
null,
merl.getX(),
merl.getY(),
merl.getZ(),
MERL_SOUND,
SoundCategory.NEUTRAL,
1.0F,
1.0F
);
}
});
});
}
public static final StructurePieceType TNT_OBELISK_PIECE =
Registry.register(
@@ -554,6 +609,7 @@ public class Szar implements ModInitializer {
.copy(Blocks.DIRT) // soft block
.strength(0.5f, 1.0f) // very easy to break, low blast resistance
)
);
@@ -852,6 +908,16 @@ public class Szar implements ModInitializer {
new Item.Settings()
)
);
public static final Item MERL_SPAWNEGG = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "merl_spawn_egg"),
new SpawnEggItem(
MerlEntityType,
0xD08B4F,
0xCD75A8,
new Item.Settings()
)
);
public static final Item ATOM = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "atom"),

View File

@@ -66,5 +66,7 @@
"item.szar.baiter": "Music Disc",
"item.szar.baiter.desc": "HaVexy - Hyperabaiter Disstrack",
"death.attack.radiation": "%1$s radiated away",
"death.attack.radiation.player": "%1$s was lethally irradiated by %2$s"
"death.attack.radiation.player": "%1$s was lethally irradiated by %2$s",
"entity.szar.merl": "Merl",
"item.szar.merl_spawn_egg": "Merl Spawn Egg"
}

View File

@@ -1,179 +1,6 @@
{
"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"}
}
}
]
}
"parent": "minecraft:item/generated",
"textures": {
"layer0": "szar:item/atom"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "minecraft:item/template_spawn_egg"
}

View File

@@ -50,5 +50,13 @@
"stream": true
}
]
},
"merl": {
"sounds": [
{
"name": "szar:merl",
"stream": true
}
]
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB