Ocelots now sit on top of IronChests again!

This commit is contained in:
alexbegt 2016-06-11 22:36:20 -04:00
parent bb8cb4ff98
commit 4d145cd90b
2 changed files with 23 additions and 12 deletions

View File

@ -64,7 +64,7 @@ public class IronChest
ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation();
// FIXME: MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
MinecraftForge.EVENT_BUS.register(IronChestEventHandler.INSTANCE);
}
}

View File

@ -1,26 +1,37 @@
package cpw.mods.ironchest;
import java.util.HashSet;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class OcelotsSitOnChestsHandler
{
@SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt)
public void changeSittingTaskForOcelots(LivingUpdateEvent evt)
{
if (evt.getEntityLiving().ticksExisted < 5 && evt.getEntityLiving() instanceof EntityOcelot)
{
// EntityOcelot ocelot = (EntityOcelot) evt.entityLiving;
// Set<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries;
HashSet<EntityAITaskEntry> hashset = new HashSet<EntityAITaskEntry>();
// for (EntityAITasks.EntityAITaskEntry task : tasks)
// {
// if (task.priority == 6 && (task.action instanceof EntityAIOcelotSit) && !(task.action instanceof IronChestAIOcelotSit))
// {
// task.action = new IronChestAIOcelotSit(ocelot, 0.4F);
// }
// }
EntityOcelot ocelot = (EntityOcelot) evt.getEntityLiving();
for (EntityAITaskEntry task : ocelot.tasks.taskEntries)
{
if (task.action.getClass() == EntityAIOcelotSit.class)
{
hashset.add(task);
}
}
for (EntityAITaskEntry task : hashset)
{
ocelot.tasks.removeTask(task.action);
ocelot.tasks.addTask(task.priority, new IronChestAIOcelotSit(ocelot, 0.4F));
}
}
}
}