generated from Slimefun/Addon-Template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Electric Explosive tools Added Electric Shearer Added Bad Omen potion Added Notch apple craft
- Loading branch information
Showing
8 changed files
with
497 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/me/bunnky/idreamofeasy/slimefun/items/Chisel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.bunnky.idreamofeasy.slimefun.items; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; | ||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; | ||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; | ||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; | ||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; | ||
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; | ||
import me.bunnky.idreamofeasy.utils.ChiselConverter; | ||
import me.bunnky.idreamofeasy.utils.IDOEUtility; | ||
import me.mrCookieSlime.Slimefun.api.BlockStorage; | ||
import org.bukkit.Material; | ||
import org.bukkit.Particle; | ||
import org.bukkit.Sound; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import java.util.Optional; | ||
|
||
public class Chisel extends SlimefunItem implements Rechargeable { | ||
|
||
private final float cap; | ||
private static final float COST = 2.5F; | ||
|
||
public Chisel(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, float cap) { | ||
super(itemGroup, item, recipeType, recipe); | ||
this.cap = cap; | ||
IDOEUtility.setGlow(item); | ||
|
||
addItemHandler((ItemUseHandler) e -> { | ||
e.cancel(); | ||
|
||
final Optional<Block> optional = e.getClickedBlock(); | ||
if (optional.isPresent()) { | ||
final Block b = optional.get(); | ||
|
||
if (!(Slimefun.getProtectionManager().hasPermission(e.getPlayer(), b.getLocation(), Interaction.INTERACT_BLOCK))) { | ||
return; | ||
} | ||
|
||
Material stoneCutterResult = ChiselConverter.convert(b.getType()); | ||
|
||
if (stoneCutterResult != b.getType() && removeItemCharge(e.getItem(), COST) && !BlockStorage.hasBlockInfo(b.getLocation())) { | ||
b.setType(stoneCutterResult); | ||
|
||
b.getWorld().playSound(b.getLocation(), Sound.BLOCK_SNIFFER_EGG_PLOP, 0.5F, 5.0F); | ||
b.getWorld().spawnParticle(Particle.SCRAPE, b.getLocation().add(0.5, 0.5, 0.5), 5, 0.5, 0.5, 0.5, 0.1); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public float getMaxItemCharge(ItemStack itemStack) { | ||
return cap; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/me/bunnky/idreamofeasy/slimefun/items/ElectricExplosivePickaxe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.bunnky.idreamofeasy.slimefun.items; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; | ||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; | ||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; | ||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; | ||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; | ||
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; | ||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosivePickaxe; | ||
import me.bunnky.idreamofeasy.utils.IDOEUtility; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
|
||
public class ElectricExplosivePickaxe extends ExplosivePickaxe implements Rechargeable { | ||
|
||
private final float cap; | ||
private static final float COST = 0.3F; | ||
|
||
public ElectricExplosivePickaxe(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, float cap) { | ||
super(itemGroup, item, recipeType, recipe); | ||
IDOEUtility.setGlow(item); | ||
this.cap = cap; | ||
addItemHandler(onRightClick()); | ||
} | ||
|
||
public ItemUseHandler onRightClick() { | ||
return PlayerRightClickEvent::cancel; | ||
} | ||
|
||
@Override | ||
public @NotNull ToolUseHandler getItemHandler() { | ||
return (e, tool, fortune, drops) -> { | ||
Player p = e.getPlayer(); | ||
ItemStack itemInHand = p.getInventory().getItemInMainHand(); | ||
|
||
if (!removeItemCharge(itemInHand, COST)) { | ||
e.setCancelled(true); | ||
return; | ||
} | ||
|
||
super.getItemHandler().onToolUse(e, tool, fortune, drops); | ||
}; | ||
} | ||
|
||
@Override | ||
public float getMaxItemCharge(ItemStack itemStack) { | ||
return cap; | ||
} | ||
|
||
@Override | ||
protected boolean canBreak(@NotNull Player p, @NotNull Block b) { | ||
ItemStack itemInHand = p.getInventory().getItemInMainHand(); | ||
return removeItemCharge(itemInHand, COST) && super.canBreak(p, b); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/me/bunnky/idreamofeasy/slimefun/items/ElectricExplosiveShovel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package me.bunnky.idreamofeasy.slimefun.items; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; | ||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; | ||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; | ||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; | ||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; | ||
import io.github.thebusybiscuit.slimefun4.core.handlers.ToolUseHandler; | ||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveShovel; | ||
import me.bunnky.idreamofeasy.utils.IDOEUtility; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
|
||
public class ElectricExplosiveShovel extends ExplosiveShovel implements Rechargeable { | ||
|
||
private final float cap; | ||
private static final float COST = 0.3F; | ||
|
||
public ElectricExplosiveShovel(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, float cap) { | ||
super(itemGroup, item, recipeType, recipe); | ||
IDOEUtility.setGlow(item); | ||
this.cap = cap; | ||
addItemHandler(onRightClick()); | ||
} | ||
|
||
public ItemUseHandler onRightClick() { | ||
return PlayerRightClickEvent::cancel; | ||
} | ||
|
||
@Override | ||
public @NotNull ToolUseHandler getItemHandler() { | ||
return (e, tool, fortune, drops) -> { | ||
Player p = e.getPlayer(); | ||
ItemStack itemInHand = p.getInventory().getItemInMainHand(); | ||
|
||
if (!removeItemCharge(itemInHand, COST)) { | ||
e.setCancelled(true); | ||
return; | ||
} | ||
|
||
super.getItemHandler().onToolUse(e, tool, fortune, drops); | ||
}; | ||
} | ||
|
||
@Override | ||
public float getMaxItemCharge(ItemStack itemStack) { | ||
return cap; | ||
} | ||
|
||
@Override | ||
protected boolean canBreak(@NotNull Player p, @NotNull Block b) { | ||
ItemStack itemInHand = p.getInventory().getItemInMainHand(); | ||
return removeItemCharge(itemInHand, COST) && super.canBreak(p, b); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/main/java/me/bunnky/idreamofeasy/slimefun/machines/ElectricShearer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package me.bunnky.idreamofeasy.slimefun.machines; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; | ||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; | ||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; | ||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; | ||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; | ||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; | ||
import me.bunnky.idreamofeasy.IDreamOfEasy; | ||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; | ||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.Particle; | ||
import org.bukkit.Sound; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Sheep; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class ElectricShearer extends SlimefunItem implements EnergyNetComponent { | ||
private final int cap; | ||
private final int ecost; | ||
|
||
public ElectricShearer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, int ecost, int cap, int range) { | ||
super(itemGroup, item, recipeType, recipe); | ||
this.cap = cap; | ||
this.ecost = ecost; | ||
|
||
addItemHandler(onRightClick()); | ||
|
||
addItemHandler(new BlockTicker() { | ||
@Override | ||
public boolean isSynchronized() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void tick(Block b, SlimefunItem sfItem, Config config) { | ||
shearSheep(b.getLocation(), range); | ||
} | ||
}); | ||
} | ||
|
||
|
||
private void shearSheep(Location loc, int range) { | ||
Bukkit.getScheduler().runTask(IDreamOfEasy.getInstance(), () -> { | ||
for (Entity entity : loc.getNearbyEntities(range, range, range)) { | ||
if (entity.getType() == EntityType.SHEEP) { | ||
if (entity.getLocation().distance(loc) <= range) { | ||
Sheep sheep = (Sheep) entity; | ||
if (!sheep.isSheared()) { | ||
sheep.setSheared(true); | ||
|
||
Material woolMaterial = Material.valueOf(sheep.getColor().name() + "_WOOL"); | ||
ItemStack wool = new ItemStack(woolMaterial, 1); | ||
|
||
entity.getWorld().dropItemNaturally(entity.getLocation(), wool); | ||
|
||
Location sheepLocation = sheep.getLocation(); | ||
sheep.getWorld().spawnParticle(Particle.CLOUD, sheepLocation, 20, 0.5, 0.5, 0.5, 0.1); | ||
sheep.getWorld().playSound(sheepLocation, Sound.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public @Nonnull BlockUseHandler onRightClick() { | ||
return PlayerRightClickEvent::cancel; | ||
} | ||
|
||
@Override | ||
public @NotNull EnergyNetComponentType getEnergyComponentType() { | ||
return EnergyNetComponentType.CONSUMER; | ||
} | ||
|
||
@Override | ||
public int getCapacity() { | ||
return this.cap; | ||
} | ||
} |
Oops, something went wrong.