Compare commits
13 Commits
ec90a2e292
...
master
Author | SHA1 | Date | |
---|---|---|---|
ce0f8643e7
|
|||
977050276c
|
|||
6fc5738e38
|
|||
8afe0c0063
|
|||
b7fc022f90
|
|||
78633a1338
|
|||
2395fa83ff | |||
3487a054cc | |||
2e4a221528 | |||
8205348228 | |||
0366fe425a | |||
8a53f20f77 | |||
ed1bfb65d4 |
25
build.gradle
25
build.gradle
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.11-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ dependencies {
|
||||
modImplementation include("eu.pb4:polymer-virtual-entity:${project.polymer_version}")
|
||||
modImplementation include("eu.pb4:polymer-blocks:${project.polymer_version}")
|
||||
modImplementation include("eu.pb4:polymer-resource-pack:${project.polymer_version}")
|
||||
modImplementation include("eu.pb4:polymer-resource-pack-extras:${project.polymer_version}")
|
||||
modImplementation include("eu.pb4:polymer-autohost:${project.polymer_version}")
|
||||
modImplementation "eu.pb4.polyport:trinkets:${project.trinkets_version}"
|
||||
|
||||
@@ -54,8 +55,8 @@ processResources {
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version,
|
||||
"minecraft_version": project.minecraft_version,
|
||||
"loader_version": project.loader_version,
|
||||
"trinkets_version": project.trinkets_version
|
||||
"trinkets_version": project.trinkets_version,
|
||||
"loader_version": project.loader_version
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,24 +95,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")
|
||||
}
|
||||
|
@@ -2,17 +2,17 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21
|
||||
yarn_mappings=1.21+build.9
|
||||
loader_version=0.16.0
|
||||
minecraft_version=1.21.8
|
||||
yarn_mappings=1.21.8+build.1
|
||||
loader_version=0.16.14
|
||||
# Mod Properties
|
||||
mod_version=1.9
|
||||
mod_version=2.0.3
|
||||
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.129.0+1.21.8
|
||||
|
||||
polymer_version=0.9.4+1.21
|
||||
server_translations_api_version=2.3.1+1.21-pre2
|
||||
trinkets_version=3.10.0+polymerport.2
|
||||
trinkets_version=3.11.0-beta.1+polymerport.2
|
||||
polymer_version=0.13.7+1.21.8
|
||||
server_translations_api_version=2.5.1+1.21.5
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@@ -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;
|
||||
@@ -15,11 +14,13 @@ import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.loot.LootTables;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
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;
|
||||
@@ -34,8 +35,6 @@ import systems.brn.plasticgun.lib.CraftingItem;
|
||||
import systems.brn.plasticgun.lib.EventHandler;
|
||||
import systems.brn.plasticgun.lib.ItemGroups;
|
||||
import systems.brn.plasticgun.packets.ModDetect;
|
||||
import systems.brn.plasticgun.packets.Reload;
|
||||
import systems.brn.plasticgun.packets.Shoot;
|
||||
import systems.brn.plasticgun.shurikens.ShurikenEntity;
|
||||
import systems.brn.plasticgun.shurikens.ShurikenItem;
|
||||
import systems.brn.plasticgun.testing.DamageTester;
|
||||
@@ -59,20 +58,36 @@ public class PlasticGun implements ModInitializer {
|
||||
|
||||
public static final ArrayList<CraftingItem> craftingItems = new ArrayList<>();
|
||||
|
||||
public static final ArrayList<WeaponArmor> weaponArmors = new ArrayList<>();
|
||||
|
||||
public static Map<Item, Gun> itemGunMap;
|
||||
public static Map<Item, BulletItem> itemBulletItemMap;
|
||||
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(RegistryKey.of(RegistryKeys.ENTITY_TYPE, id("bullet")))
|
||||
);
|
||||
|
||||
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(RegistryKey.of(RegistryKeys.ENTITY_TYPE, id("grenade")))
|
||||
);
|
||||
|
||||
public static final ArrayList<WeaponArmor> weaponArmors = new ArrayList<>();
|
||||
public static final EntityType<ShurikenEntity> SHURIKEN_ENTITY_TYPE = Registry.register(
|
||||
Registries.ENTITY_TYPE,
|
||||
id("shuriken"),
|
||||
EntityType.Builder.<ShurikenEntity>create(ShurikenEntity::new, SpawnGroup.MISC).build(RegistryKey.of(RegistryKeys.ENTITY_TYPE, id("shuriken")))
|
||||
);
|
||||
|
||||
public static EntityType<ShurikenEntity> SHURIKEN_ENTITY_TYPE;
|
||||
|
||||
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(RegistryKey.of(RegistryKeys.ENTITY_TYPE, id("damagetester")))
|
||||
);
|
||||
|
||||
public static final Logger logger = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@@ -107,17 +122,17 @@ 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("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
|
||||
guns.add(new Gun("colt_45", 0.4, 9, 5, 7, 48, 45, 10, 0, 0, 1.5f, 2, 0.15f, 0.4f, -1, 1)); // 3.6
|
||||
guns.add(new Gun("snub_nosed_revolver", 0.4, 7, 3, 5, 36, 38, 20, 0, 0, 1f, 2, 0.2f, 0.45f, -1, 1)); // 2.8
|
||||
guns.add(new Gun("colt_peacemaker", 0.6, 8, 5, 6, 43, 45, 10, 0, 0, 0.9f, 2, 0.2f, 0.5f, -1, 1)); // 4.8
|
||||
guns.add(new Gun("tokarev_tt_33", 0.7, 10, 5, 8, 45, 762, 10, 0, 0, 1.5f, 2.5f, 0.25f, 0.5f, -1, 1)); // 7
|
||||
guns.add(new Gun("357_revolver", 1, 8, 5, 6, 45, 357, 20, 0, 0, 2, 4, 0.2f, 0.5f, -1, 1)); // 8
|
||||
guns.add(new Gun("awp", 1, 4, 20, 1, 75, 762, 40, 0, 0, 2f, 8, 0.3f, 0.6f, -1, 1)); // 4
|
||||
guns.add(new Gun("rpg9", 2, 4, 20, 1, 10, 999, 20, 20, 0, 3f, 0.5f, 1, 2, -1, 1)); // 8
|
||||
guns.add(new Gun("forcegun", 0, 4, 5, 10, 10, 888, 5, 0, 10, 0f, 0f, 0f, 1f, 0, 0)); // 0
|
||||
guns.add(new Gun("p2022", 0.2, 12, 5, 10, 41, 9, 10, 0, 0, 0f, 0.7f, 0.1f, 0.25f, -0.2, 0.2)); // 1.8
|
||||
guns.add(new Gun("colt_1903", 0.3, 10, 5, 8, 38, 32, 10, 0, 0, 0, 0.5f, 0.1f, 0.3f, -0.2, 0.2)); // 3
|
||||
guns.add(new Gun("ak_47", 0.2, 4, 5, 30, 45, 762, 0, 0, 0, 0.1f, 0.3f, 0.2f, 0.3f, -0.2, 0.2)); // 9
|
||||
guns.add(new Gun("colt_45", 0.4, 9, 5, 7, 48, 45, 10, 0, 0, 0, 0.5f, 0.15f, 0.4f, -0.2, 0.2)); // 3.6
|
||||
guns.add(new Gun("snub_nosed_revolver", 0.4, 7, 3, 5, 36, 38, 20, 0, 0, 0f, 0.4f, 0.2f, 0.45f, -0.2, 0.2)); // 2.8
|
||||
guns.add(new Gun("colt_peacemaker", 0.6, 8, 5, 6, 43, 45, 10, 0, 0, 0, 1, 0.2f, 0.5f, -0.2, 0.2)); // 4.8
|
||||
guns.add(new Gun("tokarev_tt_33", 0.7, 10, 5, 8, 45, 762, 10, 0, 0, 0, 2f, 0.25f, 0.5f, -0.2, 0.2)); // 7
|
||||
guns.add(new Gun("357_revolver", 1, 8, 5, 6, 45, 357, 20, 0, 0, 2, 3, 0.2f, 0.5f, -0.2, 0.2)); // 8
|
||||
guns.add(new Gun("awp", 1, 4, 20, 1, 75, 762, 40, 0, 0, 4f, 6f, 0.3f, 0.6f, -2, 2)); // 4
|
||||
guns.add(new Gun("rpg9", 2, 4, 20, 1, 10, 999, 20, 10, 0, 2f, 4f, 1, 2, -1, 1)); // 8
|
||||
|
||||
|
||||
grenades.add(new GrenadeItem("grenade_m18", 1, 0.1f, 0.2f, 50, false, false, 0, 0, 100, 15, 30)); // 0.02
|
||||
@@ -169,6 +184,129 @@ public class PlasticGun implements ModInitializer {
|
||||
craftingItems.add(new CraftingItem("titanium_alloy"));
|
||||
craftingItems.add(new CraftingItem("trigger_mechanism"));
|
||||
|
||||
|
||||
for (Item craftingItem : craftingItems) {
|
||||
addItemToLootTable(LootTables.ABANDONED_MINESHAFT_CHEST, craftingItem, 2);
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_CHEST, craftingItem, 6);
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_ICE_BOX_CHEST, craftingItem, 6);
|
||||
addItemToLootTable(LootTables.END_CITY_TREASURE_CHEST, craftingItem, 5);
|
||||
addItemToLootTable(LootTables.BASTION_BRIDGE_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.BASTION_HOGLIN_STABLE_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.BASTION_OTHER_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.BASTION_TREASURE_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.BURIED_TREASURE_CHEST, craftingItem, 2);
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_ARMORER_GIFT_GAMEPLAY, craftingItem, 1);
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_WEAPONSMITH_GIFT_GAMEPLAY, craftingItem, 2);
|
||||
addItemToLootTable(LootTables.VILLAGE_WEAPONSMITH_CHEST, craftingItem, 10);
|
||||
addItemToLootTable(LootTables.VILLAGE_ARMORER_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.DESERT_PYRAMID_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.WOODLAND_MANSION_CHEST, craftingItem, 4);
|
||||
addItemToLootTable(LootTables.TRIAL_CHAMBERS_REWARD_CHEST, craftingItem, 4);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Item shuriken : shurikens) {
|
||||
float weightCoeff = (float) i / shurikens.size();
|
||||
addItemToLootTable(LootTables.ABANDONED_MINESHAFT_CHEST, shuriken, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_CHEST, shuriken, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_ICE_BOX_CHEST, shuriken, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.END_CITY_TREASURE_CHEST, shuriken, getAfterWeight(weightCoeff, 5));
|
||||
addItemToLootTable(LootTables.BASTION_BRIDGE_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_HOGLIN_STABLE_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_OTHER_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_TREASURE_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BURIED_TREASURE_CHEST, shuriken, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_WEAPONSMITH_GIFT_GAMEPLAY, shuriken, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.VILLAGE_WEAPONSMITH_CHEST, shuriken, getAfterWeight(weightCoeff, 10));
|
||||
addItemToLootTable(LootTables.VILLAGE_ARMORER_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.DESERT_PYRAMID_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.WOODLAND_MANSION_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.TRIAL_CHAMBERS_REWARD_CHEST, shuriken, getAfterWeight(weightCoeff, 4));
|
||||
i++;
|
||||
}
|
||||
|
||||
for (Item weaponArmor : weaponArmors) {
|
||||
addItemToLootTable(LootTables.ABANDONED_MINESHAFT_CHEST, weaponArmor, 4);
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_CHEST, weaponArmor, 12);
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_ICE_BOX_CHEST, weaponArmor, 12);
|
||||
addItemToLootTable(LootTables.END_CITY_TREASURE_CHEST, weaponArmor, 10);
|
||||
addItemToLootTable(LootTables.BASTION_BRIDGE_CHEST, weaponArmor, 8);
|
||||
addItemToLootTable(LootTables.BASTION_HOGLIN_STABLE_CHEST, weaponArmor, 2);
|
||||
addItemToLootTable(LootTables.BASTION_OTHER_CHEST, weaponArmor, 4);
|
||||
addItemToLootTable(LootTables.BASTION_TREASURE_CHEST, weaponArmor, 4);
|
||||
addItemToLootTable(LootTables.BURIED_TREASURE_CHEST, weaponArmor, 2);
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_ARMORER_GIFT_GAMEPLAY, weaponArmor, 10);
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_WEAPONSMITH_GIFT_GAMEPLAY, weaponArmor, 2);
|
||||
addItemToLootTable(LootTables.VILLAGE_WEAPONSMITH_CHEST, weaponArmor, 10);
|
||||
addItemToLootTable(LootTables.VILLAGE_ARMORER_CHEST, weaponArmor, 20);
|
||||
addItemToLootTable(LootTables.DESERT_PYRAMID_CHEST, weaponArmor, 4);
|
||||
addItemToLootTable(LootTables.WOODLAND_MANSION_CHEST, weaponArmor, 4);
|
||||
addItemToLootTable(LootTables.TRIAL_CHAMBERS_REWARD_CHEST, weaponArmor, 4);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (Item gun : guns) {
|
||||
float weightCoeff = (float) i / guns.size();
|
||||
weightCoeff *= 5;
|
||||
addItemToLootTable(LootTables.ABANDONED_MINESHAFT_CHEST, gun, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_CHEST, gun, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_ICE_BOX_CHEST, gun, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.END_CITY_TREASURE_CHEST, gun, getAfterWeight(weightCoeff, 5));
|
||||
addItemToLootTable(LootTables.BASTION_BRIDGE_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_HOGLIN_STABLE_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_OTHER_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_TREASURE_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BURIED_TREASURE_CHEST, gun, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_WEAPONSMITH_GIFT_GAMEPLAY, gun, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.VILLAGE_WEAPONSMITH_CHEST, gun, getAfterWeight(weightCoeff, 10));
|
||||
addItemToLootTable(LootTables.DESERT_PYRAMID_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.WOODLAND_MANSION_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.TRIAL_CHAMBERS_REWARD_CHEST, gun, getAfterWeight(weightCoeff, 4));
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (Item grenade : grenades) {
|
||||
float weightCoeff = (float) i / grenades.size();
|
||||
weightCoeff *= 6;
|
||||
addItemToLootTable(LootTables.ABANDONED_MINESHAFT_CHEST, grenade, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_CHEST, grenade, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_ICE_BOX_CHEST, grenade, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.END_CITY_TREASURE_CHEST, grenade, getAfterWeight(weightCoeff, 5));
|
||||
addItemToLootTable(LootTables.BASTION_BRIDGE_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_HOGLIN_STABLE_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_OTHER_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_TREASURE_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BURIED_TREASURE_CHEST, grenade, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_WEAPONSMITH_GIFT_GAMEPLAY, grenade, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.VILLAGE_WEAPONSMITH_CHEST, grenade, getAfterWeight(weightCoeff, 10));
|
||||
addItemToLootTable(LootTables.DESERT_PYRAMID_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.WOODLAND_MANSION_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.TRIAL_CHAMBERS_REWARD_CHEST, grenade, getAfterWeight(weightCoeff, 4));
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (Item bullet : bullets) {
|
||||
float weightCoeff = (float) i / bullets.size();
|
||||
weightCoeff *= 8;
|
||||
addItemToLootTable(LootTables.ABANDONED_MINESHAFT_CHEST, bullet, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_CHEST, bullet, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.ANCIENT_CITY_ICE_BOX_CHEST, bullet, getAfterWeight(weightCoeff, 6));
|
||||
addItemToLootTable(LootTables.END_CITY_TREASURE_CHEST, bullet, getAfterWeight(weightCoeff, 5));
|
||||
addItemToLootTable(LootTables.BASTION_BRIDGE_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_HOGLIN_STABLE_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_OTHER_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BASTION_TREASURE_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.BURIED_TREASURE_CHEST, bullet, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.HERO_OF_THE_VILLAGE_WEAPONSMITH_GIFT_GAMEPLAY, bullet, getAfterWeight(weightCoeff, 2));
|
||||
addItemToLootTable(LootTables.VILLAGE_WEAPONSMITH_CHEST, bullet, getAfterWeight(weightCoeff, 10));
|
||||
addItemToLootTable(LootTables.DESERT_PYRAMID_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.WOODLAND_MANSION_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
addItemToLootTable(LootTables.TRIAL_CHAMBERS_REWARD_CHEST, bullet, getAfterWeight(weightCoeff, 4));
|
||||
i++;
|
||||
}
|
||||
|
||||
itemGunMap = generateItemMap(guns);
|
||||
itemBulletItemMap = generateItemMap(bullets);
|
||||
itemGrenadeItemMap = generateItemMap(grenades);
|
||||
@@ -178,34 +316,13 @@ 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);
|
||||
FabricDefaultAttributeRegistry.register(DAMAGE_TESTER_ENTITY_TYPE, DamageTester.createDamageTesterAttributes());
|
||||
|
||||
|
||||
// Detect item use
|
||||
@@ -222,13 +339,9 @@ public class PlasticGun implements ModInitializer {
|
||||
ItemGroups.register();
|
||||
|
||||
PayloadTypeRegistry.playC2S().register(ModDetect.PACKET_ID, ModDetect.PACKET_CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(Reload.PACKET_ID, Reload.PACKET_CODEC);
|
||||
PayloadTypeRegistry.playC2S().register(Shoot.PACKET_ID, Shoot.PACKET_CODEC);
|
||||
|
||||
// Register the global receiver
|
||||
ServerPlayNetworking.registerGlobalReceiver(ModDetect.PACKET_ID, EventHandler::onClientConfirm);
|
||||
ServerPlayNetworking.registerGlobalReceiver(Reload.PACKET_ID, EventHandler::onClientReload);
|
||||
ServerPlayNetworking.registerGlobalReceiver(Shoot.PACKET_ID, EventHandler::onClientShoot);
|
||||
|
||||
PolymerResourcePackUtils.addModAssets(MOD_ID);
|
||||
PolymerResourcePackUtils.markAsRequired();
|
||||
|
@@ -19,6 +19,7 @@ import net.minecraft.world.World;
|
||||
import systems.brn.plasticgun.grenades.GrenadeExplosionBehavior;
|
||||
import systems.brn.plasticgun.guns.Gun;
|
||||
import systems.brn.plasticgun.lib.WeaponDamageType;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
@@ -35,7 +36,7 @@ public class BulletEntity extends PersistentProjectileEntity implements PolymerE
|
||||
private final float scale;
|
||||
|
||||
public BulletEntity(LivingEntity livingEntity, ItemStack stack, Hand hand, Gun gun, float scale, double damage, float speed, double explosionPower, double repulsionPower, boolean isIncendiary) {
|
||||
super(BULLET_ENTITY_TYPE, livingEntity.getPos().x, livingEntity.getPos().y + 1.75d, livingEntity.getPos().z, livingEntity.getEntityWorld(), stack, livingEntity.getStackInHand(hand));
|
||||
super(BULLET_ENTITY_TYPE, livingEntity.getPos().x, livingEntity.getPos().y + 1.75d, livingEntity.getPos().z, livingEntity.getWorld(), stack, livingEntity.getStackInHand(hand));
|
||||
this.setOwner(livingEntity);
|
||||
this.setVelocity(livingEntity, livingEntity.getPitch(), livingEntity.getYaw(), 0.0F, speed, 0);
|
||||
this.pickupType = PickupPermission.DISALLOWED;
|
||||
@@ -87,7 +88,7 @@ public class BulletEntity extends PersistentProjectileEntity implements PolymerE
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType<?> getPolymerEntityType(ServerPlayerEntity player) {
|
||||
public EntityType<?> getPolymerEntityType(PacketContext packetContext) {
|
||||
return EntityType.ITEM_DISPLAY;
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ public class BulletEntity extends PersistentProjectileEntity implements PolymerE
|
||||
this.setPosition(blockHitResult.getPos());
|
||||
if (blockHitResult.getType() == HitResult.Type.BLOCK) {
|
||||
BlockState block = this.getWorld().getBlockState(blockHitResult.getBlockPos());
|
||||
blockHitParticles(this.getPos(), block, this.getWorld(), this.getDamage() * this.getVelocity().length());
|
||||
blockHitParticles(this.getPos(), block, this.getWorld(), this.damage * this.getVelocity().length());
|
||||
SoundEvent soundEvent = block.getSoundGroup().getHitSound();
|
||||
setSilent(false);
|
||||
playSound(soundEvent, 4.0F, 1.0F);
|
||||
@@ -117,8 +118,8 @@ public class BulletEntity extends PersistentProjectileEntity implements PolymerE
|
||||
setSilent(true);
|
||||
|
||||
if (entityHitResult.getEntity() instanceof LivingEntity livingEntity) {
|
||||
this.setDamage(getFinalDamage(livingEntity, WeaponDamageType.BULLET, this.getDamage()));
|
||||
entityHitParticles(livingEntity, this.getDamage() * this.getVelocity().length());
|
||||
this.setDamage(getFinalDamage(livingEntity, WeaponDamageType.BULLET, this.damage));
|
||||
entityHitParticles(livingEntity, this.damage * this.getVelocity().length());
|
||||
}
|
||||
|
||||
super.onEntityHit(entityHitResult);
|
||||
|
@@ -5,6 +5,8 @@ import net.minecraft.component.type.LoreComponent;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import systems.brn.plasticgun.lib.SimpleItem;
|
||||
|
||||
@@ -23,13 +25,13 @@ 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")
|
||||
))
|
||||
)
|
||||
)))
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, id(path)))
|
||||
,
|
||||
id(path),
|
||||
Items.STICK);
|
||||
|
@@ -1,38 +1,17 @@
|
||||
package systems.brn.plasticgun.companion;
|
||||
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
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;
|
||||
import systems.brn.plasticgun.packets.Shoot;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static systems.brn.plasticgun.PlasticGun.flashbangEffect;
|
||||
import static systems.brn.plasticgun.lib.Util.shouldSendClickEvents;
|
||||
|
||||
public class ClientEvents {
|
||||
public static void tick(MinecraftClient minecraftClient) {
|
||||
if (minecraftClient.options.useKey.isPressed() && minecraftClient.player != null) {
|
||||
if (shouldSendClickEvents(minecraftClient.player)) {
|
||||
UUID reloadUUID = UUID.randomUUID();
|
||||
ClientPlayNetworking.send(new Reload(reloadUUID));
|
||||
}
|
||||
}
|
||||
if (minecraftClient.options.attackKey.isPressed() && minecraftClient.player != null) {
|
||||
if (shouldSendClickEvents(minecraftClient.player)) {
|
||||
UUID shootUUID = UUID.randomUUID();
|
||||
ClientPlayNetworking.send(new Shoot(shootUUID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void join(ClientPlayNetworkHandler clientPlayNetworkHandler, PacketSender packetSender, MinecraftClient minecraftClient) {
|
||||
UUID joinUUID = UUID.randomUUID();
|
||||
packetSender.sendPacket(new ModDetect(joinUUID));
|
||||
@@ -43,7 +22,7 @@ public class ClientEvents {
|
||||
if (MinecraftClient.getInstance().player.hasStatusEffect(flashbangEffect)) {
|
||||
int width = drawContext.getScaledWindowWidth();
|
||||
int height = drawContext.getScaledWindowHeight();
|
||||
drawContext.fill(0, 0, width, height, ColorHelper.Argb.fromFloats(1, 1, 1, 1));
|
||||
drawContext.fill(0, 0, width, height, ColorHelper.fromFloats(1, 1, 1, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,12 @@
|
||||
package systems.brn.plasticgun.companion;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
||||
|
||||
public class PlasticGunClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(ClientEvents::tick);
|
||||
ClientPlayConnectionEvents.JOIN.register(ClientEvents::join);
|
||||
HudRenderCallback.EVENT.register(ClientEvents::HUDDraw);
|
||||
}
|
||||
|
@@ -1,11 +1,14 @@
|
||||
package systems.brn.plasticgun.defence;
|
||||
|
||||
import dev.emi.trinkets.api.Trinket;
|
||||
import dev.emi.trinkets.api.TrinketsApi;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.LoreComponent;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.text.Text;
|
||||
import systems.brn.plasticgun.lib.TrinketPolymerItem;
|
||||
import systems.brn.plasticgun.lib.WeaponDamageType;
|
||||
@@ -15,7 +18,7 @@ import java.util.List;
|
||||
|
||||
import static systems.brn.plasticgun.lib.Util.id;
|
||||
|
||||
public class WeaponArmor extends TrinketPolymerItem {
|
||||
public class WeaponArmor extends TrinketPolymerItem implements Trinket {
|
||||
public final HashMap<WeaponDamageType, Double> resistances = new HashMap<>();
|
||||
|
||||
public WeaponArmor(String name, int durability, double grenadeDamageCoefficient, double fragmentationDamageCoefficient, double bulletDamageCoefficient, double shurikenDamageCoefficient) {
|
||||
@@ -25,7 +28,7 @@ public class WeaponArmor extends TrinketPolymerItem {
|
||||
Text.translatable("gun.description.armor.grenade", (int) ((1 - grenadeDamageCoefficient) * 100)),
|
||||
Text.translatable("gun.description.armor.fragmentation_grenade", (int) ((1 - fragmentationDamageCoefficient) * 100)),
|
||||
Text.translatable("gun.description.armor.shuriken", (int) ((1 - shurikenDamageCoefficient) * 100))
|
||||
)))
|
||||
))).registryKey(RegistryKey.of(RegistryKeys.ITEM, id(name)))
|
||||
, name)
|
||||
;
|
||||
Registry.register(Registries.ITEM, id(name), this);
|
||||
|
@@ -5,10 +5,12 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import systems.brn.plasticgun.PlasticGun;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import static systems.brn.plasticgun.PlasticGun.flashbangEffect;
|
||||
import static systems.brn.plasticgun.PlasticGun.stunEffect;
|
||||
|
||||
public class FlashbangEffect extends StatusEffect implements PolymerStatusEffect {
|
||||
public FlashbangEffect() {
|
||||
@@ -26,14 +28,13 @@ public class FlashbangEffect extends StatusEffect implements PolymerStatusEffect
|
||||
|
||||
// Called when the effect is applied.
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
return super.applyUpdateEffect(entity, amplifier);
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
return super.applyUpdateEffect(world, entity, amplifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusEffect getPolymerReplacement(ServerPlayerEntity player){
|
||||
if (PlasticGun.clientsWithMod.contains(player)){
|
||||
return flashbangEffect.value();
|
||||
public StatusEffect getPolymerReplacement(StatusEffect potion, PacketContext packetContext) {
|
||||
if (PlasticGun.clientsWithMod.contains(packetContext.getPlayer())){
|
||||
return stunEffect.value();
|
||||
}
|
||||
return StatusEffects.BLINDNESS.value();
|
||||
}
|
||||
|
@@ -6,10 +6,10 @@ import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import systems.brn.plasticgun.PlasticGun;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import static systems.brn.plasticgun.PlasticGun.flashbangEffect;
|
||||
import static systems.brn.plasticgun.PlasticGun.stunEffect;
|
||||
|
||||
public class StunEffect extends StatusEffect implements PolymerStatusEffect {
|
||||
@@ -35,16 +35,16 @@ public class StunEffect extends StatusEffect implements PolymerStatusEffect {
|
||||
|
||||
// Called when the effect is applied.
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
applied = true;
|
||||
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, stunDuration, 255, true, false));
|
||||
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.JUMP_BOOST, stunDuration, 255, true, false));
|
||||
return super.applyUpdateEffect(entity, amplifier);
|
||||
return super.applyUpdateEffect(world, entity, amplifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusEffect getPolymerReplacement(ServerPlayerEntity player) {
|
||||
if (PlasticGun.clientsWithMod.contains(player)){
|
||||
public StatusEffect getPolymerReplacement(StatusEffect potion, PacketContext packetContext) {
|
||||
if (PlasticGun.clientsWithMod.contains(packetContext.getPlayer())){
|
||||
return stunEffect.value();
|
||||
}
|
||||
return null;
|
||||
|
@@ -63,8 +63,8 @@ public class FragmentationExplosionBehavior extends ExplosionBehavior {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float calculateDamage(Explosion explosion, Entity entity) {
|
||||
float original = super.calculateDamage(explosion, entity);
|
||||
public float calculateDamage(Explosion explosion, Entity entity, float amount) {
|
||||
float original = super.calculateDamage(explosion, entity, amount);
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
original = (float) getFinalDamage(livingEntity, WeaponDamageType.FRAGMENTATION_GRENADE, original);
|
||||
if (original > 0) {
|
||||
|
@@ -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;
|
||||
|
@@ -13,8 +13,8 @@ public class GrenadeExplosionBehavior extends ExplosionBehavior {
|
||||
|
||||
|
||||
@Override
|
||||
public float calculateDamage(Explosion explosion, Entity entity) {
|
||||
float original = super.calculateDamage(explosion, entity);
|
||||
public float calculateDamage(Explosion explosion, Entity entity, float amount) {
|
||||
float original = super.calculateDamage(explosion, entity, amount);
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
original = (float) getFinalDamage(livingEntity, WeaponDamageType.GRENADE, original);
|
||||
if (original > 0) {
|
||||
|
@@ -8,6 +8,8 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
@@ -57,6 +59,7 @@ public class GrenadeItem extends SimpleItem implements PolymerItem {
|
||||
Text.translatable("gun.description.effect_radius", effectRadius),
|
||||
Text.translatable("gun.description.particle_count", smokeCount)
|
||||
)))
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, id(path)))
|
||||
.maxDamage(explosionTarget + 1)
|
||||
, id(path), Items.STICK
|
||||
);
|
||||
@@ -114,14 +117,14 @@ public class GrenadeItem extends SimpleItem implements PolymerItem {
|
||||
|
||||
public void turnIntoEntity(ServerPlayerEntity player, @Nullable ItemStack stack, int speed, int timer) {
|
||||
GrenadeEntity grenadeEntity = new GrenadeEntity(player, stack, timer, 0.5f, speed, explosionPower, repulsionPower, isIncendiary, isFragmentation, flashBangDuration, stunDuration, smokeTicks, 8, smokeCount);
|
||||
player.getServerWorld().spawnEntity(grenadeEntity);
|
||||
player.getServerWorld().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.UI_BUTTON_CLICK.value(), SoundCategory.PLAYERS, 1.0f, 2.0f);
|
||||
player.getWorld().spawnEntity(grenadeEntity);
|
||||
player.getWorld().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.UI_BUTTON_CLICK.value(), SoundCategory.PLAYERS, 1.0f, 2.0f);
|
||||
}
|
||||
|
||||
public void turnIntoEntity(Entity entity, @Nullable ItemStack stack, int speed, int timer) {
|
||||
GrenadeEntity grenadeEntity = new GrenadeEntity(entity.getEntityWorld(), entity.getPos(), stack, timer, 1f, explosionPower, repulsionPower, isIncendiary, isFragmentation, flashBangDuration, stunDuration, smokeTicks, 8, smokeCount);
|
||||
entity.getEntityWorld().spawnEntity(grenadeEntity);
|
||||
entity.getEntityWorld().playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.UI_BUTTON_CLICK.value(), SoundCategory.PLAYERS, 1.0f, 2.0f);
|
||||
GrenadeEntity grenadeEntity = new GrenadeEntity(entity.getWorld(), entity.getPos(), stack, timer, 1f, explosionPower, repulsionPower, isIncendiary, isFragmentation, flashBangDuration, stunDuration, smokeTicks, 8, smokeCount);
|
||||
entity.getWorld().spawnEntity(grenadeEntity);
|
||||
entity.getWorld().playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.UI_BUTTON_CLICK.value(), SoundCategory.PLAYERS, 1.0f, 2.0f);
|
||||
}
|
||||
|
||||
public void checkExplosions(ServerWorld world, PlayerEntity playerEntity, ItemStack stackInSlot) {
|
||||
|
@@ -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;
|
||||
@@ -11,6 +10,8 @@ import net.minecraft.item.*;
|
||||
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
@@ -29,8 +30,8 @@ import systems.brn.plasticgun.lib.SimpleItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static systems.brn.plasticgun.PlasticGun.bullets;
|
||||
import static systems.brn.plasticgun.PlasticGun.itemBulletItemMap;
|
||||
import static java.lang.Math.*;
|
||||
import static systems.brn.plasticgun.PlasticGun.*;
|
||||
import static systems.brn.plasticgun.lib.GunComponents.*;
|
||||
import static systems.brn.plasticgun.lib.Util.*;
|
||||
|
||||
@@ -74,15 +75,25 @@ public class Gun extends SimpleItem implements PolymerItem {
|
||||
Text.translatable("gun.description.explosion_power", explosionPowerGun),
|
||||
Text.translatable("gun.description.repulsion_power", repulsionPowerGun)
|
||||
)))
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, id(path)))
|
||||
.maxDamage(clipSize + 1)
|
||||
, id(path), Items.WOODEN_SWORD
|
||||
);
|
||||
this.verticalRecoilMin = verticalRecoilMin;
|
||||
this.verticalRecoilMax = verticalRecoilMax;
|
||||
this.verticalRecoilMin = verticalRecoilMin / 100f;
|
||||
this.verticalRecoilMax = verticalRecoilMax / 100f;
|
||||
this.velocityRecoilMin = velocityRecoilMin;
|
||||
this.velocityRecoilMax = velocityRecoilMax;
|
||||
this.horizontalRecoilMin = horizontalRecoilMin;
|
||||
this.horizontalRecoilMax = horizontalRecoilMax;
|
||||
this.horizontalRecoilMin = horizontalRecoilMin / 100f;
|
||||
this.horizontalRecoilMax = horizontalRecoilMax / 100f;
|
||||
if (verticalRecoilMin > verticalRecoilMax) {
|
||||
logger.error("verticalRecoilMin > verticalRecoilMax for {}", path);
|
||||
}
|
||||
if (horizontalRecoilMin > horizontalRecoilMax) {
|
||||
logger.error("horizontalRecoilMin > horizontalRecoilMax for {}", path);
|
||||
}
|
||||
if (velocityRecoilMin > velocityRecoilMax) {
|
||||
logger.error("velocityRecoilMin > velocityRecoilMax for {}", path);
|
||||
}
|
||||
Registry.register(Registries.ITEM, id(path), this);
|
||||
this.damage = damage;
|
||||
this.reloadCount = reloadCount;
|
||||
@@ -243,27 +254,30 @@ public class Gun extends SimpleItem implements PolymerItem {
|
||||
stack.set(DataComponentTypes.LORE, newLore);
|
||||
}
|
||||
|
||||
public void doRecoil(LivingEntity entity) {
|
||||
if (entity.getEntityWorld() instanceof ServerWorld serverWorld) {
|
||||
public int doRecoil(LivingEntity entity) {
|
||||
if (entity.getWorld() instanceof ServerWorld serverWorld) {
|
||||
Random rng = entity.getWorld().getRandom();
|
||||
// Get the entity's current position and yaw
|
||||
Vec3d pos = entity.getPos();
|
||||
float yaw = entity.getYaw();
|
||||
float newPitch = entity.getPitch();
|
||||
Vec3d currentLook = entity.getRotationVector().multiply(-1);
|
||||
newPitch -= verticalRecoilMin + rng.nextFloat() * (verticalRecoilMax - verticalRecoilMin);
|
||||
yaw -= (float) (horizontalRecoilMin + rng.nextFloat() * (horizontalRecoilMax - horizontalRecoilMin));
|
||||
|
||||
|
||||
entity.teleport(serverWorld, pos.x, pos.y, pos.z, PositionFlag.ROT, yaw, newPitch);
|
||||
float yawChange = verticalRecoilMin + rng.nextFloat() * (verticalRecoilMax - verticalRecoilMin);
|
||||
float pitchChange = (float) (horizontalRecoilMin + rng.nextFloat() * (horizontalRecoilMax - horizontalRecoilMin));
|
||||
newPitch -= yawChange;
|
||||
yaw -= pitchChange;
|
||||
entity.teleport(serverWorld, pos.x, pos.y, pos.z, PositionFlag.ROT, yaw, newPitch, true);
|
||||
double velocityRecoil = rng.nextDouble() * (velocityRecoilMax - velocityRecoilMin);
|
||||
if (velocityRecoil > 0) {
|
||||
entity.setVelocity(currentLook.multiply(velocityRecoil));
|
||||
}
|
||||
return (int) ((abs(yawChange) + abs(pitchChange) + abs(velocityRecoil) + max(abs(yawChange), max(abs(pitchChange), abs(velocityRecoil)))) / 4f) * 40;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void shoot(ServerWorld world, LivingEntity user, Hand hand) {
|
||||
public int shoot(ServerWorld world, LivingEntity user, Hand hand) {
|
||||
int stunLen = 0;
|
||||
if (!world.isClient()) {
|
||||
ItemStack stack = user.getStackInHand(hand);
|
||||
int currentReload = stack.getOrDefault(GUN_LOADING_COMPONENT, 1);
|
||||
@@ -281,7 +295,7 @@ public class Gun extends SimpleItem implements PolymerItem {
|
||||
world.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE.value(), SoundCategory.PLAYERS, 0.1f, 1.2f);
|
||||
chamber.decrement(1);
|
||||
stack.set(GUN_COOLDOWN_COMPONENT, cooldownTarget);
|
||||
doRecoil(user);
|
||||
stunLen = doRecoil(user);
|
||||
if (chamber.isEmpty()) {
|
||||
stack.remove(GUN_AMMO_COMPONENT);
|
||||
} else {
|
||||
@@ -292,6 +306,7 @@ public class Gun extends SimpleItem implements PolymerItem {
|
||||
}
|
||||
updateDamage(stack);
|
||||
}
|
||||
return stunLen;
|
||||
}
|
||||
|
||||
private @NotNull BulletEntity getBulletEntity(LivingEntity entity, Hand hand, BulletItem bullet, ItemStack chamber) {
|
||||
|
@@ -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.*;
|
||||
|
||||
@@ -152,7 +147,7 @@ public class WeaponShootGoal<T extends HostileEntity & RangedAttackMob> extends
|
||||
if (itemGunMap.containsKey(gunStack.getItem())) {
|
||||
Gun gun = itemGunMap.get(gunStack.getItem());
|
||||
// Handle item usage
|
||||
gun.reload(this.actor.getEntityWorld(), this.actor, gunHand, this.actor.getRandom(), this.actor.getWorld().getLocalDifficulty(this.actor.getBlockPos()));
|
||||
gun.reload(this.actor.getWorld(), this.actor, gunHand, this.actor.getRandom(), this.actor.getWorld().getLocalDifficulty(this.actor.getBlockPos()));
|
||||
if (!canSeeTarget && this.targetSeeingTicker < -60) {
|
||||
this.actor.clearActiveItem();
|
||||
} else if (canSeeTarget) {
|
||||
@@ -161,8 +156,8 @@ public class WeaponShootGoal<T extends HostileEntity & RangedAttackMob> extends
|
||||
int currentCooldown = gunStack.getOrDefault(GUN_COOLDOWN_COMPONENT, 1);
|
||||
ItemStack chamber = gunStack.getOrDefault(GUN_AMMO_COMPONENT, ItemStack.EMPTY).copy();
|
||||
if (!chamber.isEmpty() && currentReload == 1 && currentCooldown == 0 && lockedTicks >= 10) {
|
||||
if (this.actor.getEntityWorld() instanceof ServerWorld serverWorld) {
|
||||
gun.shoot(serverWorld, this.actor, gunHand);
|
||||
if (this.actor.getWorld() instanceof ServerWorld serverWorld) {
|
||||
this.targetSeeingTicker -= gun.shoot(serverWorld, this.actor, gunHand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,13 +3,15 @@ package systems.brn.plasticgun.lib;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
|
||||
import static systems.brn.plasticgun.lib.Util.id;
|
||||
|
||||
public class CraftingItem extends SimpleItem{
|
||||
|
||||
public CraftingItem(String name) {
|
||||
super(new Settings(), id(name), Items.STICK);
|
||||
super(new Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, id(name))), id(name), Items.STICK);
|
||||
Registry.register(Registries.ITEM, id(name), this);
|
||||
}
|
||||
}
|
||||
|
@@ -15,16 +15,12 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
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;
|
||||
|
||||
@@ -32,18 +28,17 @@ import static systems.brn.plasticgun.PlasticGun.*;
|
||||
import static systems.brn.plasticgun.lib.GunComponents.*;
|
||||
|
||||
public class EventHandler {
|
||||
public static TypedActionResult<ItemStack> onItemUse(PlayerEntity playerEntity, World world, Hand hand) {
|
||||
ItemStack stack = playerEntity.getStackInHand(hand);
|
||||
public static ActionResult onItemUse(PlayerEntity playerEntity, World world, Hand hand) {
|
||||
if (playerEntity instanceof ServerPlayerEntity serverPlayerEntity) {
|
||||
if (!world.isClient && !clientsWithMod.contains(serverPlayerEntity)) {
|
||||
if (!world.isClient) {
|
||||
rightClickWithItem(serverPlayerEntity, hand);
|
||||
}
|
||||
}
|
||||
return TypedActionResult.pass(stack);
|
||||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
public static void rightClickWithItem(ServerPlayerEntity serverPlayerEntity, Hand hand) {
|
||||
if (serverPlayerEntity.getEntityWorld() instanceof ServerWorld world) {
|
||||
if (serverPlayerEntity.getWorld() instanceof ServerWorld world) {
|
||||
Item stackInHand = serverPlayerEntity.getStackInHand(hand).getItem();
|
||||
if (itemGunMap.containsKey(stackInHand)) {
|
||||
itemGunMap.get(stackInHand).reload(world, serverPlayerEntity, hand);
|
||||
@@ -59,7 +54,7 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
public static void leftClickWithItem(ServerPlayerEntity serverPlayerEntity, Hand hand) {
|
||||
if (serverPlayerEntity.getEntityWorld() instanceof ServerWorld world) {
|
||||
if (serverPlayerEntity.getWorld() instanceof ServerWorld world) {
|
||||
ItemStack stackInHand = serverPlayerEntity.getStackInHand(hand);
|
||||
Item itemInHand = stackInHand.getItem();
|
||||
if (itemGrenadeItemMap.containsKey(itemInHand)) {
|
||||
@@ -73,7 +68,7 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
public static void tickItemUpdate(ServerPlayerEntity serverPlayerEntity) {
|
||||
if (serverPlayerEntity.getEntityWorld() instanceof ServerWorld world) {
|
||||
if (serverPlayerEntity.getWorld() instanceof ServerWorld world) {
|
||||
Hand hand = serverPlayerEntity.getActiveHand();
|
||||
ItemStack stackInHand = serverPlayerEntity.getStackInHand(hand);
|
||||
Item itemInHand = stackInHand.getItem();
|
||||
@@ -83,8 +78,8 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
PlayerInventory playerInventory = serverPlayerEntity.getInventory();
|
||||
for (int i = 1; i < playerInventory.main.size(); i++) {
|
||||
ItemStack stackInSlot = playerInventory.main.get(i);
|
||||
for (int i = 1; i < playerInventory.getMainStacks().size(); i++) {
|
||||
ItemStack stackInSlot = playerInventory.getMainStacks().get(i);
|
||||
Item itemInSlot = stackInSlot.getItem();
|
||||
if (itemGrenadeItemMap.containsKey(itemInSlot)) {
|
||||
decrementComponent(GRENADE_TIMER_COMPONENT, stackInSlot);
|
||||
@@ -100,25 +95,22 @@ public class EventHandler {
|
||||
public static void mobTickUpdate(ServerWorld world) {
|
||||
Predicate<Entity> allEntities = entity -> true;
|
||||
for (SkeletonEntity skeletonEntity : world.getEntitiesByType(EntityType.SKELETON, allEntities)) {
|
||||
for (ItemStack itemStack : skeletonEntity.getEquippedItems()) {
|
||||
ItemStack itemStack = skeletonEntity.getActiveItem();
|
||||
if (itemGunMap.containsKey(itemStack.getItem())) {
|
||||
decrementComponent(GUN_COOLDOWN_COMPONENT, itemStack);
|
||||
decrementComponent(GUN_RELOAD_COOLDOWN_COMPONENT, itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void onServerWorldTick(ServerWorld world) {
|
||||
// Iterate through all players to detect hand swings or item interactions
|
||||
if (!world.isClient) {
|
||||
for (ServerPlayerEntity player : world.getPlayers()) {
|
||||
Hand hand = player.getActiveHand();
|
||||
if (!clientsWithMod.contains(player)) {
|
||||
if (player.handSwinging && player.handSwingTicks == -1) {
|
||||
leftClickWithItem(player, hand);
|
||||
}
|
||||
}
|
||||
tickItemUpdate(player);
|
||||
}
|
||||
mobTickUpdate(world);
|
||||
@@ -163,16 +155,4 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void onClientReload(Reload reload, ServerPlayNetworking.Context context) {
|
||||
ServerPlayerEntity player = context.player();
|
||||
Hand hand = player.getActiveHand();
|
||||
rightClickWithItem(player, hand);
|
||||
}
|
||||
|
||||
public static void onClientShoot(Shoot shoot, ServerPlayNetworking.Context context) {
|
||||
ServerPlayerEntity player = context.player();
|
||||
Hand hand = player.getActiveHand();
|
||||
leftClickWithItem(player, hand);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -2,35 +2,29 @@ package systems.brn.plasticgun.lib;
|
||||
|
||||
import eu.pb4.polymer.core.api.item.PolymerItem;
|
||||
import eu.pb4.polymer.core.api.item.SimplePolymerItem;
|
||||
import eu.pb4.polymer.resourcepack.api.PolymerModelData;
|
||||
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
||||
import eu.pb4.polymer.resourcepack.extras.api.ResourcePackExtras;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import systems.brn.plasticgun.PlasticGun;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
public abstract class SimpleItem extends SimplePolymerItem implements PolymerItem {
|
||||
private final PolymerModelData polymerModel;
|
||||
private final Identifier polymerModel;
|
||||
protected final Identifier identifier;
|
||||
|
||||
public SimpleItem(Settings settings, Identifier identifier, Item replacement) {
|
||||
super(settings, replacement);
|
||||
this.identifier = identifier;
|
||||
this.polymerModel = PolymerResourcePackUtils.requestModel(replacement, identifier.withPath("item/" + identifier.getPath()));
|
||||
this.polymerModel = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||
if (PlasticGun.clientsWithMod.contains(player)) {
|
||||
return this;
|
||||
}
|
||||
return this.polymerModel.item();
|
||||
public Identifier getPolymerItemModel(ItemStack stack, PacketContext context) {
|
||||
return this.polymerModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||
return this.polymerModel.value();
|
||||
public Item getPolymerItem(ItemStack itemStack, PacketContext player) {
|
||||
return Items.STICK;
|
||||
}
|
||||
|
||||
}
|
@@ -1,36 +1,30 @@
|
||||
package systems.brn.plasticgun.lib;
|
||||
|
||||
import dev.emi.trinkets.TrinketSlot;
|
||||
import dev.emi.trinkets.api.*;
|
||||
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.event.GameEvent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static systems.brn.plasticgun.lib.Util.id;
|
||||
|
||||
public class TrinketPolymerItem extends SimpleItem implements Trinket {
|
||||
public class TrinketPolymerItem extends SimpleItem {
|
||||
|
||||
public TrinketPolymerItem(Item.Settings settings, String name) {
|
||||
super(settings, id(name), Items.STICK);
|
||||
TrinketsApi.registerTrinket(this, this);
|
||||
super(settings.equippable(EquipmentSlot.CHEST), id(name), Items.STICK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||
public ActionResult use(World world, PlayerEntity user, Hand hand) {
|
||||
ItemStack stack = user.getStackInHand(hand);
|
||||
if (equipItem(user, stack)) {
|
||||
return TypedActionResult.success(stack, world.isClient());
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
return super.use(world, user, hand);
|
||||
}
|
||||
@@ -40,31 +34,8 @@ public class TrinketPolymerItem extends SimpleItem implements Trinket {
|
||||
}
|
||||
|
||||
public static boolean equipItem(LivingEntity user, ItemStack stack) {
|
||||
Optional<TrinketComponent> optional = TrinketsApi.getTrinketComponent(user);
|
||||
if (optional.isPresent()) {
|
||||
TrinketComponent comp = optional.get();
|
||||
for (Map<String, TrinketInventory> group : comp.getInventory().values()) {
|
||||
for (TrinketInventory inv : group.values()) {
|
||||
for (int i = 0; i < inv.size(); i++) {
|
||||
if (inv.getStack(i).isEmpty()) {
|
||||
SlotReference ref = new SlotReference(inv, i);
|
||||
if (TrinketSlot.canInsert(stack, ref, user)) {
|
||||
ItemStack newStack = stack.copy();
|
||||
inv.setStack(i, newStack);
|
||||
Trinket trinket = TrinketsApi.getTrinket(stack.getItem());
|
||||
RegistryEntry<SoundEvent> soundEvent = trinket.getEquipSound(stack, ref, user);
|
||||
if (!stack.isEmpty() && soundEvent != null) {
|
||||
user.emitGameEvent(GameEvent.EQUIP);
|
||||
user.playSound(soundEvent.value(), 1.0F, 1.0F);
|
||||
}
|
||||
stack.setCount(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
user.equipStack(EquipmentSlot.CHEST, stack);
|
||||
user.playSound(SoundEvents.ITEM_ARMOR_EQUIP_CHAIN.value());
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -1,19 +1,12 @@
|
||||
package systems.brn.plasticgun.lib;
|
||||
|
||||
import dev.emi.trinkets.api.SlotReference;
|
||||
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.fabricmc.fabric.api.loot.v3.LootTableEvents;
|
||||
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.EquipmentSlot;
|
||||
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;
|
||||
@@ -21,17 +14,15 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
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.registry.RegistryKey;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -44,14 +35,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 {
|
||||
@@ -64,7 +51,7 @@ public class Util {
|
||||
if (bulletItem == null || bulletItem.isEmpty()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
for (ItemStack itemStack : player.getInventory().main) {
|
||||
for (ItemStack itemStack : player.getInventory().getMainStacks()) {
|
||||
for (Item item : bulletItem) {
|
||||
if (item == itemStack.getItem()) {
|
||||
return itemStack;
|
||||
@@ -80,8 +67,8 @@ public class Util {
|
||||
|
||||
if (inventory instanceof PlayerInventory playerInventory) {
|
||||
// Iterate through the slots in the player's inventory
|
||||
for (int i = 0; i < playerInventory.main.size(); i++) {
|
||||
ItemStack slotStack = playerInventory.main.get(i);
|
||||
for (int i = 0; i < playerInventory.getMainStacks().size(); i++) {
|
||||
ItemStack slotStack = playerInventory.getMainStacks().get(i);
|
||||
maxInsert = canInsertToStack(slotStack, itemStack, maxInsert);
|
||||
}
|
||||
} else {
|
||||
@@ -148,7 +135,7 @@ public class Util {
|
||||
int minZ = MathHelper.floor(pos.z - radius - 1.0);
|
||||
int maxZ = MathHelper.floor(pos.z + radius + 1.0);
|
||||
Box box = new Box(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
return entity.getEntityWorld().getOtherEntities(entity, box);
|
||||
return entity.getWorld().getOtherEntities(entity, box);
|
||||
}
|
||||
|
||||
public static void setProjectileData(List<DataTracker.SerializedEntry<?>> data, boolean initial, float scale, ItemStack itemStack) {
|
||||
@@ -157,7 +144,6 @@ public class Util {
|
||||
data.add(DataTracker.SerializedEntry.of(DisplayTrackedData.SCALE, new Vector3f(scale)));
|
||||
data.add(DataTracker.SerializedEntry.of(DisplayTrackedData.BILLBOARD, (byte) DisplayEntity.BillboardMode.CENTER.ordinal()));
|
||||
data.add(DataTracker.SerializedEntry.of(DisplayTrackedData.Item.ITEM, itemStack));
|
||||
data.add(DataTracker.SerializedEntry.of(DisplayTrackedData.Item.ITEM_DISPLAY, ModelTransformationMode.FIXED.getIndex()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,18 +159,12 @@ public class Util {
|
||||
}
|
||||
|
||||
public static double getFinalDamage(LivingEntity livingEntity, WeaponDamageType damageType, double damage) {
|
||||
Optional<TrinketComponent> trinketComponentTemp = TrinketsApi.getTrinketComponent(livingEntity);
|
||||
if (trinketComponentTemp.isPresent()) {
|
||||
TrinketComponent trinketComponent = trinketComponentTemp.get();
|
||||
for (WeaponArmor weaponArmor : weaponArmors) {
|
||||
if (weaponArmor.resistances.containsKey(damageType)) {
|
||||
|
||||
List<Pair<SlotReference, ItemStack>> vestsComponents = trinketComponent.getEquipped(weaponArmor);
|
||||
if (!vestsComponents.isEmpty()) {
|
||||
Pair<SlotReference, ItemStack> vestComponent = vestsComponents.getFirst();
|
||||
TrinketInventory trinketInventory = vestComponent.getLeft().inventory();
|
||||
int currentDamage = vestComponent.getRight().getDamage();
|
||||
int maxDamage = vestComponent.getRight().getMaxDamage();
|
||||
ItemStack chestStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST);
|
||||
int currentDamage = chestStack.getDamage();
|
||||
int maxDamage = chestStack.getMaxDamage();
|
||||
double reducedDamage = 0;
|
||||
if (currentDamage < maxDamage) {
|
||||
double coefficient = weaponArmor.resistances.get(damageType);
|
||||
@@ -193,16 +173,12 @@ public class Util {
|
||||
}
|
||||
|
||||
int nextDamage = currentDamage + (int) reducedDamage;
|
||||
int inventoryIndex = vestComponent.getLeft().index();
|
||||
ItemStack vestStack = trinketInventory.getStack(inventoryIndex);
|
||||
if (nextDamage >= maxDamage) {
|
||||
vestStack.setCount(0);
|
||||
chestStack.setCount(0);
|
||||
} else {
|
||||
vestStack.setDamage(nextDamage);
|
||||
}
|
||||
trinketInventory.setStack(inventoryIndex, vestStack);
|
||||
}
|
||||
chestStack.setDamage(nextDamage);
|
||||
}
|
||||
livingEntity.equipStack(EquipmentSlot.CHEST, chestStack);
|
||||
}
|
||||
}
|
||||
return damage;
|
||||
@@ -236,7 +212,6 @@ public class Util {
|
||||
case EASY -> 1;
|
||||
case NORMAL -> 2;
|
||||
case HARD -> 3;
|
||||
default -> 1;
|
||||
};
|
||||
|
||||
// Determine the chance to equip a gun
|
||||
@@ -286,7 +261,13 @@ public class Util {
|
||||
}
|
||||
|
||||
public static void entityHitParticles(LivingEntity livingEntity, double damage) {
|
||||
if (livingEntity.getEntityWorld() instanceof ServerWorld world) {
|
||||
if (livingEntity.getWorld() instanceof ServerWorld world) {
|
||||
if (livingEntity instanceof ServerPlayerEntity) {
|
||||
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) livingEntity;
|
||||
if (serverPlayerEntity.isCreative()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Vec3d pos = livingEntity.getPos();
|
||||
int particleCount = (int) damage * 4; // Number of particles
|
||||
double radius = livingEntity.getWidth() / 2 + 0.5; // Radius of the circle
|
||||
@@ -313,4 +294,16 @@ public class Util {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addItemToLootTable(RegistryKey<LootTable> tableId, Item item, Integer weight) {
|
||||
LootTableEvents.MODIFY.register((key, tableBuilder, source, wrapperLookup) -> {
|
||||
if (source.isBuiltin() && tableId.equals(key)) {
|
||||
tableBuilder.modifyPools(poolBuilder -> poolBuilder.with(ItemEntry.builder(item).weight(weight)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int getAfterWeight(float coeff, int weight) {
|
||||
return (int) Math.ceil(coeff * weight);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -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;
|
||||
@@ -55,7 +52,9 @@ public abstract class ZombieGrenadeMixin extends MobEntity {
|
||||
} else if (i < 14) {
|
||||
int grenadeIndex = selectWeaponIndex(random, localDifficulty, grenades.size());
|
||||
stackToEquip = new ItemStack(grenades.get(grenadeIndex));
|
||||
Arrays.fill(this.handDropChances, 0F);
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
this.setEquipmentDropChance(slot, 0f);
|
||||
}
|
||||
} else {
|
||||
stackToEquip = new ItemStack(Items.IRON_SHOVEL);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -1,19 +0,0 @@
|
||||
package systems.brn.plasticgun.packets;
|
||||
|
||||
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Uuids;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record Reload(UUID slapped) implements CustomPayload {
|
||||
public static final Id<Reload> PACKET_ID = new Id<>(CustomPayload.id("reload").id());
|
||||
public static final PacketCodec<RegistryByteBuf, Reload> PACKET_CODEC = Uuids.PACKET_CODEC.xmap(Reload::new, Reload::slapped).cast();
|
||||
|
||||
@Override
|
||||
public Id<? extends CustomPayload> getId() {
|
||||
return PACKET_ID;
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package systems.brn.plasticgun.packets;
|
||||
|
||||
|
||||
import net.minecraft.network.RegistryByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Uuids;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record Shoot(UUID slapped) implements CustomPayload {
|
||||
public static final Id<Shoot> PACKET_ID = new Id<>(CustomPayload.id("shoot").id());
|
||||
public static final PacketCodec<RegistryByteBuf, Shoot> PACKET_CODEC = Uuids.PACKET_CODEC.xmap(Shoot::new, Shoot::slapped).cast();
|
||||
|
||||
@Override
|
||||
public Id<? extends CustomPayload> getId() {
|
||||
return PACKET_ID;
|
||||
}
|
||||
}
|
@@ -33,7 +33,7 @@ public class ShurikenEntity extends ThrowableProjectile implements PolymerEntity
|
||||
if (blockHitResult.getType() == HitResult.Type.BLOCK) {
|
||||
BlockState block = this.getWorld().getBlockState(blockHitResult.getBlockPos());
|
||||
|
||||
blockHitParticles(this.getPos(), block, this.getWorld(), this.getDamage() * this.getVelocity().length());
|
||||
blockHitParticles(this.getPos(), block, this.getWorld(), this.damage * this.getVelocity().length());
|
||||
SoundEvent soundEvent = block.getSoundGroup().getHitSound();
|
||||
setSilent(false);
|
||||
playSound(soundEvent, 4.0F, 1.0F);
|
||||
@@ -54,8 +54,8 @@ public class ShurikenEntity extends ThrowableProjectile implements PolymerEntity
|
||||
@Override
|
||||
protected void onEntityHit(EntityHitResult entityHitResult) {
|
||||
if (entityHitResult.getEntity() instanceof LivingEntity livingEntity) {
|
||||
this.setDamage(getFinalDamage(livingEntity, WeaponDamageType.SHURIKEN, this.getDamage()));
|
||||
entityHitParticles(livingEntity, this.getDamage());
|
||||
this.setDamage(getFinalDamage(livingEntity, WeaponDamageType.SHURIKEN, this.damage));
|
||||
entityHitParticles(livingEntity, this.damage);
|
||||
}
|
||||
|
||||
super.onEntityHit(entityHitResult);
|
||||
|
@@ -8,13 +8,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
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;
|
||||
@@ -36,6 +37,7 @@ public class ShurikenItem extends SimpleItem implements PolymerItem {
|
||||
Text.translatable("gun.description.speed", speed),
|
||||
Text.translatable("gun.description.damage_with_coefficient_max_speed", speed, speed * damage)
|
||||
)))
|
||||
.registryKey(RegistryKey.of(RegistryKeys.ITEM, id(path)))
|
||||
, id(path), Items.WOODEN_PICKAXE
|
||||
);
|
||||
Registry.register(Registries.ITEM, id(path), this);
|
||||
|
@@ -10,11 +10,12 @@ import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Arm;
|
||||
import eu.pb4.polymer.core.api.entity.PolymerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -25,10 +26,10 @@ public class DamageTester extends LivingEntity implements PolymerEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damage(DamageSource source, float amount) {
|
||||
public boolean damage(ServerWorld world, DamageSource source, float amount) {
|
||||
Entity attacker = source.getAttacker();
|
||||
if (attacker instanceof PlayerEntity player) {
|
||||
player.sendMessage(Text.literal("You damaged by " + amount));
|
||||
player.sendMessage(Text.literal("You damaged by " + amount), false);
|
||||
if (player.isSneaking()) {
|
||||
this.remove(RemovalReason.KILLED);
|
||||
}
|
||||
@@ -39,18 +40,8 @@ public class DamageTester extends LivingEntity implements PolymerEntity {
|
||||
|
||||
public static DefaultAttributeContainer.Builder createDamageTesterAttributes() {
|
||||
return LivingEntity.createLivingAttributes()
|
||||
.add(EntityAttributes.GENERIC_MAX_HEALTH, 1.0)
|
||||
.add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 0.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType<?> getPolymerEntityType(ServerPlayerEntity player) {
|
||||
return EntityType.ZOMBIE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ItemStack> getArmorItems() {
|
||||
return Collections.emptyList();
|
||||
.add(EntityAttributes.MAX_HEALTH, 1.0)
|
||||
.add(EntityAttributes.ATTACK_DAMAGE, 0.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,4 +58,9 @@ public class DamageTester extends LivingEntity implements PolymerEntity {
|
||||
public Arm getMainArm() {
|
||||
return Arm.RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType<?> getPolymerEntityType(PacketContext context) {
|
||||
return EntityType.ZOMBIE;
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import net.minecraft.item.Items;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import xyz.nucleoid.packettweaker.PacketContext;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
@@ -17,31 +18,43 @@ 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 double prevX;
|
||||
public double prevY;
|
||||
public double prevZ;
|
||||
|
||||
public ThrowableProjectile(EntityType<? extends ThrowableProjectile> entityType, World world, Vec3d pos, ItemStack itemStack, float scale, double damage, PickupPermission pickupPermission, byte penetration) {
|
||||
super(entityType, pos.getX(), pos.getY() + 1.5d, pos.getZ(), world, itemStack, null);
|
||||
this.pickupType = pickupPermission;
|
||||
this.setDamage(damage);
|
||||
this.setSilent(true);
|
||||
this.scale = scale;
|
||||
this.entityType = entityType;
|
||||
this.setCustomPierceLevel(penetration);
|
||||
this.setItemStack(itemStack.copy());
|
||||
}
|
||||
|
||||
public ThrowableProjectile(EntityType<? extends PersistentProjectileEntity> entityType, ServerPlayerEntity player, ItemStack itemStack, float scale, float speed, double damage, PickupPermission pickupPermission, byte penetration) {
|
||||
super(entityType, player.getPos().x, player.getPos().y + 1.5d, player.getPos().z, player.getServerWorld(), itemStack, itemStack);
|
||||
super(entityType, player.getPos().x, player.getPos().y + 1.5d, player.getPos().z, player.getWorld(), itemStack, itemStack);
|
||||
this.setOwner(player);
|
||||
this.setVelocity(player, player.getPitch(), player.getYaw(), 0.0F, speed, 0);
|
||||
this.pickupType = pickupPermission;
|
||||
this.setDamage(damage);
|
||||
this.setSilent(true);
|
||||
this.scale = scale;
|
||||
this.entityType = entityType;
|
||||
this.setCustomPierceLevel(penetration);
|
||||
this.setItemStack(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityType<?> getPolymerEntityType(PacketContext context) {
|
||||
return EntityType.ITEM_DISPLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyRawTrackedData(List<DataTracker.SerializedEntry<?>> data, ServerPlayerEntity player, boolean initial) {
|
||||
setProjectileData(data, initial, scale, this.itemStack);
|
||||
@@ -70,10 +83,5 @@ public class ThrowableProjectile extends PersistentProjectileEntity implements P
|
||||
return this.itemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType<?> getPolymerEntityType(ServerPlayerEntity player) {
|
||||
return EntityType.ITEM_DISPLAY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
6
src/main/resources/assets/plasticgun/items/32_acp.json
Normal file
6
src/main/resources/assets/plasticgun/items/32_acp.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/32_acp"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/32_acp_high_velocity"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/357_magnum"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/357_revolver"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/357_standard"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/38_special"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/38_special_p"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/45_acp.json
Normal file
6
src/main/resources/assets/plasticgun/items/45_acp.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/45_acp"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/45_acp_hollow_point"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/762_tokarev"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/762_tokarev_ap"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/9mm_jhp.json
Normal file
6
src/main/resources/assets/plasticgun/items/9mm_jhp.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/9mm_jhp"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/9mm_parabellum"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/advanced_circuit"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/ak_47.json
Normal file
6
src/main/resources/assets/plasticgun/items/ak_47.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/ak_47"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/alloy_wheel"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/awp.json
Normal file
6
src/main/resources/assets/plasticgun/items/awp.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/awp"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/ceramic_mixture"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/ceramic_plate"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/colt_1903"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/colt_45.json
Normal file
6
src/main/resources/assets/plasticgun/items/colt_45.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/colt_45"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/colt_peacemaker"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/composite_frame"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/composite_resin"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/copper_wiring"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/diamond_shuriken"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/enhanced_gunpowder"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/explosive_powder"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/flak_vest"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/force_container"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/forcegun.json
Normal file
6
src/main/resources/assets/plasticgun/items/forcegun.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/forcegun"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/golden_shuriken"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/graphene_sheet"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_an_m14"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_f1"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_k417"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_m18"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_m34"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_m67"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_m7a3"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_m84"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_mk3a2"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_no_69"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_rgd_5"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_rgo"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/grenade_thermite"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/hardened_steel"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/hyperalloy"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/iron_shuriken"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/kevlar_sheet"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/kevlar_vest"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/magnetic_coil"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/microchip"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/nano_tubes"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/netherite_shuriken"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/p2022.json
Normal file
6
src/main/resources/assets/plasticgun/items/p2022.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/p2022"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/plasma_core"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/power_cell"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/precision_gear"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/reinforced_fiber"
|
||||
}
|
||||
}
|
6
src/main/resources/assets/plasticgun/items/rpg9.json
Normal file
6
src/main/resources/assets/plasticgun/items/rpg9.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/rpg9"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/rpg_shell"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/rpg_shell_incendiary"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/silicon_mixture"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/silicon_wafer"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/snub_nosed_revolver"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/stone_shuriken"
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"model": {
|
||||
"type": "minecraft:model",
|
||||
"model": "plasticgun:item/titanium_alloy"
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user