This commit is contained in:
BuildTools 2023-09-21 15:30:32 +05:00
parent f5109635ff
commit fe8108ca62
11 changed files with 26 additions and 24 deletions

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.6</version> <version>3.5.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -81,27 +81,27 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId> <artifactId>V1_17_R1</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R2</artifactId> <artifactId>V1_18_R2</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R3</artifactId> <artifactId>V1_19_R3</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R1</artifactId> <artifactId>V1_20_R1</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -141,18 +141,16 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha
// Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука.
event.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); event.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1);
chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0]));
event.getItems().clear();
if (chest.getBlockInventory().isEmpty()) { if (chest.getBlockInventory().isEmpty()) {
EnchantUtils.popResource(event, new ItemStack(chest.getType())); EnchantUtils.popResource(event, new ItemStack(chest.getType()));
return false; return false;
} }
// Добавляем кастомный сундук в кастомный дроп лист.
EnchantUtils.popResource(event, this.getSilkChest(chest)); EnchantUtils.popResource(event, this.getSilkChest(chest));
// Очищаем инвентарь сундука и дефолтный дроп лист.
chest.getBlockInventory().clear(); chest.getBlockInventory().clear();
event.getItems().clear();
return true; return true;
} }

View File

@ -89,8 +89,7 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr
@Override @Override
public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) { public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull Player player, @NotNull ItemStack item, int level) {
// TODO Use furnace recipes // TODO Use furnace recipes & Re-add smelted items instead of setType
// TODO Re-add smelted items instead of setType
if (event.getBlockState() instanceof Container) return false; if (event.getBlockState() instanceof Container) return false;
if (!this.isAvailableToUse(player)) return false; if (!this.isAvailableToUse(player)) return false;
@ -99,7 +98,11 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr
event.getItems().forEach(drop -> { event.getItems().forEach(drop -> {
Material material = this.smeltingTable.get(drop.getItemStack().getType()); Material material = this.smeltingTable.get(drop.getItemStack().getType());
if (material != null) drop.getItemStack().setType(material); if (material != null) {
ItemStack stack = drop.getItemStack();
stack.setType(material);
drop.setItemStack(stack);
}
}); });
Block block = event.getBlockState().getBlock(); Block block = event.getBlockState().getBlock();

View File

@ -347,7 +347,7 @@ public class EnchantUtils {
public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) { public static void consumeCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant, int level) {
int has = getCharges(item, enchant); int has = getCharges(item, enchant);
int use = enchant.getChargesConsumeAmount(level); int use = enchant.getChargesConsumeAmount(level);
setCharges(item, enchant, level,has - use); setCharges(item, enchant, level,has < use ? 0 : has - use);
} }
/*public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) { /*public static void restoreCharges(@NotNull ItemStack item, @NotNull ExcellentEnchant enchant) {

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.6</version> <version>3.5.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.6</version> <version>3.5.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.6</version> <version>3.5.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.6</version> <version>3.5.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.6</version> <version>3.5.7</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId> <artifactId>NMS</artifactId>
<version>3.5.6</version> <version>3.5.7</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -3,6 +3,7 @@ package su.nightexpress.excellentenchants.nms.v1_20_R1;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.network.protocol.game.ClientboundAnimatePacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@ -40,7 +41,7 @@ public class V1_20_R1 implements EnchantNMS {
@Override @Override
public void sendAttackPacket(@NotNull Player player, int id) { public void sendAttackPacket(@NotNull Player player, int id) {
CraftPlayer craftPlayer = (CraftPlayer) player; CraftPlayer craftPlayer = (CraftPlayer) player;
Entity entity = craftPlayer.getHandle(); ServerPlayer entity = craftPlayer.getHandle();
ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id); ClientboundAnimatePacket packet = new ClientboundAnimatePacket(entity, id);
craftPlayer.getHandle().connection.send(packet); craftPlayer.getHandle().connection.send(packet);
} }

View File

@ -7,7 +7,7 @@
<groupId>su.nightexpress.excellentenchants</groupId> <groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>ExcellentEnchants</artifactId> <artifactId>ExcellentEnchants</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>3.5.6</version> <version>3.5.7</version>
<modules> <modules>
<module>Core</module> <module>Core</module>
<module>NMS</module> <module>NMS</module>