3.1.3 + Mojang Mappings for NMS

This commit is contained in:
nulli0n 2022-03-03 06:33:14 +05:00
parent e8a5e77026
commit 490c1c7c96
10 changed files with 160 additions and 108 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.1.2</version>
<version>3.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -32,22 +32,22 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_16_R1</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R1</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>

View File

@ -1,5 +1,7 @@
package su.nightexpress.excellentenchants.manager.enchants.tool;
import com.google.common.collect.Sets;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.Container;
@ -23,10 +25,7 @@ import su.nightexpress.excellentenchants.manager.EnchantManager;
import su.nightexpress.excellentenchants.manager.EnchantRegister;
import su.nightexpress.excellentenchants.manager.type.FitItemType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.function.UnaryOperator;
public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockBreakEnchant {
@ -38,6 +37,12 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB
private final String messageItemSeparator;
public static final String ID = "telekinesis";
private static final Set<Material> INFESTED = Sets.newHashSet(
Material.INFESTED_CHISELED_STONE_BRICKS, Material.INFESTED_COBBLESTONE,
Material.INFESTED_CRACKED_STONE_BRICKS, Material.INFESTED_DEEPSLATE,
Material.INFESTED_MOSSY_STONE_BRICKS, Material.INFESTED_STONE,
Material.INFESTED_STONE_BRICKS
);
public EnchantTelekinesis(@NotNull ExcellentEnchants plugin, @NotNull JYML cfg) {
super(plugin, cfg, EnchantPriority.HIGHEST);
@ -85,6 +90,7 @@ public class EnchantTelekinesis extends IEnchantChanceTemplate implements BlockB
public boolean use(@NotNull BlockBreakEvent e, @NotNull Player player, @NotNull ItemStack item, int level) {
if (!this.isEnchantmentAvailable(player)) return false;
if (e.getBlock().getState() instanceof Container) return false;
if (INFESTED.contains(e.getBlock().getType())) return false;
if (!e.isDropItems()) return false;
if (!this.checkTriggerChance(level)) return false;

View File

@ -2,10 +2,7 @@ package su.nightexpress.excellentenchants.manager.listeners;
import org.bukkit.Material;
import org.bukkit.block.Chest;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.enchantment.EnchantItemEvent;
@ -259,25 +256,12 @@ public class EnchantGenericListener extends AbstractListener<ExcellentEnchants>
EntityEquipment equipment = entity.getEquipment();
if (equipment == null) return;
ItemStack[] armor = equipment.getArmorContents();
for (ItemStack item : armor) {
if (item != null && EnchantManager.isEnchantable(item)) {
for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemStack item = equipment.getItem(slot);
if (EnchantManager.isEnchantable(item)) {
EnchantManager.populateEnchantments(item, ObtainType.MOB_SPAWNING);
equipment.setItem(slot, item);
}
}
ItemStack itemMain = equipment.getItemInMainHand();
if (EnchantManager.isEnchantable(itemMain)) {
EnchantManager.populateEnchantments(itemMain, ObtainType.MOB_SPAWNING);
}
ItemStack itemOff = equipment.getItemInOffHand();
if (EnchantManager.isEnchantable(itemOff)) {
EnchantManager.populateEnchantments(itemOff, ObtainType.MOB_SPAWNING);
}
equipment.setArmorContents(armor);
equipment.setItemInMainHand(itemMain);
equipment.setItemInOffHand(itemOff);
}
}

View File

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

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.1.2</version>
<version>3.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -25,7 +25,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.1.2</version>
<version>3.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,12 +21,51 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.17.1-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,13 +1,12 @@
package su.nightexpress.excellentenchants.nms;
import net.minecraft.core.BlockPosition;
import net.minecraft.util.MathHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.BlockFluids;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
@ -15,7 +14,6 @@ import org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.utils.random.Rnd;
import java.util.HashSet;
import java.util.Set;
@ -24,38 +22,34 @@ public class V1_17_R1 implements EnchantNMS {
@Override
@NotNull
public Set<Block> handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) {
Entity entity = ((CraftLivingEntity) entity1).getHandle();
BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ());
World world = ((CraftWorld) entity1.getWorld()).getHandle();
public Set<Block> handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) {
Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle();
BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ());
ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle();
IBlockData bStone = Blocks.iX.getBlockData();
float rad = Math.min(16, 2 + level);
float radius = Math.min(16F, 2F + level);
BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState();
BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos();
org.bukkit.World w1 = entity1.getWorld();
BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition();
Set<Block> blocks = new HashSet<>();
for (BlockPosition bNear : BlockPosition.a(pos.b(-rad, -1.0, -rad), pos.b(rad, -1.0, rad))) {
if (!bNear.a(entity.getPositionVector(), rad)) continue;
posMut.d(bNear.getX(), bNear.getY() + 1, bNear.getZ());
for (BlockPos posNear : BlockPos.betweenClosed(pos.b(-radius, -1.0, -radius), pos.b(radius, -1.0, radius))) {
if (!posNear.closerThan(entity.position(), radius)) continue;
IBlockData bLavaUp = world.getType(posMut);
IBlockData bLava = world.getType(bNear);
posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ());
if (!bLavaUp.isAir()) continue;
// меня заебало нахуй искать и подбирать ебучую лаву в NMS
Block normal = w1.getBlockAt(bNear.getX(), bNear.getY(), bNear.getZ());
if (normal.getType() != org.bukkit.Material.LAVA) continue;
if (bLava.get(BlockFluids.a) != 0) continue;
if (!bStone.canPlace(world, bNear)) continue;
if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue;
if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue;
BlockState bLavaAbove = world.getBlockState(posAbove);
BlockState bLava = world.getBlockState(posNear);
world.getBlockTickList().a(bNear, Blocks.iX, MathHelper.nextInt(Rnd.rnd, 60, 120));
if (!bLavaAbove.isAir()) continue;
if (!bLava.getBlock().equals(Blocks.LAVA)) continue;
if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue;
if (!bStone.canSurvive(world, posNear)) continue;
if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue;
if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue;
//world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120));
Location loc2 = new Location(world.getWorld(), bNear.getX(), bNear.getY(), bNear.getZ());
blocks.add(loc2.getBlock());
Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ());
blocks.add(bukkitLoc.getBlock());
}
return blocks;
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.1.2</version>
<version>3.1.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,12 +21,51 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.1.2</version>
<version>3.1.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.1-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.1-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,14 +1,12 @@
package su.nightexpress.excellentenchants.nms;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemBow;
import net.minecraft.world.level.IWorldReader;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.BlockFluids;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.level.block.LiquidBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
@ -24,37 +22,34 @@ public class V1_18_R1 implements EnchantNMS {
@Override
@NotNull
public Set<Block> handleFlameWalker(@NotNull LivingEntity entity1, @NotNull Location location, int level) {
Entity entity = ((CraftLivingEntity) entity1).getHandle();
BlockPosition pos = new BlockPosition(location.getX(), location.getY(), location.getZ());
World world = ((CraftWorld) entity1.getWorld()).getHandle();
public Set<Block> handleFlameWalker(@NotNull LivingEntity bukkitEntity, @NotNull Location location, int level) {
Entity entity = ((CraftLivingEntity) bukkitEntity).getHandle();
BlockPos pos = new BlockPos(location.getX(), location.getY(), location.getZ());
ServerLevel world = ((CraftWorld) bukkitEntity.getWorld()).getHandle();
IBlockData bStone = Blocks.iX.n();
float rad = Math.min(16, 2 + level);
org.bukkit.World w1 = entity1.getWorld();
BlockPosition.MutableBlockPosition posMut = new BlockPosition.MutableBlockPosition();
float radius = Math.min(16F, 2F + level);
BlockState bStone = Blocks.MAGMA_BLOCK.defaultBlockState();
BlockPos.MutableBlockPos posAbove = new BlockPos.MutableBlockPos();
Set<Block> blocks = new HashSet<>();
for (BlockPosition bNear : BlockPosition.a(pos.a(-rad, -1.0, -rad), pos.a(rad, -1.0, rad))) {
if (!bNear.a(entity.cV(), rad)) continue;
posMut.d(bNear.u(), bNear.v() + 1, bNear.w());
for (BlockPos posNear : BlockPos.betweenClosed(pos.offset(-radius, -1.0, -radius), pos.offset(radius, -1.0, radius))) {
if (!posNear.closerThan(entity.position(), radius)) continue;
IBlockData bLavaUp = world.a_(posMut);
IBlockData bLava = world.a_(bNear);
posAbove.set(posNear.getX(), posNear.getY() + 1, posNear.getZ());
if (!bLavaUp.g()) continue;
// меня заебало нахуй искать и подбирать ебучую лаву в NMS
Block normal = w1.getBlockAt(bNear.u(), bNear.v(), bNear.w());
if (normal.getType() != org.bukkit.Material.LAVA) continue;
if (bLava.c(BlockFluids.a) != 0) continue;
if (!bStone.a((IWorldReader) world, bNear)) continue;
if (!world.a(bStone, bNear, VoxelShapeCollision.a())) continue;
if (!CraftEventFactory.handleBlockFormEvent(world, bNear, bStone, entity)) continue;
world.N().a(bNear, Blocks.iX);
BlockState bLavaAbove = world.getBlockState(posAbove);
BlockState bLava = world.getBlockState(posNear);
Location loc2 = new Location(world.getWorld(), bNear.u(), bNear.v(), bNear.w());
blocks.add(loc2.getBlock());
if (!bLavaAbove.isAir()) continue;
if (!bLava.getBlock().equals(Blocks.LAVA)) continue;
if (bLava.getValue(LiquidBlock.LEVEL) != 0) continue;
if (!bStone.canSurvive(world, posNear)) continue;
if (!world.isUnobstructed(bStone, posNear, CollisionContext.empty())) continue;
if (!CraftEventFactory.handleBlockFormEvent(world, posNear, bStone, entity)) continue;
//world.scheduleTick(posNear, Blocks.STONE, Rnd.get(60, 120));
Location bukkitLoc = new Location(world.getWorld(), posNear.getX(), posNear.getY(), posNear.getZ());
blocks.add(bukkitLoc.getBlock());
}
return blocks;
}

View File

@ -7,7 +7,7 @@
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>ExcellentEnchants</artifactId>
<packaging>pom</packaging>
<version>3.1.2</version>
<version>3.1.3</version>
<modules>
<module>Core</module>
<module>NMS</module>
@ -25,12 +25,7 @@
<dependency>
<groupId>su.nexmedia</groupId>
<artifactId>NexEngine</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>su.nexmedia</groupId>
<artifactId>NexEngine_CustomEffects</artifactId>
<version>1.0.0</version>
<version>2.1.1</version>
</dependency>
</dependencies>