mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-18 11:19:20 +00:00
Begin Mantle's update to 1.11. Not everything is 100% completed.
This commit is contained in:
1 parent
952778fad6
commit
1ccbee7720
36 files changed
+271
-207
No files matched your search
@@ -42,7 +42,7 @@ public abstract class BlockInventory extends BlockContainer {
|
||||
protected abstract boolean openGui(EntityPlayer player, World world, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing side,
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ) {
|
||||
if(player.isSneaking()) {
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -36,7 +37,7 @@ public class EnumBlock<E extends Enum<E> & EnumBlock.IEnumMeta & IStringSerializ
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, List<ItemStack> list) {
|
||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for(E type : values) {
|
||||
list.add(new ItemStack(this, 1, type.getMeta()));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -39,7 +40,7 @@ public abstract class EnumBlockSlab<E extends Enum<E> & EnumBlock.IEnumMeta & IS
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, List<ItemStack> list) {
|
||||
public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
for(E type : values) {
|
||||
list.add(new ItemStack(this, 1, type.getMeta()));
|
||||
}
|
||||
|
||||
@@ -32,16 +32,10 @@ public class CreativeTab extends CreativeTabs {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getIconItemDamage() {
|
||||
return icon.getItemDamage();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
return icon.getItem();
|
||||
public ItemStack getTabIconItem() {
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class ExtraHeartRenderHandler {
|
||||
GlStateManager.enableBlend();
|
||||
|
||||
EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
|
||||
int health = MathHelper.ceiling_float_int(player.getHealth());
|
||||
int health = MathHelper.ceil(player.getHealth());
|
||||
boolean highlight = healthUpdateCounter > (long)updateCounter && (healthUpdateCounter - (long)updateCounter) / 3L %2L == 1L;
|
||||
|
||||
if (health < this.playerHealth && player.hurtResistantTime > 0)
|
||||
@@ -93,14 +93,14 @@ public class ExtraHeartRenderHandler {
|
||||
|
||||
IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
|
||||
float healthMax = (float)attrMaxHealth.getAttributeValue();
|
||||
float absorb = MathHelper.ceiling_float_int(player.getAbsorptionAmount());
|
||||
float absorb = MathHelper.ceil(player.getAbsorptionAmount());
|
||||
|
||||
// CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one row max
|
||||
healthMax = Math.min(healthMax, 20f);
|
||||
health = Math.min(health, 20);
|
||||
absorb = Math.min(absorb, 20);
|
||||
|
||||
int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F);
|
||||
int healthRows = MathHelper.ceil((healthMax + absorb) / 2.0F / 10.0F);
|
||||
int rowHeight = Math.max(10 - (healthRows - 2), 3);
|
||||
|
||||
this.rand.setSeed((long)(updateCounter * 312871));
|
||||
@@ -116,17 +116,17 @@ public class ExtraHeartRenderHandler {
|
||||
regen = updateCounter % 25;
|
||||
}
|
||||
|
||||
final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
|
||||
final int TOP = 9 * (mc.world.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0);
|
||||
final int BACKGROUND = (highlight ? 25 : 16);
|
||||
int MARGIN = 16;
|
||||
if (player.isPotionActive(MobEffects.POISON)) MARGIN += 36;
|
||||
else if (player.isPotionActive(MobEffects.WITHER)) MARGIN += 72;
|
||||
float absorbRemaining = absorb;
|
||||
|
||||
for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
|
||||
for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
|
||||
{
|
||||
//int b0 = (highlight ? 1 : 0);
|
||||
int row = MathHelper.ceiling_float_int((float)(i + 1) / 10.0F) - 1;
|
||||
int row = MathHelper.ceil((float)(i + 1) / 10.0F) - 1;
|
||||
int x = left + i % 10 * 8;
|
||||
int y = top - row * rowHeight;
|
||||
|
||||
@@ -188,7 +188,7 @@ public class ExtraHeartRenderHandler {
|
||||
// Extra hearts
|
||||
this.mc.getTextureManager().bindTexture(ICON_HEARTS);
|
||||
|
||||
int hp = MathHelper.ceiling_float_int(player.getHealth());
|
||||
int hp = MathHelper.ceil(player.getHealth());
|
||||
renderCustomHearts(xBasePos, yBasePos, potionOffset, hp, false);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class ExtraHeartRenderHandler {
|
||||
if(potion != null) {
|
||||
potionOffset = 9;
|
||||
}
|
||||
if(mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) {
|
||||
if(mc.world.getWorldInfo().isHardcoreModeEnabled()) {
|
||||
potionOffset += 27;
|
||||
}
|
||||
return potionOffset;
|
||||
@@ -240,7 +240,7 @@ public class ExtraHeartRenderHandler {
|
||||
// Extra hearts
|
||||
this.mc.getTextureManager().bindTexture(ICON_ABSORB);
|
||||
|
||||
int absorb = MathHelper.ceiling_float_int(player.getAbsorptionAmount());
|
||||
int absorb = MathHelper.ceil(player.getAbsorptionAmount());
|
||||
renderCustomHearts(xBasePos, yBasePos, potionOffset, absorb, true);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import java.util.Arrays;
|
||||
public class BookHelper {
|
||||
|
||||
public static String getSavedPage(ItemStack item) {
|
||||
if(item != null && item.hasTagCompound()) {
|
||||
if(item != ItemStack.EMPTY && item.hasTagCompound()) {
|
||||
NBTTagCompound mantleBook = item.getTagCompound().getCompoundTag("mantle").getCompoundTag("book");
|
||||
|
||||
if(mantleBook.hasKey("page", Arrays.asList(NBTBase.NBT_TYPES).indexOf("STRING"))) {
|
||||
|
||||
@@ -158,7 +158,7 @@ public class BookLoader implements IResourceManagerReloadListener {
|
||||
if(player == null) {
|
||||
return;
|
||||
}
|
||||
if(player.getHeldItem(EnumHand.MAIN_HAND) == null) {
|
||||
if(player.getHeldItem(EnumHand.MAIN_HAND) == ItemStack.EMPTY) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public class StructureInfo {
|
||||
state = block.getDefaultState();
|
||||
|
||||
for(Map.Entry<String, String> entry : data.state.entrySet()) {
|
||||
Optional<IProperty<?>> property = state.getPropertyNames().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst();
|
||||
Optional<IProperty<?>> property = state.getPropertyKeys().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst();
|
||||
|
||||
if(property.isPresent()) {
|
||||
state = setProperty(state, property.get(), entry.getValue());
|
||||
|
||||
@@ -306,9 +306,9 @@ public class BookData implements IDataItem {
|
||||
}
|
||||
|
||||
public void openGui(@Nullable ItemStack item) {
|
||||
if(Minecraft.getMinecraft().thePlayer != null) {
|
||||
if(Minecraft.getMinecraft().player != null) {
|
||||
Minecraft.getMinecraft()
|
||||
.displayGuiScreen(new GuiBook(this, Minecraft.getMinecraft().thePlayer.getStatFileWriter(), item));
|
||||
.displayGuiScreen(new GuiBook(this, Minecraft.getMinecraft().player.getStatFileWriter(), item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package slimeknights.mantle.client.book.data.content;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -62,23 +63,23 @@ public class ContentSmelting extends PageContent {
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack[] getFuelsList() {
|
||||
public NonNullList<ItemStack> getFuelsList() {
|
||||
//TODO ask JEI for fuel list if it is present
|
||||
|
||||
ItemStack[] fuels = new ItemStack[13];
|
||||
fuels[0] = new ItemStack(Blocks.WOODEN_SLAB);
|
||||
fuels[1] = new ItemStack(Blocks.PLANKS);
|
||||
fuels[2] = new ItemStack(Blocks.COAL_BLOCK);
|
||||
fuels[3] = new ItemStack(Items.WOODEN_PICKAXE);
|
||||
fuels[4] = new ItemStack(Items.WOODEN_SWORD);
|
||||
fuels[5] = new ItemStack(Items.WOODEN_HOE);
|
||||
fuels[6] = new ItemStack(Items.STICK);
|
||||
fuels[7] = new ItemStack(Items.COAL);
|
||||
fuels[8] = new ItemStack(Items.LAVA_BUCKET);
|
||||
fuels[9] = new ItemStack(Blocks.SAPLING);
|
||||
fuels[10] = new ItemStack(Items.BLAZE_ROD);
|
||||
fuels[11] = new ItemStack(Items.WOODEN_SHOVEL);
|
||||
fuels[12] = new ItemStack(Items.WOODEN_AXE);
|
||||
NonNullList<ItemStack> fuels = NonNullList.<ItemStack> withSize(13, ItemStack.EMPTY);
|
||||
fuels.set(0, new ItemStack(Blocks.WOODEN_SLAB));
|
||||
fuels.set(1, new ItemStack(Blocks.PLANKS));
|
||||
fuels.set(2, new ItemStack(Blocks.COAL_BLOCK));
|
||||
fuels.set(3, new ItemStack(Items.WOODEN_PICKAXE));
|
||||
fuels.set(4, new ItemStack(Items.WOODEN_SWORD));
|
||||
fuels.set(5, new ItemStack(Items.WOODEN_HOE));
|
||||
fuels.set(6, new ItemStack(Items.STICK));
|
||||
fuels.set(7, new ItemStack(Items.COAL));
|
||||
fuels.set(8, new ItemStack(Items.LAVA_BUCKET));
|
||||
fuels.set(9, new ItemStack(Blocks.SAPLING));
|
||||
fuels.set(10, new ItemStack(Items.BLAZE_ROD));
|
||||
fuels.set(11, new ItemStack(Items.WOODEN_SHOVEL));
|
||||
fuels.set(12, new ItemStack(Items.WOODEN_AXE));
|
||||
|
||||
return fuels;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import slimeknights.mantle.client.book.BookLoader;
|
||||
@@ -29,15 +30,15 @@ public class ItemStackData {
|
||||
public short damage = 0;
|
||||
public JsonObject nbt;
|
||||
|
||||
public ItemStack[] getItems() {
|
||||
public NonNullList<ItemStack> getItems() {
|
||||
if(itemListLocation != null && source.resourceExists(itemListLocation)) {
|
||||
try {
|
||||
ItemsList itemsList = BookLoader.GSON
|
||||
.fromJson(source.resourceToString(source.getResource(itemListLocation)), ItemsList.class);
|
||||
ItemStack[] items = new ItemStack[itemsList.items.length];
|
||||
NonNullList<ItemStack> items = NonNullList.<ItemStack> withSize(itemsList.items.length, ItemStack.EMPTY);
|
||||
|
||||
for(int i = 0; i < itemsList.items.length; i++) {
|
||||
items[i] = itemsList.items[i].getItem();
|
||||
items.set(i,itemsList.items[i].getItem());
|
||||
}
|
||||
|
||||
this.action = itemsList.action;
|
||||
@@ -47,7 +48,7 @@ public class ItemStackData {
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack[]{getItem()};
|
||||
return NonNullList.<ItemStack> withSize(1, getItem());
|
||||
}
|
||||
|
||||
private ItemStack getItem() {
|
||||
@@ -75,7 +76,7 @@ public class ItemStackData {
|
||||
}
|
||||
|
||||
if(isMissingItem) {
|
||||
NBTTagCompound display = itemStack.getSubCompound("display", true);
|
||||
NBTTagCompound display = itemStack.getOrCreateSubCompound("display");
|
||||
display.setString("Name", "\u00A7rUnknown Item");
|
||||
NBTTagList lore = new NBTTagList();
|
||||
lore.appendTag(new NBTTagString("\u00A7r\u00A7eItem Name:"));
|
||||
@@ -93,7 +94,7 @@ public class ItemStackData {
|
||||
public static ItemStackData getItemStackData(ItemStack stack, boolean ignoreNbt) {
|
||||
ItemStackData data = new ItemStackData();
|
||||
data.id = Item.REGISTRY.getNameForObject(stack.getItem()).toString();
|
||||
data.amount = (byte) stack.stackSize;
|
||||
data.amount = (byte) stack.getCount();
|
||||
data.damage = (short) stack.getItemDamage();
|
||||
if(!ignoreNbt && stack.getTagCompound() != null) {
|
||||
data.nbt = BookLoader.GSON.toJsonTree(stack.getTagCompound(), NBTTagCompound.class).getAsJsonObject();
|
||||
|
||||
@@ -127,7 +127,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
protected void drawPlayerInventoryName() {
|
||||
String localizedName = Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText();
|
||||
String localizedName = Minecraft.getMinecraft().player.inventory.getDisplayName().getUnformattedText();
|
||||
this.fontRendererObj.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
@@ -222,8 +222,8 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
|
||||
|
||||
// update slot positions
|
||||
if(slotIn instanceof SlotWrapper) {
|
||||
slotIn.xDisplayPosition = ((SlotWrapper) slotIn).parent.xDisplayPosition;
|
||||
slotIn.yDisplayPosition = ((SlotWrapper) slotIn).parent.yDisplayPosition;
|
||||
slotIn.xPos = ((SlotWrapper) slotIn).parent.xPos;
|
||||
slotIn.yPos = ((SlotWrapper) slotIn).parent.yPos;
|
||||
}
|
||||
|
||||
super.drawSlot(slotIn);
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GuiWidgetSlider extends GuiWidget {
|
||||
maxValue = slideBar.h;
|
||||
increment = 1;
|
||||
|
||||
sliderOffset = MathHelper.abs_int(slideBar.w - slider.w) / 2;
|
||||
sliderOffset = MathHelper.abs(slideBar.w - slider.w) / 2;
|
||||
|
||||
isScrolling = false;
|
||||
isHighlighted = false;
|
||||
|
||||
@@ -49,14 +49,14 @@ public class BoxRenderer {
|
||||
int totalHeight = segH * 3 + segGH * 2;
|
||||
|
||||
return getTextureMatrixCoords((index % (256 / sprW) * sprW) + (sprW / 2 - totalWidth / 2), (MathHelper
|
||||
.floor_float(index / (256F / sprH)) * sprH) + (sprH / 2 - totalHeight / 2), segW, segH, segGW, segGH, segId);
|
||||
.floor(index / (256F / sprH)) * sprH) + (sprH / 2 - totalHeight / 2), segW, segH, segGW, segGH, segId);
|
||||
}
|
||||
|
||||
public static int[] getTextureMatrixCoords(int u, int v, int segW, int segH, int segGW, int segGH, int segId) {
|
||||
int[] coords = new int[4];
|
||||
|
||||
int col = segId % 3;
|
||||
int row = MathHelper.floor_float(segId / 3F);
|
||||
int row = MathHelper.floor(segId / 3F);
|
||||
|
||||
coords[0] = u + col * segW + col * segGW;
|
||||
coords[1] = v + row * segH + row * segGH;
|
||||
|
||||
@@ -615,7 +615,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
if(loadingAchievements) {
|
||||
return;
|
||||
}
|
||||
if(mc.thePlayer == null) {
|
||||
if(mc.player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -626,9 +626,9 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
}
|
||||
|
||||
if(this.page == -1) {
|
||||
BookLoader.updateSavedPage(mc.thePlayer, item, "");
|
||||
BookLoader.updateSavedPage(mc.player, item, "");
|
||||
} else if(page != null && page.parent != null) {
|
||||
BookLoader.updateSavedPage(mc.thePlayer, item, page.parent.name + "." + page.name);
|
||||
BookLoader.updateSavedPage(mc.player, item, page.parent.name + "." + page.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class BookElement extends Gui {
|
||||
|
||||
public void renderToolTip(FontRenderer fontRenderer, ItemStack stack, int x, int y) {
|
||||
if(stack != null) {
|
||||
List<String> list = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
|
||||
List<String> list = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
for(int i = 0; i < list.size(); ++i) {
|
||||
if(i == 0) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ElementImage extends SizedBookElement {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(width, height, 1F);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(image.item.getItems()[0], x, y);
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(image.item.getItems().get(0), x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -21,7 +22,7 @@ public class ElementItem extends SizedBookElement {
|
||||
public static final int ITEM_SIZE_HARDCODED = 16;
|
||||
public static final int ITEM_SWITCH_TICKS = 90;
|
||||
|
||||
public ItemStack[] itemCycle;
|
||||
public NonNullList<ItemStack> itemCycle;
|
||||
public float scale;
|
||||
public String action;
|
||||
public List<String> tooltip;
|
||||
@@ -54,9 +55,16 @@ public class ElementItem extends SizedBookElement {
|
||||
}
|
||||
|
||||
public ElementItem(int x, int y, float scale, ItemStack[] itemCycle, String action) {
|
||||
super(x, y, MathHelper.floor_float(ITEM_SIZE_HARDCODED * scale), MathHelper.floor_float(ITEM_SIZE_HARDCODED * scale));
|
||||
super(x, y, MathHelper.floor(ITEM_SIZE_HARDCODED * scale), MathHelper.floor(ITEM_SIZE_HARDCODED * scale));
|
||||
|
||||
this.itemCycle = itemCycle;
|
||||
NonNullList<ItemStack> nonNullStacks = NonNullList.<ItemStack> withSize(itemCycle.length, ItemStack.EMPTY);
|
||||
for(int i = 0; i < itemCycle.length; i++) {
|
||||
if(itemCycle[i] != ItemStack.EMPTY) {
|
||||
nonNullStacks.set(i, itemCycle[i].copy());
|
||||
}
|
||||
}
|
||||
|
||||
this.itemCycle = nonNullStacks;
|
||||
this.scale = scale;
|
||||
this.action = action;
|
||||
}
|
||||
@@ -69,7 +77,7 @@ public class ElementItem extends SizedBookElement {
|
||||
renderTick = 0;
|
||||
currentItem++;
|
||||
|
||||
if(currentItem >= itemCycle.length) {
|
||||
if(currentItem >= itemCycle.size()) {
|
||||
currentItem = 0;
|
||||
}
|
||||
}
|
||||
@@ -79,8 +87,8 @@ public class ElementItem extends SizedBookElement {
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, 1.0F);
|
||||
|
||||
if(currentItem < itemCycle.length) {
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(itemCycle[currentItem], 0, 0);
|
||||
if(currentItem < itemCycle.size()) {
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(itemCycle.get(currentItem), 0, 0);
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
@@ -89,23 +97,23 @@ public class ElementItem extends SizedBookElement {
|
||||
|
||||
@Override
|
||||
public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) {
|
||||
if(isHovered(mouseX, mouseY) && currentItem < itemCycle.length) {
|
||||
if(isHovered(mouseX, mouseY) && currentItem < itemCycle.size()) {
|
||||
if(tooltip != null) {
|
||||
drawHoveringText(tooltip, mouseX, mouseY, fontRenderer);
|
||||
}
|
||||
else {
|
||||
renderToolTip(fontRenderer, itemCycle[currentItem], mouseX, mouseY);
|
||||
renderToolTip(fontRenderer, itemCycle.get(currentItem), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if(mouseButton == 0 && isHovered(mouseX, mouseY) && currentItem < itemCycle.length) {
|
||||
if(mouseButton == 0 && isHovered(mouseX, mouseY) && currentItem < itemCycle.size()) {
|
||||
if(action != null) {
|
||||
StringActionProcessor.process(action, parent);
|
||||
} else {
|
||||
parent.itemClicked(itemCycle[currentItem]);
|
||||
parent.itemClicked(itemCycle.get(currentItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ElementSection extends SizedBookElement {
|
||||
GlStateManager.translate(iconX, iconY, 0);
|
||||
GlStateManager.scale(2F, 2F, 1F);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(section.icon.item.getItems()[0], 0, 0);
|
||||
mc.getRenderItem().renderItemAndEffectIntoGUI(section.icon.item.getItems().get(0), 0, 0);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ class ExampleSync {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void playerJoinedWorld(TickEvent.ClientTickEvent event) {
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
|
||||
EntityPlayerSP player = Minecraft.getMinecraft().player;
|
||||
if(needsRestart) {
|
||||
player.addChatMessage(new TextComponentString("Configs synced with server. Configs require a restart"));
|
||||
player.sendMessage(new TextComponentString("Configs synced with server. Configs require a restart"));
|
||||
}
|
||||
else {
|
||||
player.addChatMessage(new TextComponentString("Configs synced with server."));
|
||||
player.sendMessage(new TextComponentString("Configs synced with server."));
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.IWorldNameable;
|
||||
@@ -121,7 +122,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
@Nonnull
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ItemStack> getInventory() {
|
||||
public NonNullList<ItemStack> getInventory() {
|
||||
return super.getInventory();
|
||||
}
|
||||
|
||||
@@ -191,10 +192,10 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
// we can only support inventory <-> playerInventory
|
||||
if(playerInventoryStart < 0) {
|
||||
// so we don't do anything if no player inventory is present because we don't know what to do
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack itemstack = null;
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
// slot that was clicked on not empty?
|
||||
@@ -207,16 +208,16 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
if(index < playerInventoryStart) {
|
||||
// try to put it into the player inventory (if we have a player inventory)
|
||||
if(!this.mergeItemStack(itemstack1, playerInventoryStart, end, true)) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
// Slot is in the player inventory (if it exists), transfer to main inventory
|
||||
else if(!this.mergeItemStack(itemstack1, 0, playerInventoryStart, false)) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if(itemstack1.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
if(itemstack1.getCount() == 0) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
else {
|
||||
slot.onSlotChanged();
|
||||
@@ -230,7 +231,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
@Override
|
||||
protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
boolean ret = mergeItemStackRefill(stack, startIndex, endIndex, useEndIndex);
|
||||
if(stack != null && stack.stackSize > 0) {
|
||||
if(stack != ItemStack.EMPTY && stack.getCount() > 0) {
|
||||
ret |= mergeItemStackMove(stack, startIndex, endIndex, useEndIndex);
|
||||
}
|
||||
return ret;
|
||||
@@ -238,7 +239,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
|
||||
// only refills items that are already present
|
||||
protected boolean mergeItemStackRefill(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
if(stack.stackSize <= 0) {
|
||||
if(stack.getCount() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -253,27 +254,27 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
ItemStack itemstack1;
|
||||
|
||||
if(stack.isStackable()) {
|
||||
while(stack.stackSize > 0 && (!useEndIndex && k < endIndex || useEndIndex && k >= startIndex)) {
|
||||
while(stack.getCount() > 0 && (!useEndIndex && k < endIndex || useEndIndex && k >= startIndex)) {
|
||||
slot = this.inventorySlots.get(k);
|
||||
itemstack1 = slot.getStack();
|
||||
|
||||
if(itemstack1 != null
|
||||
if(itemstack1 != ItemStack.EMPTY
|
||||
&& itemstack1.getItem() == stack.getItem()
|
||||
&& (!stack.getHasSubtypes() || stack.getMetadata() == itemstack1.getMetadata())
|
||||
&& ItemStack.areItemStackTagsEqual(stack, itemstack1)
|
||||
&& this.canMergeSlot(stack, slot)) {
|
||||
int l = itemstack1.stackSize + stack.stackSize;
|
||||
int l = itemstack1.getCount() + stack.getCount();
|
||||
int limit = Math.min(stack.getMaxStackSize(), slot.getItemStackLimit(stack));
|
||||
|
||||
if(l <= limit) {
|
||||
stack.stackSize = 0;
|
||||
itemstack1.stackSize = l;
|
||||
stack.setCount(0);
|
||||
itemstack1.setCount(l);
|
||||
slot.onSlotChanged();
|
||||
flag1 = true;
|
||||
}
|
||||
else if(itemstack1.stackSize < limit) {
|
||||
stack.stackSize -= limit - itemstack1.stackSize;
|
||||
itemstack1.stackSize = limit;
|
||||
else if(itemstack1.getCount() < limit) {
|
||||
stack.shrink(limit - itemstack1.getCount());
|
||||
itemstack1.setCount(limit);
|
||||
slot.onSlotChanged();
|
||||
flag1 = true;
|
||||
}
|
||||
@@ -293,7 +294,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
|
||||
// only moves items into empty slots
|
||||
protected boolean mergeItemStackMove(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) {
|
||||
if(stack.stackSize <= 0) {
|
||||
if(stack.getCount() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -311,22 +312,22 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
|
||||
Slot slot = this.inventorySlots.get(k);
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
|
||||
if(itemstack1 == null && slot.isItemValid(stack) && this.canMergeSlot(stack, slot)) // Forge: Make sure to respect isItemValid in the slot.
|
||||
if(itemstack1 == ItemStack.EMPTY && slot.isItemValid(stack) && this.canMergeSlot(stack, slot)) // Forge: Make sure to respect isItemValid in the slot.
|
||||
{
|
||||
int limit = slot.getItemStackLimit(stack);
|
||||
ItemStack stack2 = stack.copy();
|
||||
if(stack2.stackSize > limit) {
|
||||
stack2.stackSize = limit;
|
||||
stack.stackSize -= limit;
|
||||
if(stack2.getCount() > limit) {
|
||||
stack2.setCount(limit);
|
||||
stack.shrink(limit);
|
||||
}
|
||||
else {
|
||||
stack.stackSize = 0;
|
||||
stack.setCount(0);
|
||||
}
|
||||
slot.putStack(stack2);
|
||||
slot.onSlotChanged();
|
||||
flag1 = true;
|
||||
|
||||
if(stack.stackSize == 0) {
|
||||
if(stack.getCount() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if(slot == null || !slot.getHasStack()) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
ItemStack ret = slot.getStack().copy();
|
||||
@@ -165,11 +165,11 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
}
|
||||
// you violated some assumption or something. Shame on you.
|
||||
else {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if(nothingDone) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return notifySlotAfterTransfer(playerIn, itemstack, ret, slot);
|
||||
@@ -179,23 +179,23 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
// notify slot
|
||||
slot.onSlotChange(stack, original);
|
||||
|
||||
if(stack.stackSize == original.stackSize) {
|
||||
return null;
|
||||
if(stack.getCount() == original.getCount()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// update slot we pulled from
|
||||
slot.putStack(stack);
|
||||
slot.onPickupFromSlot(player, stack);
|
||||
slot.onTake(player, stack);
|
||||
|
||||
if(slot.getHasStack() && slot.getStack().stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
if(slot.getHasStack() && slot.getStack().getCount() == 0) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
return original;
|
||||
}
|
||||
|
||||
protected boolean moveToTileInventory(ItemStack itemstack) {
|
||||
if(itemstack == null || itemstack.stackSize == 0) {
|
||||
if(itemstack == ItemStack.EMPTY || itemstack.getCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
}
|
||||
|
||||
protected boolean moveToPlayerInventory(ItemStack itemstack) {
|
||||
if(itemstack == null || itemstack.stackSize == 0) {
|
||||
if(itemstack == ItemStack.EMPTY || itemstack.getCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
}
|
||||
|
||||
protected boolean moveToAnyContainer(ItemStack itemstack, Collection<Container> containers) {
|
||||
if(itemstack == null || itemstack.stackSize == 0) {
|
||||
if(itemstack == ItemStack.EMPTY || itemstack.getCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
|
||||
|
||||
|
||||
protected boolean refillAnyContainer(ItemStack itemstack, Collection<Container> containers) {
|
||||
if(itemstack == null || itemstack.stackSize == 0) {
|
||||
if(itemstack == ItemStack.EMPTY || itemstack.getCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,12 @@ public class SlotCraftingCustom extends SlotCrafting {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer playerIn, @Nonnull ItemStack stack) {
|
||||
public ItemStack onTake(EntityPlayer playerIn, @Nonnull ItemStack stack) {
|
||||
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
|
||||
this.onCrafting(stack);
|
||||
|
||||
callback.onCrafting(playerIn, stack, craftMatrix);
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,6 @@ public class SlotRestrictedItem extends Slot {
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack != null && stack.getItem() == allowedItem;
|
||||
return stack != ItemStack.EMPTY && stack.getItem() == allowedItem;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class SlotWrapper extends Slot {
|
||||
public final Slot parent;
|
||||
|
||||
public SlotWrapper(Slot slot) {
|
||||
super(slot.inventory, slot.getSlotIndex(), slot.xDisplayPosition, slot.yDisplayPosition);
|
||||
super(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos);
|
||||
this.parent = slot;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,9 @@ public class SlotWrapper extends Slot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) {
|
||||
parent.onPickupFromSlot(playerIn, stack);
|
||||
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
|
||||
parent.onTake(playerIn, stack);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,9 +44,10 @@ public class ItemBlockSlab<T extends Enum<T> &EnumBlock.IEnumMeta & IStringSeria
|
||||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumActionResult onItemUse(ItemStack stack, @Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumHand hand, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
public EnumActionResult onItemUse(@Nonnull EntityPlayer player, World world, @Nonnull BlockPos pos, EnumHand hand, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
// don't place the slab if unable to edit
|
||||
if(stack.stackSize != 0 && player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||
if(stack.getCount() != 0 && player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||
|
||||
// try placing the slab at the current position
|
||||
// note that this requires the slab to be extended on the side the block was clicked
|
||||
@@ -58,7 +59,7 @@ public class ItemBlockSlab<T extends Enum<T> &EnumBlock.IEnumMeta & IStringSeria
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
else {
|
||||
return EnumActionResult.FAIL;
|
||||
@@ -106,7 +107,7 @@ public class ItemBlockSlab<T extends Enum<T> &EnumBlock.IEnumMeta & IStringSeria
|
||||
if(axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, fullBlock, 11)) {
|
||||
SoundType soundtype = fullBlock.getBlock().getSoundType();
|
||||
worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
|
||||
--stack.stackSize;
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -131,7 +132,7 @@ public class ItemEdible extends ItemFood {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
|
||||
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
dynamic.getSubItems(itemIn, tab, subItems);
|
||||
}
|
||||
|
||||
@@ -142,17 +143,18 @@ public class ItemEdible extends ItemFood {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand)
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand)
|
||||
{
|
||||
int meta = itemStackIn.getMetadata();
|
||||
if(dynamic.isValid(meta) && playerIn.canEat(this.alwaysEdible.get(itemStackIn.getMetadata())))
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
int meta = stack.getMetadata();
|
||||
if(dynamic.isValid(meta) && playerIn.canEat(this.alwaysEdible.get(stack.getMetadata())))
|
||||
{
|
||||
playerIn.setActiveHand(hand);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
@@ -80,7 +81,7 @@ public class ItemMetaDynamic extends ItemTooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
|
||||
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
for(int i = 0; i <= availabilityMask.length; i++) {
|
||||
if(isValid(i)) {
|
||||
subItems.add(new ItemStack(itemIn, 1, i));
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj
|
||||
if(this.world.getBlockState(this.master).getBlock() == this.masterBlock && this.world
|
||||
.getBlockState(this.master) == this.state) {
|
||||
return true;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
public void overrideMaster(BlockPos pos) {
|
||||
this.hasMaster = true;
|
||||
this.master = pos;
|
||||
this.state = this.worldObj.getBlockState(this.master);
|
||||
this.state = this.world.getBlockState(this.master);
|
||||
this.masterBlock = this.state.getBlock();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
|
||||
@Deprecated
|
||||
public boolean verifyMaster(IMasterLogic logic, BlockPos pos) {
|
||||
return this.master.equals(pos) && this.worldObj.getBlockState(pos) == this.state && this.worldObj.getBlockState(pos)
|
||||
return this.master.equals(pos) && this.world.getBlockState(pos) == this.state && this.world.getBlockState(pos)
|
||||
.getBlock() == this.masterBlock;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
@Override
|
||||
public void notifyMasterOfChange() {
|
||||
if(this.hasValidMaster()) {
|
||||
IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master);
|
||||
IMasterLogic logic = (IMasterLogic) this.world.getTileEntity(this.master);
|
||||
logic.notifyChange(this, this.pos);
|
||||
}
|
||||
}
|
||||
@@ -151,20 +151,20 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
|
||||
this.readCustomNBT(packet.getNbtCompound());
|
||||
this.worldObj.notifyLightSet(this.pos);
|
||||
IBlockState state = worldObj.getBlockState(this.pos);
|
||||
this.worldObj.notifyBlockUpdate(this.pos, state, state, 3);
|
||||
this.world.notifyLightSet(this.pos);
|
||||
IBlockState state = world.getBlockState(this.pos);
|
||||
this.world.notifyBlockUpdate(this.pos, state, state, 3);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.worldObj;
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setMaster(BlockPos pos) {
|
||||
if(!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj
|
||||
if(!this.hasMaster || this.world.getBlockState(this.master) != this.state || (this.world
|
||||
.getBlockState(this.master)
|
||||
.getBlock() != this.masterBlock)) {
|
||||
this.overrideMaster(pos);
|
||||
|
||||
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
@@ -17,13 +18,14 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
// Updated version of InventoryLogic in Mantle. Also contains a few bugfixes
|
||||
public class TileInventory extends TileEntity implements IInventory {
|
||||
|
||||
private ItemStack[] inventory;
|
||||
private NonNullList<ItemStack> inventory;
|
||||
protected String inventoryTitle;
|
||||
protected boolean hasCustomName;
|
||||
protected int stackSizeLimit;
|
||||
@@ -40,7 +42,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
* @param name Localization String for the inventory title. Can be overridden through setCustomName
|
||||
*/
|
||||
public TileInventory(String name, int inventorySize, int maxStackSize) {
|
||||
this.inventory = new ItemStack[inventorySize];
|
||||
this.inventory = NonNullList.<ItemStack> withSize(inventorySize, ItemStack.EMPTY);
|
||||
this.stackSizeLimit = maxStackSize;
|
||||
this.inventoryTitle = name;
|
||||
this.itemHandler = new InvWrapper(this);
|
||||
@@ -68,24 +70,25 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
if(slot < 0 || slot >= inventory.length) {
|
||||
return null;
|
||||
if(slot < 0 || slot >= inventory.size()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return inventory[slot];
|
||||
return inventory.get(slot);
|
||||
}
|
||||
|
||||
public boolean isStackInSlot(int slot) {
|
||||
return getStackInSlot(slot) != null;
|
||||
return getStackInSlot(slot) != ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void resize(int size) {
|
||||
inventory = Arrays.copyOf(inventory, size);
|
||||
//TODO: Make sure this didn't break inventory contents.
|
||||
inventory = NonNullList.<ItemStack> withSize(size, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.length;
|
||||
return inventory.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,13 +98,13 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack itemstack) {
|
||||
if(slot < 0 || slot >= inventory.length) {
|
||||
if(slot < 0 || slot >= inventory.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
inventory[slot] = itemstack;
|
||||
if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
|
||||
itemstack.stackSize = getInventoryStackLimit();
|
||||
inventory.set(slot, itemstack);
|
||||
if(itemstack != ItemStack.EMPTY && itemstack.getCount() > getInventoryStackLimit()) {
|
||||
itemstack.setCount(getInventoryStackLimit());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,22 +112,22 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
public ItemStack decrStackSize(int slot, int quantity) {
|
||||
ItemStack itemStack = getStackInSlot(slot);
|
||||
|
||||
if(itemStack == null) {
|
||||
return null;
|
||||
if(itemStack == ItemStack.EMPTY) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
// whole itemstack taken out
|
||||
if(itemStack.stackSize <= quantity) {
|
||||
setInventorySlotContents(slot, null);
|
||||
if(itemStack.getCount() <= quantity) {
|
||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
this.markDirty();
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
// split itemstack
|
||||
itemStack = itemStack.splitStack(quantity);
|
||||
// slot is empty, set to null
|
||||
if(getStackInSlot(slot).stackSize == 0) {
|
||||
setInventorySlotContents(slot, null);
|
||||
// slot is empty, set to ItemStack.EMPTY
|
||||
if(getStackInSlot(slot).getCount() == 0) {
|
||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
@@ -135,14 +138,14 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
ItemStack itemStack = getStackInSlot(slot);
|
||||
setInventorySlotContents(slot, null);
|
||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, @Nonnull ItemStack itemstack) {
|
||||
if(slot < getSizeInventory()) {
|
||||
if(inventory[slot] == null || itemstack.stackSize + inventory[slot].stackSize <= getInventoryStackLimit()) {
|
||||
if(inventory.get(slot) == ItemStack.EMPTY || itemstack.getCount() + inventory.get(slot).getCount() <= getInventoryStackLimit()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -151,8 +154,8 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
for(int i = 0; i < inventory.length; i++) {
|
||||
inventory[i] = null;
|
||||
for(int i = 0; i < inventory.size(); i++) {
|
||||
inventory.set(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +188,9 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
|
||||
/* Supporting methods */
|
||||
@Override
|
||||
public boolean isUseableByPlayer(@Nonnull EntityPlayer entityplayer) {
|
||||
public boolean isUsableByPlayer(@Nonnull EntityPlayer entityplayer) {
|
||||
// block changed/got broken?
|
||||
if(worldObj.getTileEntity(pos) != this || worldObj.getBlockState(pos).getBlock() == Blocks.AIR) {
|
||||
if(world.getTileEntity(pos) != this || world.getBlockState(pos).getBlock() == Blocks.AIR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -224,7 +227,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
|
||||
tags.setInteger("InventorySize", inventory.length);
|
||||
tags.setInteger("InventorySize", inventory.size());
|
||||
|
||||
writeInventoryToNBT(tags);
|
||||
|
||||
@@ -240,7 +243,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if(inventory.getStackInSlot(i) != null) {
|
||||
if(inventory.getStackInSlot(i) != ItemStack.EMPTY) {
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setByte("Slot", (byte) i);
|
||||
inventory.getStackInSlot(i).writeToNBT(itemTag);
|
||||
@@ -261,14 +264,14 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
int slot = itemTag.getByte("Slot") & 255;
|
||||
|
||||
if(slot >= 0 && slot < inventory.getSizeInventory()) {
|
||||
inventory.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(itemTag));
|
||||
inventory.setInventorySlotContents(slot, new ItemStack(itemTag));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Default implementations of hardly used methods */
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return null;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,4 +288,18 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
public int getFieldCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for (ItemStack itemstack : this.inventory)
|
||||
{
|
||||
if (!itemstack.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,10 @@ import javax.annotation.Nullable;
|
||||
import mezz.jei.api.IJeiRuntime;
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.IModRegistry;
|
||||
import mezz.jei.api.ISubtypeRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.gui.IAdvancedGuiHandler;
|
||||
import mezz.jei.api.ingredients.IModIngredientRegistration;
|
||||
import slimeknights.mantle.client.gui.GuiMultiModule;
|
||||
|
||||
@JEIPlugin
|
||||
@@ -30,10 +32,26 @@ public class JeiPlugin implements IModPlugin {
|
||||
public List<Rectangle> getGuiExtraAreas(@Nonnull GuiMultiModule guiContainer) {
|
||||
return guiContainer.getModuleAreas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getIngredientUnderMouse(GuiMultiModule guiContainer, int mouseX, int mouseY)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRuntimeAvailable(@Nonnull IJeiRuntime jeiRuntime) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIngredients(IModIngredientRegistration registry)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.google.common.collect.Sets;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.Iterator;
|
||||
@@ -39,7 +40,7 @@ public abstract class RecipeMatch {
|
||||
*/
|
||||
public abstract List<ItemStack> getInputs();
|
||||
|
||||
public abstract Match matches(ItemStack[] stacks);
|
||||
public abstract Match matches(NonNullList<ItemStack> stacks);
|
||||
|
||||
public static RecipeMatch of(String oredict) {
|
||||
return of(oredict, 1);
|
||||
@@ -110,26 +111,26 @@ public abstract class RecipeMatch {
|
||||
}
|
||||
|
||||
/** Removes the match from the stacks. Has to be ensured that the match is contained in the stacks. */
|
||||
public static void removeMatch(ItemStack[] stacks, Match match) {
|
||||
public static void removeMatch(NonNullList<ItemStack> stacks, Match match) {
|
||||
int[] amountsRemoved = new int[match.stacks.size()];
|
||||
|
||||
removeOrder(stacks, match.stacks, amountsRemoved);
|
||||
removeRemaining(stacks, match.stacks, amountsRemoved);
|
||||
}
|
||||
|
||||
private static void removeOrder(ItemStack[] stacks, List<ItemStack> toRemove, int[] amountsRemoved) {
|
||||
private static void removeOrder(NonNullList<ItemStack> stacks, List<ItemStack> toRemove, int[] amountsRemoved) {
|
||||
int i = 0;
|
||||
for(int j = 0; j < amountsRemoved.length; j++) {
|
||||
ItemStack stack = toRemove.get(j);
|
||||
for(; i < stacks.length; i++) {
|
||||
for(; i < stacks.size(); i++) {
|
||||
// nbt sensitive since toolparts etc. use nbt
|
||||
if(ItemStack.areItemsEqual(stack, stacks[i]) && ItemStack.areItemStackTagsEqual(stack, stacks[i])) {
|
||||
if(stacks[i].stackSize >= stack.stackSize) {
|
||||
stacks[i].stackSize -= stack.stackSize;
|
||||
if(stacks[i].stackSize == 0) {
|
||||
stacks[i] = null;
|
||||
if(ItemStack.areItemsEqual(stack, stacks.get(i)) && ItemStack.areItemStackTagsEqual(stack, stacks.get(i))) {
|
||||
if(stacks.get(i).getCount() >= stack.getCount()) {
|
||||
stacks.get(i).shrink(stack.getCount());
|
||||
if(stacks.get(i).getCount() == 0) {
|
||||
stacks.set(i, ItemStack.EMPTY);
|
||||
}
|
||||
amountsRemoved[j] += stack.stackSize;
|
||||
amountsRemoved[j] += stack.getCount();
|
||||
}
|
||||
i++;
|
||||
break;
|
||||
@@ -138,16 +139,16 @@ public abstract class RecipeMatch {
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeRemaining(ItemStack[] stacks, List<ItemStack> toRemove, int[] amountsRemoved) {
|
||||
private static void removeRemaining(NonNullList<ItemStack> stacks, List<ItemStack> toRemove, int[] amountsRemoved) {
|
||||
for(int j = 0; j < amountsRemoved.length; j++) {
|
||||
ItemStack stack = toRemove.get(j);
|
||||
int needed = stack.stackSize - amountsRemoved[j];
|
||||
for(int i = 0; i < stacks.length && needed > 0; i++) {
|
||||
if(ItemStack.areItemsEqual(stack, stacks[i]) && ItemStack.areItemStackTagsEqual(stack, stacks[i])) {
|
||||
int change = Math.min(stacks[i].stackSize, needed);
|
||||
stacks[i].stackSize -= change;
|
||||
if(stacks[i].stackSize == 0) {
|
||||
stacks[i] = null;
|
||||
int needed = stack.getCount() - amountsRemoved[j];
|
||||
for(int i = 0; i < stacks.size() && needed > 0; i++) {
|
||||
if(ItemStack.areItemsEqual(stack, stacks.get(i)) && ItemStack.areItemStackTagsEqual(stack, stacks.get(i))) {
|
||||
int change = Math.min(stacks.get(i).getCount(), needed);
|
||||
stacks.get(i).shrink(change);
|
||||
if(stacks.get(i).getCount() == 0) {
|
||||
stacks.set(i, ItemStack.EMPTY);
|
||||
}
|
||||
needed -= change;
|
||||
}
|
||||
@@ -180,7 +181,7 @@ public abstract class RecipeMatch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Match matches(ItemStack[] stacks) {
|
||||
public Match matches(NonNullList<ItemStack> stacks) {
|
||||
List<ItemStack> found = Lists.newLinkedList();
|
||||
int stillNeeded = amountNeeded;
|
||||
|
||||
@@ -188,9 +189,9 @@ public abstract class RecipeMatch {
|
||||
if(OreDictionary.itemMatches(template, stack, false)) {
|
||||
// add the amount found to the list
|
||||
ItemStack copy = stack.copy();
|
||||
copy.stackSize = Math.min(copy.stackSize, stillNeeded);
|
||||
copy.setCount(Math.min(copy.getCount(), stillNeeded));
|
||||
found.add(copy);
|
||||
stillNeeded -= copy.stackSize;
|
||||
stillNeeded -= copy.getCount();
|
||||
|
||||
// we found enough
|
||||
if(stillNeeded <= 0) {
|
||||
@@ -206,7 +207,7 @@ public abstract class RecipeMatch {
|
||||
/** A combination of multiple items. NBT SENSITIVE! */
|
||||
public static class ItemCombination extends RecipeMatch {
|
||||
|
||||
protected final ItemStack[] itemStacks;
|
||||
protected final NonNullList<ItemStack> itemStacks;
|
||||
|
||||
/**
|
||||
* @param amountMatched If amount needed itemstacks are present, as how many matches does this count?
|
||||
@@ -214,7 +215,14 @@ public abstract class RecipeMatch {
|
||||
public ItemCombination(int amountMatched, ItemStack... stacks) {
|
||||
super(amountMatched, 0);
|
||||
|
||||
this.itemStacks = stacks;
|
||||
NonNullList<ItemStack> nonNullStacks = NonNullList.<ItemStack> withSize(stacks.length, ItemStack.EMPTY);
|
||||
for(int i = 0; i < stacks.length; i++) {
|
||||
if(stacks[i] != ItemStack.EMPTY) {
|
||||
nonNullStacks.set(i, stacks[i].copy());
|
||||
}
|
||||
}
|
||||
|
||||
this.itemStacks = nonNullStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,12 +231,12 @@ public abstract class RecipeMatch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Match matches(ItemStack[] stacks) {
|
||||
public Match matches(NonNullList<ItemStack> stacks) {
|
||||
List<ItemStack> found = Lists.newLinkedList();
|
||||
Set<Integer> needed = Sets.newHashSet();
|
||||
|
||||
for(int i = 0; i < itemStacks.length; i++) {
|
||||
if(itemStacks[i] != null) {
|
||||
for(int i = 0; i < itemStacks.size(); i++) {
|
||||
if(itemStacks.get(i) != ItemStack.EMPTY) {
|
||||
needed.add(i);
|
||||
}
|
||||
}
|
||||
@@ -237,11 +245,11 @@ public abstract class RecipeMatch {
|
||||
Iterator<Integer> iter = needed.iterator();
|
||||
while(iter.hasNext()) {
|
||||
int index = iter.next();
|
||||
ItemStack template = itemStacks[index];
|
||||
ItemStack template = itemStacks.get(index);
|
||||
if(ItemStack.areItemsEqual(template, stack) && ItemStack.areItemStackTagsEqual(template, stack)) {
|
||||
// add the amount found to the list
|
||||
ItemStack copy = stack.copy();
|
||||
copy.stackSize = 1;
|
||||
copy.setCount(1);
|
||||
found.add(copy);
|
||||
iter.remove();
|
||||
break;
|
||||
@@ -285,7 +293,7 @@ public abstract class RecipeMatch {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Match matches(ItemStack[] stacks) {
|
||||
public Match matches(NonNullList<ItemStack> stacks) {
|
||||
List<ItemStack> found = Lists.newLinkedList();
|
||||
int stillNeeded = amountNeeded;
|
||||
|
||||
@@ -294,9 +302,9 @@ public abstract class RecipeMatch {
|
||||
if(OreDictionary.itemMatches(ore, stack, false)) {
|
||||
// add the amount found to the list
|
||||
ItemStack copy = stack.copy();
|
||||
copy.stackSize = Math.min(copy.stackSize, stillNeeded);
|
||||
copy.setCount(Math.min(copy.getCount(), stillNeeded));
|
||||
found.add(copy);
|
||||
stillNeeded -= copy.stackSize;
|
||||
stillNeeded -= copy.getCount();
|
||||
|
||||
// we found enough
|
||||
if(stillNeeded <= 0) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@@ -24,8 +25,14 @@ public class RecipeMatchRegistry {
|
||||
|
||||
// looks for a match in the given itemstacks
|
||||
public RecipeMatch.Match matches(ItemStack... stacks) {
|
||||
NonNullList<ItemStack> nonNullStacks = NonNullList.<ItemStack> withSize(stacks.length, ItemStack.EMPTY);
|
||||
for(int i = 0; i < stacks.length; i++) {
|
||||
if(stacks[i] != ItemStack.EMPTY) {
|
||||
nonNullStacks.set(i, stacks[i].copy());
|
||||
}
|
||||
}
|
||||
for(RecipeMatch recipe : items) {
|
||||
RecipeMatch.Match match = recipe.matches(stacks);
|
||||
RecipeMatch.Match match = recipe.matches(nonNullStacks);
|
||||
if(match != null) {
|
||||
return match;
|
||||
}
|
||||
@@ -35,7 +42,7 @@ public class RecipeMatchRegistry {
|
||||
}
|
||||
|
||||
// looks for a match with at least the given amount in the given itemstacks
|
||||
public RecipeMatch.Match matches(ItemStack[] stacks, int minAmount) {
|
||||
public RecipeMatch.Match matches(NonNullList<ItemStack> stacks, int minAmount) {
|
||||
stacks = copyItemStackArray(stacks); // copy so we don't modify original
|
||||
|
||||
List<RecipeMatch.Match> matches = Lists.newLinkedList();
|
||||
@@ -63,7 +70,7 @@ public class RecipeMatchRegistry {
|
||||
return new RecipeMatch.Match(foundStacks, sum);
|
||||
}
|
||||
|
||||
public RecipeMatch.Match matchesRecursively(ItemStack[] stacks) {
|
||||
public RecipeMatch.Match matchesRecursively(NonNullList<ItemStack> stacks) {
|
||||
stacks = copyItemStackArray(stacks); // copy so we don't modify original
|
||||
|
||||
List<RecipeMatch.Match> matches = Lists.newLinkedList();
|
||||
@@ -144,11 +151,11 @@ public class RecipeMatchRegistry {
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack[] copyItemStackArray(ItemStack[] in) {
|
||||
ItemStack[] stacksCopy = new ItemStack[in.length];
|
||||
for(int i = 0; i < in.length; i++) {
|
||||
if(in[i] != null) {
|
||||
stacksCopy[i] = in[i].copy();
|
||||
public static NonNullList<ItemStack> copyItemStackArray(NonNullList<ItemStack> in) {
|
||||
NonNullList<ItemStack> stacksCopy = NonNullList.<ItemStack> withSize(in.size(), ItemStack.EMPTY);
|
||||
for(int i = 0; i < in.size(); i++) {
|
||||
if(in.get(i) != ItemStack.EMPTY) {
|
||||
stacksCopy.set(i, in.get(i).copy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TagHelper {
|
||||
|
||||
/* Generic Tag Operations */
|
||||
public static NBTTagCompound getTagSafe(ItemStack stack) {
|
||||
if(stack == null || stack.getItem() == null || !stack.hasTagCompound()) {
|
||||
if(stack == ItemStack.EMPTY || stack.getItem() == null || !stack.hasTagCompound()) {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user