mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 17:04:24 +00:00
Prevent corrupt projectile entities to enter the world
This commit is contained in:
1 parent
455b92eb13
commit
44cede59cb
1 file changed
+13
@@ -8,8 +8,10 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.entity.ProjectileBase;
|
||||
import tconstruct.library.event.PartBuilderEvent;
|
||||
import tconstruct.library.event.SmelteryCastEvent;
|
||||
import tconstruct.library.util.IToolPart;
|
||||
@@ -415,4 +417,15 @@ public class WeaponryHandler {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void entityJoin(EntityJoinWorldEvent event) {
|
||||
// This prevents invalid projectiles to be created
|
||||
// This can happen because of ID remaps.
|
||||
if(event.entity instanceof ProjectileBase) {
|
||||
ProjectileBase projectile = (ProjectileBase) event.entity;
|
||||
if(projectile.returnStack == null || !(projectile.returnStack.getItem() instanceof ToolCore))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user