Skip to content

Commit d1230f2

Browse files
Fix shears, update to 1.17.1, bump version
1 parent 66c7ce3 commit d1230f2

File tree

7 files changed

+53
-19
lines changed

7 files changed

+53
-19
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>parallelmc</groupId>
88
<artifactId>parallelutils</artifactId>
9-
<version>1.2.0</version>
9+
<version>1.2.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Parallelutils</name>
@@ -106,7 +106,7 @@
106106
<dependency>
107107
<groupId>io.papermc.paper</groupId>
108108
<artifactId>paper</artifactId>
109-
<version>1.17-R0.1-SNAPSHOT</version>
109+
<version>1.17.1-R0.1-SNAPSHOT</version>
110110
<scope>provided</scope>
111111
</dependency>
112112
<!--<dependency>

src/main/java/parallelmc/parallelutils/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Constants {
44

5-
public static final Version VERSION = new Version(1, 2, 0);
5+
public static final Version VERSION = new Version(1, 2, 1);
66
public static final String PLUGIN_NAME = "ParallelUtils";
77
public static final String DEFAULT_WORLD = "world";
88
}

src/main/java/parallelmc/parallelutils/modules/custommobs/nmsmobs/CustomEntityHelper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.minecraft.world.entity.EntityInsentient;
44
import net.minecraft.world.entity.ai.goal.PathfinderGoalSelector;
5+
import net.minecraft.world.entity.ai.navigation.NavigationAbstract;
56

