nyan cat
42
src/main/java/dev/tggamesyt/szar/NyanEntity.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package dev.tggamesyt.szar;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ai.goal.LookAroundGoal;
|
||||
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
|
||||
import net.minecraft.entity.ai.goal.WanderAroundFarGoal;
|
||||
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.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class NyanEntity extends PathAwareEntity {
|
||||
|
||||
public NyanEntity(EntityType<? extends PathAwareEntity> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initGoals() {
|
||||
this.goalSelector.add(1, new WanderAroundFarGoal(this, 10.0D));
|
||||
this.goalSelector.add(0, 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) {
|
||||
this.dropItem(Szar.POPTART);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import net.minecraft.registry.tag.BiomeTags;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.structure.StructurePieceType;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -110,6 +111,15 @@ public class Szar implements ModInitializer {
|
||||
SoundEvents.ENTITY_VILLAGER_WORK_CLERIC
|
||||
)
|
||||
);
|
||||
public static final EntityType<NyanEntity> NyanEntityType =
|
||||
Registry.register(
|
||||
Registries.ENTITY_TYPE,
|
||||
new Identifier(MOD_ID, "nyan_cat"),
|
||||
FabricEntityTypeBuilder
|
||||
.create(SpawnGroup.CREATURE, NyanEntity::new)
|
||||
.dimensions(EntityDimensions.fixed(1.0F, 1.4F))
|
||||
.build()
|
||||
);
|
||||
public static final EntityType<NiggerEntity> NiggerEntityType =
|
||||
Registry.register(
|
||||
Registries.ENTITY_TYPE,
|
||||
@@ -208,6 +218,8 @@ public class Szar implements ModInitializer {
|
||||
entries.add(Szar.CHEMICAL_WORKBENCH_ITEM);
|
||||
entries.add(Szar.AK_AMMO);
|
||||
entries.add(Szar.AK47);
|
||||
entries.add(Szar.POPTART);
|
||||
entries.add(Szar.NYAN_SPAWNEGG);
|
||||
})
|
||||
.build()
|
||||
);
|
||||
@@ -358,6 +370,10 @@ public class Szar implements ModInitializer {
|
||||
NiggerEntityType,
|
||||
NiggerEntity.createAttributes()
|
||||
);
|
||||
FabricDefaultAttributeRegistry.register(
|
||||
NyanEntityType,
|
||||
NyanEntity.createAttributes()
|
||||
);
|
||||
FabricDefaultAttributeRegistry.register(
|
||||
NaziEntityType,
|
||||
NaziEntity.createAttributes()
|
||||
@@ -668,6 +684,15 @@ public class Szar implements ModInitializer {
|
||||
new Identifier(MOD_ID, "fasz"),
|
||||
new FaszItem(FASZ_BLOCK, new Item.Settings())
|
||||
);
|
||||
public static final Item POPTART = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "pop_tart"),
|
||||
new Item(new Item.Settings()
|
||||
.food(new FoodComponent.Builder()
|
||||
.saturationModifier(0.6f).
|
||||
hunger((Math.random() < 0.5) ? 6 : 7) // SIX OR SEVEN
|
||||
.build()))
|
||||
);
|
||||
public static final Item NWORD_PASS = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "nwordpass"),
|
||||
@@ -683,6 +708,16 @@ public class Szar implements ModInitializer {
|
||||
new Item.Settings()
|
||||
)
|
||||
);
|
||||
public static final Item NYAN_SPAWNEGG = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "nyan_cat_spawn_egg"),
|
||||
new SpawnEggItem(
|
||||
NyanEntityType,
|
||||
0xFF99FF,
|
||||
0xFF3399,
|
||||
new Item.Settings()
|
||||
)
|
||||
);
|
||||
public static final Item HITTER_SPAWNEGG = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "hitler_spawn_egg"),
|
||||
|
||||
@@ -43,5 +43,9 @@
|
||||
"item.szar.ak47": "AK47",
|
||||
"entity.szar.bullet": "Bullet",
|
||||
"death.attack.bullet": "%1$s was shot by %2$s",
|
||||
"death.attack.bullet.player": "%1$s was shot by %2$s"
|
||||
"death.attack.bullet.player": "%1$s was shot by %2$s",
|
||||
|
||||
"item.szar.pop_tart": "Pop Tart",
|
||||
"entity.szar.nyan_cat": "Nyan Cat",
|
||||
"item.szar.nyan_cat_spawn_egg": "Nyan Cat Spawn Egg"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "minecraft:item/template_spawn_egg"
|
||||
}
|
||||
6
src/main/resources/assets/szar/models/item/pop_tart.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "szar:item/pop_tart"
|
||||
}
|
||||
}
|
||||
18
src/main/resources/assets/szar/sounds.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"nyan_cat_first_loop": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "szar:nyan_cat_first_loop",
|
||||
"stream": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"nyan_cat_loop": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "szar:nyan_cat_loop",
|
||||
"stream": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/szar/sounds/nyan_cat_first_loop.ogg
Normal file
BIN
src/main/resources/assets/szar/sounds/nyan_cat_loop.ogg
Normal file
83
src/main/resources/assets/szar/textures/entity/nyan.py
Normal file
@@ -0,0 +1,83 @@
|
||||
from PIL import Image
|
||||
import os
|
||||
|
||||
|
||||
def find_pixels_by_color(img, color):
|
||||
"""Return list of (x, y) coordinates where the pixel matches the given color."""
|
||||
width, height = img.size
|
||||
pixels = img.load()
|
||||
coords = []
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
if pixels[x, y][:3] == color: # ignore alpha if exists
|
||||
coords.append((x, y))
|
||||
return coords
|
||||
|
||||
|
||||
def place_image(base_img, overlay_img, corner_coords):
|
||||
"""Resize overlay_img to fit corner_coords and paste onto base_img (sharp, pixel-perfect)."""
|
||||
if len(corner_coords) != 2:
|
||||
raise ValueError("corner_coords must have exactly two points")
|
||||
|
||||
(x1, y1), (x2, y2) = corner_coords
|
||||
# Calculate target box (left, top, right, bottom)
|
||||
left = min(x1, x2)
|
||||
top = min(y1, y2)
|
||||
right = max(x1, x2)
|
||||
bottom = max(y1, y2)
|
||||
|
||||
target_width = right - left + 1
|
||||
target_height = bottom - top + 1
|
||||
|
||||
# Resize using NEAREST to keep pixels sharp
|
||||
resized_overlay = overlay_img.resize((target_width, target_height), Image.Resampling.NEAREST)
|
||||
base_img.paste(resized_overlay, (left, top), resized_overlay.convert("RGBA"))
|
||||
|
||||
|
||||
|
||||
def main(input_folder, texture_file, color1, color2, output_folder):
|
||||
os.makedirs(output_folder, exist_ok=True)
|
||||
|
||||
texture = Image.open(texture_file).convert("RGBA")
|
||||
texture_width, texture_height = texture.size
|
||||
|
||||
for filename in os.listdir(input_folder):
|
||||
if not filename.lower().endswith(".png"):
|
||||
continue
|
||||
input_path = os.path.join(input_folder, filename)
|
||||
overlay = Image.open(input_path).convert("RGBA")
|
||||
|
||||
# Create a transparent image of the same size as the texture
|
||||
output_img = Image.new("RGBA", (texture_width, texture_height), (0, 0, 0, 0))
|
||||
|
||||
# Process first color
|
||||
coords1 = find_pixels_by_color(texture, color1)
|
||||
if len(coords1) != 2:
|
||||
print(f"Warning: {filename} - color1 does not have exactly 2 pixels")
|
||||
else:
|
||||
place_image(output_img, overlay, coords1)
|
||||
|
||||
# Process second color (flipped horizontally)
|
||||
coords2 = find_pixels_by_color(texture, color2)
|
||||
if len(coords2) != 2:
|
||||
print(f"Warning: {filename} - color2 does not have exactly 2 pixels")
|
||||
else:
|
||||
flipped_overlay = overlay.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
place_image(output_img, flipped_overlay, coords2)
|
||||
|
||||
# Save output
|
||||
output_path = os.path.join(output_folder, filename)
|
||||
output_img.save(output_path)
|
||||
print(f"Saved {output_path}")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Example usage
|
||||
input_folder = "nyan_cat_input"
|
||||
texture_file = "nyan_cat_example.png"
|
||||
color2 = (255, 0, 0) # red
|
||||
color1 = (0, 138, 255) # blue
|
||||
output_folder = "nyan_cat_textures"
|
||||
|
||||
main(input_folder, texture_file, color1, color2, output_folder)
|
||||
BIN
src/main/resources/assets/szar/textures/entity/nyan_cat.gif
Normal file
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 886 B |
|
After Width: | Height: | Size: 461 B |
|
After Width: | Height: | Size: 455 B |
|
After Width: | Height: | Size: 457 B |
|
After Width: | Height: | Size: 459 B |
|
After Width: | Height: | Size: 466 B |
|
After Width: | Height: | Size: 453 B |
|
After Width: | Height: | Size: 455 B |
|
After Width: | Height: | Size: 457 B |
|
After Width: | Height: | Size: 459 B |
|
After Width: | Height: | Size: 461 B |
|
After Width: | Height: | Size: 456 B |
|
After Width: | Height: | Size: 453 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
BIN
src/main/resources/assets/szar/textures/entity/smooth.zip
Normal file
BIN
src/main/resources/assets/szar/textures/item/pop_tart.png
Normal file
|
After Width: | Height: | Size: 811 B |