mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-26 06:42:57 +00:00
[ci skip] spotlessApply with the new settings
This commit is contained in:
1 parent
6b208b98bc
commit
a309488cdf
214 files changed
+9283
-9265
No files matched your search
@@ -1,12 +1,17 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
||||
* Tools | Templates and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.mc1710.item;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.block.IBlock;
|
||||
import minetweaker.api.data.DataMap;
|
||||
@@ -23,6 +28,7 @@ import minetweaker.mc1710.block.MCItemBlock;
|
||||
import minetweaker.mc1710.data.NBTConverter;
|
||||
import minetweaker.mc1710.liquid.MCLiquidStack;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,198 +37,191 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static minetweaker.api.minecraft.MineTweakerMC.getItemStack;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class MCItemStack implements IItemStack {
|
||||
private final ItemStack stack;
|
||||
private final List<IItemStack> items;
|
||||
private IData tag = null;
|
||||
private boolean wildcardSize;
|
||||
|
||||
public MCItemStack(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
throw new IllegalArgumentException("stack cannot be null");
|
||||
private final ItemStack stack;
|
||||
private final List<IItemStack> items;
|
||||
private IData tag = null;
|
||||
private boolean wildcardSize;
|
||||
|
||||
stack = itemStack.copy();
|
||||
items = Collections.singletonList(this);
|
||||
}
|
||||
public MCItemStack(ItemStack itemStack) {
|
||||
if (itemStack == null) throw new IllegalArgumentException("stack cannot be null");
|
||||
|
||||
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
|
||||
this(itemStack);
|
||||
stack = itemStack.copy();
|
||||
items = Collections.singletonList(this);
|
||||
}
|
||||
|
||||
this.wildcardSize = wildcardSize;
|
||||
}
|
||||
public MCItemStack(ItemStack itemStack, boolean wildcardSize) {
|
||||
this(itemStack);
|
||||
|
||||
private MCItemStack(ItemStack itemStack, IData tag) {
|
||||
if (itemStack == null)
|
||||
throw new IllegalArgumentException("stack cannot be null");
|
||||
this.wildcardSize = wildcardSize;
|
||||
}
|
||||
|
||||
stack = itemStack;
|
||||
items = Collections.singletonList(this);
|
||||
this.tag = tag;
|
||||
}
|
||||
private MCItemStack(ItemStack itemStack, IData tag) {
|
||||
if (itemStack == null) throw new IllegalArgumentException("stack cannot be null");
|
||||
|
||||
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
|
||||
stack = itemStack;
|
||||
items = Collections.singletonList(this);
|
||||
this.tag = tag;
|
||||
this.wildcardSize = wildcardSize;
|
||||
}
|
||||
stack = itemStack;
|
||||
items = Collections.singletonList(this);
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition getDefinition() {
|
||||
return new MCItemDefinition(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItem());
|
||||
}
|
||||
private MCItemStack(ItemStack itemStack, IData tag, boolean wildcardSize) {
|
||||
stack = itemStack;
|
||||
items = Collections.singletonList(this);
|
||||
this.tag = tag;
|
||||
this.wildcardSize = wildcardSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return stack.getUnlocalizedName();
|
||||
}
|
||||
@Override
|
||||
public IItemDefinition getDefinition() {
|
||||
return new MCItemDefinition(Item.itemRegistry.getNameForObject(stack.getItem()), stack.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return stack.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String name) {
|
||||
MineTweakerAPI.apply(new SetTranslationAction(getName() + ".name", name));
|
||||
}
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String name) {
|
||||
MineTweakerAPI.apply(new SetTranslationAction(getName() + ".name", name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxDamage(int damage) {
|
||||
MineTweakerAPI.apply(new SetStackmaxDamageAction(stack, damage));
|
||||
}
|
||||
@Override
|
||||
public void setMaxDamage(int damage) {
|
||||
MineTweakerAPI.apply(new SetStackmaxDamageAction(stack, damage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return stack.getMaxStackSize();
|
||||
}
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return stack.getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxStackSize(int size) {
|
||||
MineTweakerAPI.apply(new SetStackSizeAction((ItemStack) getInternal(), size));
|
||||
}
|
||||
@Override
|
||||
public void setMaxStackSize(int size) {
|
||||
MineTweakerAPI.apply(new SetStackSizeAction((ItemStack) getInternal(), size));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBlockHardness() {
|
||||
return ReflectionHelper.getPrivateValue(Block.class, Block.getBlockFromItem(stack.getItem()), "blockHardness");
|
||||
}
|
||||
@Override
|
||||
public float getBlockHardness() {
|
||||
return ReflectionHelper.getPrivateValue(Block.class, Block.getBlockFromItem(stack.getItem()), "blockHardness");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockHardness(float hardness) {
|
||||
MineTweakerAPI.apply(new SetBlockHardnessAction(stack, hardness));
|
||||
}
|
||||
@Override
|
||||
public void setBlockHardness(float hardness) {
|
||||
MineTweakerAPI.apply(new SetBlockHardnessAction(stack, hardness));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage() {
|
||||
return stack.getItemDamage();
|
||||
}
|
||||
@Override
|
||||
public int getDamage() {
|
||||
return stack.getItemDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IData getTag() {
|
||||
if (tag == null) {
|
||||
if (stack.stackTagCompound == null) {
|
||||
return DataMap.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public IData getTag() {
|
||||
if (tag == null) {
|
||||
if (stack.stackTagCompound == null) {
|
||||
return DataMap.EMPTY;
|
||||
}
|
||||
|
||||
tag = NBTConverter.from(stack.stackTagCompound, true);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
tag = NBTConverter.from(stack.stackTagCompound, true);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage() {
|
||||
return stack.getMaxDamage();
|
||||
}
|
||||
@Override
|
||||
public int getMaxDamage() {
|
||||
return stack.getMaxDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidStack getLiquid() {
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
return liquid == null ? null : new MCLiquidStack(liquid);
|
||||
}
|
||||
@Override
|
||||
public ILiquidStack getLiquid() {
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
return liquid == null ? null : new MCLiquidStack(liquid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient anyDamage() {
|
||||
if (stack.getItem().getHasSubtypes()) {
|
||||
MineTweakerAPI.logWarning("subitems don't have damaged states");
|
||||
return this;
|
||||
} else {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, OreDictionary.WILDCARD_VALUE);
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IIngredient anyDamage() {
|
||||
if (stack.getItem().getHasSubtypes()) {
|
||||
MineTweakerAPI.logWarning("subitems don't have damaged states");
|
||||
return this;
|
||||
} else {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, OreDictionary.WILDCARD_VALUE);
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack withDamage(int damage) {
|
||||
if (stack.getItem().getHasSubtypes()) {
|
||||
MineTweakerAPI.logWarning("subitems don't have damaged states");
|
||||
return this;
|
||||
} else {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, damage);
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IItemStack withDamage(int damage) {
|
||||
if (stack.getItem().getHasSubtypes()) {
|
||||
MineTweakerAPI.logWarning("subitems don't have damaged states");
|
||||
return this;
|
||||
} else {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, damage);
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack anyAmount() {
|
||||
ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag, true);
|
||||
}
|
||||
@Override
|
||||
public IItemStack anyAmount() {
|
||||
ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack withAmount(int amount) {
|
||||
ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
@Override
|
||||
public IItemStack withAmount(int amount) {
|
||||
ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
|
||||
result.stackTagCompound = stack.stackTagCompound;
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack withTag(IData tag) {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
||||
if (tag == null) {
|
||||
result.stackTagCompound = null;
|
||||
} else {
|
||||
result.stackTagCompound = (NBTTagCompound) NBTConverter.from(tag);
|
||||
}
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack withTag(IData tag) {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
||||
if (tag == null) {
|
||||
result.stackTagCompound = null;
|
||||
} else {
|
||||
result.stackTagCompound = (NBTTagCompound) NBTConverter.from(tag);
|
||||
}
|
||||
return new MCItemStack(result, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack withEmptyTag() {
|
||||
final ItemStack itemStack = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
||||
itemStack.stackTagCompound = null;
|
||||
return new MCItemStack(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IItemStack updateTag(IData tagUpdate) {
|
||||
if (tag == null) {
|
||||
if (stack.stackTagCompound == null) {
|
||||
return withTag(tagUpdate);
|
||||
}
|
||||
public IItemStack updateTag(IData tagUpdate) {
|
||||
if (tag == null) {
|
||||
if (stack.stackTagCompound == null) {
|
||||
return withTag(tagUpdate);
|
||||
}
|
||||
|
||||
tag = NBTConverter.from(stack.stackTagCompound, true);
|
||||
}
|
||||
tag = NBTConverter.from(stack.stackTagCompound, true);
|
||||
}
|
||||
|
||||
IData updated = tag.update(tagUpdate);
|
||||
return withTag(updated);
|
||||
}
|
||||
IData updated = tag.update(tagUpdate);
|
||||
return withTag(updated);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public IItemStack removeTag(String tag) {
|
||||
ItemStack result = new ItemStack(stack.getItem(), stack.stackSize, stack.getItemDamage());
|
||||
|
||||
@@ -234,199 +233,204 @@ public class MCItemStack implements IItemStack {
|
||||
IData dataTag = NBTConverter.from(result.stackTagCompound, false);
|
||||
return new MCItemStack(result, dataTag);
|
||||
}
|
||||
@Override
|
||||
public String getMark() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return stack.stackSize;
|
||||
}
|
||||
@Override
|
||||
public String getMark() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
@Override
|
||||
public int getAmount() {
|
||||
return stack.stackSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@Override
|
||||
public List<IItemStack> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack amount(int amount) {
|
||||
return withAmount(amount);
|
||||
}
|
||||
@Override
|
||||
public List<ILiquidStack> getLiquids() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeightedItemStack percent(float chance) {
|
||||
return new WeightedItemStack(this, chance * 0.01f);
|
||||
}
|
||||
@Override
|
||||
public IItemStack amount(int amount) {
|
||||
return withAmount(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeightedItemStack weight(float chance) {
|
||||
return new WeightedItemStack(this, chance);
|
||||
}
|
||||
@Override
|
||||
public WeightedItemStack percent(float chance) {
|
||||
return new WeightedItemStack(this, chance * 0.01f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient transform(IItemTransformer transformer) {
|
||||
return new IngredientItem(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[] { transformer });
|
||||
}
|
||||
@Override
|
||||
public WeightedItemStack weight(float chance) {
|
||||
return new WeightedItemStack(this, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient only(IItemCondition condition) {
|
||||
return new IngredientItem(this, null, new IItemCondition[] { condition }, ArrayUtil.EMPTY_TRANSFORMERS);
|
||||
}
|
||||
@Override
|
||||
public IIngredient transform(IItemTransformer transformer) {
|
||||
return new IngredientItem(this, null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[] { transformer });
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient marked(String mark) {
|
||||
return new IngredientItem(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
|
||||
}
|
||||
@Override
|
||||
public IIngredient only(IItemCondition condition) {
|
||||
return new IngredientItem(this, null, new IItemCondition[] { condition }, ArrayUtil.EMPTY_TRANSFORMERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIngredient or(IIngredient ingredient) {
|
||||
return new IngredientOr(this, ingredient);
|
||||
}
|
||||
@Override
|
||||
public IIngredient marked(String mark) {
|
||||
return new IngredientItem(this, mark, ArrayUtil.EMPTY_CONDITIONS, ArrayUtil.EMPTY_TRANSFORMERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
ItemStack internal = getItemStack(item);
|
||||
return internal !=null && stack !=null &&internal.getItem() == stack.getItem() && (wildcardSize || internal.stackSize >= stack.stackSize) && (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack.getItemDamage() == internal.getItemDamage() || (!stack.getHasSubtypes() && !stack.getItem().isDamageable()));
|
||||
}
|
||||
@Override
|
||||
public IIngredient or(IIngredient ingredient) {
|
||||
return new IngredientOr(this, ingredient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesExact(IItemStack item) {
|
||||
ItemStack internal = getItemStack(item);
|
||||
if (internal.getTagCompound() != null && stack.getTagCompound() == null) {
|
||||
return false;
|
||||
}
|
||||
if (internal.getTagCompound() == null && stack.getTagCompound() != null) {
|
||||
return false;
|
||||
}
|
||||
if (internal.getTagCompound() == null && stack.getTagCompound() == null) {
|
||||
return stack.getItem() == internal.getItem() && (internal.getItemDamage() == 32767 || stack.getItemDamage() == internal.getItemDamage());
|
||||
}
|
||||
if (internal.getTagCompound().func_150296_c().equals(stack.getTagCompound().func_150296_c())) {
|
||||
for (String s : (Set<String>)internal.getTagCompound().func_150296_c()) {
|
||||
if (!internal.getTagCompound().getTag(s).equals(stack.getTagCompound().getTag(s))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack.getItem() == internal.getItem() && (internal.getItemDamage() == 32767 || stack.getItemDamage() == internal.getItemDamage());
|
||||
}
|
||||
@Override
|
||||
public boolean matches(IItemStack item) {
|
||||
ItemStack internal = getItemStack(item);
|
||||
return internal != null && stack != null
|
||||
&& internal.getItem() == stack.getItem()
|
||||
&& (wildcardSize || internal.stackSize >= stack.stackSize)
|
||||
&& (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
|| stack.getItemDamage() == internal.getItemDamage()
|
||||
|| (!stack.getHasSubtypes() && !stack.getItem().isDamageable()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean matchesExact(IItemStack item) {
|
||||
ItemStack internal = getItemStack(item);
|
||||
if (internal.getTagCompound() != null && stack.getTagCompound() == null) {
|
||||
return false;
|
||||
}
|
||||
if (internal.getTagCompound() == null && stack.getTagCompound() != null) {
|
||||
return false;
|
||||
}
|
||||
if (internal.getTagCompound() == null && stack.getTagCompound() == null) {
|
||||
return stack.getItem() == internal.getItem()
|
||||
&& (internal.getItemDamage() == 32767 || stack.getItemDamage() == internal.getItemDamage());
|
||||
}
|
||||
if (internal.getTagCompound().func_150296_c().equals(stack.getTagCompound().func_150296_c())) {
|
||||
for (String s : (Set<String>) internal.getTagCompound().func_150296_c()) {
|
||||
if (!internal.getTagCompound().getTag(s).equals(stack.getTagCompound().getTag(s))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack.getItem() == internal.getItem()
|
||||
&& (internal.getItemDamage() == 32767 || stack.getItemDamage() == internal.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
List<IItemStack> iitems = ingredient.getItems();
|
||||
if (iitems == null || iitems.size() != 1)
|
||||
return false;
|
||||
return matches(iitems.get(0));
|
||||
}
|
||||
@Override
|
||||
public boolean matches(ILiquidStack liquid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
||||
return item;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(IIngredient ingredient) {
|
||||
List<IItemStack> iitems = ingredient.getItems();
|
||||
if (iitems == null || iitems.size() != 1) return false;
|
||||
return matches(iitems.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTransformers() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInternal() {
|
||||
return stack;
|
||||
}
|
||||
@Override
|
||||
public boolean hasTransformers() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlock asBlock() {
|
||||
String name = Block.blockRegistry.getNameForObject(Block.getBlockFromItem(stack.getItem()));
|
||||
if (Block.blockRegistry.containsKey(name)) {
|
||||
return new MCItemBlock(stack);
|
||||
} else {
|
||||
throw new ClassCastException("This item is not a block");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Object getInternal() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IOreDictEntry> getOres() {
|
||||
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
|
||||
@Override
|
||||
public IBlock asBlock() {
|
||||
String name = Block.blockRegistry.getNameForObject(Block.getBlockFromItem(stack.getItem()));
|
||||
if (Block.blockRegistry.containsKey(name)) {
|
||||
return new MCItemBlock(stack);
|
||||
} else {
|
||||
throw new ClassCastException("This item is not a block");
|
||||
}
|
||||
}
|
||||
|
||||
for (String key : OreDictionary.getOreNames()) {
|
||||
for (ItemStack is : OreDictionary.getOres(key)) {
|
||||
if (is.getItem() == stack.getItem() && (is.getItemDamage() == OreDictionary.WILDCARD_VALUE || is.getItemDamage() == stack.getItemDamage())) {
|
||||
result.add(MineTweakerAPI.oreDict.get(key));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<IOreDictEntry> getOres() {
|
||||
List<IOreDictEntry> result = new ArrayList<IOreDictEntry>();
|
||||
|
||||
return result;
|
||||
}
|
||||
for (String key : OreDictionary.getOreNames()) {
|
||||
for (ItemStack is : OreDictionary.getOres(key)) {
|
||||
if (is.getItem() == stack.getItem() && (is.getItemDamage() == OreDictionary.WILDCARD_VALUE
|
||||
|| is.getItemDamage() == stack.getItemDamage())) {
|
||||
result.add(MineTweakerAPI.oreDict.get(key));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #############################
|
||||
// ### Object implementation ###
|
||||
// #############################
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 41 * hash + stack.getItem().hashCode();
|
||||
hash = 41 * hash + stack.getItemDamage();
|
||||
hash = 41 * hash + stack.stackSize;
|
||||
hash = 41 * hash + (stack.stackTagCompound == null ? 0 : stack.stackTagCompound.hashCode());
|
||||
hash = 41 * hash + (this.wildcardSize ? 1 : 0);
|
||||
return hash;
|
||||
}
|
||||
// #############################
|
||||
// ### Object implementation ###
|
||||
// #############################
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final MCItemStack other = (MCItemStack) obj;
|
||||
if (this.stack.getItem() != other.stack.getItem())
|
||||
return false;
|
||||
if (this.stack.getItemDamage() != other.stack.getItemDamage())
|
||||
return false;
|
||||
if (this.stack.stackSize != other.stack.stackSize)
|
||||
return false;
|
||||
if (this.stack.stackTagCompound != other.stack.stackTagCompound && (this.stack == null || this.stack.equals(other.stack)))
|
||||
return false;
|
||||
if (this.wildcardSize != other.wildcardSize)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 41 * hash + stack.getItem().hashCode();
|
||||
hash = 41 * hash + stack.getItemDamage();
|
||||
hash = 41 * hash + stack.stackSize;
|
||||
hash = 41 * hash + (stack.stackTagCompound == null ? 0 : stack.stackTagCompound.hashCode());
|
||||
hash = 41 * hash + (this.wildcardSize ? 1 : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('<');
|
||||
result.append(Item.itemRegistry.getNameForObject(stack.getItem()));
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final MCItemStack other = (MCItemStack) obj;
|
||||
if (this.stack.getItem() != other.stack.getItem()) return false;
|
||||
if (this.stack.getItemDamage() != other.stack.getItemDamage()) return false;
|
||||
if (this.stack.stackSize != other.stack.stackSize) return false;
|
||||
if (this.stack.stackTagCompound != other.stack.stackTagCompound
|
||||
&& (this.stack == null || this.stack.equals(other.stack)))
|
||||
return false;
|
||||
if (this.wildcardSize != other.wildcardSize) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
result.append(":*");
|
||||
} else if (stack.getItemDamage() > 0) {
|
||||
result.append(':').append(stack.getItemDamage());
|
||||
}
|
||||
result.append('>');
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append('<');
|
||||
result.append(Item.itemRegistry.getNameForObject(stack.getItem()));
|
||||
|
||||
if (stack.getTagCompound() != null) {
|
||||
result.append(".withTag(");
|
||||
result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
|
||||
result.append(")");
|
||||
}
|
||||
if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
result.append(":*");
|
||||
} else if (stack.getItemDamage() > 0) {
|
||||
result.append(':').append(stack.getItemDamage());
|
||||
}
|
||||
result.append('>');
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
if (stack.getTagCompound() != null) {
|
||||
result.append(".withTag(");
|
||||
result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
|
||||
result.append(")");
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user