mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
Switch from forge item use tick callback to vanilla's
This commit is contained in:
1 parent
4a8661bcac
commit
ecadc618f7
12 files changed
+52
-50
No files matched your search
@@ -132,8 +132,8 @@ public class ItemCacophonium extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity player, int count) {
|
||||
if (count % (isDOIT(stack) ? 20 : 6) == 0) {
|
||||
public void onUse(World world, @Nonnull LivingEntity player, @Nonnull ItemStack stack, int count) {
|
||||
if (!world.isRemote && count % (isDOIT(stack) ? 20 : 6) == 0) {
|
||||
playSound(player.world, stack, player.getPosX(), player.getPosY(), player.getPosZ(), SoundCategory.PLAYERS, 0.9F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ public class ItemHorn extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity player, int time) {
|
||||
if (!player.world.isRemote) {
|
||||
public void onUse(World world, @Nonnull LivingEntity player, @Nonnull ItemStack stack, int time) {
|
||||
if (!world.isRemote) {
|
||||
if (time != getUseDuration(stack) && time % 5 == 0) {
|
||||
breakGrass(player.world, stack, player.func_233580_cy_());
|
||||
breakGrass(world, stack, player.func_233580_cy_());
|
||||
}
|
||||
player.world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.BLOCKS, 1F, 0.001F);
|
||||
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_NOTE_BLOCK_BASS, SoundCategory.BLOCKS, 1F, 0.001F);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +76,10 @@ public class ItemSextant extends Item {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
public void onUse(World world, LivingEntity living, ItemStack stack, int count) {
|
||||
if (getUseDuration(stack) - count < 10
|
||||
|| !(living instanceof PlayerEntity)) {
|
||||
|| !(living instanceof PlayerEntity)
|
||||
|| world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ public class ItemSextant extends Item {
|
||||
if (y != -1) {
|
||||
Vector3 source = new Vector3(x, y, z);
|
||||
|
||||
double radius = calculateRadius(stack, (PlayerEntity) living);
|
||||
double radius = calculateRadius(stack, living);
|
||||
|
||||
if (count % 10 == 0) {
|
||||
WispParticleData data = WispParticleData.wisp(0.3F, 0F, 1F, 1F, 1);
|
||||
@@ -96,7 +97,7 @@ public class ItemSextant extends Item {
|
||||
float radian = (float) (i * Math.PI / 180);
|
||||
double xp = x + Math.cos(radian) * radius;
|
||||
double zp = z + Math.sin(radian) * radius;
|
||||
living.world.addParticle(data, xp + 0.5, source.y + 1, zp + 0.5, 0, - -0.01F, 0);
|
||||
world.addParticle(data, xp + 0.5, source.y + 1, zp + 0.5, 0, - -0.01F, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ public class ItemSextant extends Item {
|
||||
return;
|
||||
}
|
||||
|
||||
double radius = calculateRadius(stack, (PlayerEntity) living);
|
||||
double radius = calculateRadius(stack, living);
|
||||
if (1 < radius && radius <= MAX_RADIUS) {
|
||||
IStateMatcher matcher = PatchouliAPI.instance.predicateMatcher(Blocks.COBBLESTONE, s -> !s.isAir());
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
|
||||
@@ -162,17 +163,17 @@ public class ItemSextant extends Item {
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
private static double calculateRadius(ItemStack stack, PlayerEntity player) {
|
||||
private static double calculateRadius(ItemStack stack, LivingEntity living) {
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SOURCE_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SOURCE_Y, -1);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SOURCE_Z, 0);
|
||||
Vector3 source = new Vector3(x, y, z);
|
||||
WispParticleData data = WispParticleData.wisp(0.2F, 1F, 0F, 0F, 1);
|
||||
player.world.addParticle(data, source.x + 0.5, source.y + 1, source.z + 0.5, 0, - -0.1F, 0);
|
||||
living.world.addParticle(data, source.x + 0.5, source.y + 1, source.z + 0.5, 0, - -0.1F, 0);
|
||||
|
||||
Vector3 centerVec = Vector3.fromEntityCenter(player);
|
||||
Vector3 centerVec = Vector3.fromEntityCenter(living);
|
||||
Vector3 diffVec = source.subtract(centerVec);
|
||||
Vector3 lookVec = new Vector3(player.getLookVec());
|
||||
Vector3 lookVec = new Vector3(living.getLookVec());
|
||||
double mul = diffVec.y / lookVec.y;
|
||||
lookVec = lookVec.multiply(mul).add(centerVec);
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.core.helper.AccessoryRenderHelper;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.client.core.helper.AccessoryRenderHelper;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.fx.SparkleParticleData;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
|
||||
@@ -26,9 +26,9 @@ import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
import vazkii.botania.client.core.helper.AccessoryRenderHelper;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.helper.AccessoryRenderHelper;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.core.handler.EquipmentHandler;
|
||||
|
||||
|
||||
+3
-3
@@ -56,15 +56,15 @@ public class ItemElementiumShears extends ItemManasteelShears {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
if (living.world.isRemote) {
|
||||
public void onUse(World world, @Nonnull LivingEntity living, @Nonnull ItemStack stack, int count) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (count != getUseDuration(stack) && count % 5 == 0) {
|
||||
int range = 12;
|
||||
Predicate<Entity> shearablePred = e -> e instanceof IShearable || e instanceof IForgeShearable;
|
||||
List<Entity> shearable = living.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.getPosX() - range, living.getPosY() - range, living.getPosZ() - range, living.getPosX() + range, living.getPosY() + range, living.getPosZ() + range), shearablePred);
|
||||
List<Entity> shearable = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(living.getPosX() - range, living.getPosY() - range, living.getPosZ() - range, living.getPosX() + range, living.getPosY() + range, living.getPosZ() + range), shearablePred);
|
||||
if (shearable.size() > 0) {
|
||||
for (Entity entity : shearable) {
|
||||
if (entity instanceof IShearable && ((IShearable) entity).func_230262_K__()) {
|
||||
|
||||
@@ -76,12 +76,14 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
float x = (float) (living.getPosX() - Math.random() * living.getWidth());
|
||||
float y = (float) (living.getPosY() + Math.random());
|
||||
float z = (float) (living.getPosZ() - Math.random() * living.getWidth());
|
||||
WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.7F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
|
||||
living.world.addParticle(data, x, y, z, 0, 0.05F + (float) Math.random() * 0.05F, 0);
|
||||
public void onUse(World world, LivingEntity living, ItemStack stack, int count) {
|
||||
if (world.isRemote) {
|
||||
float x = (float) (living.getPosX() - Math.random() * living.getWidth());
|
||||
float y = (float) (living.getPosY() + Math.random());
|
||||
float z = (float) (living.getPosZ() - Math.random() * living.getWidth());
|
||||
WispParticleData data = WispParticleData.wisp((float) Math.random() * 0.7F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
|
||||
world.addParticle(data, x, y, z, 0, 0.05F + (float) Math.random() * 0.05F, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -54,8 +54,7 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
super.onUsingTick(stack, living, count);
|
||||
public void onUse(@Nonnull World world, @Nonnull LivingEntity living, @Nonnull ItemStack stack, int count) {
|
||||
if (!(living instanceof PlayerEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
public void onUse(World world, LivingEntity living, ItemStack stack, int count) {
|
||||
int spawned = getWeaponsSpawned(stack);
|
||||
|
||||
if (count != getUseDuration(stack) && spawned < 20 && !living.world.isRemote && (!(living instanceof PlayerEntity) || ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) living, 150, true))) {
|
||||
if (count != getUseDuration(stack) && spawned < 20 && !world.isRemote && (!(living instanceof PlayerEntity) || ManaItemHandler.instance().requestManaExact(stack, (PlayerEntity) living, 150, true))) {
|
||||
Vector3 look = new Vector3(living.getLookVec()).multiply(1, 0, 1);
|
||||
|
||||
double playerRot = Math.toRadians(living.rotationYaw + 90);
|
||||
@@ -78,7 +78,7 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
|
||||
|
||||
Vector3 pl = look.add(Vector3.fromEntityCenter(living)).add(0, 1.6, div * 0.1);
|
||||
|
||||
Random rand = living.world.rand;
|
||||
Random rand = world.rand;
|
||||
Vector3 axis = look.normalize().crossProduct(new Vector3(-1, 0, -1)).normalize();
|
||||
|
||||
double rot = mod * Math.PI / 4 - Math.PI / 2;
|
||||
@@ -90,15 +90,15 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
|
||||
|
||||
Vector3 end = pl.add(axis1);
|
||||
|
||||
EntityBabylonWeapon weapon = new EntityBabylonWeapon(living, living.world);
|
||||
EntityBabylonWeapon weapon = new EntityBabylonWeapon(living, world);
|
||||
weapon.setPosition(end.x, end.y, end.z);
|
||||
weapon.rotationYaw = living.rotationYaw;
|
||||
weapon.setVariety(rand.nextInt(WEAPON_TYPES));
|
||||
weapon.setDelay(spawned);
|
||||
weapon.setRotation(MathHelper.wrapDegrees(-living.rotationYaw + 180));
|
||||
|
||||
living.world.addEntity(weapon);
|
||||
weapon.playSound(ModSounds.babylonSpawn, 1F, 1F + living.world.rand.nextFloat() * 3F);
|
||||
world.addEntity(weapon);
|
||||
weapon.playSound(ModSounds.babylonSpawn, 1F, 1F + world.rand.nextFloat() * 3F);
|
||||
setWeaponsSpawned(stack, spawned + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +55,19 @@ public class ItemMissileRod extends Item implements IManaUsingItem, IAvatarWield
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
public void onUse(World world, LivingEntity living, ItemStack stack, int count) {
|
||||
if (!(living instanceof PlayerEntity)) {
|
||||
return;
|
||||
}
|
||||
PlayerEntity player = (PlayerEntity) living;
|
||||
|
||||
if (count != getUseDuration(stack) && count % (IManaProficiencyArmor.hasProficiency(player, stack) ? 1 : 2) == 0 && !player.world.isRemote && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
if (spawnMissile(player.world, player, player.getPosX() + (Math.random() - 0.5 * 0.1), player.getPosY() + 2.4 + (Math.random() - 0.5 * 0.1), player.getPosZ() + (Math.random() - 0.5 * 0.1))) {
|
||||
if (count != getUseDuration(stack) && count % (IManaProficiencyArmor.hasProficiency(player, stack) ? 1 : 2) == 0 && !world.isRemote && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST_PER, false)) {
|
||||
if (spawnMissile(world, player, player.getPosX() + (Math.random() - 0.5 * 0.1), player.getPosY() + 2.4 + (Math.random() - 0.5 * 0.1), player.getPosZ() + (Math.random() - 0.5 * 0.1))) {
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, player, COST_PER, true);
|
||||
}
|
||||
|
||||
SparkleParticleData data = SparkleParticleData.sparkle(6F, 1F, 0.4F, 1F, 6);
|
||||
player.world.addParticle(data, player.getPosX(), player.getPosY() + 2.4, player.getPosZ(), 0, 0, 0);
|
||||
world.addParticle(data, player.getPosX(), player.getPosY() + 2.4, player.getPosZ(), 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int time) {
|
||||
public void onUse(World world, LivingEntity living, ItemStack stack, int time) {
|
||||
if (!(living instanceof PlayerEntity)) {
|
||||
return;
|
||||
}
|
||||
@@ -84,10 +84,10 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
BlockRayTraceResult pos = ToolCommons.raytraceFromEntity(p, 32, false);
|
||||
|
||||
if (pos.getType() == RayTraceResult.Type.BLOCK) {
|
||||
BlockState state = p.world.getBlockState(pos.getPos());
|
||||
BlockState state = world.getBlockState(pos.getPos());
|
||||
|
||||
dummyInv.setInventorySlotContents(0, new ItemStack(state.getBlock()));
|
||||
Optional<ItemStack> maybeResult = p.world.getRecipeManager()
|
||||
Optional<ItemStack> maybeResult = world.getRecipeManager()
|
||||
.getRecipe(IRecipeType.SMELTING, dummyInv, p.world)
|
||||
.map(r -> r.getCraftingResult(dummyInv));
|
||||
|
||||
@@ -104,10 +104,10 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
data.progress--;
|
||||
decremented = true;
|
||||
if (data.progress <= 0) {
|
||||
if (!p.world.isRemote) {
|
||||
p.world.setBlockState(pos.getPos(), Block.getBlockFromItem(result.getItem()).getDefaultState());
|
||||
p.world.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F);
|
||||
p.world.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
|
||||
if (!world.isRemote) {
|
||||
world.setBlockState(pos.getPos(), Block.getBlockFromItem(result.getItem()).getDefaultState());
|
||||
world.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F);
|
||||
world.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
|
||||
|
||||
ManaItemHandler.instance().requestManaExactForTool(stack, p, COST_PER_TICK, true);
|
||||
playerData.remove(p);
|
||||
@@ -119,7 +119,7 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
double x = pos.getPos().getX() + Math.random();
|
||||
double y = pos.getPos().getY() + Math.random();
|
||||
double z = pos.getPos().getZ() + Math.random();
|
||||
p.world.addParticle(data1, x, y, z, 0, (float) -Math.random() / 10F, 0);
|
||||
world.addParticle(data1, x, y, z, 0, (float) -Math.random() / 10F, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,10 +133,10 @@ public class ItemSmeltRod extends Item implements IManaUsingItem {
|
||||
double y = pos.getPos().getY() + Math.random();
|
||||
double z = pos.getPos().getZ() + Math.random();
|
||||
WispParticleData data = WispParticleData.wisp(0.5F, 1F, 0.2F, 0.2F, 1);
|
||||
p.world.addParticle(data, x, y, z, 0, (float) Math.random() / 10F, 0);
|
||||
world.addParticle(data, x, y, z, 0, (float) Math.random() / 10F, 0);
|
||||
}
|
||||
if (time % 10 == 0) {
|
||||
p.world.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, (float) Math.random() / 2F + 0.5F, 1F);
|
||||
world.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, (float) Math.random() / 2F + 0.5F, 1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ public class ItemTerraformRod extends Item implements IManaUsingItem, IBlockProv
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
|
||||
public void onUse(@Nonnull World world, @Nonnull LivingEntity living, @Nonnull ItemStack stack, int count) {
|
||||
if (count != getUseDuration(stack) && count % 10 == 0 && living instanceof PlayerEntity) {
|
||||
terraform(stack, living.world, (PlayerEntity) living);
|
||||
terraform(stack, world, (PlayerEntity) living);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user