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(); ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation(); proxy.registerRenderInformation();
// FIXME: MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler()); MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
MinecraftForge.EVENT_BUS.register(IronChestEventHandler.INSTANCE); MinecraftForge.EVENT_BUS.register(IronChestEventHandler.INSTANCE);
} }
} }

View File

@ -1,26 +1,37 @@
package cpw.mods.ironchest; 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.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; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class OcelotsSitOnChestsHandler public class OcelotsSitOnChestsHandler
{ {
@SubscribeEvent @SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt) public void changeSittingTaskForOcelots(LivingUpdateEvent evt)
{ {
if (evt.getEntityLiving().ticksExisted < 5 && evt.getEntityLiving() instanceof EntityOcelot) if (evt.getEntityLiving().ticksExisted < 5 && evt.getEntityLiving() instanceof EntityOcelot)
{ {
// EntityOcelot ocelot = (EntityOcelot) evt.entityLiving; HashSet<EntityAITaskEntry> hashset = new HashSet<EntityAITaskEntry>();
// Set<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries;
// for (EntityAITasks.EntityAITaskEntry task : tasks) EntityOcelot ocelot = (EntityOcelot) evt.getEntityLiving();
// {
// if (task.priority == 6 && (task.action instanceof EntityAIOcelotSit) && !(task.action instanceof IronChestAIOcelotSit)) for (EntityAITaskEntry task : ocelot.tasks.taskEntries)
// { {
// task.action = new IronChestAIOcelotSit(ocelot, 0.4F); 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));
}
} }
} }
} }