added railgun recipe
This commit is contained in:
@@ -170,11 +170,18 @@ public abstract class ItemPresets {
|
||||
|
||||
public static ItemStack RAILGUN = ItemBuilder.create()
|
||||
.material(Material.DIAMOND_HORSE_ARMOR)
|
||||
.name("Railgun")
|
||||
.name(Text.color("&bRailgun &3>>>"))
|
||||
.lore(Text.color("&7- Another funny gadget!"))
|
||||
.customModelData(1111)
|
||||
.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()
|
||||
.material(Material.LIGHT_GRAY_STAINED_GLASS_PANE)
|
||||
.name(" ")
|
||||
|
||||
@@ -13,6 +13,8 @@ public abstract class CraftingKeys {
|
||||
|
||||
public static void initRecipes() {
|
||||
// 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.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{}]");
|
||||
|
||||
@@ -7,10 +7,14 @@ import fun.ogre.ogredupealias.utils.RaycastUtils;
|
||||
import fun.ogre.ogredupealias.utils.SoundPlayer;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.joml.AxisAngle4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
|
||||
|
||||
public class RailgunItem extends CustomItem {
|
||||
@@ -27,14 +31,22 @@ public class RailgunItem extends CustomItem {
|
||||
World world = player.getWorld();
|
||||
|
||||
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 hitEntity = !world.getNearbyEntities(point, 3, 3, 3, entity -> {
|
||||
return entity instanceof LivingEntity le && !le.isDead() && le != player && le.getBoundingBox().contains(point.toVector());
|
||||
}).isEmpty();
|
||||
boolean hitEntity = !entities.isEmpty();
|
||||
return hitBlock || hitEntity;
|
||||
});
|
||||
Particle.DustOptions dust = new Particle.DustOptions(Color.fromRGB(2, 255, 255), 10F);
|
||||
world.spawnParticle(Particle.REDSTONE, end, 30, 0, 0, 0, 1, dust);
|
||||
Particle.DustOptions dust = new Particle.DustOptions(Color.fromRGB(2, 255, 255), 100F);
|
||||
world.spawnParticle(Particle.REDSTONE, end, 100, 0.5, 0.5, 0.5, 1, dust);
|
||||
|
||||
this.beam(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) {
|
||||
float dist = (float)loc.distance(end);
|
||||
float diameter = 1F;
|
||||
float diameter = 3F;
|
||||
float radius = diameter / 2F;
|
||||
AxisAngle4f angle = new AxisAngle4f(0F, 0F, 0F, 1F);
|
||||
Vector3f translation = new Vector3f(0F, 0F, 0F);
|
||||
|
||||
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);
|
||||
|
||||
entity.setBrightness(new Display.Brightness(15, 15));
|
||||
@@ -62,7 +74,7 @@ public class RailgunItem extends CustomItem {
|
||||
});
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
Vector3f scale = new Vector3f(diameter, diameter, dist);
|
||||
Vector3f scale = new Vector3f(diameter, diameter, 10000.0F);
|
||||
Vector3f trans = new Vector3f(-radius);
|
||||
Transformation transformation = new Transformation(trans, angle, scale, angle);
|
||||
|
||||
@@ -112,7 +124,7 @@ public class RailgunItem extends CustomItem {
|
||||
beam.setInterpolationDelay(0);
|
||||
beam.setInterpolationDuration(20);
|
||||
beam.setTransformation(transformation);
|
||||
}, 20);
|
||||
}, 40);
|
||||
}
|
||||
|
||||
private void explosion(Location loc, Entity source) {
|
||||
@@ -124,13 +136,13 @@ public class RailgunItem extends CustomItem {
|
||||
|
||||
BlockDisplay ball = world.spawn(loc, BlockDisplay.class, entity -> {
|
||||
entity.setTransformation(transformation);
|
||||
entity.setBlock(Material.WHITE_CONCRETE.createBlockData());
|
||||
entity.setViewRange(1000F);
|
||||
entity.setBlock(Material.LIGHT_BLUE_STAINED_GLASS.createBlockData());
|
||||
entity.setViewRange(10000F);
|
||||
Bukkit.getScheduler().runTaskLater(instance, entity::remove, 30);
|
||||
});
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(instance, task -> {
|
||||
float diameter = 5F;
|
||||
float diameter = 10F;
|
||||
float radius = diameter / 2.0F;
|
||||
Vector3f enlarge = new Vector3f(diameter, diameter, diameter);
|
||||
Vector3f enlargeTransition = new Vector3f(-radius, -radius, -radius);
|
||||
@@ -141,7 +153,7 @@ public class RailgunItem extends CustomItem {
|
||||
ball.setTransformation(rescale);
|
||||
|
||||
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);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(instance, task -> {
|
||||
@@ -150,7 +162,7 @@ public class RailgunItem extends CustomItem {
|
||||
ball.setTransformation(transformation);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user