Skip to content

Commit

Permalink
Prevent corrupt projectile entities to enter the world
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed May 10, 2015
1 parent 455b92e commit 44cede5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryHandler.java
Expand Up @@ -8,8 +8,10 @@
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;
Expand Down Expand Up @@ -415,4 +417,15 @@ public void boneanaBuilding(ToolCraftEvent.NormalTool event) {
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);
}
}
}

0 comments on commit 44cede5

Please sign in to comment.