Compare commits

...

2 Commits

Author SHA1 Message Date
8a53f20f77 Fix bug 2024-08-02 20:05:56 +02:00
ed1bfb65d4 Fix bug 2024-08-02 20:02:46 +02:00
19 changed files with 36 additions and 93 deletions

View File

@@ -94,24 +94,6 @@ jar {
}
}
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
loom {
accessWidenerPath = file("src/main/resources/plasticgun.accesswidener")
}

View File

@@ -6,13 +6,13 @@ minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.16.0
# Mod Properties
mod_version=1.9
mod_version=1.9.1
maven_group=systems.brn
archives_base_name=plasticgun
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.100.7+1.21
fabric_version=0.100.8+1.21
polymer_version=0.9.4+1.21
polymer_version=0.9.8+1.21
server_translations_api_version=2.3.1+1.21-pre2
trinkets_version=3.10.0+polymerport.2

View File

@@ -3,7 +3,6 @@ package systems.brn.plasticgun;
import eu.pb4.polymer.core.api.entity.PolymerEntityUtils;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerEntityEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
@@ -19,7 +18,6 @@ import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import systems.brn.plasticgun.bullets.BulletEntity;
@@ -64,15 +62,31 @@ public class PlasticGun implements ModInitializer {
public static Map<Item, GrenadeItem> itemGrenadeItemMap;
public static Map<Item, ShurikenItem> itemShurikenItemMap;
public static EntityType<BulletEntity> BULLET_ENTITY_TYPE;
public static final EntityType<BulletEntity> BULLET_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("bullet"),
EntityType.Builder.<BulletEntity>create(BulletEntity::new, SpawnGroup.MISC).build()
);
public static EntityType<GrenadeEntity> GRENADE_ENTITY_TYPE;
public static final EntityType<GrenadeEntity> GRENADE_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("grenade"),
EntityType.Builder.<GrenadeEntity>create(GrenadeEntity::new, SpawnGroup.MISC).build()
);
public static final ArrayList<WeaponArmor> weaponArmors = new ArrayList<>();
public static EntityType<ShurikenEntity> SHURIKEN_ENTITY_TYPE;
public static final EntityType<ShurikenEntity> SHURIKEN_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("shuriken"),
EntityType.Builder.<ShurikenEntity>create(ShurikenEntity::new, SpawnGroup.MISC).build()
);
public static EntityType<DamageTester> DAMAGE_TESTER_ENTITY_TYPE;
public static final EntityType<DamageTester> DAMAGE_TESTER_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("damagetester"),
EntityType.Builder.create(DamageTester::new, SpawnGroup.MISC).build()
);
public static final Logger logger = LoggerFactory.getLogger(MOD_ID);
@@ -80,8 +94,8 @@ public class PlasticGun implements ModInitializer {
public static final ArrayList<Item> clickEventItems = new ArrayList<>();
public static final RegistryEntry.Reference<StatusEffect> flashbangEffect = Registry.registerReference(Registries.STATUS_EFFECT, id("flashbang"), new FlashbangEffect());
public static final RegistryEntry.Reference<StatusEffect> stunEffect = Registry.registerReference(Registries.STATUS_EFFECT, id("stun"), new StunEffect());
public static final RegistryEntry.Reference<StatusEffect> flashbangEffect = Registry.registerReference(Registries.STATUS_EFFECT, id("flashbang"), new FlashbangEffect());
public static final RegistryEntry.Reference<StatusEffect> stunEffect = Registry.registerReference(Registries.STATUS_EFFECT, id("stun"), new StunEffect());
@Override
public void onInitialize() {
@@ -107,7 +121,7 @@ public class PlasticGun implements ModInitializer {
bullets.add(new BulletItem("force_container", 99, 0, 888, false, 0, 1));
// Guns
guns.add(new Gun("forcegun", 0, 4, 5, 10, 10, 888, 5, 0, 2, 0f, 0f, 5f, 10f, 0, 0)); // 0
guns.add(new Gun("forcegun", 0, 4, 5, 10, 10, 888, 5, 0, 4, 0f, 0f, 5f, 10f, 0, 0)); // 0
guns.add(new Gun("p2022", 0.2, 12, 5, 10, 41, 9, 10, 0, 0, 1f, 4, 0.1f, 0.25f, -1, 1)); // 1.8
guns.add(new Gun("colt_1903", 0.3, 10, 5, 8, 38, 32, 10, 0, 0, 1, 3, 0.1f, 0.3f, -1, 1)); // 3
guns.add(new Gun("ak_47", 0.2, 4, 5, 30, 45, 762, 0, 0, 0, 1f, 2, 0.2f, 0.4f, -1, 1)); // 9
@@ -178,32 +192,11 @@ public class PlasticGun implements ModInitializer {
registerIntoClickEvents(grenades);
registerIntoClickEvents(shurikens);
GRENADE_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("grenade"),
EntityType.Builder.<GrenadeEntity>create(GrenadeEntity::new, SpawnGroup.MISC).build()
);
PolymerEntityUtils.registerType(GRENADE_ENTITY_TYPE);
BULLET_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("bullet"),
EntityType.Builder.<BulletEntity>create(BulletEntity::new, SpawnGroup.MISC).build()
);
PolymerEntityUtils.registerType(BULLET_ENTITY_TYPE);
SHURIKEN_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("shuriken"),
EntityType.Builder.<ShurikenEntity>create(ShurikenEntity::new, SpawnGroup.MISC).build()
);
PolymerEntityUtils.registerType(SHURIKEN_ENTITY_TYPE);
DAMAGE_TESTER_ENTITY_TYPE = Registry.register(
Registries.ENTITY_TYPE,
id("damagetester"),
EntityType.Builder.create(DamageTester::new, SpawnGroup.MISC).build()
);
FabricDefaultAttributeRegistry.register(DAMAGE_TESTER_ENTITY_TYPE, DamageTester.createDamageTesterAttributes());
PolymerEntityUtils.registerType(DAMAGE_TESTER_ENTITY_TYPE);

View File

@@ -23,10 +23,10 @@ public class BulletItem extends SimpleItem {
new Settings()
.maxCount(maxCount)
.component(DataComponentTypes.LORE, new LoreComponent(List.of(
Text.translatable("gun.description.caliber", caliber),
Text.translatable("gun.description.speed", damageCoefficient),
Text.translatable("gun.description.explosion_coefficient", explosionPowerCoefficient),
Text.translatable("gun.description.repulsion_efficient", repulsionPowerCoefficient),
Text.translatable("gun.description.repulsion_efficient", repulsionPowerCoefficient),
Text.translatable(isIncendiary ? "gun.description.incendiary_yes" : "gun.description.incendiary_no")
))
)

View File

@@ -6,7 +6,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.ColorHelper;
import systems.brn.plasticgun.packets.ModDetect;
import systems.brn.plasticgun.packets.Reload;

View File

@@ -9,7 +9,6 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.server.network.ServerPlayerEntity;
import systems.brn.plasticgun.PlasticGun;
import static systems.brn.plasticgun.PlasticGun.flashbangEffect;
import static systems.brn.plasticgun.PlasticGun.stunEffect;
public class StunEffect extends StatusEffect implements PolymerStatusEffect {

View File

@@ -6,7 +6,6 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.network.ServerPlayerEntity;
@@ -14,7 +13,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.random.Random;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import systems.brn.plasticgun.effects.FlashbangEffect;
import systems.brn.plasticgun.throwables.ThrowableProjectile;
import java.util.List;

View File

@@ -3,7 +3,6 @@ package systems.brn.plasticgun.guns;
import eu.pb4.polymer.core.api.item.PolymerItem;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.LoreComponent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;

View File

@@ -12,16 +12,11 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.RangedAttackMob;
import net.minecraft.entity.ai.goal.Goal;
import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import static systems.brn.plasticgun.PlasticGun.guns;
import static systems.brn.plasticgun.PlasticGun.itemGunMap;
import static systems.brn.plasticgun.lib.GunComponents.*;

View File

@@ -20,11 +20,9 @@ import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import systems.brn.plasticgun.grenades.GrenadeEntity;
import systems.brn.plasticgun.grenades.GrenadeItem;
import systems.brn.plasticgun.guns.Gun;
import systems.brn.plasticgun.packets.ModDetect;
import systems.brn.plasticgun.packets.Reload;
import systems.brn.plasticgun.packets.Shoot;
import systems.brn.plasticgun.shurikens.ShurikenItem;
import java.util.function.Predicate;

View File

@@ -3,7 +3,6 @@ package systems.brn.plasticgun.lib;
import com.mojang.serialization.Codec;
import eu.pb4.polymer.core.api.other.PolymerComponent;
import net.minecraft.component.ComponentType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;

View File

@@ -22,7 +22,7 @@ public abstract class SimpleItem extends SimplePolymerItem implements PolymerIte
@Override
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
if (PlasticGun.clientsWithMod.contains(player)) {
if(PlasticGun.clientsWithMod.contains(player)){
return this;
}
return this.polymerModel.item();

View File

@@ -5,15 +5,11 @@ import dev.emi.trinkets.api.TrinketComponent;
import dev.emi.trinkets.api.TrinketInventory;
import dev.emi.trinkets.api.TrinketsApi;
import eu.pb4.polymer.virtualentity.api.tracker.DisplayTrackedData;
import net.fabricmc.loader.impl.lib.sat4j.core.Vec;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.particle.BlockDustParticle;
import net.minecraft.client.render.model.json.ModelTransformationMode;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.DataTracker;
import net.minecraft.entity.decoration.DisplayEntity;
import net.minecraft.entity.player.PlayerEntity;
@@ -22,11 +18,7 @@ import net.minecraft.inventory.Inventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.BlockStateParticleEffect;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.Registries;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundEvents;
@@ -44,14 +36,10 @@ import net.minecraft.world.explosion.Explosion;
import net.minecraft.world.explosion.ExplosionBehavior;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
import systems.brn.plasticgun.PlasticGun;
import systems.brn.plasticgun.defence.WeaponArmor;
import java.util.*;
import java.util.function.Function;
import static net.minecraft.entity.projectile.AbstractWindChargeEntity.EXPLOSION_BEHAVIOR;
import static net.minecraft.world.explosion.Explosion.getExposure;
import static systems.brn.plasticgun.PlasticGun.*;
public class Util {
@@ -236,7 +224,6 @@ public class Util {
case EASY -> 1;
case NORMAL -> 2;
case HARD -> 3;
default -> 1;
};
// Determine the chance to equip a gun

View File

@@ -2,29 +2,22 @@ package systems.brn.plasticgun.mixins;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.ai.goal.BowAttackGoal;
import net.minecraft.entity.ai.goal.GoalSelector;
import net.minecraft.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.entity.mob.AbstractSkeletonEntity;
import net.minecraft.entity.projectile.ProjectileUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.RangedWeaponItem;
import net.minecraft.util.Hand;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.Difficulty;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import systems.brn.plasticgun.PlasticGun;
import systems.brn.plasticgun.guns.Gun;
import systems.brn.plasticgun.guns.WeaponShootGoal;
import static systems.brn.plasticgun.PlasticGun.guns;

View File

@@ -5,12 +5,10 @@ import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.Difficulty;
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
@@ -18,7 +16,6 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import systems.brn.plasticgun.PlasticGun;
import systems.brn.plasticgun.grenades.GrenadeItem;
import java.util.Arrays;

View File

@@ -1,11 +1,9 @@
package systems.brn.plasticgun.packets;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.RegistryByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import net.minecraft.util.Uuids;
import java.util.UUID;

View File

@@ -14,7 +14,6 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import systems.brn.plasticgun.lib.SimpleItem;
import java.util.List;

View File

@@ -17,6 +17,7 @@ import static systems.brn.plasticgun.lib.Util.setProjectileData;
public class ThrowableProjectile extends PersistentProjectileEntity implements PolymerEntity {
private ItemStack itemStack = Items.ARROW.getDefaultStack();
public final EntityType<? extends PersistentProjectileEntity> entityType;
private final float scale;
public ThrowableProjectile(EntityType<? extends ThrowableProjectile> entityType, World world, Vec3d pos, ItemStack itemStack, float scale, double damage, PickupPermission pickupPermission, byte penetration) {
@@ -25,6 +26,7 @@ public class ThrowableProjectile extends PersistentProjectileEntity implements P
this.setDamage(damage);
this.setSilent(true);
this.scale = scale;
this.entityType = entityType;
this.setCustomPierceLevel(penetration);
this.setItemStack(itemStack.copy());
}
@@ -37,6 +39,7 @@ public class ThrowableProjectile extends PersistentProjectileEntity implements P
this.setDamage(damage);
this.setSilent(true);
this.scale = scale;
this.entityType = entityType;
this.setCustomPierceLevel(penetration);
this.setItemStack(itemStack);
}

View File

@@ -79,6 +79,10 @@
"effect.plasticgun.flashbang": "Flashbang",
"trinkets.slot.chest.vest": "Vest",
"tag.item.trinkets.chest.vest": "Vest slot compatible",
"entity.plasticgun.bullet": "Bullet",
"entity.plasticgun.grenade": "Grenade",
"entity.plasticgun.shuriken": "Shuriken",
"entity.plasticgun.damagetester": "Damage testing dummy",
"gun.description.damage_coefficient": "Damage coefficient: %d",
"gun.description.explosion_coefficient": "Explosion coefficient: %d",
"gun.description.repulsion_efficient": "Repulsion coefficient: %d",