mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2025-01-09 19:17:35 +01:00
Check Cauldron Block Type on Update
This commit is contained in:
parent
3d9309e2d9
commit
29830e0405
@ -53,17 +53,38 @@ public class BCauldron {
|
|||||||
particleLocation = block.getLocation().add(0.5, 0.8, 0.5);
|
particleLocation = block.getLocation().add(0.5, 0.8, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUpdate() {
|
/**
|
||||||
// Check if fire still alive
|
* Updates this Cauldron, increasing the cook time and checking for Heatsource
|
||||||
if (!BUtil.isChunkLoaded(block) || LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN))) {
|
*
|
||||||
|
* @return false if Cauldron needs to be removed
|
||||||
|
*/
|
||||||
|
public boolean onUpdate() {
|
||||||
// add a minute to cooking time
|
// add a minute to cooking time
|
||||||
|
if (!BUtil.isChunkLoaded(block)) {
|
||||||
|
increaseState();
|
||||||
|
} else {
|
||||||
|
if (block.getType() != Material.CAULDRON) {
|
||||||
|
// Catch any WorldEdit etc. removal
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check if fire still alive
|
||||||
|
if (LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN))) {
|
||||||
|
increaseState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will add a minute to the cooking time
|
||||||
|
*/
|
||||||
|
public void increaseState() {
|
||||||
state++;
|
state++;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
ingredients = ingredients.copy();
|
ingredients = ingredients.copy();
|
||||||
changed = false;
|
changed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// add an ingredient to the cauldron
|
// add an ingredient to the cauldron
|
||||||
public void add(ItemStack ingredient, RecipeItem rItem) {
|
public void add(ItemStack ingredient, RecipeItem rItem) {
|
||||||
@ -79,9 +100,8 @@ public class BCauldron {
|
|||||||
state--;
|
state--;
|
||||||
}
|
}
|
||||||
if (BConfig.enableCauldronParticles) {
|
if (BConfig.enableCauldronParticles) {
|
||||||
//block.getWorld().spawnParticle(Particle.SPELL_INSTANT, getRandomized(),0, -0.5 + particleRandom.nextFloat(), 1, -0.5 + particleRandom.nextFloat());
|
// Few little sparks and lots of water splashes. Offset by 0.2 in x and z
|
||||||
block.getWorld().spawnParticle(Particle.SPELL_INSTANT, particleLocation,3, 0.2, 0, 0.2);
|
block.getWorld().spawnParticle(Particle.SPELL_INSTANT, particleLocation,3, 0.2, 0, 0.2);
|
||||||
//block.getWorld().spawnParticle(Particle.REDSTONE, pLoc1, 15, 0.5, 0.4, 0.5, new Particle.DustOptions(Color.GREEN, 12f));
|
|
||||||
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 10, 0.2, 0, 0.2);
|
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 10, 0.2, 0, 0.2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,60 +231,29 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createParticlePackets() {
|
|
||||||
try {
|
|
||||||
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
double test = 0;
|
|
||||||
|
|
||||||
public void cookEffect() {
|
public void cookEffect() {
|
||||||
long time1 = System.nanoTime();
|
|
||||||
if (BUtil.isChunkLoaded(block) && LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN))) {
|
if (BUtil.isChunkLoaded(block) && LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN))) {
|
||||||
time1 = System.nanoTime() - time1;
|
|
||||||
long time2 = System.nanoTime();
|
|
||||||
//block.getWorld().spawnParticle(particle, pLoc1, 2, 0.2, 1, 0.2, 0);
|
|
||||||
//block.getWorld().spigot().playEffect(pLoc1, effect, 0, 0, 0.2F, 0, 0.2F, 0, 8, 15);
|
|
||||||
time2 = System.nanoTime() - time2;
|
|
||||||
long time3 = System.nanoTime();
|
|
||||||
//block.getWorld().spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, pLoc1, 0, 0.01, 1, 0.01, 0.05);
|
|
||||||
//block.getWorld().spawnParticle(Particle.WATER_SPLASH, getRandomized(), 1, 0.1, 0, 0.1, 0.005);
|
|
||||||
if (particleRandom.nextFloat() > 0.75) {
|
if (particleRandom.nextFloat() > 0.75) {
|
||||||
block.getWorld().spawnParticle(Particle.CLOUD, getRandomized(), 0, 0, 1, 0, 0.07);
|
// Pixely cloud at 0.4 random in x and z
|
||||||
//block.getWorld().spawnParticle(Particle.REDSTONE, pLoc2, 3, 0.3, 0, 0.3, 10, new Particle.DustOptions(Color.BLUE, 1));
|
// 0 count enables direction, send to y = 1 with speed 0.07
|
||||||
//block.getWorld().spawnParticle(Particle.SPELL_INSTANT, getRandomized(), 0, 0, 1, 0, 0.005);
|
block.getWorld().spawnParticle(Particle.CLOUD, getRandParticleLoc(), 0, 0, 1, 0, 0.07);
|
||||||
}
|
}
|
||||||
if (particleRandom.nextFloat() > 0.2) {
|
if (particleRandom.nextFloat() > 0.2) {
|
||||||
|
// A Water Splash with 0.2 offset in x and z
|
||||||
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 1, 0.2, 0, 0.2);
|
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 1, 0.2, 0, 0.2);
|
||||||
}
|
}
|
||||||
block.getWorld().spawnParticle(Particle.SPELL_MOB, getRandomized(), 0, 180.0/255.0, 40.0/255.0, 1.0/255.0, 1025.0);
|
// Colorable spirally spell, 0 count enables color instead of the offset variables
|
||||||
//block.getWorld().playEffect(pLoc1, Effect.);
|
// Configurable RGB color. 1025 seems to be the best for color brightness and upwards motion
|
||||||
//block.getWorld().spigot().playEffect(pLoc2, Effect.SPELL, 0, 0, 0.2F, 0.2F, 0.2F, 0, 2, 25);
|
block.getWorld().spawnParticle(Particle.SPELL_MOB, getRandParticleLoc(), 0, 180.0/255.0, 40.0/255.0, 1.0/255.0, 1025.0);
|
||||||
time3 = System.nanoTime() - time3;
|
|
||||||
//P.p.log("Time: 1: " + time1 + " 2: " + time2 + " 3: " + time3);
|
|
||||||
//block.getWorld().spigot().playEffect(block.getLocation().add(0.5, 1, 0.5), Effect.COLOURED_DUST, 0, 1, 0.3F, 0.5F, 0.3F, 0, 5, 15);
|
|
||||||
//block.getWorld().spigot().playEffect(block.getLocation().add(0.5, 0.5, 0.5), Effect.PARTICLE_SMOKE, 0, 0, 0.3F, 0.5F, 0.3F, 0, 8, 20);
|
|
||||||
//test+=1;
|
|
||||||
//P.p.log(test + "");
|
|
||||||
//test = 512.0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getRandomized() {
|
private Location getRandParticleLoc() {
|
||||||
return new Location(particleLocation.getWorld(), particleLocation.getX() + (particleRandom.nextDouble() * 0.8) - 0.4, particleLocation.getY(), particleLocation.getZ() + (particleRandom.nextDouble() * 0.8) - 0.4);
|
return new Location(particleLocation.getWorld(),
|
||||||
|
particleLocation.getX() + (particleRandom.nextDouble() * 0.8) - 0.4,
|
||||||
|
particleLocation.getY(),
|
||||||
|
particleLocation.getZ() + (particleRandom.nextDouble() * 0.8) - 0.4);
|
||||||
}
|
}
|
||||||
// Item Crack
|
|
||||||
// Block Dust
|
|
||||||
// FAlling dust
|
|
||||||
// CAmpfire
|
|
||||||
// Explosion normal
|
|
||||||
|
|
||||||
// Water Splash
|
|
||||||
// Spell Mob
|
|
||||||
// Spell Witch
|
|
||||||
// CLoud
|
|
||||||
|
|
||||||
public static void cookEffects() {
|
public static void cookEffects() {
|
||||||
if (!BConfig.enableCauldronParticles) return;
|
if (!BConfig.enableCauldronParticles) return;
|
||||||
@ -314,20 +303,6 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static void cookEffects() {
|
|
||||||
int size = bcauldrons.size();
|
|
||||||
if (size <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int numCauldrons = Math.max(size / 40, 1);
|
|
||||||
Random r = new Random();
|
|
||||||
while (numCauldrons > 0) {
|
|
||||||
bcauldrons.get(r.nextInt(size)).cookEffect();
|
|
||||||
numCauldrons--;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static void clickCauldron(PlayerInteractEvent event) {
|
public static void clickCauldron(PlayerInteractEvent event) {
|
||||||
Material materialInHand = event.getMaterial();
|
Material materialInHand = event.getMaterial();
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
@ -447,13 +422,12 @@ public class BCauldron {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset to normal cauldron
|
/**
|
||||||
|
* reset to normal cauldron
|
||||||
|
*/
|
||||||
public static boolean remove(Block block) {
|
public static boolean remove(Block block) {
|
||||||
if (LegacyUtil.getFillLevel(block) != EMPTY) {
|
|
||||||
return bcauldrons.remove(block) != null;
|
return bcauldrons.remove(block) != null;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// unloads cauldrons that are in a unloading world
|
// unloads cauldrons that are in a unloading world
|
||||||
// as they were written to file just before, this is safe to do
|
// as they were written to file just before, this is safe to do
|
||||||
|
@ -18,7 +18,6 @@ import org.bstats.bukkit.Metrics;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@ -27,6 +26,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class P extends JavaPlugin {
|
public class P extends JavaPlugin {
|
||||||
@ -34,7 +34,6 @@ public class P extends JavaPlugin {
|
|||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
public static boolean useUUID;
|
public static boolean useUUID;
|
||||||
public static boolean useNBT;
|
public static boolean useNBT;
|
||||||
public boolean hasSpigot;
|
|
||||||
public static boolean use1_9;
|
public static boolean use1_9;
|
||||||
public static boolean use1_11;
|
public static boolean use1_11;
|
||||||
public static boolean use1_13;
|
public static boolean use1_13;
|
||||||
@ -69,13 +68,6 @@ public class P extends JavaPlugin {
|
|||||||
use1_13 = !v.matches("(^|.*[^.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
use1_13 = !v.matches("(^|.*[^.\\d])1\\.1[0-2]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
use1_14 = !v.matches("(^|.*[^.\\d])1\\.1[0-3]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
use1_14 = !v.matches("(^|.*[^.\\d])1\\.1[0-3]([^\\d].*|$)") && !v.matches("(^|.*[^.\\d])1\\.[0-9]([^\\d].*|$)");
|
||||||
|
|
||||||
try {
|
|
||||||
Class c = World.Spigot.class;
|
|
||||||
hasSpigot = true;
|
|
||||||
} catch (LinkageError e) {
|
|
||||||
hasSpigot = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//MC 1.13 uses a different NBT API than the newer versions..
|
//MC 1.13 uses a different NBT API than the newer versions..
|
||||||
// We decide here which to use, the new or the old or none at all
|
// We decide here which to use, the new or the old or none at all
|
||||||
if (LegacyUtil.initNbt()) {
|
if (LegacyUtil.initNbt()) {
|
||||||
@ -462,8 +454,12 @@ public class P extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
long t1 = System.nanoTime();
|
long t1 = System.nanoTime();
|
||||||
BConfig.reloader = null;
|
BConfig.reloader = null;
|
||||||
for (BCauldron cauldron : BCauldron.bcauldrons.values()) {
|
Iterator<BCauldron> iter = BCauldron.bcauldrons.values().iterator();
|
||||||
cauldron.onUpdate();// runs every min to update cooking time
|
while (iter.hasNext()) {
|
||||||
|
// runs every min to update cooking time
|
||||||
|
if (!iter.next().onUpdate()) {
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
long t2 = System.nanoTime();
|
long t2 = System.nanoTime();
|
||||||
Barrel.onUpdate();// runs every min to check and update ageing time
|
Barrel.onUpdate();// runs every min to check and update ageing time
|
||||||
|
@ -7,9 +7,7 @@ import com.dre.brewery.recipe.BRecipe;
|
|||||||
import com.dre.brewery.recipe.Ingredient;
|
import com.dre.brewery.recipe.Ingredient;
|
||||||
import com.dre.brewery.recipe.RecipeItem;
|
import com.dre.brewery.recipe.RecipeItem;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -17,7 +15,6 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -166,33 +163,12 @@ public class CommandListener implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable r;
|
|
||||||
private int pos = 0;
|
|
||||||
|
|
||||||
public void cmdHelp(CommandSender sender, String[] args) {
|
public void cmdHelp(CommandSender sender, String[] args) {
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
BCauldron.particle = Particle.valueOf(args[1]);
|
|
||||||
if (BCauldron.particle != null) {
|
|
||||||
p.msg(sender, "Effekt: " + BCauldron.particle.name());
|
|
||||||
} else {
|
|
||||||
BCauldron.particle = Particle.REDSTONE;
|
|
||||||
}
|
|
||||||
page = p.parseInt(args[1]);
|
page = p.parseInt(args[1]);
|
||||||
}
|
}
|
||||||
r = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
pos++;
|
|
||||||
if (pos >= Particle.values().length) {
|
|
||||||
pos = 0;
|
|
||||||
}
|
|
||||||
BCauldron.particle = Particle.values()[pos];
|
|
||||||
sender.sendMessage("Particle: " + BCauldron.particle.name());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
P.p.getServer().getScheduler().runTaskTimer(P.p, r, 100, 100);
|
|
||||||
|
|
||||||
ArrayList<String> commands = getCommands(sender);
|
ArrayList<String> commands = getCommands(sender);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user