added railgun recipe

This commit is contained in:
ImproperIssues
2023-07-27 12:48:49 -07:00
parent 169c6a9250
commit 2b8ae6af2e
3 changed files with 36 additions and 15 deletions

View File

@@ -170,11 +170,18 @@ public abstract class ItemPresets {
public static ItemStack RAILGUN = ItemBuilder.create() public static ItemStack RAILGUN = ItemBuilder.create()
.material(Material.DIAMOND_HORSE_ARMOR) .material(Material.DIAMOND_HORSE_ARMOR)
.name("Railgun") .name(Text.color("&bRailgun &3>>>"))
.lore(Text.color("&7- Another funny gadget!")) .lore(Text.color("&7- Another funny gadget!"))
.customModelData(1111) .customModelData(1111)
.build(); .build();
public static ItemStack BLUE_LAZER_DIODE = ItemBuilder.create()
.material(Material.LIGHT_BLUE_CANDLE)
.name(Text.color("&bBlue Lazer Diode"))
.lore(Text.color("&7- Use this to craft the &blazer guns"))
.customModelData(1111)
.build();
public static ItemStack BLANK = ItemBuilder.create() public static ItemStack BLANK = ItemBuilder.create()
.material(Material.LIGHT_GRAY_STAINED_GLASS_PANE) .material(Material.LIGHT_GRAY_STAINED_GLASS_PANE)
.name(" ") .name(" ")

View File

@@ -13,6 +13,8 @@ public abstract class CraftingKeys {
public static void initRecipes() { public static void initRecipes() {
// my custom // my custom
register(ItemPresets.BLUE_LAZER_DIODE, "[beacon{}, beacon{}, beacon{}, beacon{}, beacon{}, beacon{}, beacon{}, beacon{}, beacon{}]");
register(ItemPresets.RAILGUN, "[light_blue_candle{CustomModelData:1111,display:{Lore:['{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"gray\",\"text\":\"- Use this to craft the \"},{\"italic\":false,\"color\":\"aqua\",\"text\":\"lazer guns\"}],\"text\":\"\"}'],Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"aqua\",\"text\":\"Blue Lazer Diode\"}],\"text\":\"\"}'}}, diamond{}, iron_block{}, air{}, air{}, iron_block{}, air{}, air{}, air{}]");
register(ItemPresets.SPBRifle, "[iron_horse_armor{}]"); register(ItemPresets.SPBRifle, "[iron_horse_armor{}]");
register(ItemPresets.POTATOCANNON, "[potato{}, potato{}, potato{}, potato{}, golden_hoe{}, potato{}, potato{}, potato{}, potato{}]"); register(ItemPresets.POTATOCANNON, "[potato{}, potato{}, potato{}, potato{}, golden_hoe{}, potato{}, potato{}, potato{}, potato{}]");
register(ItemPresets.LASER_POINTER, "[polished_blackstone_button{}, lime_concrete{}, lime_stained_glass{}, lime_concrete{}, diamond{}, lime_concrete{}, stick{}, lime_concrete{}, air{}]"); register(ItemPresets.LASER_POINTER, "[polished_blackstone_button{}, lime_concrete{}, lime_stained_glass{}, lime_concrete{}, diamond{}, lime_concrete{}, stick{}, lime_concrete{}, air{}]");

View File

@@ -7,10 +7,14 @@ import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer; import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Transformation; import org.bukkit.util.Transformation;
import org.joml.AxisAngle4f; import org.joml.AxisAngle4f;
import org.joml.Vector3f; import org.joml.Vector3f;
import java.util.List;
import static fun.ogre.ogredupealias.OgreDupeAlias.instance; import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
public class RailgunItem extends CustomItem { public class RailgunItem extends CustomItem {
@@ -27,14 +31,22 @@ public class RailgunItem extends CustomItem {
World world = player.getWorld(); World world = player.getWorld();
Location end = RaycastUtils.raycast(eye, loc.getDirection(), 100, 0.5, point -> { Location end = RaycastUtils.raycast(eye, loc.getDirection(), 100, 0.5, point -> {
List<LivingEntity> entities = world.getNearbyEntities(point, 3, 3, 3, entity -> {
return entity instanceof LivingEntity le && !le.isDead() && le != player && le.getBoundingBox().expand(1).contains(point.toVector());
}).stream().map(e -> (LivingEntity)e).toList();
if (!entities.isEmpty()) {
entities.get(0).damage(10, player);
entities.get(0).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 255, true));
entities.get(0).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 255, true));
}
boolean hitBlock = !point.getBlock().isPassable(); boolean hitBlock = !point.getBlock().isPassable();
boolean hitEntity = !world.getNearbyEntities(point, 3, 3, 3, entity -> { boolean hitEntity = !entities.isEmpty();
return entity instanceof LivingEntity le && !le.isDead() && le != player && le.getBoundingBox().contains(point.toVector());
}).isEmpty();
return hitBlock || hitEntity; return hitBlock || hitEntity;
}); });
Particle.DustOptions dust = new Particle.DustOptions(Color.fromRGB(2, 255, 255), 10F); Particle.DustOptions dust = new Particle.DustOptions(Color.fromRGB(2, 255, 255), 100F);
world.spawnParticle(Particle.REDSTONE, end, 30, 0, 0, 0, 1, dust); world.spawnParticle(Particle.REDSTONE, end, 100, 0.5, 0.5, 0.5, 1, dust);
this.beam(loc, end, eye, world, player); this.beam(loc, end, eye, world, player);
this.flash(loc, end, eye, world, player); this.flash(loc, end, eye, world, player);
@@ -43,13 +55,13 @@ public class RailgunItem extends CustomItem {
private void flash(Location loc, Location end, Location eye, World world, Player player) { private void flash(Location loc, Location end, Location eye, World world, Player player) {
float dist = (float)loc.distance(end); float dist = (float)loc.distance(end);
float diameter = 1F; float diameter = 3F;
float radius = diameter / 2F; float radius = diameter / 2F;
AxisAngle4f angle = new AxisAngle4f(0F, 0F, 0F, 1F); AxisAngle4f angle = new AxisAngle4f(0F, 0F, 0F, 1F);
Vector3f translation = new Vector3f(0F, 0F, 0F); Vector3f translation = new Vector3f(0F, 0F, 0F);
BlockDisplay beam = world.spawn(eye, BlockDisplay.class, entity -> { BlockDisplay beam = world.spawn(eye, BlockDisplay.class, entity -> {
Vector3f scale = new Vector3f(0F, 0.5F, dist); Vector3f scale = new Vector3f(0F, 0F, 10000.0F);
Transformation transformation = new Transformation(translation, angle, scale, angle); Transformation transformation = new Transformation(translation, angle, scale, angle);
entity.setBrightness(new Display.Brightness(15, 15)); entity.setBrightness(new Display.Brightness(15, 15));
@@ -62,7 +74,7 @@ public class RailgunItem extends CustomItem {
}); });
Bukkit.getScheduler().runTaskLater(instance, () -> { Bukkit.getScheduler().runTaskLater(instance, () -> {
Vector3f scale = new Vector3f(diameter, diameter, dist); Vector3f scale = new Vector3f(diameter, diameter, 10000.0F);
Vector3f trans = new Vector3f(-radius); Vector3f trans = new Vector3f(-radius);
Transformation transformation = new Transformation(trans, angle, scale, angle); Transformation transformation = new Transformation(trans, angle, scale, angle);
@@ -112,7 +124,7 @@ public class RailgunItem extends CustomItem {
beam.setInterpolationDelay(0); beam.setInterpolationDelay(0);
beam.setInterpolationDuration(20); beam.setInterpolationDuration(20);
beam.setTransformation(transformation); beam.setTransformation(transformation);
}, 20); }, 40);
} }
private void explosion(Location loc, Entity source) { private void explosion(Location loc, Entity source) {
@@ -124,13 +136,13 @@ public class RailgunItem extends CustomItem {
BlockDisplay ball = world.spawn(loc, BlockDisplay.class, entity -> { BlockDisplay ball = world.spawn(loc, BlockDisplay.class, entity -> {
entity.setTransformation(transformation); entity.setTransformation(transformation);
entity.setBlock(Material.WHITE_CONCRETE.createBlockData()); entity.setBlock(Material.LIGHT_BLUE_STAINED_GLASS.createBlockData());
entity.setViewRange(1000F); entity.setViewRange(10000F);
Bukkit.getScheduler().runTaskLater(instance, entity::remove, 30); Bukkit.getScheduler().runTaskLater(instance, entity::remove, 30);
}); });
Bukkit.getScheduler().runTaskLater(instance, task -> { Bukkit.getScheduler().runTaskLater(instance, task -> {
float diameter = 5F; float diameter = 10F;
float radius = diameter / 2.0F; float radius = diameter / 2.0F;
Vector3f enlarge = new Vector3f(diameter, diameter, diameter); Vector3f enlarge = new Vector3f(diameter, diameter, diameter);
Vector3f enlargeTransition = new Vector3f(-radius, -radius, -radius); Vector3f enlargeTransition = new Vector3f(-radius, -radius, -radius);
@@ -141,7 +153,7 @@ public class RailgunItem extends CustomItem {
ball.setTransformation(rescale); ball.setTransformation(rescale);
world.spawnParticle(Particle.EXPLOSION_LARGE, loc, 1, 2, 2, 2, 0); world.spawnParticle(Particle.EXPLOSION_LARGE, loc, 1, 2, 2, 2, 0);
world.createExplosion(loc, 3, false, false, source); world.createExplosion(loc, 5, false, false, source);
}, 5); }, 5);
Bukkit.getScheduler().runTaskLater(instance, task -> { Bukkit.getScheduler().runTaskLater(instance, task -> {
@@ -150,7 +162,7 @@ public class RailgunItem extends CustomItem {
ball.setTransformation(transformation); ball.setTransformation(transformation);
world.spawnParticle(Particle.EXPLOSION_LARGE, loc, 1, 2, 2, 2, 0); world.spawnParticle(Particle.EXPLOSION_LARGE, loc, 1, 2, 2, 2, 0);
world.createExplosion(loc, 3, false, false, source); world.createExplosion(loc, 5, false, false, source);
}, 15); }, 15);
} }
} }