mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Cleanups in API
This commit is contained in:
1 parent
db23bffea6
commit
3084b058da
21 files changed
+120
-119
No files matched your search
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.block.BlockCarpet;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.block.BlockStainedGlass;
|
||||
@@ -38,6 +39,7 @@ import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.fml.common.LoaderState;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.DummyMethodHandler;
|
||||
@@ -299,14 +301,14 @@ public final class BotaniaAPI {
|
||||
return fallbackBrew;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Registers a Block as disposable using its Ore Dictionary Name.
|
||||
*/
|
||||
public static void registerDisposableBlock(String oreDictName) {
|
||||
disposableBlocks.add(oreDictName);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Registers a Block as semi disposable using its Ore Dictionary Name.
|
||||
* This means it will not be trashed when sneaking.
|
||||
*/
|
||||
@@ -317,14 +319,13 @@ public final class BotaniaAPI {
|
||||
/**
|
||||
* Registers a paintableBlock and returns it.
|
||||
* You must also provide the PropertyEnum that this block uses to express its color
|
||||
* The component type of the property must be EnumDyeColor
|
||||
*/
|
||||
public static Block registerPaintableBlock(Block paintable, PropertyEnum<EnumDyeColor> colorProp){
|
||||
paintableBlocks.put(paintable, colorProp);
|
||||
return paintable;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Blacklists an Entity from being affected by the Rod of the Shaded Mesa.
|
||||
* Pass in the class for the Entity, e.g. EntityCow.class
|
||||
*/
|
||||
@@ -332,7 +333,7 @@ public final class BotaniaAPI {
|
||||
gravityRodBlacklist.add(entity);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Checks if the provided Entity is contained in the Blacklist.
|
||||
* Pass in the class for the Entity, e.g. entity.getClass()
|
||||
*/
|
||||
@@ -407,6 +408,7 @@ public final class BotaniaAPI {
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) {
|
||||
Preconditions.checkArgument(inputs.length <= 16);
|
||||
RecipePetals recipe = new RecipePetals(output, inputs);
|
||||
petalRecipes.add(recipe);
|
||||
return recipe;
|
||||
@@ -445,6 +447,7 @@ public final class BotaniaAPI {
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) {
|
||||
Preconditions.checkArgument(inputs.length <= 16);
|
||||
RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs);
|
||||
runeAltarRecipes.add(recipe);
|
||||
return recipe;
|
||||
@@ -458,6 +461,7 @@ public final class BotaniaAPI {
|
||||
* @return The recipe created.
|
||||
*/
|
||||
public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) {
|
||||
Preconditions.checkArgument(mana <= 1000000);
|
||||
RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana);
|
||||
manaInfusionRecipes.add(recipe);
|
||||
return recipe;
|
||||
@@ -503,6 +507,7 @@ public final class BotaniaAPI {
|
||||
* @inputs The items used in the recipe, no more than 6.
|
||||
*/
|
||||
public static RecipeBrew registerBrewRecipe(Brew brew, Object... inputs) {
|
||||
Preconditions.checkArgument(inputs.length <= 6);
|
||||
RecipeBrew recipe = new RecipeBrew(brew, inputs);
|
||||
brewRecipes.add(recipe);
|
||||
return recipe;
|
||||
@@ -510,9 +515,10 @@ public final class BotaniaAPI {
|
||||
|
||||
/**
|
||||
* Registers a SubTileEntity, a new special flower. Look in the subtile package of the API.
|
||||
* If you call this after PostInit you're a failiure and we are very disappointed in you.
|
||||
* Call this in preInit, and don't forget to register a model in BotaniaAPIClient.
|
||||
*/
|
||||
public static void registerSubTile(String key, Class<? extends SubTileEntity> subtileClass) {
|
||||
Preconditions.checkArgument(Loader.instance().isInState(LoaderState.PREINITIALIZATION));
|
||||
subTiles.put(key, subtileClass);
|
||||
subTileMods.put(key, Loader.instance().activeModContainer().getModId());
|
||||
}
|
||||
@@ -667,7 +673,7 @@ public final class BotaniaAPI {
|
||||
|
||||
/**
|
||||
* Registers a Wiki provider for a mod so it uses that instead of the fallback
|
||||
* FTB wiki. Make sure to call this on PostInit only!
|
||||
* FTB wiki.
|
||||
*/
|
||||
public static void registerModWiki(String mod, IWikiProvider provider) {
|
||||
WikiHooks.registerModWiki(mod, provider);
|
||||
|
||||
@@ -12,4 +12,16 @@ public class TileSignature {
|
||||
this.remoteWorld = remoteWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Boolean.hashCode(remoteWorld) ^ tile.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof TileSignature
|
||||
&& tile == ((TileSignature) o).tile
|
||||
&& remoteWorld == ((TileSignature) o).remoteWorld;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,15 +38,7 @@ public interface ISparkAttachable extends IManaReceiver {
|
||||
|
||||
/**
|
||||
* Gets the Spark that is attached to this block. A common implementation is
|
||||
* to check for Spark entities above:
|
||||
*
|
||||
List<ISparkEntity> sparks = worldObj.getEntitiesWithinAABB(ISparkEntity.class, new AxisAlignedBB(xCoord, yCoord + 1, zCoord, xCoord + 1, yCoord + 2, zCoord + 1));
|
||||
if(sparks.size() == 1) {
|
||||
Entity e = (Entity) sparks.get(0);
|
||||
return (ISparkEntity) e;
|
||||
}
|
||||
|
||||
return null;
|
||||
* to check for Spark entities above using world.getEntitiesWithinAABB()
|
||||
*/
|
||||
public ISparkEntity getAttachedSpark();
|
||||
|
||||
|
||||
@@ -19,15 +19,7 @@ public interface ISparkEntity {
|
||||
|
||||
/**
|
||||
* Which TileEntity is this Spark attached to? A common implementation is checking the block below.
|
||||
*
|
||||
int x = MathHelper.floor_double(posX);
|
||||
int y = MathHelper.floor_double(posY) - 1;
|
||||
int z = MathHelper.floor_double(posZ);
|
||||
TileEntity tile = worldObj.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof ISparkAttachable)
|
||||
return (ISparkAttachable) tile;
|
||||
|
||||
return null;
|
||||
* using world.getTileEntity(new BlockPos(this).down())
|
||||
*/
|
||||
public ISparkAttachable getAttachedTile();
|
||||
|
||||
@@ -49,12 +41,12 @@ public interface ISparkEntity {
|
||||
* 3: Recessive<br>
|
||||
* 4: Isolated
|
||||
*/
|
||||
public int getUpgrade();
|
||||
public SparkUpgradeType getUpgrade();
|
||||
|
||||
/**
|
||||
* Sets the upgrade on this Spark. See {@link ISparkEntity#getUpgrade}
|
||||
*/
|
||||
public void setUpgrade(int upgrade);
|
||||
public void setUpgrade(SparkUpgradeType upgrade);
|
||||
|
||||
/**
|
||||
* See {@link ISparkAttachable#areIncomingTranfersDone()}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package vazkii.botania.api.mana.spark;
|
||||
|
||||
public enum SparkUpgradeType {
|
||||
NONE,
|
||||
DISPERSIVE,
|
||||
DOMINANT,
|
||||
RECESSIVE,
|
||||
ISOLATED
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "76", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "77", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ElvenPortalUpdateEvent extends Event {
|
||||
*/
|
||||
public final TileEntity portalTile;
|
||||
public final AxisAlignedBB aabb;
|
||||
public boolean open;
|
||||
public final boolean open;
|
||||
public final List<ItemStack> stacksInside;
|
||||
|
||||
public ElvenPortalUpdateEvent(TileEntity te, AxisAlignedBB aabb, boolean open, List<ItemStack> stacks) {
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.api.recipe;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -23,20 +24,20 @@ import vazkii.botania.api.brew.IBrewContainer;
|
||||
|
||||
public class RecipeBrew {
|
||||
|
||||
Brew brew;
|
||||
List<Object> inputs;
|
||||
private final Brew brew;
|
||||
private final ImmutableList<Object> inputs;
|
||||
|
||||
public RecipeBrew(Brew brew, Object... inputs) {
|
||||
this.brew = brew;
|
||||
|
||||
List<Object> inputsToSet = new ArrayList<>();
|
||||
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
|
||||
for(Object obj : inputs) {
|
||||
if(obj instanceof String || obj instanceof ItemStack)
|
||||
inputsToSet.add(obj);
|
||||
else throw new IllegalArgumentException("Invalid input");
|
||||
}
|
||||
|
||||
this.inputs = inputsToSet;
|
||||
this.inputs = inputsToSet.build();
|
||||
}
|
||||
|
||||
public boolean matches(IItemHandler inv) {
|
||||
@@ -112,4 +113,16 @@ public class RecipeBrew {
|
||||
return container.getItemForBrew(brew, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * brew.hashCode() ^ inputs.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof RecipeBrew
|
||||
&& brew == ((RecipeBrew) o).brew
|
||||
&& inputs.equals(((RecipeBrew) o).inputs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,25 +3,26 @@ package vazkii.botania.api.recipe;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class RecipeElvenTrade {
|
||||
|
||||
ItemStack output;
|
||||
List<Object> inputs;
|
||||
private final ItemStack output;
|
||||
private final ImmutableList<Object> inputs;
|
||||
|
||||
public RecipeElvenTrade(ItemStack output, Object... inputs) {
|
||||
this.output = output;
|
||||
|
||||
List<Object> inputsToSet = new ArrayList<>();
|
||||
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
|
||||
for(Object obj : inputs) {
|
||||
if(obj instanceof String || obj instanceof ItemStack)
|
||||
inputsToSet.add(obj);
|
||||
else throw new IllegalArgumentException("Invalid input");
|
||||
}
|
||||
|
||||
this.inputs = inputsToSet;
|
||||
this.inputs = inputsToSet.build();
|
||||
}
|
||||
|
||||
public boolean matches(List<ItemStack> stacks, boolean remove) {
|
||||
@@ -84,7 +85,7 @@ public class RecipeElvenTrade {
|
||||
}
|
||||
|
||||
public List<Object> getInputs() {
|
||||
return new ArrayList<>(inputs);
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
|
||||
@@ -17,9 +17,9 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class RecipeManaInfusion {
|
||||
|
||||
ItemStack output;
|
||||
Object input;
|
||||
int mana;
|
||||
private final ItemStack output;
|
||||
private final Object input;
|
||||
private final int mana;
|
||||
boolean isAlchemy = false;
|
||||
boolean isConjuration = false;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class RecipeMiniFlower extends RecipeManaInfusion {
|
||||
@Override
|
||||
public boolean matches(ItemStack stack) {
|
||||
String key = BotaniaAPI.internalHandler.getStackSubTileKey(stack);
|
||||
String input = this.input instanceof String ? (String) this.input : BotaniaAPI.internalHandler.getStackSubTileKey((ItemStack) this.input);
|
||||
String input = this.getInput() instanceof String ? (String) this.getInput() : BotaniaAPI.internalHandler.getStackSubTileKey((ItemStack) this.getInput());
|
||||
return key != null && key.equals(input);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.api.recipe;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -20,20 +21,20 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class RecipePetals {
|
||||
|
||||
ItemStack output;
|
||||
List<Object> inputs;
|
||||
private final ItemStack output;
|
||||
private final ImmutableList<Object> inputs;
|
||||
|
||||
public RecipePetals(ItemStack output, Object... inputs) {
|
||||
this.output = output;
|
||||
|
||||
List<Object> inputsToSet = new ArrayList<>();
|
||||
ImmutableList.Builder<Object> inputsToSet = ImmutableList.builder();
|
||||
for(Object obj : inputs) {
|
||||
if(obj instanceof String || obj instanceof ItemStack)
|
||||
inputsToSet.add(obj);
|
||||
else throw new IllegalArgumentException("Invalid input");
|
||||
}
|
||||
|
||||
this.inputs = inputsToSet;
|
||||
this.inputs = inputsToSet.build();
|
||||
}
|
||||
|
||||
public boolean matches(IItemHandler inv) {
|
||||
@@ -87,7 +88,7 @@ public class RecipePetals {
|
||||
}
|
||||
|
||||
public List<Object> getInputs() {
|
||||
return new ArrayList<>(inputs);
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RecipeRuneAltar extends RecipePetals {
|
||||
|
||||
int mana;
|
||||
private final int mana;
|
||||
|
||||
public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) {
|
||||
super(output, inputs);
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Holds all Botania block state properties. Use these to set botania blockstates
|
||||
*/
|
||||
public class BotaniaStateProps {
|
||||
public final class BotaniaStateProps {
|
||||
|
||||
/** Unlisted properties **/
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.util.BlockPos;
|
||||
*/
|
||||
public class RadiusDescriptor {
|
||||
|
||||
final BlockPos subtileCoords;
|
||||
private final BlockPos subtileCoords;
|
||||
|
||||
public RadiusDescriptor(BlockPos subtileCoords) {
|
||||
this.subtileCoords = subtileCoords;
|
||||
|
||||
@@ -28,7 +28,7 @@ import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
*/
|
||||
public class BasicSignature extends SubTileSignature {
|
||||
|
||||
final String name;
|
||||
private final String name;
|
||||
|
||||
public BasicSignature(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
public class SimpleWikiProvider implements IWikiProvider {
|
||||
|
||||
final String name, urlBase, replacement;
|
||||
final boolean lowercase;
|
||||
private final String name, urlBase, replacement;
|
||||
private final boolean lowercase;
|
||||
|
||||
public SimpleWikiProvider(String name, String urlBase) {
|
||||
this(name, urlBase, "%20");
|
||||
|
||||
@@ -23,7 +23,7 @@ public class RenderSpark extends RenderSparkBase<EntitySpark> {
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getSpinningIcon(EntitySpark entity) {
|
||||
int upgrade = entity.getUpgrade() - 1;
|
||||
int upgrade = entity.getUpgrade().ordinal() - 1;
|
||||
return upgrade >= 0 && upgrade < MiscellaneousIcons.INSTANCE.sparkUpgradeIcons.length ? MiscellaneousIcons.INSTANCE.sparkUpgradeIcons[upgrade] : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
import vazkii.botania.api.mana.spark.SparkUpgradeType;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@@ -37,8 +38,8 @@ public class TileSparkChanger extends TileSimpleInventory {
|
||||
ISparkAttachable attach = (ISparkAttachable) tile;
|
||||
ISparkEntity spark = attach.getAttachedSpark();
|
||||
if(spark != null) {
|
||||
int upg = spark.getUpgrade();
|
||||
int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1;
|
||||
SparkUpgradeType upg = spark.getUpgrade();
|
||||
SparkUpgradeType newUpg = changeStack == null ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1];
|
||||
if(upg != newUpg)
|
||||
attachables.add(attach);
|
||||
}
|
||||
@@ -48,9 +49,9 @@ public class TileSparkChanger extends TileSimpleInventory {
|
||||
if(attachables.size() > 0) {
|
||||
ISparkAttachable attach = attachables.get(worldObj.rand.nextInt(attachables.size()));
|
||||
ISparkEntity spark = attach.getAttachedSpark();
|
||||
int upg = spark.getUpgrade();
|
||||
ItemStack sparkStack = upg == 0 ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg - 1);
|
||||
int newUpg = changeStack == null ? 0 : changeStack.getItemDamage() + 1;
|
||||
SparkUpgradeType upg = spark.getUpgrade();
|
||||
ItemStack sparkStack = upg == SparkUpgradeType.NONE ? null : new ItemStack(ModItems.sparkUpgrade, 1, upg.ordinal() - 1);
|
||||
SparkUpgradeType newUpg = changeStack == null ? SparkUpgradeType.NONE : SparkUpgradeType.values()[changeStack.getItemDamage() + 1];
|
||||
spark.setUpgrade(newUpg);
|
||||
Collection transfers = spark.getTransfers();
|
||||
if(transfers != null)
|
||||
|
||||
@@ -34,6 +34,7 @@ import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.api.mana.spark.ISparkAttachable;
|
||||
import vazkii.botania.api.mana.spark.ISparkEntity;
|
||||
import vazkii.botania.api.mana.spark.SparkHelper;
|
||||
import vazkii.botania.api.mana.spark.SparkUpgradeType;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
@@ -77,9 +78,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
}
|
||||
|
||||
boolean first = worldObj.isRemote && !firstTick;
|
||||
int upgrade = getUpgrade();
|
||||
SparkUpgradeType upgrade = getUpgrade();
|
||||
List<ISparkEntity> allSparks = null;
|
||||
if(first || upgrade == 2 || upgrade == 3)
|
||||
if(first || upgrade == SparkUpgradeType.DOMINANT || upgrade == SparkUpgradeType.RECESSIVE)
|
||||
allSparks = SparkHelper.getSparksAround(worldObj, posX, posY, posZ);
|
||||
|
||||
if(first)
|
||||
@@ -88,9 +89,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
Collection<ISparkEntity> transfers = getTransfers();
|
||||
|
||||
|
||||
if(upgrade != 0) {
|
||||
if(upgrade != SparkUpgradeType.NONE) {
|
||||
switch(upgrade) {
|
||||
case 1 : { // Dispersive
|
||||
case DISPERSIVE : {
|
||||
List<EntityPlayer> players = SparkHelper.getEntitiesAround(EntityPlayer.class, worldObj, posX, posY, posZ);
|
||||
|
||||
Map<EntityPlayer, Map<ItemStack, Integer>> receivingPlayers = new HashMap<>();
|
||||
@@ -141,14 +142,14 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
|
||||
break;
|
||||
}
|
||||
case 2 : { // Dominant
|
||||
case DOMINANT : {
|
||||
List<ISparkEntity> validSparks = new ArrayList<>();
|
||||
for(ISparkEntity spark : allSparks) {
|
||||
if(spark == this)
|
||||
continue;
|
||||
|
||||
int upgrade_ = spark.getUpgrade();
|
||||
if(upgrade_ == 0 && spark.getAttachedTile() instanceof IManaPool)
|
||||
SparkUpgradeType upgrade_ = spark.getUpgrade();
|
||||
if(upgrade_ == SparkUpgradeType.NONE && spark.getAttachedTile() instanceof IManaPool)
|
||||
validSparks.add(spark);
|
||||
}
|
||||
if(validSparks.size() > 0)
|
||||
@@ -156,13 +157,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
|
||||
break;
|
||||
}
|
||||
case 3 : { // Recessive
|
||||
case RECESSIVE : { // Recessive
|
||||
for(ISparkEntity spark : allSparks) {
|
||||
if(spark == this)
|
||||
continue;
|
||||
|
||||
int upgrade_ = spark.getUpgrade();
|
||||
if(upgrade_ != 2 && upgrade_ != 3 && upgrade_ != 4)
|
||||
SparkUpgradeType upgrade_ = spark.getUpgrade();
|
||||
if(upgrade_ != SparkUpgradeType.DOMINANT && upgrade_ != SparkUpgradeType.RECESSIVE && upgrade_ != SparkUpgradeType.ISOLATED)
|
||||
transfers.add(spark);
|
||||
}
|
||||
break;
|
||||
@@ -252,13 +253,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
public boolean interactFirst(EntityPlayer player) {
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack != null) {
|
||||
int upgrade = getUpgrade();
|
||||
SparkUpgradeType upgrade = getUpgrade();
|
||||
if(stack.getItem() == ModItems.twigWand) {
|
||||
if(player.isSneaking()) {
|
||||
if(upgrade > 0) {
|
||||
if(upgrade != SparkUpgradeType.NONE) {
|
||||
if(!worldObj.isRemote)
|
||||
entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F);
|
||||
setUpgrade(0);
|
||||
entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade.ordinal() - 1), 0F);
|
||||
setUpgrade(SparkUpgradeType.NONE);
|
||||
|
||||
transfers.clear();
|
||||
removeTransferants = 2;
|
||||
@@ -272,9 +273,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
particleBeam(this, (Entity) spark);
|
||||
return true;
|
||||
}
|
||||
} else if(stack.getItem() == ModItems.sparkUpgrade && upgrade == 0) {
|
||||
} else if(stack.getItem() == ModItems.sparkUpgrade && upgrade == SparkUpgradeType.NONE) {
|
||||
int newUpgrade = stack.getItemDamage() + 1;
|
||||
setUpgrade(newUpgrade);
|
||||
setUpgrade(SparkUpgradeType.values()[newUpgrade]);
|
||||
stack.stackSize--;
|
||||
if(player.worldObj.isRemote)
|
||||
player.swingItem();
|
||||
@@ -297,13 +298,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound cmp) {
|
||||
setUpgrade(cmp.getInteger(TAG_UPGRADE));
|
||||
setUpgrade(SparkUpgradeType.values()[cmp.getInteger(TAG_UPGRADE)]);
|
||||
dataWatcher.updateObject(INVISIBILITY_DATA_WATCHER_KEY, cmp.getInteger(TAG_INVIS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound cmp) {
|
||||
cmp.setInteger(TAG_UPGRADE, getUpgrade());
|
||||
cmp.setInteger(TAG_UPGRADE, getUpgrade().ordinal());
|
||||
cmp.setInteger(TAG_INVIS, dataWatcher.getWatchableObjectInt(INVISIBILITY_DATA_WATCHER_KEY));
|
||||
}
|
||||
|
||||
@@ -311,10 +312,10 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
public void setDead() {
|
||||
super.setDead();
|
||||
if(!worldObj.isRemote) {
|
||||
int upgrade = getUpgrade();
|
||||
SparkUpgradeType upgrade = getUpgrade();
|
||||
entityDropItem(new ItemStack(ModItems.spark), 0F);
|
||||
if(upgrade > 0)
|
||||
entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade - 1), 0F);
|
||||
if(upgrade != SparkUpgradeType.NONE)
|
||||
entityDropItem(new ItemStack(ModItems.sparkUpgrade, 1, upgrade.ordinal() - 1), 0F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,14 +336,16 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
public Collection<ISparkEntity> getTransfers() {
|
||||
Collection<ISparkEntity> removals = new ArrayList<>();
|
||||
|
||||
for(ISparkEntity e : transfers) {
|
||||
ISparkEntity spark = e;
|
||||
int upgr = getUpgrade();
|
||||
int supgr = spark.getUpgrade();
|
||||
for(ISparkEntity spark : transfers) {
|
||||
SparkUpgradeType upgr = getUpgrade();
|
||||
SparkUpgradeType supgr = spark.getUpgrade();
|
||||
ISparkAttachable atile = spark.getAttachedTile();
|
||||
|
||||
if(!(spark != this && !spark.areIncomingTransfersDone() && atile != null && !atile.isFull() && (upgr == 0 && supgr == 2 || upgr == 3 && (supgr == 0 || supgr == 1) || !(atile instanceof IManaPool))))
|
||||
removals.add(e);
|
||||
if(!(spark != this
|
||||
&& !spark.areIncomingTransfersDone()
|
||||
&& atile != null && !atile.isFull()
|
||||
&& (upgr == SparkUpgradeType.NONE && supgr == SparkUpgradeType.DOMINANT || upgr == SparkUpgradeType.RECESSIVE && (supgr == SparkUpgradeType.NONE || supgr == SparkUpgradeType.DISPERSIVE) || !(atile instanceof IManaPool))))
|
||||
removals.add(spark);
|
||||
}
|
||||
|
||||
if(!removals.isEmpty())
|
||||
@@ -363,13 +366,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpgrade() {
|
||||
return dataWatcher.getWatchableObjectInt(28);
|
||||
public SparkUpgradeType getUpgrade() {
|
||||
return SparkUpgradeType.values()[dataWatcher.getWatchableObjectInt(28)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUpgrade(int upgrade) {
|
||||
dataWatcher.updateObject(28, upgrade);
|
||||
public void setUpgrade(SparkUpgradeType upgrade) {
|
||||
dataWatcher.updateObject(28, upgrade.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user