67
import java.lang.reflect.Field;
78
import java.util.Map;
@@ -17,13 +18,14 @@ public class CustomEntityHelper {
1718
* @param entity The entity to clear the pathfinding goals of
1819
*/
1920
public static void clearGoals(EntityInsentient entity) {
20-
Map goalC = (Map) getPrivateField("c", PathfinderGoalSelector.class, entity.bO);
21+
22+
Map goalC = (Map) getPrivateField("c", PathfinderGoalSelector.class, entity.bP);
2123
goalC.clear();
22-
Set goalD = (Set) getPrivateField("d", PathfinderGoalSelector.class, entity.bO);
24+
Set goalD = (Set) getPrivateField("d", PathfinderGoalSelector.class, entity.bP);
2325
goalD.clear();
24-
Map targetC = (Map) getPrivateField("c", PathfinderGoalSelector.class, entity.bP);
26+
Map targetC = (Map) getPrivateField("c", PathfinderGoalSelector.class, entity.bQ);
2527
targetC.clear();
26-
Set targetD = (Set) getPrivateField("d", PathfinderGoalSelector.class, entity.bP);
28+
Set targetD = (Set) getPrivateField("d", PathfinderGoalSelector.class, entity.bQ);
2729
targetD.clear();
2830
}
2931

src/main/java/parallelmc/parallelutils/modules/custommobs/nmsmobs/EntityFireWisp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public static void initPathfinder(EntityZombie zombie) {
4343
//clearing Zombie goals
4444
CustomEntityHelper.clearGoals(zombie);
4545

46-
zombie.bO.a(0, new PathfinderGoalMeleeAttack(zombie, 1.0, false));
47-
zombie.bO.a(1, new PathfinderGoalRandomStroll(zombie, 1.0));
46+
zombie.bP.a(0, new PathfinderGoalMeleeAttack(zombie, 1.0, false));
47+
zombie.bP.a(1, new PathfinderGoalRandomStroll(zombie, 1.0));
4848

49-
zombie.bP.a(0, new PathfinderGoalNearestAttackableTarget<>(zombie,
49+
zombie.bQ.a(0, new PathfinderGoalNearestAttackableTarget<>(zombie,
5050
EntityPlayer.class, true));
5151
}
5252

src/main/java/parallelmc/parallelutils/modules/custommobs/nmsmobs/EntityWisp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public static void initPathfinder(EntityZombie zombie) {
4343
//clearing Zombie goals
4444
CustomEntityHelper.clearGoals(zombie);
4545

46-
zombie.bO.a(0, new PathfinderGoalMeleeAttack(zombie, 1.0, false));
47-
zombie.bO.a(1, new PathfinderGoalRandomStroll(zombie, 1.0));
46+
zombie.bP.a(0, new PathfinderGoalMeleeAttack(zombie, 1.0, false));
47+
zombie.bP.a(1, new PathfinderGoalRandomStroll(zombie, 1.0));
4848

49-
zombie.bP.a(0, new PathfinderGoalHurtByTarget(zombie));
49+
zombie.bQ.a(0, new PathfinderGoalHurtByTarget(zombie));
5050
}
5151

5252
public static EntityWisp spawn(JavaPlugin plugin, CraftServer server, CraftWorld world, Location l) {

src/main/java/parallelmc/parallelutils/modules/discordintegration/BotManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
178178
*/
179179
private void executeCommand(@NotNull MessageReceivedEvent event, String command, String[] args) {
180180
if (command.strip().equals("vanish")) {
181+
if (args.length <= 0) return;
182+
181183
String target = args[0].strip();
182184
synchronized (JoinQuitSuppressorListener.hiddenUsersLock) {
183185
if (!JoinQuitSuppressorListener.hiddenUsers.contains(target)) {

src/main/java/parallelmc/parallelutils/modules/parallelitems/PlayerInteractListener.java

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package parallelmc.parallelutils.modules.parallelitems;
22

3+
import net.minecraft.world.item.ItemShears;
34
import org.bukkit.*;
45
import org.bukkit.block.Block;
56
import org.bukkit.block.BlockFace;
@@ -19,6 +20,7 @@
1920
import org.bukkit.event.player.PlayerInteractEvent;
2021
import org.bukkit.event.player.PlayerShearEntityEvent;
2122
import org.bukkit.inventory.ItemStack;
23+
import org.bukkit.inventory.meta.Damageable;
2224
import org.bukkit.inventory.meta.ItemMeta;
2325
import org.bukkit.material.Mushroom;
2426
import org.bukkit.persistence.PersistentDataType;
@@ -170,7 +172,7 @@ public void onHumanEat(FoodLevelChangeEvent event){
170172
// Looting shears
171173
@EventHandler(priority = EventPriority.HIGH)
172174
public void playerShearEvent(PlayerShearEntityEvent event) {
173-
if (event.getEntity() instanceof Sheep) {
175+
if (event.getEntity() instanceof Sheep sheep) {
174176
// check for looting level
175177
ItemStack shears = event.getItem();
176178
if (shears.getType() == Material.SHEARS) {
@@ -183,7 +185,6 @@ public void playerShearEvent(PlayerShearEntityEvent event) {
183185
int numWool = random.nextInt((max-level)+1) + level;
184186

185187
// Make sheep drop their respective color of wool
186-
Sheep sheep = (Sheep) event.getEntity();
187188
DyeColor woolColor = sheep.getColor();
188189
if (woolColor == null) {
189190
woolColor = DyeColor.WHITE;
@@ -196,8 +197,31 @@ public void playerShearEvent(PlayerShearEntityEvent event) {
196197
event.setCancelled(true);
197198
sheep.setSheared(true);
198199
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), new ItemStack(wool, numWool));
200+
199201
Player player = event.getPlayer();
200-
player.playSound(player.getLocation(),Sound.ENTITY_SHEEP_SHEAR, 1f, 1f);
202+
player.playSound(sheep.getLocation(),Sound.ENTITY_SHEEP_SHEAR, 1f, 1f);
203+
204+
// TODO: Implement unbreaking here
205+
206+
if (!player.getGameMode().equals(GameMode.CREATIVE)) {
207+
208+
ItemStack shearsInventory = player.getInventory().getItem(event.getHand());
209+
210+
if (shearsInventory != null) {
211+
ItemMeta shearsMeta = shearsInventory.getItemMeta();
212+
213+
if (shearsMeta instanceof Damageable shearsDamageable) {
214+
int newDamage = shearsDamageable.getDamage() + 1;
215+
shearsDamageable.setDamage(newDamage);
216+
217+
if (shearsDamageable.getDamage() < 0) {
218+
shearsInventory.setAmount(0);
219+
} else {
220+
shearsInventory.setItemMeta(shearsMeta);
221+
}
222+
}
223+
}
224+
}
201225
}
202226
}
203227
}
@@ -211,11 +235,17 @@ public void playerShearEvent(PlayerShearEntityEvent event) {
211235
// make mooshroom drop the extra 1-3 respective type of mushroom
212236
MushroomCow mooshroom = (MushroomCow) event.getEntity();
213237
MushroomCow.Variant variant = mooshroom.getVariant();
238+
239+
Material itemMat;
240+
214241
if (variant == MushroomCow.Variant.RED) {
215-
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), new ItemStack(Material.getMaterial("RED_MUSHROOM"), level));
216-
} else if (variant == MushroomCow.Variant.BROWN) {
217-
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), new ItemStack(Material.getMaterial("BROWN_MUSHROOM"), level));
242+
itemMat = Material.RED_MUSHROOM;
243+
} else {
244+
itemMat = Material.BROWN_MUSHROOM;
218245
}
246+
247+
event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(),
248+
new ItemStack(itemMat, level));
219249
}
220250
}
221251
}

0 commit comments

Comments
 (0)