diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java index 1e547ab..9ce0412 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllBlock.java @@ -17,6 +17,7 @@ public class AllBlock { public static final HashMap BlockItems = new HashMap<>(); public static Block MAGIC_WORKSTATION = new MagicWorkstation(FabricBlockSettings.of(Material.STONE).strength(50.0f, 1200.0f).luminance(state -> 10)); + @SuppressWarnings("SameParameterValue") private static void registerBlock(String name, Block block){ Registry.register(Registry.BLOCK,new Identifier(the_origin_of_magic.Mod_Id, name),block); BlockItems.put(name,new BlockItem(block,new FabricItemSettings().group(AllItem.TheOriginOfMagicItemGroup))); diff --git a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java index 3118e7a..940bb70 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/Contents/AllItem.java @@ -1,6 +1,5 @@ package com.ictye.the_origin_of_magic.Contents; -import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.HoglinEntityLimiter; import com.ictye.the_origin_of_magic.foundation.Items.Magic.LimiterItem.UndeadEntityLimiterItem; import com.ictye.the_origin_of_magic.foundation.Items.Magic.TestMagicEntityItem; import com.ictye.the_origin_of_magic.foundation.Items.Staff.DeadwoodStaff; diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/HoglinEntityLimiter.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/HostileEntityLimiter.java similarity index 67% rename from src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/HoglinEntityLimiter.java rename to src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/HostileEntityLimiter.java index 5de0e5d..55b7b00 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/HoglinEntityLimiter.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/HostileEntityLimiter.java @@ -1,15 +1,19 @@ package com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters; import net.minecraft.entity.mob.HoglinEntity; +import net.minecraft.entity.mob.ZombieEntity; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; import org.jetbrains.annotations.Nullable; -public class HoglinEntityLimiter extends StdMagicLimiter { +public class HostileEntityLimiter extends StdMagicLimiter { @Override public boolean canEffect(@Nullable EntityHitResult entityHitResult, @Nullable HitResult hitResult, @Nullable BlockHitResult blockHitResult) { // 判斷是否為亡靈生物 - return super.canEffect(entityHitResult, hitResult, blockHitResult) && entityHitResult.getEntity() != null && entityHitResult.getEntity() instanceof HoglinEntity; + if (entityHitResult != null) { + return entityHitResult.getEntity() instanceof ZombieEntity; + } + return false; } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/StdMagicLimiter.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/StdMagicLimiter.java index e1ed27f..7563651 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/StdMagicLimiter.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/Limiters/StdMagicLimiter.java @@ -1,12 +1,13 @@ package com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; import org.jetbrains.annotations.Nullable; //限制魔法,給魔法添加效果,限制魔法結果 -public class StdMagicLimiter { +public class StdMagicLimiter implements StdMagicInterface { public void onHit( @Nullable EntityHitResult entityHitResult, @Nullable HitResult hitResult, @Nullable BlockHitResult blockHitResult){ } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java index feee784..a93e1a3 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/StdThrownMagic.java @@ -77,10 +77,12 @@ protected void onCollision(HitResult hitResult) { HitResult.Type type = hitResult.getType(); if (type == HitResult.Type.ENTITY) { if (hitResult instanceof EntityHitResult && !(limiter.canEffect((EntityHitResult) hitResult, hitResult, null))) { + this.remove(RemovalReason.CHANGED_DIMENSION); return; } } else if (type == HitResult.Type.BLOCK) { if (hitResult instanceof BlockHitResult && !(limiter.canEffect(null, hitResult, (BlockHitResult) hitResult))) { + this.remove(RemovalReason.CHANGED_DIMENSION); return; } } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/TestThrownMagic.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/TestThrownMagic.java index 4d2b1c9..289043c 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/TestThrownMagic.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Entitys/Magics/TestThrownMagic.java @@ -41,6 +41,9 @@ protected void collision(HitResult hitResult) { /* * 撞擊后爆炸~ * */ + if (this.world.isClient){ + return; + } BlockPos pos = new BlockPos(hitResult.getPos()); this.world.createExplosion(this, pos.getX(), pos.getY(), pos.getZ(), 5.0F * exolisionRate, Explosion.DestructionType.BREAK); this.remove(RemovalReason.CHANGED_DIMENSION); diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java index f3fd21c..b613814 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/StdLimiterItem.java @@ -11,11 +11,4 @@ public abstract class StdLimiterItem extends StdMagicItem { public StdLimiterItem(Settings settings, EntityType entityType) { super(settings, entityType); } - - @Override - public StdThrownMagic getMagic(PlayerEntity user, World world, float exolisionRate, int hartRate) { - return null; - } - - public abstract StdMagicLimiter getMagic(); } diff --git a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java index 06a747f..09bd023 100644 --- a/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java +++ b/src/main/java/com/ictye/the_origin_of_magic/foundation/Items/Magic/LimiterItem/UndeadEntityLimiterItem.java @@ -1,17 +1,21 @@ package com.ictye.the_origin_of_magic.foundation.Items.Magic.LimiterItem; -import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.HoglinEntityLimiter; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.HostileEntityLimiter; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.Limiters.StdMagicLimiter; +import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdMagicInterface; import com.ictye.the_origin_of_magic.foundation.Entitys.Magics.StdThrownMagic; import net.minecraft.entity.EntityType; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.world.World; public class UndeadEntityLimiterItem extends StdLimiterItem{ public UndeadEntityLimiterItem(Settings settings, EntityType entityType) { super(settings, entityType); } + @Override - public StdMagicLimiter getMagic() { - return new HoglinEntityLimiter(); + public StdMagicInterface getMagic(PlayerEntity user, World world, float exolisionRate, int hartRate) { + return new HostileEntityLimiter(); } }