use of stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook in project MorePlanets by SteveKunG.
the class ClientProxyMP method handleSpaceFishHookSpawning.
private static void handleSpaceFishHookSpawning() {
EntityRegistration entityRegistration = EntityRegistry.instance().lookupModSpawn(EntitySpaceFishHook.class, false);
Function<EntitySpawnMessage, Entity> handler = input -> {
int entityID = 0;
double posX = 0;
double posY = 0;
double posZ = 0;
WorldClient world = FMLClientHandler.instance().getWorldClient();
try {
entityID = ReflectionHelper.findField(EntitySpawnMessage.class, "throwerId").getInt(input);
posX = ReflectionHelper.findField(EntitySpawnMessage.class, "rawX").getDouble(input);
posY = ReflectionHelper.findField(EntitySpawnMessage.class, "rawY").getDouble(input);
posZ = ReflectionHelper.findField(EntitySpawnMessage.class, "rawZ").getDouble(input);
} catch (Exception e) {
e.printStackTrace();
}
Entity angler = world.getEntityByID(entityID);
if (angler instanceof EntityPlayer) {
Entity entity = new EntitySpaceFishHook(world, (EntityPlayer) angler, posX, posY, posZ);
return entity;
}
return null;
};
entityRegistration.setCustomSpawning(handler, false);
}
use of stevekung.mods.moreplanets.entity.projectile.EntitySpaceFishHook in project MorePlanets by SteveKunG.
the class ItemSpaceFishingRod method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (player.fishEntity != null) {
int i = player.fishEntity.handleHookRetraction();
itemStack.damageItem(i, player);
player.swingArm(hand);
if (itemStack.hasTagCompound() && itemStack.getTagCompound().getBoolean("Cast")) {
itemStack.getTagCompound().setBoolean("Cast", false);
}
} else {
world.playSound((EntityPlayer) null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote) {
EntitySpaceFishHook entityfishhook = new EntitySpaceFishHook(world, player);
int lure = EnchantmentHelper.getFishingSpeedBonus(itemStack);
int luck = EnchantmentHelper.getFishingLuckBonus(itemStack);
if (lure > 0) {
entityfishhook.setLureSpeed(lure);
}
if (luck > 0) {
entityfishhook.setLuck(luck);
}
world.spawnEntity(entityfishhook);
}
if (itemStack.hasTagCompound()) {
itemStack.getTagCompound().setBoolean("Cast", true);
} else {
itemStack.setTagCompound(new NBTTagCompound());
itemStack.getTagCompound().setBoolean("Cast", true);
}
player.swingArm(hand);
player.addStat(StatList.getObjectUseStats(this));
}
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
}
Aggregations