more random fixes

This commit is contained in:
Vincent Lee committed 2019-06-25 21:04:36 -07:00
1 parent e7dc900634
commit 207a66b121
53 files changed
+465 -435

No files matched your search

@@ -12,17 +12,16 @@ package vazkii.botania.common;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MultiPartEntityPart;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.boss.dragon.EnderDragonEntity;
import net.minecraft.entity.boss.WitherEntity;
import net.minecraft.entity.boss.dragon.EnderDragonPartEntity;
import net.minecraft.entity.item.EnderCrystalEntity;
import net.minecraft.entity.item.EnderCrystalEntity;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.item.PaintingEntity;
import net.minecraft.entity.item.ItemFrameEntity;
import net.minecraft.entity.item.PaintingEntity;
import net.minecraft.item.crafting.RecipeSerializers;
import net.minecraft.world.storage.loot.conditions.LootConditionManager;
import net.minecraft.world.storage.loot.functions.LootFunctionManager;
import net.minecraftforge.common.MinecraftForge;
@@ -195,24 +194,6 @@ public class Botania {
CriteriaTriggers.register(RelicBindTrigger.INSTANCE);
CriteriaTriggers.register(UseItemSuccessTrigger.INSTANCE);
RecipeSerializers.register(AncientWillRecipe.SERIALIZER);
RecipeSerializers.register(ArmorUpgradeRecipe.SERIALIZER);
RecipeSerializers.register(BlackHoleTalismanExtractRecipe.SERIALIZER);
RecipeSerializers.register(CompositeLensRecipe.SERIALIZER);
RecipeSerializers.register(CosmeticAttachRecipe.SERIALIZER);
RecipeSerializers.register(CosmeticRemoveRecipe.SERIALIZER);
RecipeSerializers.register(HelmRevealingRecipe.SERIALIZER);
RecipeSerializers.register(KeepIvyRecipe.SERIALIZER);
RecipeSerializers.register(LensDyeingRecipe.SERIALIZER);
RecipeSerializers.register(ManaGunClipRecipe.SERIALIZER);
RecipeSerializers.register(ManaGunLensRecipe.SERIALIZER);
RecipeSerializers.register(ManaGunRemoveLensRecipe.SERIALIZER);
RecipeSerializers.register(ManaUpgradeRecipe.SERIALIZER);
RecipeSerializers.register(ShapelessManaUpgradeRecipe.SERIALIZER);
RecipeSerializers.register(PhantomInkRecipe.SERIALIZER);
RecipeSerializers.register(SpellClothRecipe.SERIALIZER);
RecipeSerializers.register(TerraPickTippingRecipe.SERIALIZER);
CraftingHelper.register(FluxfieldConditionFactory.KEY, new FluxfieldConditionFactory());
ModBlocks.addDispenserBehaviours();
@@ -294,7 +275,7 @@ public class Botania {
private void registerDefaultEntityBlacklist() {
// Vanilla
BotaniaAPI.blacklistEntityFromGravityRod(EnderDragonEntity.class);
BotaniaAPI.blacklistEntityFromGravityRod(MultiPartEntityPart.class);
BotaniaAPI.blacklistEntityFromGravityRod(EnderDragonPartEntity.class);
BotaniaAPI.blacklistEntityFromGravityRod(WitherEntity.class);
BotaniaAPI.blacklistEntityFromGravityRod(ItemFrameEntity.class);
BotaniaAPI.blacklistEntityFromGravityRod(EnderCrystalEntity.class);
@@ -28,7 +28,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class AncientWillRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "ancient_will_attach");
public static final IRecipeSerializer<AncientWillRecipe> SERIALIZER = new SpecialRecipeSerializer<>(AncientWillRecipe::new);
public AncientWillRecipe(ResourceLocation id) {
@@ -16,22 +16,22 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.RecipeSerializers;
import net.minecraft.item.crafting.ShapedRecipe;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistryEntry;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ArmorUpgradeRecipe implements IRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "armor_upgrade");
public class ArmorUpgradeRecipe implements ICraftingRecipe {
private final ShapedRecipe compose;
public ArmorUpgradeRecipe(ShapedRecipe compose) {
@@ -39,13 +39,13 @@ public class ArmorUpgradeRecipe implements IRecipe {
}
@Override
public boolean matches(@Nonnull IInventory inv, @Nonnull World world) {
public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) {
return compose.matches(inv, world);
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull IInventory inv) {
public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) {
ItemStack out = compose.getCraftingResult(inv);
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
@@ -88,26 +88,22 @@ public class ArmorUpgradeRecipe implements IRecipe {
return SERIALIZER;
}
public static final IRecipeSerializer<ArmorUpgradeRecipe> SERIALIZER = new IRecipeSerializer<ArmorUpgradeRecipe>() {
public static final IRecipeSerializer<ArmorUpgradeRecipe> SERIALIZER = new Serializer();
private static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<ArmorUpgradeRecipe> {
@Override
public ArmorUpgradeRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
return new ArmorUpgradeRecipe(RecipeSerializers.CRAFTING_SHAPED.read(recipeId, json));
return new ArmorUpgradeRecipe(IRecipeSerializer.CRAFTING_SHAPED.read(recipeId, json));
}
@Override
public ArmorUpgradeRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
return new ArmorUpgradeRecipe(RecipeSerializers.CRAFTING_SHAPED.read(recipeId, buffer));
return new ArmorUpgradeRecipe(IRecipeSerializer.CRAFTING_SHAPED.read(recipeId, buffer));
}
@Override
public void write(@Nonnull PacketBuffer buffer, @Nonnull ArmorUpgradeRecipe recipe) {
RecipeSerializers.CRAFTING_SHAPED.write(buffer, recipe.compose);
}
@Nonnull
@Override
public ResourceLocation getName() {
return TYPE_ID;
IRecipeSerializer.CRAFTING_SHAPED.write(buffer, recipe.compose);
}
};
}
@@ -28,7 +28,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class BlackHoleTalismanExtractRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "black_hole_talisman_extract");
public static final IRecipeSerializer<BlackHoleTalismanExtractRecipe> SERIALIZER = new SpecialRecipeSerializer<>(BlackHoleTalismanExtractRecipe::new);
public BlackHoleTalismanExtractRecipe(ResourceLocation id) {
@@ -29,7 +29,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class CompositeLensRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "composite_lens");
public static final IRecipeSerializer<CompositeLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CompositeLensRecipe::new);
public CompositeLensRecipe(ResourceLocation id) {
@@ -28,7 +28,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class CosmeticAttachRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "cosmetic_attach");
public static final IRecipeSerializer<CosmeticAttachRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CosmeticAttachRecipe::new);
public CosmeticAttachRecipe(ResourceLocation id) {
@@ -27,7 +27,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class CosmeticRemoveRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "cosmetic_remove");
public static final IRecipeSerializer<CosmeticRemoveRecipe> SERIALIZER = new SpecialRecipeSerializer<>(CosmeticRemoveRecipe::new);
public CosmeticRemoveRecipe(ResourceLocation id) {
@@ -15,10 +15,10 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.RecipeSerializers;
import net.minecraft.item.crafting.ShapelessRecipe;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.ListNBT;
@@ -27,6 +27,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.item.ModItems;
@@ -34,9 +35,7 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class HelmRevealingRecipe implements IRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "helm_revealing");
public class HelmRevealingRecipe implements ICraftingRecipe {
private final ShapelessRecipe compose;
public HelmRevealingRecipe(ShapelessRecipe compose) {
@@ -44,13 +43,13 @@ public class HelmRevealingRecipe implements IRecipe {
}
@Override
public boolean matches(@Nonnull IInventory inv, @Nonnull World world) {
public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) {
return compose.matches(inv, world);
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull IInventory inv) {
public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) {
ItemStack helm = ItemStack.EMPTY;
for(int i = 0; i < inv.getSizeInventory(); i++) {
@@ -134,27 +133,23 @@ public class HelmRevealingRecipe implements IRecipe {
ItemNBTHelper.setList(destination, TAG_INFUSION_ENCH, infEnchList);
}
public static final IRecipeSerializer<HelmRevealingRecipe> SERIALIZER = new IRecipeSerializer<HelmRevealingRecipe>() {
public static final IRecipeSerializer<HelmRevealingRecipe> SERIALIZER = new Serializer();
private static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<HelmRevealingRecipe> {
@Nonnull
@Override
public HelmRevealingRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
return new HelmRevealingRecipe(RecipeSerializers.CRAFTING_SHAPELESS.read(recipeId, json));
return new HelmRevealingRecipe(IRecipeSerializer.CRAFTING_SHAPELESS.read(recipeId, json));
}
@Override
public HelmRevealingRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
return new HelmRevealingRecipe(RecipeSerializers.CRAFTING_SHAPELESS.read(recipeId, buffer));
return new HelmRevealingRecipe(IRecipeSerializer.CRAFTING_SHAPELESS.read(recipeId, buffer));
}
@Override
public void write(@Nonnull PacketBuffer buffer, @Nonnull HelmRevealingRecipe recipe) {
RecipeSerializers.CRAFTING_SHAPELESS.write(buffer, recipe.compose);
}
@Nonnull
@Override
public ResourceLocation getName() {
return TYPE_ID;
IRecipeSerializer.CRAFTING_SHAPELESS.write(buffer, recipe.compose);
}
};
}
@@ -29,7 +29,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class KeepIvyRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "keep_ivy");
public static final IRecipeSerializer<KeepIvyRecipe> SERIALIZER = new SpecialRecipeSerializer<>(KeepIvyRecipe::new);
public KeepIvyRecipe(ResourceLocation id) {
@@ -30,7 +30,6 @@ import java.util.Arrays;
import java.util.List;
public class LensDyeingRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "lens_dye");
public static final IRecipeSerializer<LensDyeingRecipe> SERIALIZER = new SpecialRecipeSerializer<>(LensDyeingRecipe::new);
private final List<Ingredient> dyes = Arrays.asList(
@@ -28,7 +28,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ManaGunClipRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "mana_gun_add_clip");
public static final IRecipeSerializer<ManaGunClipRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunClipRecipe::new);
public ManaGunClipRecipe(ResourceLocation id) {
@@ -29,7 +29,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ManaGunLensRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "mana_gun_add_lens");
public static final IRecipeSerializer<ManaGunLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunLensRecipe::new);
public ManaGunLensRecipe(ResourceLocation id) {
@@ -27,7 +27,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ManaGunRemoveLensRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "mana_gun_remove_lens");
public static final IRecipeSerializer<ManaGunRemoveLensRecipe> SERIALIZER = new SpecialRecipeSerializer<>(ManaGunRemoveLensRecipe::new);
public ManaGunRemoveLensRecipe(ResourceLocation id) {
@@ -11,8 +11,10 @@
package vazkii.botania.common.crafting.recipe;
import com.google.gson.JsonObject;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
@@ -21,13 +23,13 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistryEntry;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ManaUpgradeRecipe implements IRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "mana_upgrade");
public class ManaUpgradeRecipe implements ICraftingRecipe {
private final ShapedRecipe compose;
public ManaUpgradeRecipe(ShapedRecipe compose) {
@@ -52,13 +54,13 @@ public class ManaUpgradeRecipe implements IRecipe {
}
@Override
public boolean matches(@Nonnull IInventory inv, @Nonnull World world) {
public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) {
return compose.matches(inv, world);
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull IInventory inv) {
public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) {
return output(compose.getCraftingResult(inv), inv);
}
@@ -91,26 +93,22 @@ public class ManaUpgradeRecipe implements IRecipe {
return SERIALIZER;
}
public static final IRecipeSerializer<ManaUpgradeRecipe> SERIALIZER = new IRecipeSerializer<ManaUpgradeRecipe>() {
public static final IRecipeSerializer<ManaUpgradeRecipe> SERIALIZER = new Serializer();
private static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<ManaUpgradeRecipe> {
@Override
public ManaUpgradeRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
return new ManaUpgradeRecipe(RecipeSerializers.CRAFTING_SHAPED.read(recipeId, json));
return new ManaUpgradeRecipe(IRecipeSerializer.CRAFTING_SHAPED.read(recipeId, json));
}
@Override
public ManaUpgradeRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
return new ManaUpgradeRecipe(RecipeSerializers.CRAFTING_SHAPED.read(recipeId, buffer));
return new ManaUpgradeRecipe(IRecipeSerializer.CRAFTING_SHAPED.read(recipeId, buffer));
}
@Override
public void write(@Nonnull PacketBuffer buffer, ManaUpgradeRecipe recipe) {
RecipeSerializers.CRAFTING_SHAPED.write(buffer, recipe.compose);
}
@Nonnull
@Override
public ResourceLocation getName() {
return TYPE_ID;
IRecipeSerializer.CRAFTING_SHAPED.write(buffer, recipe.compose);
}
};
}
@@ -27,7 +27,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class PhantomInkRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "phantom_ink_apply");
public static final IRecipeSerializer<PhantomInkRecipe> SERIALIZER = new SpecialRecipeSerializer<>(PhantomInkRecipe::new);
public PhantomInkRecipe(ResourceLocation id) {
@@ -11,37 +11,37 @@
package vazkii.botania.common.crafting.recipe;
import com.google.gson.JsonObject;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.RecipeSerializers;
import net.minecraft.item.crafting.ShapelessRecipe;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.registries.ForgeRegistryEntry;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class ShapelessManaUpgradeRecipe implements IRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "mana_upgrade_shapeless");
public class ShapelessManaUpgradeRecipe implements ICraftingRecipe {
private final ShapelessRecipe compose;
public ShapelessManaUpgradeRecipe(ShapelessRecipe compose) {
this.compose = compose;
}
@Override
public boolean matches(@Nonnull IInventory inv, @Nonnull World world) {
public boolean matches(@Nonnull CraftingInventory inv, @Nonnull World world) {
return compose.matches(inv, world);
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull IInventory inv) {
public ItemStack getCraftingResult(@Nonnull CraftingInventory inv) {
return ManaUpgradeRecipe.output(compose.getCraftingResult(inv), inv);
}
@@ -74,30 +74,25 @@ public class ShapelessManaUpgradeRecipe implements IRecipe {
return SERIALIZER;
}
public static final IRecipeSerializer<ShapelessManaUpgradeRecipe> SERIALIZER = new IRecipeSerializer<ShapelessManaUpgradeRecipe>() {
public static final IRecipeSerializer<ShapelessManaUpgradeRecipe> SERIALIZER = new Serializer();
private static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<ShapelessManaUpgradeRecipe> {
@Nonnull
@Override
public ShapelessManaUpgradeRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json) {
return new ShapelessManaUpgradeRecipe(RecipeSerializers.CRAFTING_SHAPELESS.read(recipeId, json));
return new ShapelessManaUpgradeRecipe(IRecipeSerializer.CRAFTING_SHAPELESS.read(recipeId, json));
}
@Nonnull
@Override
public ShapelessManaUpgradeRecipe read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer) {
return new ShapelessManaUpgradeRecipe(RecipeSerializers.CRAFTING_SHAPELESS.read(recipeId, buffer));
return new ShapelessManaUpgradeRecipe(IRecipeSerializer.CRAFTING_SHAPELESS.read(recipeId, buffer));
}
@SuppressWarnings("unchecked")
@Override
public void write(@Nonnull PacketBuffer buffer, @Nonnull ShapelessManaUpgradeRecipe recipe) {
IRecipeSerializer<ShapelessRecipe> compose = (IRecipeSerializer<ShapelessRecipe>) recipe.compose.getSerializer();
compose.write(buffer, recipe.compose);
IRecipeSerializer.CRAFTING_SHAPELESS.write(buffer, recipe.compose);
}
@Nonnull
@Override
public ResourceLocation getName() {
return TYPE_ID;
}
};
}
}
@@ -28,7 +28,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class SpellClothRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "spell_cloth_apply");
public static final IRecipeSerializer<SpellClothRecipe> SERIALIZER = new SpecialRecipeSerializer<>(SpellClothRecipe::new);
public SpellClothRecipe(ResourceLocation id) {
@@ -30,7 +30,6 @@ import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class TerraPickTippingRecipe extends SpecialRecipe {
private static final ResourceLocation TYPE_ID = new ResourceLocation(LibMisc.MOD_ID, "terra_pick_tipping");
public static final IRecipeSerializer<TerraPickTippingRecipe> SERIALIZER = new SpecialRecipeSerializer<>(TerraPickTippingRecipe::new);
public TerraPickTippingRecipe(ResourceLocation id) {
@@ -22,6 +22,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
@@ -40,7 +41,7 @@ import java.util.List;
public class EntityBabylonWeapon extends EntityThrowableCopy {
@ObjectHolder(LibMisc.MOD_ID + ":babylon_weapon")
public static EntityType<?> TYPE;
public static EntityType<EntityBabylonWeapon> TYPE;
private static final String TAG_CHARGING = "charging";
private static final String TAG_VARIETY = "variety";
@@ -66,9 +67,6 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
@Override
protected void registerData() {
super.registerData();
setSize(0F, 0F);
dataManager.register(CHARGING, false);
dataManager.register(VARIETY, 0);
dataManager.register(CHARGE_TICKS, 0);
@@ -109,9 +107,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
charging &= liveTime == 0;
if(charging) {
motionX = 0;
motionY = 0;
motionZ = 0;
setMotion(Vec3d.ZERO);
int chargeTime = getChargeTicks();
setChargeTicks(chargeTime + 1);
@@ -120,9 +116,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
world.playSound(null, posX, posY, posZ, ModSounds.babylonSpawn, SoundCategory.PLAYERS, 0.1F, 1F + world.rand.nextFloat() * 3F);
} else {
if(liveTime < delay) {
motionX = 0;
motionY = 0;
motionZ = 0;
setMotion(Vec3d.ZERO);
} else if (liveTime == delay && player != null) {
Vector3 playerLook;
RayTraceResult lookat = ToolCommons.raytraceFromEntity(world, player, true, 64);
@@ -9,11 +9,17 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.projectile.ProjectileHelper;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.network.IPacket;
import net.minecraft.network.play.server.SSpawnObjectPacket;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.ServerWorld;
@@ -22,37 +28,29 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public abstract class EntityThrowableCopy extends Entity implements IProjectile {
private int xTile;
private int yTile;
private int zTile;
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
protected boolean inGround;
public int throwableShake;
/** The entity that threw this throwable item. */
protected LivingEntity thrower;
private UUID field_200218_h;
public Entity ignoreEntity;
protected LivingEntity owner;
private UUID ownerId;
private Entity ignoreEntity;
private int ignoreTime;
protected EntityThrowableCopy(EntityType<?> type, World p_i48540_2_) {
super(type, p_i48540_2_);
this.xTile = -1;
this.yTile = -1;
this.zTile = -1;
this.setSize(0.25F, 0.25F);
protected EntityThrowableCopy(EntityType<? extends EntityThrowableCopy> type, World worldIn) {
super(type, worldIn);
}
protected EntityThrowableCopy(EntityType<?> type, double p_i48541_2_, double p_i48541_4_, double p_i48541_6_, World p_i48541_8_) {
this(type, p_i48541_8_);
this.setPosition(p_i48541_2_, p_i48541_4_, p_i48541_6_);
protected EntityThrowableCopy(EntityType<? extends EntityThrowableCopy> type, double x, double y, double z, World worldIn) {
this(type, worldIn);
this.setPosition(x, y, z);
}
protected EntityThrowableCopy(EntityType<?> type, LivingEntity p_i48542_2_, World p_i48542_3_) {
this(type, p_i48542_2_.posX, p_i48542_2_.posY + (double)p_i48542_2_.getEyeHeight() - (double)0.1F, p_i48542_2_.posZ, p_i48542_3_);
this.thrower = p_i48542_2_;
this.field_200218_h = p_i48542_2_.getUniqueID();
}
protected void registerData() {
protected EntityThrowableCopy(EntityType<? extends EntityThrowableCopy> type, LivingEntity livingEntityIn, World worldIn) {
this(type, livingEntityIn.posX, livingEntityIn.posY + (double)livingEntityIn.getEyeHeight() - (double)0.1F, livingEntityIn.posZ, worldIn);
this.owner = livingEntityIn;
this.ownerId = livingEntityIn.getUniqueID();
}
/**
@@ -77,34 +75,19 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * ((float)Math.PI / 180F));
float f2 = MathHelper.cos(rotationYawIn * ((float)Math.PI / 180F)) * MathHelper.cos(rotationPitchIn * ((float)Math.PI / 180F));
this.shoot((double)f, (double)f1, (double)f2, velocity, inaccuracy);
this.motionX += entityThrower.motionX;
this.motionZ += entityThrower.motionZ;
if (!entityThrower.onGround) {
this.motionY += entityThrower.motionY;
}
Vec3d vec3d = entityThrower.getMotion();
this.setMotion(this.getMotion().add(vec3d.x, entityThrower.onGround ? 0.0D : vec3d.y, vec3d.z));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
public void shoot(double x, double y, double z, float velocity, float inaccuracy) {
float f = MathHelper.sqrt(x * x + y * y + z * z);
x = x / (double)f;
y = y / (double)f;
z = z / (double)f;
x = x + this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy;
y = y + this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy;
z = z + this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy;
x = x * (double)velocity;
y = y * (double)velocity;
z = z * (double)velocity;
this.motionX = x;
this.motionY = y;
this.motionZ = z;
float f1 = MathHelper.sqrt(x * x + z * z);
this.rotationYaw = (float)(MathHelper.atan2(x, z) * (double)(180F / (float)Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (double)(180F / (float)Math.PI));
Vec3d vec3d = (new Vec3d(x, y, z)).normalize().add(this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy, this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy, this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy).scale((double)velocity);
this.setMotion(vec3d);
float f = MathHelper.sqrt(func_213296_b(vec3d));
this.rotationYaw = (float)(MathHelper.atan2(vec3d.x, vec3d.z) * (double)(180F / (float)Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(vec3d.y, (double)f) * (double)(180F / (float)Math.PI));
this.prevRotationYaw = this.rotationYaw;
this.prevRotationPitch = this.rotationPitch;
}
@@ -114,9 +97,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
*/
@OnlyIn(Dist.CLIENT)
public void setVelocity(double x, double y, double z) {
this.motionX = x;
this.motionY = y;
this.motionZ = z;
this.setMotion(x, y, z);
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt(x * x + z * z);
this.rotationYaw = (float)(MathHelper.atan2(x, z) * (double)(180F / (float)Math.PI));
@@ -141,75 +122,49 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
if (this.inGround) {
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.setMotion(this.getMotion().mul((double)(this.rand.nextFloat() * 0.2F), (double)(this.rand.nextFloat() * 0.2F), (double)(this.rand.nextFloat() * 0.2F)));
}
Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
Vec3d vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(this.posX, this.posY, this.posZ);
vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (raytraceresult != null) {
vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z);
}
AxisAlignedBB axisalignedbb = this.getBoundingBox().expand(this.getMotion()).grow(1.0D);
Entity entity = null;
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
double d0 = 0.0D;
boolean flag = false;
for(Entity entity : this.world.getEntitiesInAABBexcluding(this, axisalignedbb, (p_213881_0_) -> {
return !p_213881_0_.isSpectator() && p_213881_0_.canBeCollidedWith();
})) {
if (entity == this.ignoreEntity) {
++this.ignoreTime;
break;
}
for(int i = 0; i < list.size(); ++i) {
Entity entity1 = list.get(i);
if (entity1.canBeCollidedWith()) {
if (entity1 == this.ignoreEntity) {
flag = true;
} else if (this.thrower != null && this.ticksExisted < 2 && this.ignoreEntity == null) {
this.ignoreEntity = entity1;
flag = true;
} else {
flag = false;
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().grow((double)0.3F);
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (raytraceresult1 != null) {
double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
}
}
if (this.owner != null && this.ticksExisted < 2 && this.ignoreEntity == null) {
this.ignoreEntity = entity;
this.ignoreTime = 3;
break;
}
}
if (this.ignoreEntity != null) {
if (flag) {
this.ignoreTime = 2;
} else if (this.ignoreTime-- <= 0) {
this.ignoreEntity = null;
}
RayTraceResult raytraceresult = ProjectileHelper.func_221267_a(this, axisalignedbb, (p_213880_1_) -> {
return !p_213880_1_.isSpectator() && p_213880_1_.canBeCollidedWith() && p_213880_1_ != this.ignoreEntity;
}, RayTraceContext.BlockMode.OUTLINE, true);
if (this.ignoreEntity != null && this.ignoreTime-- <= 0) {
this.ignoreEntity = null;
}
if (entity != null) {
raytraceresult = new RayTraceResult(entity);
}
if (raytraceresult != null) {
if (raytraceresult.type == RayTraceResult.Type.BLOCK && this.world.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.NETHER_PORTAL) {
this.setPortal(raytraceresult.getBlockPos());
if (raytraceresult.getType() != RayTraceResult.Type.MISS) {
if (raytraceresult.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)raytraceresult).getPos()).getBlock() == Blocks.NETHER_PORTAL) {
this.setPortal(((BlockRayTraceResult)raytraceresult).getPos());
} else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)){
this.onImpact(raytraceresult);
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (double)(180F / (float)Math.PI));
Vec3d vec3d = this.getMotion();
this.posX += vec3d.x;
this.posY += vec3d.y;
this.posZ += vec3d.z;
float f = MathHelper.sqrt(func_213296_b(vec3d));
this.rotationYaw = (float)(MathHelper.atan2(vec3d.x, vec3d.z) * (double)(180F / (float)Math.PI));
for(this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (double)(180F / (float)Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
for(this.rotationPitch = (float)(MathHelper.atan2(vec3d.y, (double)f) * (double)(180F / (float)Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
;
}
@@ -225,24 +180,24 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f1 = 0.99F;
float f2 = this.getGravityVelocity();
this.rotationPitch = MathHelper.lerp(0.2F, this.prevRotationPitch, this.rotationPitch);
this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw);
float f1;
if (this.isInWater()) {
for(int j = 0; j < 4; ++j) {
float f3 = 0.25F;
this.world.addParticle(ParticleTypes.BUBBLE, this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ);
for(int i = 0; i < 4; ++i) {
float f2 = 0.25F;
this.world.addParticle(ParticleTypes.BUBBLE, this.posX - vec3d.x * 0.25D, this.posY - vec3d.y * 0.25D, this.posZ - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
}
f1 = 0.8F;
} else {
f1 = 0.99F;
}
this.motionX *= (double)f1;
this.motionY *= (double)f1;
this.motionZ *= (double)f1;
this.setMotion(vec3d.scale((double)f1));
if (!this.hasNoGravity()) {
this.motionY -= (double)f2;
Vec3d vec3d1 = this.getMotion();
this.setMotion(vec3d1.x, vec3d1.y - (double)this.getGravityVelocity(), vec3d1.z);
}
this.setPosition(this.posX, this.posY, this.posZ);
@@ -260,18 +215,14 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
*/
protected abstract void onImpact(RayTraceResult result);
/**
* Writes the extra NBT data specific to this type of entity. Should <em>not</em> be called from outside this class;
* use {@link #writeUnlessPassenger} or {@link #writeWithoutTypeId} instead.
*/
public void writeAdditional(CompoundNBT compound) {
compound.putInt("xTile", this.xTile);
compound.putInt("yTile", this.yTile);
compound.putInt("zTile", this.zTile);
compound.putByte("shake", (byte)this.throwableShake);
compound.putByte("inGround", (byte)(this.inGround ? 1 : 0));
if (this.field_200218_h != null) {
compound.put("owner", NBTUtil.writeUniqueId(this.field_200218_h));
if (this.ownerId != null) {
compound.put("owner", NBTUtil.writeUniqueId(this.ownerId));
}
}
@@ -285,24 +236,28 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.zTile = compound.getInt("zTile");
this.throwableShake = compound.getByte("shake") & 255;
this.inGround = compound.getByte("inGround") == 1;
this.thrower = null;
this.owner = null;
if (compound.contains("owner", 10)) {
this.field_200218_h = NBTUtil.readUniqueId(compound.getCompound("owner"));
this.ownerId = NBTUtil.readUniqueId(compound.getCompound("owner"));
}
}
@Nullable
public LivingEntity getThrower() {
if (this.thrower == null && this.field_200218_h != null && this.world instanceof ServerWorld) {
Entity entity = ((ServerWorld)this.world).getEntityFromUuid(this.field_200218_h);
if (this.owner == null && this.ownerId != null && this.world instanceof ServerWorld) {
Entity entity = ((ServerWorld)this.world).getEntityByUuid(this.ownerId);
if (entity instanceof LivingEntity) {
this.thrower = (LivingEntity)entity;
this.owner = (LivingEntity)entity;
} else {
this.field_200218_h = null;
this.ownerId = null;
}
}
return this.thrower;
return this.owner;
}
public IPacket<?> createSpawnPacket() {
return new SSpawnObjectPacket(this);
}
}
@@ -75,6 +75,7 @@ public final class ModEntities {
.tracker(64, 10, false).build("")
.setRegistryName(LibEntityNames.MANA_STORM));
evt.getRegistry().register(EntityType.Builder.create(EntityBabylonWeapon.class, EntityBabylonWeapon::new)
.size(0, 0)
.tracker(64, 10, true).build("")
.setRegistryName(LibEntityNames.BABYLON_WEAPON));
evt.getRegistry().register(EntityType.Builder.create(EntityFallingStar.class, EntityFallingStar::new)
@@ -26,6 +26,7 @@ import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -183,7 +184,7 @@ public class ItemAstrolabe extends ItemMod {
public static List<BlockPos> getBlocksToPlace(ItemStack stack, PlayerEntity player) {
List<BlockPos> coords = new ArrayList<>();
RayTraceResult rtr = ToolCommons.raytraceFromEntity(player.world, player, true, 5);
RayTraceResult rtr = ToolCommons.raytraceFromEntity(player.world, player, RayTraceContext.FluidMode.SOURCE_ONLY, 5);
if(rtr != null) {
BlockPos pos = rtr.getBlockPos();
BlockState state = player.world.getBlockState(pos);
@@ -10,28 +10,15 @@
*/
package vazkii.botania.common.item;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.BotaniaCreativeTab;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.Locale;
public class ItemManaCookie extends ItemFood {
public class ItemManaCookie extends ItemMod {
public ItemManaCookie(Properties props) {
super(0, 0.1F, false, props);
setPotionEffect(new EffectInstance(Effects.SATURATION, 20, 0), 1F);
super(props);
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "totalbiscuit"),
(stack, worldIn, entityIn) -> stack.getDisplayName().getString().toLowerCase(Locale.ROOT).contains("totalbiscuit") ? 1F : 0F);
}
@@ -12,11 +12,16 @@ package vazkii.botania.common.item;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Food;
import net.minecraft.item.Items;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@@ -32,6 +37,23 @@ import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileGaiaHead;
import vazkii.botania.common.core.BotaniaCreativeTab;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.crafting.recipe.AncientWillRecipe;
import vazkii.botania.common.crafting.recipe.ArmorUpgradeRecipe;
import vazkii.botania.common.crafting.recipe.BlackHoleTalismanExtractRecipe;
import vazkii.botania.common.crafting.recipe.CompositeLensRecipe;
import vazkii.botania.common.crafting.recipe.CosmeticAttachRecipe;
import vazkii.botania.common.crafting.recipe.CosmeticRemoveRecipe;
import vazkii.botania.common.crafting.recipe.HelmRevealingRecipe;
import vazkii.botania.common.crafting.recipe.KeepIvyRecipe;
import vazkii.botania.common.crafting.recipe.LensDyeingRecipe;
import vazkii.botania.common.crafting.recipe.ManaGunClipRecipe;
import vazkii.botania.common.crafting.recipe.ManaGunLensRecipe;
import vazkii.botania.common.crafting.recipe.ManaGunRemoveLensRecipe;
import vazkii.botania.common.crafting.recipe.ManaUpgradeRecipe;
import vazkii.botania.common.crafting.recipe.PhantomInkRecipe;
import vazkii.botania.common.crafting.recipe.ShapelessManaUpgradeRecipe;
import vazkii.botania.common.crafting.recipe.SpellClothRecipe;
import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe;
import vazkii.botania.common.item.brew.*;
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumBoots;
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumChest;
@@ -214,7 +236,7 @@ public final class ModItems {
public static final Item manaTablet = new ItemManaTablet(unstackable()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_TABLET);
public static final Item manaGun = new ItemManaGun(unstackable().setNoRepair()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_GUN);
public static final Item manaCookie = new ItemManaCookie(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_COOKIE);
public static final Item manaCookie = new ItemManaCookie(defaultBuilder().food(new Food.Builder().hunger(0).saturation(0.1F).effect(new EffectInstance(Effects.SATURATION, 20, 0), 1).build())).setRegistryName(LibMisc.MOD_ID, LibItemNames.MANA_COOKIE);
public static final Item fertilizer = new ItemFertilizer(defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.FERTILIZER);
public static final Item grassSeeds = new ItemGrassSeeds(IFloatingFlower.IslandType.GRASS, defaultBuilder()).setRegistryName(LibMisc.MOD_ID, LibItemNames.GRASS_SEEDS);
@@ -667,6 +689,28 @@ public final class ModItems {
registerOreDictionary();
}
@SubscribeEvent
public static void registerRecipeSerializers(RegistryEvent.Register<IRecipeSerializer<?>> evt) {
IForgeRegistry<IRecipeSerializer<?>> r = evt.getRegistry();
r.register(AncientWillRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "ancient_will_attach")));
r.register(ArmorUpgradeRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "armor_upgrade")));
r.register(BlackHoleTalismanExtractRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "black_hole_talisman_extract")));
r.register(CompositeLensRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "composite_lens")));
r.register(CosmeticAttachRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "cosmetic_attach")));
r.register(CosmeticRemoveRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "cosmetic_remove")));
r.register(HelmRevealingRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "helm_revealing")));
r.register(KeepIvyRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "keep_ivy")));
r.register(LensDyeingRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "lens_dye")));
r.register(ManaGunClipRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "mana_gun_add_clip")));
r.register(ManaGunLensRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "mana_gun_add_lens")));
r.register(ManaGunRemoveLensRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "mana_gun_remove_lens")));
r.register(ManaUpgradeRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "mana_upgrade")));
r.register(ShapelessManaUpgradeRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "mana_upgrade_shapeless")));
r.register(PhantomInkRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "phantom_ink_apply")));
r.register(SpellClothRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "spell_cloth_apply")));
r.register(TerraPickTippingRecipe.SERIALIZER.setRegistryName(new ResourceLocation(LibMisc.MOD_ID, "terra_pick_tipping")));
}
private static void registerOreDictionary() {
/* TODO 1.13 reevaluate these
@@ -72,7 +72,7 @@ public class ItemIncenseStick extends ItemMod implements IBrewItem, IBrewContain
list.add(new TranslationTextComponent("botaniamisc.brewOf", new TranslationTextComponent(brew.getUnlocalizedName(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE));
for(EffectInstance effect : brew.getPotionEffects(stack)) {
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
TextFormatting format = !effect.getPotion().isBeneficial() ? TextFormatting.RED : TextFormatting.GRAY;
EffectInstance longEffect = new EffectInstance(effect.getPotion(), effect.getDuration() * TIME_MULTIPLIER, effect.getAmplifier(), false, true);
ITextComponent cmp = new TranslationTextComponent(effect.getEffectName());
if(effect.getAmplifier() > 0) {
@@ -26,6 +26,7 @@ import net.minecraft.item.ToolItem;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceFluidMode;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
@@ -46,7 +47,7 @@ import java.util.function.Predicate;
public final class ToolCommons {
public static final List<Material> materialsPick = Arrays.asList(Material.ROCK, Material.IRON, Material.ICE, Material.GLASS, Material.PISTON, Material.ANVIL);
public static final List<Material> materialsShovel = Arrays.asList(Material.GRASS, Material.GROUND, Material.SAND, Material.SNOW, Material.CRAFTED_SNOW, Material.CLAY);
public static final List<Material> materialsShovel = Arrays.asList(Material.ORGANIC, Material.EARTH, Material.SAND, Material.SNOW, Material.SNOW_BLOCK, Material.CLAY);
public static final List<Material> materialsAxe = Arrays.asList(Material.CORAL, Material.LEAVES, Material.PLANTS, Material.WOOD, Material.GOURD);
public static void damageItem(ItemStack stack, int dmg, LivingEntity entity, int manaPerDamage) {
@@ -54,14 +55,16 @@ public final class ToolCommons {
boolean manaRequested = entity instanceof PlayerEntity && ManaItemHandler.requestManaExactForTool(stack, (PlayerEntity) entity, manaToRequest, true);
if(!manaRequested)
stack.damageItem(dmg, entity);
stack.damageItem(dmg, entity, e -> {});
}
public static void removeBlocksInIteration(PlayerEntity player, ItemStack stack, World world, BlockPos centerPos,
Vec3i startDelta, Vec3i endDelta, Predicate<BlockState> filter,
boolean dispose) {
for (BlockPos iterPos : BlockPos.getAllInBox(centerPos.add(startDelta), centerPos.add(endDelta))) {
if (iterPos.equals(centerPos)) // skip original block space to avoid crash, vanilla code in the tool class will handle it
for (BlockPos iterPos : BlockPos.getAllInBoxMutable(centerPos.add(startDelta),
centerPos.add(endDelta))) {
// skip original block space to avoid crash, vanilla code in the tool class will handle it
if (iterPos.equals(centerPos))
continue;
removeBlockWithDrops(player, stack, world, iterPos, filter, dispose);
}
@@ -102,7 +105,7 @@ public final class ToolCommons {
}
damageItem(stack, 1, player, 80);
} else world.removeBlock(pos);
} else world.removeBlock(pos, false);
if(particles && ConfigHandler.COMMON.blockBreakParticles.get() && ConfigHandler.COMMON.blockBreakParticlesTool.get())
world.playEvent(2001, pos, Block.getStateId(state));
@@ -136,26 +139,18 @@ public final class ToolCommons {
}
// [VanillaCopy] of Item.rayTrace, edits noted
public static RayTraceResult raytraceFromEntity(World worldIn, Entity playerIn, boolean useLiquids, double range) {
float f = playerIn.rotationPitch;
float f1 = playerIn.rotationYaw;
double d0 = playerIn.posX;
double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
double d2 = playerIn.posZ;
Vec3d vec3d = new Vec3d(d0, d1, d2);
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
float f4 = -MathHelper.cos(-f * 0.017453292F);
float f5 = MathHelper.sin(-f * 0.017453292F);
public static RayTraceResult raytraceFromEntity(World worldIn, PlayerEntity player, RayTraceContext.FluidMode fluidMode, double range) {
float f = player.rotationPitch;
float f1 = player.rotationYaw;
Vec3d vec3d = player.getEyePosition(1.0F);
float f2 = MathHelper.cos(-f1 * ((float)Math.PI / 180F) - (float)Math.PI);
float f3 = MathHelper.sin(-f1 * ((float)Math.PI / 180F) - (float)Math.PI);
float f4 = -MathHelper.cos(-f * ((float)Math.PI / 180F));
float f5 = MathHelper.sin(-f * ((float)Math.PI / 180F));
float f6 = f3 * f4;
float f7 = f2 * f4;
double d3 = range; // Botania - use custom range param, don't limit to reach distance
/*if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
{
d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
}*/
Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids ? RayTraceFluidMode.SOURCE_ONLY : RayTraceFluidMode.NEVER, false, false);
double d0 = range; // Botania - use custom range
Vec3d vec3d1 = vec3d.add((double)f6 * d0, (double)f5 * d0, (double)f7 * d0);
return worldIn.rayTraceBlocks(new RayTraceContext(vec3d, vec3d1, RayTraceContext.BlockMode.OUTLINE, fluidMode, player));
}
}
@@ -14,6 +14,7 @@ import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.core.helper.Vector3;
@@ -22,11 +23,12 @@ public class LensBounce extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!isManaBlock && pos.entity == null) {
if(!isManaBlock && pos.getType() == RayTraceResult.Type.BLOCK) {
BlockPos coords = burst.getBurstSourceBlockPos();
if (!coords.equals(pos.getBlockPos())) {
Vector3 currentMovementVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
Direction dir = pos.sideHit;
BlockRayTraceResult rtr = (BlockRayTraceResult) pos;
if (!coords.equals(rtr.getPos())) {
Vector3 currentMovementVec = new Vector3(entity.getMotion());
Direction dir = rtr.getFace();
Vector3 normalVector = new Vector3(dir.getXOffset(), dir.getYOffset(), dir.getZOffset()).normalize();
Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec);
@@ -14,17 +14,21 @@ package vazkii.botania.common.item.lens;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.Explosion;
import vazkii.botania.api.internal.IManaBurst;
public class LensExplosive extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake()) {
if(!entity.world.isRemote && !burst.isFake() && pos.getType() == RayTraceResult.Type.BLOCK) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(pos.entity == null && !isManaBlock && !coords.equals(pos.getBlockPos()))
entity.world.createExplosion(entity, entity.posX, entity.posY, entity.posZ, burst.getMana() / 50F, true);
if(!isManaBlock && !coords.equals(((BlockRayTraceResult) pos).getPos()))
entity.world.createExplosion(entity, entity.posX, entity.posY, entity.posZ,
burst.getMana() / 50F, Explosion.Mode.BREAK);
} else dead = false;
return dead;
@@ -16,6 +16,7 @@ import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
@@ -27,25 +28,30 @@ public class LensFire extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult rtr, boolean isManaBlock, boolean dead, ItemStack stack) {
BlockPos coords = burst.getBurstSourceBlockPos();
BlockPos pos = rtr.getBlockPos();
if(!entity.world.isRemote && !coords.equals(pos) && !burst.isFake() && !isManaBlock) {
Direction dir = rtr.sideHit;
BlockPos offPos = pos.offset(dir);
if(!entity.world.isRemote && rtr.getType() == RayTraceResult.Type.BLOCK
&& !burst.isFake() && !isManaBlock) {
BlockRayTraceResult brtr = (BlockRayTraceResult) rtr;
BlockPos pos = brtr.getPos();
if(!coords.equals(pos)) {
Direction dir = brtr.getFace();
Block blockAt = entity.world.getBlockState(pos).getBlock();
Block blockAtOffset = entity.world.getBlockState(offPos).getBlock();
BlockPos offPos = pos.offset(dir);
if(blockAt == Blocks.NETHER_PORTAL)
entity.world.setBlockState(pos, Blocks.AIR.getDefaultState());
if(blockAtOffset == Blocks.NETHER_PORTAL)
entity.world.setBlockState(offPos, Blocks.AIR.getDefaultState());
else if(blockAt == ModBlocks.incensePlate) {
TileIncensePlate plate = (TileIncensePlate) entity.world.getTileEntity(pos);
plate.ignite();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate);
} else if(blockAtOffset.isAir(entity.world.getBlockState(offPos), entity.world, offPos))
entity.world.setBlockState(offPos, Blocks.FIRE.getDefaultState());
Block blockAt = entity.world.getBlockState(pos).getBlock();
Block blockAtOffset = entity.world.getBlockState(offPos).getBlock();
if(blockAt == Blocks.NETHER_PORTAL)
entity.world.setBlockState(pos, Blocks.AIR.getDefaultState());
if(blockAtOffset == Blocks.NETHER_PORTAL)
entity.world.setBlockState(offPos, Blocks.AIR.getDefaultState());
else if(blockAt == ModBlocks.incensePlate) {
TileIncensePlate plate = (TileIncensePlate) entity.world.getTileEntity(pos);
plate.ignite();
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(plate);
} else if(blockAtOffset.isAir(entity.world.getBlockState(offPos), entity.world, offPos))
entity.world.setBlockState(offPos, Blocks.FIRE.getDefaultState());
}
}
return dead;
@@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.core.helper.ItemNBTHelper;
@@ -27,7 +29,9 @@ public class LensFirework extends Lens {
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake()) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(pos.entity == null && !isManaBlock && !pos.getBlockPos().equals(coords)) {
if(pos.getType() == RayTraceResult.Type.BLOCK
&& !isManaBlock
&& !((BlockRayTraceResult) pos).getPos().equals(coords)) {
ItemStack fireworkStack = generateFirework(burst.getColor());
FireworkRocketEntity rocket = new FireworkRocketEntity(entity.world, entity.posX, entity.posY, entity.posZ, fireworkStack);
@@ -47,11 +47,10 @@ public class LensInfluence extends Lens {
if(!lens.isEmpty() && lens.getItem() == ModItems.lensInfluence)
continue;
((IManaBurst) movable).setBurstMotion(entity.motionX, entity.motionY, entity.motionZ);
((IManaBurst) movable).setBurstMotion(entity.getMotion().getX(),
entity.getMotion().getY(), entity.getMotion().getZ());
} else {
movable.motionX = entity.motionX;
movable.motionY = entity.motionY;
movable.motionZ = entity.motionZ;
movable.setMotion(entity.getMotion());
}
}
}
@@ -17,6 +17,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.common.block.ModBlocks;
@@ -27,20 +28,23 @@ public class LensLight extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(!entity.world.isRemote && pos.type == RayTraceResult.Type.BLOCK && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) {
BlockPos neighborPos = pos.getBlockPos().offset(pos.sideHit);
if(!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK && !burst.isFake() && !isManaBlock) {
BlockRayTraceResult rtr = (BlockRayTraceResult) pos;
if(!coords.equals(rtr.getPos())) {
BlockPos neighborPos = rtr.getPos().offset(rtr.getFace());
Block blockAt = entity.world.getBlockState(pos.getBlockPos()).getBlock();
BlockState neighbor = entity.world.getBlockState(neighborPos);
Block blockAt = entity.world.getBlockState(rtr.getPos()).getBlock();
BlockState neighbor = entity.world.getBlockState(neighborPos);
if(blockAt == ModBlocks.manaFlame)
entity.world.setBlockState(pos.getBlockPos(), Blocks.AIR.getDefaultState());
else if(neighbor.isAir(entity.world, neighborPos) || neighbor.getMaterial().isReplaceable()) {
entity.world.setBlockState(neighborPos, ModBlocks.manaFlame.getDefaultState());
TileEntity tile = entity.world.getTileEntity(neighborPos);
if(blockAt == ModBlocks.manaFlame)
entity.world.setBlockState(rtr.getPos(), Blocks.AIR.getDefaultState());
else if(neighbor.isAir(entity.world, neighborPos) || neighbor.getMaterial().isReplaceable()) {
entity.world.setBlockState(neighborPos, ModBlocks.manaFlame.getDefaultState());
TileEntity tile = entity.world.getTileEntity(neighborPos);
if(tile instanceof TileManaFlame)
((TileManaFlame) tile).setColor(burst.getColor());
if(tile instanceof TileManaFlame)
((TileManaFlame) tile).setColor(burst.getColor());
}
}
}
@@ -32,7 +32,8 @@ public class LensMagnet extends Lens {
int range = 3;
magnetize : {
for (BlockPos pos : BlockPos.getAllInBox(basePos.add(-range, -range, -range), basePos.add(range, range, range))) {
for (BlockPos pos : BlockPos.getAllInBoxMutable(basePos.add(-range, -range, -range),
basePos.add(range, range, range))) {
if(entity.world.getTileEntity(pos) instanceof IManaReceiver) {
TileEntity tile = entity.world.getTileEntity(pos);
@@ -51,7 +52,7 @@ public class LensMagnet extends Lens {
if(tile.getPos().distanceSq(srcCoords) > 9 && receiver.canRecieveManaFromBursts() && !receiver.isFull()) {
Vector3 burstVec = Vector3.fromEntity(entity);
Vector3 tileVec = Vector3.fromTileEntityCenter(tile).add(0, -0.1, 0);
Vector3 motionVec = new Vector3(entity.motionX, entity.motionY, entity.motionZ);
Vector3 motionVec = new Vector3(entity.getMotion());
Vector3 normalMotionVec = motionVec.normalize();
Vector3 magnetVec = tileVec.subtract(burstVec).normalize();
@@ -19,7 +19,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.World;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.IManaBlock;
@@ -27,15 +30,17 @@ import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ModItems;
import java.util.List;
public class LensMine extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult rtr, boolean isManaBlock, boolean dead, ItemStack stack) {
World world = entity.world;
BlockPos collidePos = rtr.getBlockPos();
if (world.isRemote)
if (world.isRemote || rtr.getType() != RayTraceResult.Type.BLOCK)
return false;
BlockPos collidePos = ((BlockRayTraceResult) rtr).getPos();
BlockState state = world.getBlockState(collidePos);
Block block = state.getBlock();
@@ -54,14 +59,17 @@ public class LensMine extends Lens {
int mana = burst.getMana();
BlockPos source = burst.getBurstSourceBlockPos();
if(!source.equals(rtr.getBlockPos()) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
if(!source.equals(collidePos)
&& !(tile instanceof IManaBlock)
&& neededHarvestLevel <= harvestLevel
&& hardness != -1 && hardness < 50F
&& (burst.isFake() || mana >= 24)) {
if(!burst.hasAlreadyCollidedAt(collidePos)) {
if(!burst.isFake()) {
NonNullList<ItemStack> items = NonNullList.create();
state.getDrops(items, world, collidePos, 0);
List<ItemStack> items = Block.getDrops(state, (ServerWorld) world, collidePos, tile);
float chance = net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, world, collidePos, state, 0, 1.0f, false, null);
world.removeBlock(collidePos);
world.removeBlock(collidePos, false);
if(ConfigHandler.COMMON.blockBreakParticles.get())
world.playEvent(2001, collidePos, Block.getStateId(state));
@@ -70,9 +78,6 @@ public class LensMine extends Lens {
BlockPos dropCoord = doWarp ? source : collidePos;
for(ItemStack stack_ : items) {
// Shulker boxes do weird things and drop themselves in breakBlock, so don't drop any dupes
if(block instanceof ShulkerBoxBlock && Block.getBlockFromItem(stack_.getItem()) instanceof ShulkerBoxBlock)
continue;
if(world.rand.nextFloat() <= chance)
Block.spawnAsEntity(world, dropCoord, stack_);
}
@@ -19,6 +19,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IManaBurst;
@@ -35,22 +37,27 @@ public class LensPaint extends Lens {
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
int storedColor = ItemLens.getStoredColor(stack);
if(!entity.world.isRemote && !burst.isFake() && storedColor > -1 && storedColor < 17) {
if(pos.entity instanceof SheepEntity) {
if(pos.getType() == RayTraceResult.Type.ENTITY
&& ((EntityRayTraceResult) pos).getEntity() instanceof SheepEntity) {
int r = 20;
DyeColor sheepColor = ((SheepEntity) pos.entity).getFleeceColor();
List<SheepEntity> sheepList = entity.world.getEntitiesWithinAABB(SheepEntity.class, new AxisAlignedBB(pos.entity.posX - r, pos.entity.posY - r, pos.entity.posZ - r, pos.entity.posX + r, pos.entity.posY + r, pos.entity.posZ + r));
for(SheepEntity sheep : sheepList) {
if(sheep.getFleeceColor() == sheepColor)
sheep.setFleeceColor(DyeColor.byId(storedColor == 16 ? sheep.world.rand.nextInt(16) : storedColor));
SheepEntity sheep = (SheepEntity) ((EntityRayTraceResult) pos).getEntity();
DyeColor sheepColor = sheep.getFleeceColor();
List<SheepEntity> sheepList = entity.world.getEntitiesWithinAABB(SheepEntity.class,
new AxisAlignedBB(sheep.posX - r, sheep.posY - r, sheep.posZ - r,
sheep.posX + r, sheep.posY + r, sheep.posZ + r));
for(SheepEntity other : sheepList) {
if(other.getFleeceColor() == sheepColor)
other.setFleeceColor(DyeColor.byId(storedColor == 16 ? other.world.rand.nextInt(16) : storedColor));
}
dead = true;
} else {
BlockState state = entity.world.getBlockState(pos.getBlockPos());
} else if (pos.getType() == RayTraceResult.Type.BLOCK) {
BlockPos hit = ((BlockRayTraceResult) pos).getPos();
BlockState state = entity.world.getBlockState(hit);
Block block = state.getBlock();
if(BotaniaAPI.paintableBlocks.containsKey(block.delegate)) {
List<BlockPos> coordsToPaint = new ArrayList<>();
List<BlockPos> coordsFound = new ArrayList<>();
coordsFound.add(pos.getBlockPos());
coordsFound.add(hit);
do {
List<BlockPos> iterCoords = new ArrayList<>(coordsFound);
@@ -17,6 +17,7 @@ import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
@@ -25,16 +26,23 @@ public class LensPiston extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(!entity.world.isRemote && pos.getBlockPos() != null && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) {
BlockPos pos_ = pos.getBlockPos().offset(pos.sideHit.getOpposite());
if(!entity.world.isRemote
&& pos.getType() == RayTraceResult.Type.BLOCK
&& !burst.isFake()
&& !isManaBlock) {
BlockRayTraceResult rtr = (BlockRayTraceResult) pos;
if(!coords.equals(rtr.getPos())) {
BlockPos pos_ = rtr.getPos().offset(rtr.getFace().getOpposite());
if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getMaterial().isReplaceable()) {
BlockState state = entity.world.getBlockState(pos.getBlockPos());
TileEntity tile = entity.world.getTileEntity(pos.getBlockPos());
if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getMaterial().isReplaceable()) {
BlockState state = entity.world.getBlockState(rtr.getPos());
TileEntity tile = entity.world.getTileEntity(rtr.getPos());
if(state.getPushReaction() == PushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN && state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) {
entity.world.destroyBlock(pos.getBlockPos(), false);
entity.world.setBlockState(pos_, state, 1 | 2);
if(state.getPushReaction() == PushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN
&& state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) {
entity.world.destroyBlock(rtr.getPos(), false);
entity.world.setBlockState(pos_, state, 1 | 2);
}
}
}
}
@@ -15,6 +15,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.shapes.VoxelShape;
import vazkii.botania.api.internal.IManaBurst;
@@ -27,8 +29,10 @@ public class LensRedirect extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(!entity.world.isRemote && pos.entity == null && coords.getY() != -1 && (pos.getBlockPos() == null || !pos.getBlockPos().equals(coords))) {
TileEntity tile = entity.world.getTileEntity(pos.getBlockPos());
if(!entity.world.isRemote && pos.getType() == RayTraceResult.Type.BLOCK
&& coords.getY() != -1
&& !((BlockRayTraceResult) pos).getPos().equals(coords)) {
TileEntity tile = entity.world.getTileEntity(((BlockRayTraceResult) pos).getPos());
if(tile instanceof IDirectioned) {
if(!burst.isFake()) {
IDirectioned redir = (IDirectioned) tile;
@@ -13,7 +13,10 @@ package vazkii.botania.common.item.lens;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.Explosion;
import vazkii.botania.api.internal.IManaBurst;
public class LensStorm extends Lens {
@@ -22,8 +25,10 @@ public class LensStorm extends Lens {
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake()) {
BlockPos coords = burst.getBurstSourceBlockPos();
if(pos.type == RayTraceResult.Type.BLOCK && !isManaBlock && !coords.equals(pos.getBlockPos()))
entity.world.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, true);
if(pos.getType() == RayTraceResult.Type.BLOCK
&& !isManaBlock
&& !coords.equals(((BlockRayTraceResult) pos).getPos()))
entity.world.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 5F, Explosion.Mode.DESTROY);
} else dead = false;
return dead;
@@ -13,6 +13,8 @@ package vazkii.botania.common.item.lens;
import net.minecraft.block.Block;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.IManaReceiver;
@@ -25,12 +27,13 @@ public class LensWarp extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(burst.isFake() || pos.type != RayTraceResult.Type.BLOCK)
if(burst.isFake() || pos.getType() != RayTraceResult.Type.BLOCK)
return dead;
Block block = entity.world.getBlockState(pos.getBlockPos()).getBlock();
BlockPos hit = ((BlockRayTraceResult) pos).getPos();
Block block = entity.world.getBlockState(hit).getBlock();
if(block == ModBlocks.pistonRelay) {
BlockPistonRelay.DimWithPos key = ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(new BlockPistonRelay.DimWithPos(entity.world.getDimension().getType(), pos.getBlockPos()));
BlockPistonRelay.DimWithPos key = ((BlockPistonRelay) ModBlocks.pistonRelay).mappedPositions.get(new BlockPistonRelay.DimWithPos(entity.world.getDimension().getType(), hit));
if(key != null) {
if(key.dim == entity.world.getDimension().getType()) {
entity.setPosition(key.blockPos.getX() + 0.5, key.blockPos.getY() + 0.5, key.blockPos.getZ() + 0.5);
@@ -18,6 +18,8 @@ import net.minecraft.particles.ParticleTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.BlockParticleData;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.ServerWorld;
import vazkii.botania.api.internal.IManaBurst;
@@ -26,18 +28,22 @@ import vazkii.botania.common.core.handler.ConfigHandler;
public class LensWeight extends Lens {
@Override
public boolean collideBurst(IManaBurst burst, ThrowableEntity entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) {
if(!entity.world.isRemote && !burst.isFake() && pos.type == RayTraceResult.Type.BLOCK) {
if(!entity.world.isRemote && !burst.isFake() && pos.getType() == RayTraceResult.Type.BLOCK) {
int harvestLevel = ConfigHandler.COMMON.harvestLevelWeight.get();
BlockPos bPos = pos.getBlockPos();
BlockPos bPos = ((BlockRayTraceResult) pos).getPos();
Block block = entity.world.getBlockState(bPos).getBlock();
BlockState state = entity.world.getBlockState(bPos);
int neededHarvestLevel = block.getHarvestLevel(state);
if(entity.world.isAirBlock(bPos.down()) && state.getBlockHardness(entity.world, bPos) != -1 && neededHarvestLevel <= harvestLevel && entity.world.getTileEntity(bPos) == null && state.canSilkHarvest(entity.world, bPos, null)) {
if(entity.world.isAirBlock(bPos.down())
&& state.getBlockHardness(entity.world, bPos) != -1
&& neededHarvestLevel <= harvestLevel
&& entity.world.getTileEntity(bPos) == null
&& state.canSilkHarvest(entity.world, bPos, null)) {
FallingBlockEntity falling = new FallingBlockEntity(entity.world, bPos.getX() + 0.5, bPos.getY(), bPos.getZ() + 0.5, state);
falling.fallTime = 1;
entity.world.removeBlock(bPos);
entity.world.removeBlock(bPos, false);
((ServerWorld) entity.world).spawnParticle(new BlockParticleData(ParticleTypes.FALLING_DUST, state), bPos.getX() + 0.5, bPos.getY() + 0.5, bPos.getZ() + 0.5, 10, 0.45, 0.45, 0.45, 5);
entity.world.addEntity(falling);
}
@@ -89,9 +89,9 @@ public class ItemFlugelEye extends ItemRelic implements ICoordBoundItem, IManaUs
@Override
public void onUsingTick(ItemStack stack, LivingEntity living, int count) {
float x = (float) (living.posX - Math.random() * living.width);
float x = (float) (living.posX - Math.random() * living.getWidth());
float y = (float) (living.posY + Math.random());
float z = (float) (living.posZ - Math.random() * living.width);
float z = (float) (living.posZ - Math.random() * living.getWidth());
Botania.proxy.wispFX(x, y, z, (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random() * 0.7F, -0.05F - (float) Math.random() * 0.05F);
}
@@ -13,15 +13,21 @@ package vazkii.botania.common.item.relic;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -67,24 +73,25 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
ItemStack heldItemStack = event.getItemStack();
BlockPos originCoords = getOriginPos(lokiRing);
RayTraceResult lookPos = ToolCommons.raytraceFromEntity(player.world, player, true, 10F);
RayTraceResult lookPos = ToolCommons.raytraceFromEntity(player.world, player, RayTraceContext.FluidMode.ANY, 10F);
List<BlockPos> cursors = getCursorList(lokiRing);
int cost = Math.min(cursors.size(), (int) Math.pow(Math.E, cursors.size() * 0.25));
if(lookPos == null)
if(lookPos.getType() != RayTraceResult.Type.BLOCK)
return;
BlockPos hit = ((BlockRayTraceResult) lookPos).getPos();
if(heldItemStack.isEmpty()) {
if(!event.getWorld().isRemote) {
if(originCoords.getY() == -1) {
setOriginPos(lokiRing, lookPos.getBlockPos());
setOriginPos(lokiRing, hit);
setCursorList(lokiRing, null);
} else {
if(originCoords.equals(lookPos.getBlockPos())) {
if(originCoords.equals(hit)) {
setOriginPos(lokiRing, new BlockPos(0, -1, 0));
} else {
addCursor : {
BlockPos relPos = lookPos.getBlockPos().add(new BlockPos(-originCoords.getX(), -originCoords.getY(), -originCoords.getZ()));
BlockPos relPos = hit.subtract(originCoords);
for(BlockPos cursor : cursors)
if(cursor.equals(relPos)) {
@@ -103,10 +110,13 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
event.setCancellationResult(ActionResultType.SUCCESS);
} else {
for(BlockPos cursor : cursors) {
BlockPos pos = lookPos.getBlockPos().add(cursor);
BlockPos pos = hit.add(cursor);
if(player.world.isAirBlock(pos) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) {
ItemStack saveHeld = heldItemStack.copy();
heldItemStack.onItemUse(new ItemUseContext(player, heldItemStack, pos, lookPos.sideHit, (float) lookPos.hitVec.x - pos.getX(), (float) lookPos.hitVec.y - pos.getY(), (float) lookPos.hitVec.z - pos.getZ()));
BlockRayTraceResult newHit = new BlockRayTraceResult(
lookPos.getHitVec().subtract(pos.getX(), pos.getY(), pos.getZ()),
((BlockRayTraceResult) lookPos).getFace(), pos, false);
heldItemStack.onItemUse(new ItemUseContext(player, event.getHand(), newHit));
if(player.isCreative())
player.setHeldItem(event.getHand(), saveHeld);
}
@@ -132,11 +142,6 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
}
}
@Override
public boolean shouldSyncToTracking(ItemStack stack, LivingEntity entity) {
return true;
}
@Override
public void onUnequipped(ItemStack stack, LivingEntity living) {
setCursorList(stack, null);
@@ -150,7 +155,9 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
RayTraceResult lookPos = Minecraft.getInstance().objectMouseOver;
if(lookPos != null && !player.world.isAirBlock(lookPos.getBlockPos()) && lookPos.entity == null) {
if(lookPos != null
&& lookPos.getType() == RayTraceResult.Type.BLOCK
&& !player.world.isAirBlock(((BlockRayTraceResult) lookPos).getPos())) {
List<BlockPos> list = getCursorList(stack);
BlockPos origin = getOriginPos(stack);
@@ -158,7 +165,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(origin.getY() != -1) {
list.set(i, list.get(i).add(origin));
} else {
list.set(i, list.get(i).add(lookPos.getBlockPos()));
list.set(i, list.get(i).add(((BlockRayTraceResult) lookPos).getPos()));
}
}
@@ -211,7 +218,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(stack == null)
return;
NBTTagCompound cmp = new NBTTagCompound();
CompoundNBT cmp = new CompoundNBT();
if(cursors != null) {
int i = 0;
for(BlockPos cursor : cursors) {
@@ -57,7 +57,9 @@ public class ItemOdinRing extends ItemRelicBauble {
@Override
public Multimap<String, AttributeModifier> getEquippedAttributeModifiers(ItemStack stack) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false));
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(),
new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, AttributeModifier.Operation.ADDITION)
.setSaved(false));
return attributes;
}
@@ -63,7 +63,7 @@ public class ItemRelic extends ItemMod implements IRelic {
@OnlyIn(Dist.CLIENT)
public void addBindInfo(List<ITextComponent> list, ItemStack stack) {
if(Screen.isShiftKeyDown()) {
if(Screen.hasShiftDown()) {
if(!hasUUID(stack)) {
list.add(new TranslationTextComponent("botaniamisc.relicUnbound"));
} else {
@@ -27,6 +27,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import vazkii.botania.api.item.IAvatarTile;
import vazkii.botania.api.item.IAvatarWieldable;
@@ -63,17 +64,25 @@ public class ItemDirtRod extends ItemMod implements IManaUsingItem, IBlockProvid
Direction side = ctx.getFace();
BlockPos pos = ctx.getPos();
if(ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) {
int entities = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
if(player != null && ManaItemHandler.requestManaExactForTool(stack, player, cost, false)) {
int entities = world.getEntitiesWithinAABB(LivingEntity.class,
new AxisAlignedBB(pos.offset(side), pos.offset(side).add(1, 1, 1))).size();
if(entities == 0) {
ItemStack save = player.getHeldItem(ctx.getHand());
ItemStack stackToPlace = new ItemStack(block);
stackToPlace.onItemUse(new ItemUseContext(player, stackToPlace, pos, side, ctx.getHitX(), ctx.getHitY(), ctx.getHitZ()));
player.setHeldItem(ctx.getHand(), stackToPlace);
ItemUseContext newCtx = new ItemUseContext(player, ctx.getHand(),
new BlockRayTraceResult(ctx.getHitVec(), side, pos, ctx.func_221533_k()));
stackToPlace.onItemUse(newCtx);
player.setHeldItem(ctx.getHand(), save);
if(stackToPlace.isEmpty()) {
ManaItemHandler.requestManaExactForTool(stack, player, cost, true);
for(int i = 0; i < 6; i++)
Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(), pos.getY() + side.getYOffset() + Math.random(), pos.getZ() + side.getZOffset() + Math.random(), r, g, b, 1F, 5);
Botania.proxy.sparkleFX(pos.getX() + side.getXOffset() + Math.random(),
pos.getY() + side.getYOffset() + Math.random(),
pos.getZ() + side.getZOffset() + Math.random(), r, g, b, 1F, 5);
return ActionResultType.SUCCESS;
}
}
@@ -68,12 +68,17 @@ public class ItemDiviningRod extends ItemMod implements IManaUsingItem, IAvatarW
private void doHighlight(World world, BlockPos pos, int range, long seedxor) {
Botania.proxy.setWispFXDepthTest(false);
for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) {
for(BlockPos pos_ : BlockPos.getAllInBoxMutable(pos.add(-range, -range, -range),
pos.add(range, range, range))) {
BlockState state = world.getBlockState(pos_);
if(Tags.Blocks.ORES.contains(state.getBlock())) {
Random rand = new Random(state.hashCode() ^ seedxor);
Botania.proxy.wispFX(pos_.getX() + world.rand.nextFloat(), pos_.getY() + world.rand.nextFloat(), pos_.getZ() + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8);
Botania.proxy.wispFX(pos_.getX() + world.rand.nextFloat(),
pos_.getY() + world.rand.nextFloat(),
pos_.getZ() + world.rand.nextFloat(),
rand.nextFloat(), rand.nextFloat(), rand.nextFloat(),
0.25F, 0F, 8);
}
}
Botania.proxy.setWispFXDepthTest(true);
@@ -166,7 +166,11 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
float xm = ((float) Math.random() - 0.5F) * m;
float ym = ((float) Math.random() - 0.5F) * m;
float zm = ((float) Math.random() - 0.5F) * m;
Botania.proxy.wispFX(item.posX + item.width / 2, item.posY + item.height / 2, item.posZ + item.width / 2, r, 0F, b, s, xm, ym, zm);
Botania.proxy.wispFX(item.posX + item.getWidth() / 2,
item.posY + item.getHeight() / 2,
item.posZ + item.getWidth() / 2,
r, 0F, b,
s, xm, ym, zm);
}
MathHelper.setEntityMotionFromVector(item, target3, 0.3333333F);
@@ -217,18 +221,14 @@ public class ItemGravityRod extends ItemMod implements IManaUsingItem {
if(item instanceof ItemEntity) {
((ItemEntity) item).setPickupDelay(20);
float mot = IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 2.25F : 1.5F;
item.motionX = moveVector.x * mot;
item.motionY = moveVector.y;
item.motionZ = moveVector.z * mot;
item.setMotion(moveVector.x * mot, moveVector.y, moveVector.z * mot);
if(!player.world.isRemote) {
EntityThrownItem thrown = new EntityThrownItem(item.world, item.posX, item.posY, item.posZ, (ItemEntity) item);
item.world.addEntity(thrown);
}
item.remove();
} else {
item.motionX = moveVector.x * 3.0F;
item.motionY = moveVector.y * 1.5F;
item.motionZ = moveVector.z * 3.0F;
item.setMotion(item.getMotion().mul(3, 1.5, 3));
}
ItemNBTHelper.setInt(stack, TAG_TICKS_COOLDOWN, 10);
}
@@ -23,7 +23,9 @@ import net.minecraft.util.Hand;
import net.minecraft.util.Hand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.Botania;
@@ -54,9 +56,13 @@ public class ItemSkyDirtRod extends ItemDirtRod {
int entities = world.getEntitiesWithinAABB(LivingEntity.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1)).size();
if(entities == 0) {
ItemStack save = player.getHeldItem(hand);
ItemStack stackToPlace = new ItemStack(Blocks.DIRT);
ItemUseContext ctx = new ItemUseContext(player, stackToPlace, new BlockPos(x, y, z), Direction.DOWN, 0, 0, 0);
player.setHeldItem(hand, stackToPlace);
BlockRayTraceResult hit = new BlockRayTraceResult(Vec3d.ZERO, Direction.DOWN, new BlockPos(x, y, z), false);
ItemUseContext ctx = new ItemUseContext(player, hand, hit);
stackToPlace.onItemUse(ctx);
player.setHeldItem(hand, save);
if(stackToPlace.isEmpty()) {
ManaItemHandler.requestManaExactForTool(stack, player, COST * 2, true);
@@ -16,6 +16,8 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.BlockItem;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
import net.minecraft.inventory.IInventory;
@@ -24,9 +26,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.VanillaRecipeTypes;
import vazkii.botania.api.item.IManaProficiencyArmor;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -36,6 +39,7 @@ import vazkii.botania.common.item.equipment.tool.ToolCommons;
import javax.annotation.Nonnull;
import java.util.Map;
import java.util.Optional;
import java.util.WeakHashMap;
public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
@@ -72,20 +76,26 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
public void onUsingTick(ItemStack stack, LivingEntity living, int time) {
if(!(living instanceof PlayerEntity)) return;
PlayerEntity p = (PlayerEntity) living;
IInventory dummyInv = new Inventory(null, 1);
IInventory dummyInv = new Inventory(1);
if(!ManaItemHandler.requestManaExactForTool(stack, p, COST_PER_TICK, false))
return;
RayTraceResult pos = ToolCommons.raytraceFromEntity(p.world, p, false, 32);
RayTraceResult ray = ToolCommons.raytraceFromEntity(p.world, p, RayTraceContext.FluidMode.NONE, 32);
if(pos != null && pos.getBlockPos() != null) {
BlockState state = p.world.getBlockState(pos.getBlockPos());
if(ray.getType() == RayTraceResult.Type.BLOCK) {
BlockRayTraceResult pos = (BlockRayTraceResult) ray;
BlockState state = p.world.getBlockState(pos.getPos());
dummyInv.setInventorySlotContents(0, new ItemStack(state.getBlock()));
ItemStack result = p.world.getRecipeManager().getResult(dummyInv, p.world, VanillaRecipeTypes.SMELTING);
Optional<ItemStack> maybeResult= p.world.getRecipeManager()
.getRecipe(IRecipeType.SMELTING, dummyInv, p.world)
.map(IRecipe::getRecipeOutput);
if(!result.isEmpty() && result.getItem() instanceof BlockItem) {
if(maybeResult.isPresent()
&& !maybeResult.get().isEmpty()
&& maybeResult.get().getItem() instanceof BlockItem) {
ItemStack result = maybeResult.get();
boolean decremented = false;
if(playerData.containsKey(p)) {
@@ -96,7 +106,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
decremented = true;
if(data.progress <= 0) {
if(!p.world.isRemote) {
p.world.setBlockState(pos.getBlockPos(), Block.getBlockFromItem(result.getItem()).getDefaultState());
p.world.setBlockState(pos.getPos(), Block.getBlockFromItem(result.getItem()).getDefaultState());
p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.PLAYERS, 0.6F, 1F);
p.world.playSound(null, p.posX, p.posY, p.posZ, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1F, 1F);
@@ -106,9 +116,9 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
}
for(int i = 0; i < 25; i++) {
double x = pos.getBlockPos().getX() + Math.random();
double y = pos.getBlockPos().getY() + Math.random();
double z = pos.getBlockPos().getZ() + Math.random();
double x = pos.getPos().getX() + Math.random();
double y = pos.getPos().getY() + Math.random();
double z = pos.getPos().getZ() + Math.random();
Botania.proxy.wispFX(x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F);
}
@@ -120,9 +130,9 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
playerData.put(p, new SmeltData(pos, IManaProficiencyArmor.Helper.hasProficiency(p, stack) ? (int) (TIME * 0.6) : TIME));
else {
for(int i = 0; i < 2; i++) {
double x = pos.getBlockPos().getX() + Math.random();
double y = pos.getBlockPos().getY() + Math.random();
double z = pos.getBlockPos().getZ() + Math.random();
double x = pos.getPos().getX() + Math.random();
double y = pos.getPos().getY() + Math.random();
double z = pos.getPos().getZ() + Math.random();
Botania.proxy.wispFX(x, y, z, 1F, 0.2F, 0.2F, 0.5F, (float) -Math.random() / 10F);
}
if(time % 10 == 0)
@@ -138,16 +148,16 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
}
static class SmeltData {
public final RayTraceResult pos;
public final BlockRayTraceResult pos;
public int progress;
public SmeltData(RayTraceResult pos, int progress) {
public SmeltData(BlockRayTraceResult pos, int progress) {
this.pos = pos;
this.progress = progress;
}
public boolean equalPos(RayTraceResult pos) {
return pos.getBlockPos().equals(this.pos.getBlockPos());
public boolean equalPos(BlockRayTraceResult pos) {
return pos.getPos().equals(this.pos.getPos());
}
}
}
@@ -77,7 +77,9 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
} else if(isFlying(stack)) {
if(holding) {
player.fallDistance = 0F;
player.motionY = IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 1.6 : 1.25;
double dy = player.getMotion().getY()
+ (IManaProficiencyArmor.Helper.hasProficiency(player, stack) ? 1.6 : 1.25);
player.setMotion(player.getMotion().add(0, dy, 0));
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.airRod, SoundCategory.PLAYERS, 0.1F, 0.25F);
for(int i = 0; i < 5; i++)
@@ -144,8 +146,8 @@ public class ItemTornadoRod extends ItemMod implements IManaUsingItem, IAvatarWi
int rangeY = 3;
List<PlayerEntity> players = world.getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(te.getPos().add(-0.5 - range, -0.5 - rangeY, -0.5 - range), te.getPos().add(0.5 + range, 0.5 + rangeY, 0.5 + range)));
for(PlayerEntity p : players) {
if(p.motionY > 0.3 && p.motionY < 2 && !p.isSneaking()) {
p.motionY = 2.8;
if(p.getMotion().getY() > 0.3 && p.getMotion().getY() < 2 && !p.isSneaking()) {
p.setMotion(p.getMotion().getX(), 2.8, p.getMotion().getZ());
for(int i = 0; i < 20; i++)
for(int j = 0; j < 5; j++)
@@ -2,17 +2,24 @@ package vazkii.botania.common.item.rod;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.BlockState;
import net.minecraft.block.IBucketPickupHandler;
import net.minecraft.block.ILiquidContainer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.Items;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.item.BucketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import vazkii.botania.api.mana.IManaUsingItem;
@@ -30,26 +37,26 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
super(props);
}
// [VanillaCopy] From ItemBucket
// [VanillaCopy] From BucketItem
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, @Nonnull Hand handIn) {
ItemStack itemstack = playerIn.getHeldItem(handIn);
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, false);
RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.NONE);
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(playerIn, worldIn, itemstack, raytraceresult);
if (ret != null) return ret;
if (raytraceresult == null) {
if (raytraceresult.getType() == RayTraceResult.Type.MISS) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else if (raytraceresult.type == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = raytraceresult.getBlockPos();
if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, raytraceresult.sideHit, itemstack)) {
BlockState iblockstate = worldIn.getBlockState(blockpos);
BlockPos blockpos1 = this.getPlacementPosition(iblockstate, blockpos, raytraceresult);
} else if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) {
return new ActionResult<>(ActionResultType.PASS, itemstack);
} else {
BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)raytraceresult;
BlockPos blockpos = blockraytraceresult.getPos();
if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, blockraytraceresult.getFace(), itemstack)) {
BlockState blockstate = worldIn.getBlockState(blockpos);
BlockPos blockpos1 = blockstate.getBlock() instanceof ILiquidContainer ? blockpos : blockraytraceresult.getPos().offset(blockraytraceresult.getFace());
if (ManaItemHandler.requestManaExactForTool(itemstack, playerIn, COST, true)
&& ((BucketItem) Items.WATER_BUCKET).tryPlaceContainedLiquid(playerIn, worldIn, blockpos1, raytraceresult)) {
&& ((BucketItem) Items.WATER_BUCKET).tryPlaceContainedLiquid(playerIn, worldIn, blockpos1, blockraytraceresult)) {
if (playerIn instanceof ServerPlayerEntity) {
CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayerEntity)playerIn, blockpos1, itemstack);
}
@@ -64,16 +71,9 @@ public class ItemWaterRod extends ItemMod implements IManaUsingItem {
} else {
return new ActionResult<>(ActionResultType.FAIL, itemstack);
}
} else {
return new ActionResult<>(ActionResultType.PASS, itemstack);
}
}
// [VanillaCopy] ItemBucket
private BlockPos getPlacementPosition(BlockState p_210768_1_, BlockPos p_210768_2_, RayTraceResult p_210768_3_) {
return p_210768_1_.getBlock() instanceof ILiquidContainer ? p_210768_2_ : p_210768_3_.getBlockPos().offset(p_210768_3_.sideHit);
}
@Override
public boolean usesMana(ItemStack stack) {
return true;
@@ -26,6 +26,7 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
@@ -101,7 +102,8 @@ public final class SkyblockWorldEvents {
event.setCancellationResult(ActionResultType.SUCCESS);
}
} else if(!equipped.isEmpty() && equipped.getItem() == Items.BOWL) {
RayTraceResult rtr = ToolCommons.raytraceFromEntity(event.getWorld(), event.getEntityPlayer(), true, 4.5F);
RayTraceResult rtr = ToolCommons.raytraceFromEntity(event.getWorld(), event.getEntityPlayer(),
RayTraceContext.FluidMode.SOURCE_ONLY, 4.5F);
if(rtr.getType() == RayTraceResult.Type.BLOCK) {
BlockPos pos = ((BlockRayTraceResult) rtr).getPos();
if(event.getWorld().getBlockState(pos).getMaterial() == Material.WATER) {