bugtesting over, peak has arrived
This commit is contained in:
parent
be1b59a8a2
commit
caddaa8bc8
@ -92,7 +92,7 @@ public class GunHandler implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onRightClick(PlayerInteractEvent event) {
|
public static void onRightClick(PlayerInteractEvent event) {
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||||
if (event.getAction()==Action.RIGHT_CLICK_BLOCK && Calc.isInteractable(event.getClickedBlock())) {
|
if (event.getAction()==Action.RIGHT_CLICK_BLOCK && Calc.isInteractable(event.getClickedBlock()) && !event.getPlayer().isSneaking()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getHand() == EquipmentSlot.HAND) {
|
if (event.getHand() == EquipmentSlot.HAND) {
|
||||||
@ -145,16 +145,17 @@ public class GunHandler implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
double dueDamage = gun.damage()-Math.min(GunHandler.Calc.getDamageAfterArmor(damagedPlayer), gun.damage()-0.5f);
|
double dueDamage = gun.damage()-GunHandler.Calc.getDamageAfterArmor(damagedPlayer);
|
||||||
|
if (dueDamage < 0.5) dueDamage=0.5;
|
||||||
damagedPlayer.damage(dueDamage, bulletOwner);
|
damagedPlayer.damage(dueDamage, bulletOwner);
|
||||||
gun.onHitEntity(damagedPlayer.getLocation(), damagedPlayer);
|
gun.onHitEntity(damagedPlayer.getLocation(), damagedPlayer);
|
||||||
Calc.makeBlood(event.getEntity().getLocation(), (float) dueDamage);
|
if (gun.makeBlood()) Calc.makeBlood(event.getEntity().getLocation(), (float) dueDamage);
|
||||||
physicsBullets.remove(physbullet);
|
physicsBullets.remove(physbullet);
|
||||||
}
|
}
|
||||||
} else if (event.getHitEntity() instanceof LivingEntity livingEntity) {
|
} else if (event.getHitEntity() instanceof LivingEntity livingEntity) {
|
||||||
livingEntity.damage(gun.damage(), bulletOwner);
|
livingEntity.damage(gun.damage(), bulletOwner);
|
||||||
gun.onHitEntity(event.getEntity().getLocation(), livingEntity);
|
gun.onHitEntity(event.getEntity().getLocation(), livingEntity);
|
||||||
Calc.makeBlood(event.getEntity().getLocation(), (int) gun.damage());
|
if (gun.makeBlood()) Calc.makeBlood(event.getEntity().getLocation(), (int) gun.damage());
|
||||||
physicsBullets.remove(physbullet);
|
physicsBullets.remove(physbullet);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -214,7 +215,7 @@ public class GunHandler implements Listener {
|
|||||||
else if(chest == Material.DIAMOND_CHESTPLATE)red = red + 0.32;
|
else if(chest == Material.DIAMOND_CHESTPLATE)red = red + 0.32;
|
||||||
else if(chest == Material.NETHERITE_CHESTPLATE)red = red + 0.38;
|
else if(chest == Material.NETHERITE_CHESTPLATE)red = red + 0.38;
|
||||||
|
|
||||||
return red;
|
return red * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean decreaseMatchingItem(Player player, ItemStack targetItem) {
|
public static boolean decreaseMatchingItem(Player player, ItemStack targetItem) {
|
||||||
|
@ -11,6 +11,7 @@ public class Guns {
|
|||||||
GunHandler.register(new barrettM82());
|
GunHandler.register(new barrettM82());
|
||||||
GunHandler.register(new AK47());
|
GunHandler.register(new AK47());
|
||||||
GunHandler.register(new m4a1s());
|
GunHandler.register(new m4a1s());
|
||||||
|
GunHandler.register(new rocketJumper());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static final IGun hecateII = new IGun() {
|
// public static final IGun hecateII = new IGun() {
|
||||||
|
@ -54,6 +54,7 @@ public interface IGun {
|
|||||||
gunItem.setItemMeta(meta);
|
gunItem.setItemMeta(meta);
|
||||||
return gunItem;
|
return gunItem;
|
||||||
}
|
}
|
||||||
|
default boolean makeBlood() {return true;}
|
||||||
default boolean gravity() {return false;}
|
default boolean gravity() {return false;}
|
||||||
default IBullet compileBullet() {
|
default IBullet compileBullet() {
|
||||||
IGun gun = this;
|
IGun gun = this;
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package com.s5gi.giGuns.guns.ind;
|
package com.s5gi.giGuns.guns.ind;
|
||||||
|
|
||||||
import com.s5gi.giGuns.guns.BulletType;
|
import com.s5gi.giGuns.guns.BulletType;
|
||||||
|
import com.s5gi.giGuns.guns.GunHandler;
|
||||||
import com.s5gi.giGuns.guns.IGun;
|
import com.s5gi.giGuns.guns.IGun;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.CraftingRecipe;
|
import org.bukkit.inventory.CraftingRecipe;
|
||||||
import org.bukkit.inventory.ShapedRecipe;
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -47,7 +51,27 @@ public class m1Bazooka implements IGun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void explode(Location location) {
|
private static void explode(Location location) {
|
||||||
location.getWorld().createExplosion(location, 4.5f, false, false);
|
//location.getWorld().createExplosion(location, 1f, false, false);
|
||||||
|
for (Entity entity : location.getWorld().getNearbyEntities(location, 5f, 5f, 5f)) {
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity livingEntity) {
|
||||||
|
if (entity instanceof Player player) {
|
||||||
|
player.damage(4f - GunHandler.Calc.getDamageAfterArmor(player));
|
||||||
|
} else {
|
||||||
|
livingEntity.damage(4f);
|
||||||
|
}
|
||||||
|
Location playerLocation = livingEntity.getLocation();
|
||||||
|
|
||||||
|
// Calculate direction vector (from point to player)
|
||||||
|
Vector direction = playerLocation.toVector().subtract(location.toVector());
|
||||||
|
|
||||||
|
// Normalize the vector to keep consistent speed
|
||||||
|
direction.normalize().multiply(1); // Change the multiplier for speed adjustments
|
||||||
|
|
||||||
|
// Apply velocity to the player
|
||||||
|
livingEntity.setVelocity(livingEntity.getVelocity().add(direction));
|
||||||
|
}
|
||||||
|
}
|
||||||
location.getWorld().spawnParticle(Particle.EXPLOSION, location, 10, 0.1f, 0.1f, 0.1f);
|
location.getWorld().spawnParticle(Particle.EXPLOSION, location, 10, 0.1f, 0.1f, 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
105
src/main/java/com/s5gi/giGuns/guns/ind/rocketJumper.java
Normal file
105
src/main/java/com/s5gi/giGuns/guns/ind/rocketJumper.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package com.s5gi.giGuns.guns.ind;
|
||||||
|
|
||||||
|
import com.s5gi.giGuns.guns.BulletType;
|
||||||
|
import com.s5gi.giGuns.guns.IGun;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.inventory.CraftingRecipe;
|
||||||
|
import org.bukkit.inventory.ShapedRecipe;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class rocketJumper implements IGun {
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return "&6Rocket Jumper";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> description() {
|
||||||
|
return List.of("&6Fictional", "&6Rocket jump like your a tf2 player...");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BulletType bulletType() {
|
||||||
|
return BulletType.HEAVY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Sound> sound() {
|
||||||
|
return List.of(Sound.ENTITY_GENERIC_EXPLODE, Sound.ENTITY_FIREWORK_ROCKET_BLAST);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float soundPitch() {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHitEntity(Location location, LivingEntity entity) {
|
||||||
|
explode(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHitBlock(Location location, Block block) {
|
||||||
|
explode(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void explode(Location location) {
|
||||||
|
//location.getWorld().createExplosion(location, 1f, false, false);
|
||||||
|
for (Entity entity : location.getWorld().getNearbyEntities(location, 5f, 5f, 5f)) {
|
||||||
|
|
||||||
|
if (entity instanceof LivingEntity livingEntity) {
|
||||||
|
Location playerLocation = livingEntity.getLocation();
|
||||||
|
|
||||||
|
// Calculate direction vector (from point to player)
|
||||||
|
Vector direction = playerLocation.toVector().subtract(location.toVector());
|
||||||
|
|
||||||
|
// Normalize the vector to keep consistent speed
|
||||||
|
direction.normalize().multiply(2); // Change the multiplier for speed adjustments
|
||||||
|
|
||||||
|
// Apply velocity to the player
|
||||||
|
livingEntity.setVelocity(livingEntity.getVelocity().add(direction));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
location.getWorld().spawnParticle(Particle.EXPLOSION, location, 10, 0.1f, 0.1f, 0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean makeBlood() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double bulletSpeed() {return 4;}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double damage() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int cooldown() {
|
||||||
|
return 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int textureId() {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CraftingRecipe recipe() {
|
||||||
|
ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.fromString("giguns:rocketjumper"), compileGun());
|
||||||
|
recipe.shape("III","rgT","IIs");
|
||||||
|
recipe.setIngredient('T', Material.TNT);
|
||||||
|
recipe.setIngredient('I', Material.IRON_BLOCK);
|
||||||
|
recipe.setIngredient('r', Material.BREEZE_ROD);
|
||||||
|
recipe.setIngredient('s', Material.STICK);
|
||||||
|
recipe.setIngredient('g', Material.SLIME_BLOCK);
|
||||||
|
return recipe;
|
||||||
|
}
|
||||||
|
}
|
@ -55,8 +55,14 @@
|
|||||||
"type": "model",
|
"type": "model",
|
||||||
"model": "item/m4a1s"
|
"model": "item/m4a1s"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"when": "gunmodel7",
|
||||||
|
"model": {
|
||||||
|
"type": "model",
|
||||||
|
"model": "item/rocketjumper"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"model": {
|
|
||||||
"type": "select",
|
|
||||||
"property": "custom_model_data",
|
|
||||||
"fallback": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/diamond_hoe"
|
|
||||||
},
|
|
||||||
"cases": [
|
|
||||||
{
|
|
||||||
"when": "gunmodel0",
|
|
||||||
"model": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/deserteagle"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"when": "gunmodel1",
|
|
||||||
"model": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/ak47"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"model": {
|
|
||||||
"type": "select",
|
|
||||||
"property": "custom_model_data",
|
|
||||||
"fallback": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/iron_hoe"
|
|
||||||
},
|
|
||||||
"cases": [
|
|
||||||
{
|
|
||||||
"when": "gunmodel0",
|
|
||||||
"model": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/hecateii"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"model": {
|
|
||||||
"type": "select",
|
|
||||||
"property": "custom_model_data",
|
|
||||||
"fallback": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/stone_hoe"
|
|
||||||
},
|
|
||||||
"cases": [
|
|
||||||
{
|
|
||||||
"when": "gunmodel0",
|
|
||||||
"model": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/barettm82"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"model": {
|
|
||||||
"type": "select",
|
|
||||||
"property": "custom_model_data",
|
|
||||||
"fallback": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/wooden_hoe"
|
|
||||||
},
|
|
||||||
"cases": [
|
|
||||||
{
|
|
||||||
"when": "gunmodel0",
|
|
||||||
"model": {
|
|
||||||
"type": "model",
|
|
||||||
"model": "item/1911"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -5,5 +5,7 @@ api-version: '1.21'
|
|||||||
commands:
|
commands:
|
||||||
getgun:
|
getgun:
|
||||||
description: gun
|
description: gun
|
||||||
|
permission: giguns.getgun
|
||||||
getammo:
|
getammo:
|
||||||
description: ammo
|
description: ammo
|
||||||
|
permission: giguns.getammo
|
Loading…
x
Reference in New Issue
Block a user