diff --git a/gradle.properties b/gradle.properties index 6d5d5f7..e52c3bb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.18.3 # Mod Properties -mod_version=26.2.26 +mod_version=26.2.26.1 maven_group=dev.tggamesyt archives_base_name=szar # Dependencies diff --git a/src/main/java/dev/tggamesyt/szar/FaszItem.java b/src/main/java/dev/tggamesyt/szar/FaszItem.java index 3651b68..fcb8b16 100644 --- a/src/main/java/dev/tggamesyt/szar/FaszItem.java +++ b/src/main/java/dev/tggamesyt/szar/FaszItem.java @@ -1,52 +1,150 @@ package dev.tggamesyt.szar; import net.minecraft.block.Block; -import net.minecraft.block.Blocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageType; +import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUsageContext; +import net.minecraft.nbt.NbtCompound; import net.minecraft.particle.BlockStateParticleEffect; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; -import java.util.ArrayList; import java.util.List; import java.util.Random; +import static dev.tggamesyt.szar.Szar.*; + public class FaszItem extends BlockItem { + private static final int MAX_CHARGE_CLICKS = 4; + private static final int COOLDOWN_TICKS = 1; // 1 tick + private static final String BURST_KEY = "BurstCount"; + private static final Random RANDOM = new Random(); + private static final ItemStack CNDM = new ItemStack(Szar.CNDM); + public FaszItem(Block block, Settings settings) { - super(block, settings); + super(block, settings.maxDamage(MAX_CHARGE_CLICKS)); + } + + // Allow sneak-place + @Override + public ActionResult useOnBlock(ItemUsageContext context) { + if (context.getPlayer() != null && context.getPlayer().isSneaking()) { + return ActionResult.SUCCESS; + } + return ActionResult.FAIL; } @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { ItemStack stack = user.getStackInHand(hand); - if (!world.isClient && stack.isOf(this) && new Random().nextInt(5) == 1) { - ServerWorld serverWorld = (ServerWorld) world; + if (hand != Hand.MAIN_HAND) return TypedActionResult.success(stack); - // Get the direction the player's torso is looking - var lookVec = user.getRotationVec(1.0F); // normalized direction vector + if (world.isClient) return TypedActionResult.success(stack); - // Calculate the particle spawn position 2 blocks ahead - double px = user.getX() + lookVec.x * 2; - double py = user.getBodyY(0.5); // torso height - double pz = user.getZ() + lookVec.z * 2; + boolean isCreative = user.isCreative(); - // Spawn block particles - serverWorld.spawnParticles( - new BlockStateParticleEffect(ParticleTypes.BLOCK, Szar.FASZ_BLOCK.getDefaultState()), - px, py, pz, // position - 20, // particle count - 0.3, 0.3, 0.3, // spread in x/y/z - 0.05 // velocity - ); + int damage = stack.getDamage(); + int maxDamage = stack.getMaxDamage(); + NbtCompound nbt = stack.getOrCreateNbt(); + int burstCount = nbt.getInt(BURST_KEY); + + // In creative, ignore charging/cooldown + if (isCreative) { + if (user.getOffHandStack().getItem() == Szar.CNDM) {user.getOffHandStack().decrement(1);} + spawnParticlesAndDamage((ServerWorld) world, user); + return TypedActionResult.success(stack); } - return TypedActionResult.pass(stack); + // Charging phase + if (damage < maxDamage) { + stack.setDamage(damage + 1); + return TypedActionResult.success(stack); + } + +// Burst phase (after full charge) + int burstClicks = nbt.getInt("BurstClicks"); // NEW NBT counter for burst clicks + if (burstClicks < 4) { // do 4 burst clicks + spawnParticlesAndDamage((ServerWorld) world, user); + + // Optional: handle offhand special item + if (user.getOffHandStack().getItem() == Szar.CNDM) { + user.dropStack(new ItemStack(Szar.WHITE_LIQUID)); + user.getOffHandStack().decrement(1); + } + + burstClicks++; + nbt.putInt("BurstClicks", burstClicks); + + // After 4 burst clicks → cooldown + reset + if (burstClicks >= 4) { + user.getItemCooldownManager().set(this, COOLDOWN_TICKS); + stack.setDamage(0); + nbt.putInt("BurstClicks", 0); + } + + return TypedActionResult.success(stack); + } + + return TypedActionResult.success(stack); } -} + + private void spawnParticlesAndDamage(ServerWorld world, PlayerEntity user) { + var lookVec = user.getRotationVec(1.0F); + double px = user.getX() + lookVec.x * 2; + double py = user.getBodyY(0.5); + double pz = user.getZ() + lookVec.z * 2; + + // Spawn particles + world.spawnParticles( + new BlockStateParticleEffect(ParticleTypes.BLOCK, Szar.FASZ_BLOCK.getDefaultState()), + px, py, pz, + 20, + 0.3, 0.3, 0.3, + 0.05 + ); + + // Damage ANY entity whose hitbox contains the particle + world.getEntitiesByClass(Entity.class, user.getBoundingBox().expand(2), e -> e != user).forEach(e -> { + if (e.getBoundingBox().contains(px, py, pz)) { + if (e instanceof LivingEntity living) { + // Always deal half a heart + RegistryEntry radiationEntry = SERVER.getRegistryManager() + .get(RegistryKeys.DAMAGE_TYPE) + .getEntry(FCK_DAMAGE) + .orElseThrow(() -> new IllegalStateException("FCK DamageType not registered!")); + living.damage(new DamageSource(radiationEntry, user), 1.0F); + + // If the entity is a player → apply special effect logic + if (living instanceof PlayerEntity target) { + int chance = 5; // 1/5 default + ItemStack offhand = user.getOffHandStack(); + if (!offhand.isEmpty() && offhand.isOf(CNDM.getItem())) { + chance = 100; // 1/100 if special offhand + } + + if (RANDOM.nextInt(chance) == 0) { + // Apply status effect + target.addStatusEffect(new StatusEffectInstance(Szar.PREGNANT, 20 * 60 * 20)); + // If special offhand → break 1 item + if (chance == 100) offhand.decrement(1); + } + } + } + } + }); + } +} \ No newline at end of file diff --git a/src/main/java/dev/tggamesyt/szar/Szar.java b/src/main/java/dev/tggamesyt/szar/Szar.java index 12a11cd..d761e49 100644 --- a/src/main/java/dev/tggamesyt/szar/Szar.java +++ b/src/main/java/dev/tggamesyt/szar/Szar.java @@ -287,6 +287,9 @@ public class Szar implements ModInitializer { entries.add(Szar.BAITER_DISK); entries.add(Szar.MERL_SPAWNEGG); entries.add(Szar.EFN_DISK); + entries.add(Szar.CNDM); + entries.add(Szar.LATEX); + entries.add(Szar.WHITE_LIQUID); }) .build() ); @@ -653,6 +656,21 @@ public class Szar implements ModInitializer { new BlockItem(OBELISK_CORE, new Item.Settings()) ); } + public static final Item CNDM = Registry.register( + Registries.ITEM, + new Identifier(MOD_ID, "cndm"), + new Item(new Item.Settings()) + ); + public static final Item WHITE_LIQUID = Registry.register( + Registries.ITEM, + new Identifier(MOD_ID, "white_liquid"), + new Item(new Item.Settings().food(new FoodComponent.Builder().alwaysEdible().hunger(1).build())) + ); + public static final Item LATEX = Registry.register( + Registries.ITEM, + new Identifier(MOD_ID, "latex"), + new Item(new Item.Settings()) + ); public static final StructurePieceType TNT_OBELISK_PIECE = Registry.register( Registries.STRUCTURE_PIECE, @@ -704,6 +722,8 @@ public class Szar implements ModInitializer { new PregnantEffect()); public static final RegistryKey RADIATION_DAMAGE = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, new Identifier(MOD_ID, "radiation")); + public static final RegistryKey FCK_DAMAGE = + RegistryKey.of(RegistryKeys.DAMAGE_TYPE, new Identifier(MOD_ID, "fck")); public static final Item AK_AMMO = Registry.register( Registries.ITEM, new Identifier(MOD_ID, "bullet"), @@ -1186,9 +1206,9 @@ public class Szar implements ModInitializer { // Determine who is holding the special item if (isHoldingSpecial(sleeper)) { // The OTHER player gets the effect - givePregnantEffect(other, sleeper); + givePregnantEffect(other, sleeper, sleeper.getOffHandStack().getItem() == CNDM ? 100 : 5); } else if (isHoldingSpecial(other)) { - givePregnantEffect(sleeper, other); + givePregnantEffect(sleeper, other, other.getOffHandStack().getItem() == CNDM ? 100 : 5); } } } @@ -1199,10 +1219,14 @@ public class Szar implements ModInitializer { return p.getMainHandStack().getItem() == FASZITEM; } - private void givePregnantEffect(ServerPlayerEntity player, ServerPlayerEntity partner) { + private void givePregnantEffect(ServerPlayerEntity player, ServerPlayerEntity partner, int chance) { + if (partner.getOffHandStack().getItem() == Szar.CNDM) { + partner.getOffHandStack().decrement(1); + partner.dropStack(new ItemStack(WHITE_LIQUID)); + } Random r = new Random(); System.out.println(r.nextInt()); - if (r.nextInt(10) == 6) { + if (r.nextInt(chance) == 0) { player.addStatusEffect(new StatusEffectInstance(PREGNANT, 20 * 60 * 20, 0, false, false, true)); pregnantPartners.put(player.getUuid(), partner.getUuid()); } diff --git a/src/main/resources/assets/szar/lang/en_us.json b/src/main/resources/assets/szar/lang/en_us.json index 48fc540..37b30c4 100644 --- a/src/main/resources/assets/szar/lang/en_us.json +++ b/src/main/resources/assets/szar/lang/en_us.json @@ -73,5 +73,9 @@ "item.szar.merl_spawn_egg": "Merl Spawn Egg", "effect.szar.pregnant": "Pregnant", "entity.szar.kid": "Kid", - "block.szar.obelisk_core": "Towers Core Block" + "block.szar.obelisk_core": "Towers Core Block", + "item.szar.cndm": "Condom", + "item.szar.latex": "Latex", + "death.attack.fck": "%1$s got fucked too hard by %2$s", + "item.szar.white_liquid": "..." } diff --git a/src/main/resources/assets/szar/models/item/cndm.json b/src/main/resources/assets/szar/models/item/cndm.json new file mode 100644 index 0000000..10b5ebf --- /dev/null +++ b/src/main/resources/assets/szar/models/item/cndm.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "szar:item/cndm" + } +} diff --git a/src/main/resources/assets/szar/models/item/latex.json b/src/main/resources/assets/szar/models/item/latex.json new file mode 100644 index 0000000..1e93f97 --- /dev/null +++ b/src/main/resources/assets/szar/models/item/latex.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "szar:item/latex" + } +} diff --git a/src/main/resources/assets/szar/models/item/white_liquid.json b/src/main/resources/assets/szar/models/item/white_liquid.json new file mode 100644 index 0000000..d438bf3 --- /dev/null +++ b/src/main/resources/assets/szar/models/item/white_liquid.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "szar:item/white_liquid" + } +} diff --git a/src/main/resources/assets/szar/textures/item/blue_cndm_base_original.png b/src/main/resources/assets/szar/textures/item/blue_cndm_base_original.png new file mode 100644 index 0000000..40e69e4 Binary files /dev/null and b/src/main/resources/assets/szar/textures/item/blue_cndm_base_original.png differ diff --git a/src/main/resources/assets/szar/textures/item/blue_cndm_overlay_original.png b/src/main/resources/assets/szar/textures/item/blue_cndm_overlay_original.png new file mode 100644 index 0000000..dc3dc85 Binary files /dev/null and b/src/main/resources/assets/szar/textures/item/blue_cndm_overlay_original.png differ diff --git a/src/main/resources/assets/szar/textures/item/cndm.png b/src/main/resources/assets/szar/textures/item/cndm.png new file mode 100644 index 0000000..f6984b3 Binary files /dev/null and b/src/main/resources/assets/szar/textures/item/cndm.png differ diff --git a/src/main/resources/assets/szar/textures/item/latex.png b/src/main/resources/assets/szar/textures/item/latex.png new file mode 100644 index 0000000..f99f983 Binary files /dev/null and b/src/main/resources/assets/szar/textures/item/latex.png differ diff --git a/src/main/resources/assets/szar/textures/item/white_liquid.png b/src/main/resources/assets/szar/textures/item/white_liquid.png new file mode 100644 index 0000000..1c867ba Binary files /dev/null and b/src/main/resources/assets/szar/textures/item/white_liquid.png differ diff --git a/src/main/resources/data/szar/damage_type/fck.json b/src/main/resources/data/szar/damage_type/fck.json new file mode 100644 index 0000000..a6398e3 --- /dev/null +++ b/src/main/resources/data/szar/damage_type/fck.json @@ -0,0 +1,5 @@ +{ + "message_id": "fck", + "exhaustion": 0.1, + "scaling": "never" +} diff --git a/src/main/resources/data/szar/recipes/cndm.json b/src/main/resources/data/szar/recipes/cndm.json new file mode 100644 index 0000000..320a244 --- /dev/null +++ b/src/main/resources/data/szar/recipes/cndm.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "szar:latex" + }, + { + "item": "minecraft:blue_dye" + } + ], + "result": { + "item": "szar:cndm" + } +} \ No newline at end of file diff --git a/src/main/resources/data/szar/recipes/latex.json b/src/main/resources/data/szar/recipes/latex.json new file mode 100644 index 0000000..7d595e8 --- /dev/null +++ b/src/main/resources/data/szar/recipes/latex.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "SSS", + "SLS", + "SSS" + ], + "key": { + "S": { + "item": "minecraft:sugar" + }, + "L": { + "item": "minecraft:slime_ball" + } + }, + "result": { + "item": "szar:latex", + "count": 1 + } +}