Skip to content

Commit

Permalink
Merge remote-tracking branch 'Slimefun/master'
Browse files Browse the repository at this point in the history
DEV - 1092
  • Loading branch information
xMikux committed Aug 3, 2023
2 parents 6bd9d14 + 16313ef commit f7bf3bb
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/discord-webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/[email protected]

- name: Set up Java JDK 17
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v3.12.0
with:
distribution: 'adopt'
java-version: '17'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-compiler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v3.12.0
with:
distribution: 'adopt'
java-version: '17'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v3.12.0
with:
distribution: 'adopt'
java-version: '17'
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.3</version>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import io.github.thebusybiscuit.slimefun4.api.events.AsyncProfileLoadEvent;
import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint;
import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece;
import io.github.thebusybiscuit.slimefun4.api.items.ItemState;
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
Expand Down Expand Up @@ -324,10 +325,18 @@ public final void markDirty() {
return Optional.empty();
}

// returns the amount of researches with at least 1 enabled item
private int nonEmptyResearches() {
return (int) Slimefun.getRegistry().getResearches()
.stream()
.filter(research -> research.getAffectedItems().stream().anyMatch(item -> item.getState() == ItemState.ENABLED))
.count();
}

public @Nonnull String getTitle() {
List<String> titles = Slimefun.getRegistry().getResearchRanks();

float fraction = (float) researches.size() / Slimefun.getRegistry().getResearches().size();
float fraction = (float) researches.size() / nonEmptyResearches();
int index = (int) (fraction * (titles.size() - 1));

return titles.get(index);
Expand All @@ -336,7 +345,7 @@ public final void markDirty() {
public void sendStats(@Nonnull CommandSender sender) {
Set<Research> unlockedResearches = getResearches();
int levels = unlockedResearches.stream().mapToInt(Research::getCost).sum();
int allResearches = Slimefun.getRegistry().getResearches().size();
int allResearches = nonEmptyResearches();

float progress = Math.round(((unlockedResearches.size() * 100.0F) / allResearches) * 100.0F) / 100.0F;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void onBlockBreak(@Nonnull Block b) {
public @Nonnull Optional<Item> getPlacedItem(@Nonnull Block pedestal) {
Location l = pedestal.getLocation().add(0.5, 1.2, 0.5);

for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, this::testItem)) {
for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, AncientPedestal::testItem)) {
if (n instanceof Item item) {
return Optional.of(item);
}
Expand All @@ -120,7 +120,7 @@ public void onBlockBreak(@Nonnull Block b) {
return createIfNoneExists ? ArmorStandUtils.spawnArmorStand(l) : null;
}

private boolean testItem(@Nullable Entity n) {
public static boolean testItem(@Nullable Entity n) {
if (n instanceof Item item && n.isValid()) {
ItemMeta meta = item.getItemStack().getItemMeta();

Expand Down Expand Up @@ -172,7 +172,6 @@ public void placeItem(@Nonnull Player p, @Nonnull Block b) {
if (entity != null) {
ArmorStand armorStand = getArmorStand(b, true);
entity.setInvulnerable(true);
entity.setUnlimitedLifetime(true);
entity.setVelocity(new Vector(0, 0.1, 0));
entity.setCustomNameVisible(true);
entity.setCustomName(nametag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void activate(@Nonnull Player p, @Nonnull Item rune) {
*/
private boolean findCompatibleItem(@Nonnull Entity entity) {
if (entity instanceof Item item) {
return item.getPickupDelay() == 0 && !SlimefunUtils.isSoulbound(item.getItemStack()) && !isItem(item.getItemStack());
return item.getPickupDelay() <= 0 && !SlimefunUtils.isSoulbound(item.getItemStack()) && !isItem(item.getItemStack());
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ protected void registerDefaultRecipes(@Nonnull List<ItemStack> recipes) {
recipes.add(new ItemStack(Material.ANDESITE));
recipes.add(new ItemStack(Material.GRAVEL));

recipes.add(new ItemStack(Material.BLACKSTONE));
recipes.add(new ItemStack(Material.GRAVEL));

recipes.add(new ItemStack(Material.DIORITE));
recipes.add(new ItemStack(Material.GRAVEL));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public OreCrusher(ItemGroup itemGroup, SlimefunItemStack item) {

@Override
protected void registerDefaultRecipes(List<ItemStack> recipes) {
recipes.add(new ItemStack(Material.BLACKSTONE, 8));
recipes.add(new ItemStack(Material.RED_SAND, 1));

recipes.add(new ItemStack(Material.COBBLESTONE, 8));
recipes.add(new ItemStack(Material.SAND, 1));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;

import io.github.bakedlibs.dough.items.ItemUtils;
Expand Down Expand Up @@ -58,7 +56,7 @@ public GrapplingHook(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
UUID uuid = p.getUniqueId();
boolean isConsumed = consumeOnUse.getValue() && p.getGameMode() != GameMode.CREATIVE;

if (!e.getClickedBlock().isPresent() && !Slimefun.getGrapplingHookListener().isGrappling(uuid)) {
if (e.getClickedBlock().isEmpty() && !Slimefun.getGrapplingHookListener().isGrappling(uuid)) {
e.cancel();

if (p.getInventory().getItemInOffHand().getType() == Material.BOW) {
Expand All @@ -79,10 +77,11 @@ public GrapplingHook(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
arrow.setVelocity(direction);

Bat bat = (Bat) p.getWorld().spawnEntity(p.getLocation(), EntityType.BAT);
bat.setInvulnerable(true);
bat.setCanPickupItems(false);
bat.setAI(false);
bat.setSilent(true);
bat.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100000, 100000));
bat.setInvisible(true);
bat.setLeashHolder(arrow);

boolean state = item.getType() != Material.SHEARS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.ItemDespawnEvent;
import org.bukkit.inventory.ItemStack;

import io.github.bakedlibs.dough.items.CustomItemStack;
Expand Down Expand Up @@ -357,4 +358,10 @@ public void onBlockPlace(BlockPlaceEvent e) {
return Optional.empty();
}

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemDespawn(ItemDespawnEvent e) {
if (AncientPedestal.testItem(e.getEntity())) {
e.setCancelled(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,10 @@ public static void setup(@Nonnull Slimefun plugin) {
new ItemStack[] {new ItemStack(Material.GOLDEN_APPLE), null, null, null, null, null, null, null, null})
.register(plugin);

new VanillaItem(itemGroups.food, new ItemStack(Material.ENCHANTED_GOLDEN_APPLE), "ENCHANTED_GOLDEN_APPLE", RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, new ItemStack(Material.APPLE), SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK, SlimefunItems.GOLD_24K_BLOCK})
.register(plugin);

new BrokenSpawner(itemGroups.magicalResources, SlimefunItems.BROKEN_SPAWNER, new RecipeType(new NamespacedKey(plugin, "pickaxe_of_containment"), SlimefunItems.PICKAXE_OF_CONTAINMENT),
new ItemStack[] {null, null, null, null, new ItemStack(Material.SPAWNER), null, null, null, null})
.register(plugin);
Expand Down Expand Up @@ -1923,12 +1927,12 @@ public int getEnergyConsumption() {

@Override
public int getMultiplier(int y) {
return y * 64 + 600;
return y * 64 + 2100;
}

@Override
public int getEnergyConsumption() {
return 46;
return 43;
}

}.register(plugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.annotation.Nonnull;
Expand All @@ -14,8 +15,10 @@

import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.api.events.ExplosiveToolBreakBlocksEvent;
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.api.events.ReactorExplodeEvent;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan;

import net.imprex.orebfuscator.api.OrebfuscatorService;

Expand Down Expand Up @@ -61,4 +64,11 @@ public void onExplosiveToolBreakBlocks(ExplosiveToolBreakBlocksEvent event) {
public void onReactorExplode(ReactorExplodeEvent event) {
this.service.deobfuscate(Arrays.asList(event.getLocation().getBlock()));
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGoldPanUse(PlayerRightClickEvent event) {
if (event.getSlimefunItem().isPresent() && event.getClickedBlock().isPresent() && event.getSlimefunItem().get() instanceof GoldPan) {
this.service.deobfuscate(List.of(event.getClickedBlock().get()));
}
}
}

0 comments on commit f7bf3bb

Please sign in to comment.