Update Mantle to 1.11.2 + update 1.11 code to match master (1.10.2).

This commit is contained in:
alexbegt committed 2017-03-06 21:00:05 -05:00
1 parent eb1e9f9926
commit e4917779f9
35 files changed
+151 -70

No files matched your search

@@ -1,7 +1,6 @@
package slimeknights.mantle.client;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -20,7 +19,7 @@ public class CreativeTab extends CreativeTabs {
}
public void setDisplayIcon(ItemStack displayIcon) {
if(displayIcon != null && displayIcon.getItem() != null) {
if(!displayIcon.isEmpty() && displayIcon.getItem() != null) {
this.icon = displayIcon;
}
}
@@ -9,7 +9,7 @@ import java.util.Arrays;
public class BookHelper {
public static String getSavedPage(ItemStack item) {
if(item != ItemStack.EMPTY && item.hasTagCompound()) {
if(!item.isEmpty() && 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) == ItemStack.EMPTY) {
if(player.getHeldItem(EnumHand.MAIN_HAND).isEmpty()) {
return;
}
@@ -32,8 +32,8 @@ public class ContentTableOfContents extends PageContent {
for(int i = 0; i < data.length; i++) {
TextData text = data[i];
list.add(new ElementText(0, y + i * (int) (Minecraft
.getMinecraft().fontRendererObj.FONT_HEIGHT * text.scale), GuiBook.PAGE_WIDTH, Minecraft
.getMinecraft().fontRendererObj.FONT_HEIGHT, new TextData[]{text}));
.getMinecraft().fontRenderer.FONT_HEIGHT * text.scale), GuiBook.PAGE_WIDTH, Minecraft
.getMinecraft().fontRenderer.FONT_HEIGHT, new TextData[]{text}));
}
}
}
@@ -38,7 +38,7 @@ public class ItemStackData {
NonNullList<ItemStack> items = NonNullList.<ItemStack> withSize(itemsList.items.length, ItemStack.EMPTY);
for(int i = 0; i < itemsList.items.length; i++) {
items.set(i,itemsList.items[i].getItem());
items.set(i, itemsList.items[i].getItem());
}
this.action = itemsList.action;
@@ -76,7 +76,7 @@ public class ItemStackData {
}
if(isMissingItem) {
NBTTagCompound display = itemStack.getOrCreateSubCompound("display");
NBTTagCompound display = itemStack.getSubCompound("display");
display.setString("Name", "\u00A7rUnknown Item");
NBTTagList lore = new NBTTagList();
lore.appendTag(new NBTTagString("\u00A7r\u00A7eItem Name:"));
@@ -122,13 +122,13 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler {
ContainerMultiModule multiContainer = (ContainerMultiModule) this.inventorySlots;
String localizedName = multiContainer.getInventoryDisplayName();
if(localizedName != null) {
this.fontRendererObj.drawString(localizedName, 8, 6, 0x404040);
this.fontRenderer.drawString(localizedName, 8, 6, 0x404040);
}
}
protected void drawPlayerInventoryName() {
String localizedName = Minecraft.getMinecraft().player.inventory.getDisplayName().getUnformattedText();
this.fontRendererObj.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040);
this.fontRenderer.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040);
}
@Override
@@ -1,5 +1,7 @@
package slimeknights.mantle.client.gui.book;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
@@ -20,6 +22,7 @@ import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
@@ -84,7 +87,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
this.statisticsManager = statisticsManager;
this.mc = Minecraft.getMinecraft();
this.fontRendererObj = mc.fontRendererObj;
this.fontRenderer = mc.fontRenderer;
init();
}
@@ -125,16 +128,16 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
init();
FontRenderer fontRenderer = book.fontRenderer;
if(fontRenderer == null) {
fontRenderer = mc.fontRendererObj;
fontRenderer = mc.fontRenderer;
}
if(loadingAchievements) {
this.drawDefaultBackground();
this.drawCenteredString(this.fontRendererObj, I18n
this.drawCenteredString(this.fontRenderer, I18n
.format("multiplayer.downloadingStats"), this.width / 2, this.height / 2, 16777215);
this.drawCenteredString(this.fontRendererObj, LOADING_STRINGS[(int) (Minecraft
.getSystemTime() / 150L % (long) LOADING_STRINGS.length)], this.width / 2, this.height / 2 + this.fontRendererObj.FONT_HEIGHT * 2, 16777215);
this.drawCenteredString(this.fontRenderer, LOADING_STRINGS[(int) (Minecraft
.getSystemTime() / 150L % (long) LOADING_STRINGS.length)], this.width / 2, this.height / 2 + this.fontRenderer.FONT_HEIGHT * 2, 16777215);
return;
}
@@ -558,9 +561,14 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
}
// Not foreach to prevent conmodification crashes
for(int i = 0; right ? i < rightElements.size() : i < leftElements.size(); i++) {
BookElement element = right ? rightElements.get(i) : leftElements.get(i);
int oldPage = page;
List<BookElement> elementList = ImmutableList.copyOf(right ? rightElements: leftElements);
for(BookElement element : elementList) {
element.mouseClicked(mouseX, mouseY, mouseButton);
// if we changed page stop so we don't act on the new page
if(page != oldPage) {
break;
}
}
}
@@ -47,7 +47,7 @@ public class GuiBookmark extends GuiButton {
if(data.text != null && !data.text.isEmpty()) {
TextDataRenderer
.drawScaledString(mc.fontRendererObj, data.text, xPosition + 1, yPosition + height / 2 - mc.fontRendererObj.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE);
.drawScaledString(mc.fontRenderer, data.text, xPosition + 1, yPosition + height / 2 - mc.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE);
}
GlStateManager.color(1F, 1F, 1F);
@@ -59,7 +59,7 @@ public class ElementItem extends SizedBookElement {
NonNullList<ItemStack> nonNullStacks = NonNullList.<ItemStack> withSize(itemCycle.length, ItemStack.EMPTY);
for(int i = 0; i < itemCycle.length; i++) {
if(itemCycle[i] != ItemStack.EMPTY) {
if(!itemCycle[i].isEmpty()) {
nonNullStacks.set(i, itemCycle[i].copy());
}
}
@@ -17,10 +17,13 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import slimeknights.mantle.client.book.StructureBlockAccess;
import slimeknights.mantle.client.book.StructureInfo;
import slimeknights.mantle.client.book.data.element.BlockData;
import slimeknights.mantle.client.gui.book.GuiBook;
public class ElementStructure extends SizedBookElement implements IButtonClickHandler {
@@ -37,13 +40,13 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
public ElementStructure(int x, int y, int width, int height, int[] size, BlockData[] structure) {
super(x, y, width, height);
if(size.length == 3) {
scale = size[0] > size[1] ? width / size[0] - 10F : height / size[1] - 10F;
scale = 100f / (float)IntStream.of(size).max().getAsInt();
if(scale * size[0] > width) {
scale = width / size[0] - 10F;
}
float sx = (float)width / (float)GuiBook.PAGE_WIDTH;
float sy = (float)height / (float)GuiBook.PAGE_HEIGHT;
scale *= Math.min(sx, sy);
xTranslate = x + width / 2;// - (size[0] * scale) / 2;
yTranslate = y + height / 2;// - (size[1] * scale) / 2;
@@ -51,7 +54,6 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
w = size[0] * scale;
h = size[1] * scale;
}
init(size, structure);
}
@@ -61,7 +63,6 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa
float rotX = 0;
float rotY = 0;
float rotZ = 0;
List<String> componentTooltip;
public StructureInfo structureData;
StructureBlockAccess blockAccess;
@@ -14,6 +14,8 @@ import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer;
public class BlockMeta {
private static final BlockMeta MISSING = new BlockMeta(Blocks.AIR, 0);
public transient static final TypeSerializer<BlockMeta> SERIALIZER = new TypeSerializer<BlockMeta>() {
@Override
public BlockMeta deserialize(TypeToken<?> typeToken, ConfigurationNode configurationNode)
@@ -23,7 +25,7 @@ public class BlockMeta {
Block block = Block.REGISTRY.getObject(new ResourceLocation(parts[0], parts[1]));
if(block == Blocks.AIR) {
throw new ObjectMappingException("Block not found: " + val);
return MISSING;
}
int meta = -1;
if(parts.length > 2) {
@@ -231,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 != ItemStack.EMPTY && stack.getCount() > 0) {
if(!stack.isEmpty() && stack.getCount() > 0) {
ret |= mergeItemStackMove(stack, startIndex, endIndex, useEndIndex);
}
return ret;
@@ -258,7 +258,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
slot = this.inventorySlots.get(k);
itemstack1 = slot.getStack();
if(itemstack1 != ItemStack.EMPTY
if(!itemstack1.isEmpty()
&& itemstack1.getItem() == stack.getItem()
&& (!stack.getHasSubtypes() || stack.getMetadata() == itemstack1.getMetadata())
&& ItemStack.areItemStackTagsEqual(stack, itemstack1)
@@ -312,7 +312,7 @@ public abstract class BaseContainer<T extends TileEntity> extends Container {
Slot slot = this.inventorySlots.get(k);
ItemStack itemstack1 = slot.getStack();
if(itemstack1 == ItemStack.EMPTY && slot.isItemValid(stack) && this.canMergeSlot(stack, slot)) // Forge: Make sure to respect isItemValid in the slot.
if(itemstack1.isEmpty() && 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();
@@ -195,7 +195,7 @@ public class ContainerMultiModule<T extends TileEntity & IInventory> extends Bas
}
protected boolean moveToTileInventory(ItemStack itemstack) {
if(itemstack == ItemStack.EMPTY || itemstack.getCount() == 0) {
if(itemstack.isEmpty() || 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 == ItemStack.EMPTY || itemstack.getCount() == 0) {
if(itemstack.isEmpty() || 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 == ItemStack.EMPTY || itemstack.getCount() == 0) {
if(itemstack.isEmpty() || 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 == ItemStack.EMPTY || itemstack.getCount() == 0) {
if(itemstack.isEmpty() || itemstack.getCount() == 0) {
return false;
}
@@ -16,6 +16,6 @@ public class SlotRestrictedItem extends Slot {
@Override
public boolean isItemValid(ItemStack stack) {
return stack != ItemStack.EMPTY && stack.getItem() == allowedItem;
return !stack.isEmpty() && stack.getItem() == allowedItem;
}
}
@@ -51,6 +51,7 @@ public class SlotWrapper extends Slot {
@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
parent.onTake(playerIn, stack);
return stack;
}
@@ -45,8 +45,8 @@ public class ItemBlockSlab<T extends Enum<T> &EnumBlock.IEnumMeta & IStringSeria
@Nonnull
@Override
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
ItemStack stack = player.getHeldItem(hand);
if(stack.getCount() != 0 && player.canPlayerEdit(pos.offset(facing), facing, stack)) {
// try placing the slab at the current position
@@ -145,16 +145,16 @@ public class ItemEdible extends ItemFood {
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand)
{
ItemStack stack = playerIn.getHeldItem(hand);
int meta = stack.getMetadata();
if(dynamic.isValid(meta) && playerIn.canEat(this.alwaysEdible.get(stack.getMetadata())))
@Nonnull ItemStack itemStackIn = playerIn.getHeldItem(hand);
int meta = itemStackIn.getMetadata();
if(dynamic.isValid(meta) && playerIn.canEat(this.alwaysEdible.get(itemStackIn.getMetadata())))
{
playerIn.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
}
else
{
return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
}
@@ -31,8 +31,8 @@ public class PacketUpdateSavedPage extends AbstractPacket {
@Override
public IMessage handleServer(NetHandlerPlayServer netHandler) {
if (netHandler.playerEntity != null && pageName != null) {
EntityPlayer player = netHandler.playerEntity;
if (netHandler.player != null && pageName != null) {
EntityPlayer player = netHandler.player;
ItemStack is = player.getHeldItem(EnumHand.MAIN_HAND);
@@ -0,0 +1,10 @@
package slimeknights.mantle.tileentity;
import net.minecraft.tileentity.TileEntity;
public class MantleTileEntity extends TileEntity {
public boolean isClient() {
return this.getWorld() != null && this.getWorld().isRemote;
}
}
@@ -18,12 +18,11 @@ 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 {
public class TileInventory extends MantleTileEntity implements IInventory {
private NonNullList<ItemStack> inventory;
protected String inventoryTitle;
@@ -78,12 +77,21 @@ public class TileInventory extends TileEntity implements IInventory {
}
public boolean isStackInSlot(int slot) {
return getStackInSlot(slot) != ItemStack.EMPTY;
return !getStackInSlot(slot).isEmpty();
}
public void resize(int size) {
//TODO: Make sure this didn't break inventory contents.
NonNullList<ItemStack> oldInventory = inventory;
inventory = NonNullList.<ItemStack> withSize(size, ItemStack.EMPTY);
for (int i = 0; i < size; i++) {
ItemStack itemStack = oldInventory.get(i);
if (!itemStack.isEmpty()) {
inventory.set(i, itemStack);
}
}
}
@Override
@@ -103,7 +111,8 @@ public class TileInventory extends TileEntity implements IInventory {
}
inventory.set(slot, itemstack);
if(itemstack != ItemStack.EMPTY && itemstack.getCount() > getInventoryStackLimit()) {
if(!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit()) {
itemstack.setCount(getInventoryStackLimit());
}
}
@@ -112,7 +121,7 @@ public class TileInventory extends TileEntity implements IInventory {
public ItemStack decrStackSize(int slot, int quantity) {
ItemStack itemStack = getStackInSlot(slot);
if(itemStack == ItemStack.EMPTY) {
if(itemStack.isEmpty()) {
return ItemStack.EMPTY;
}
@@ -145,7 +154,7 @@ public class TileInventory extends TileEntity implements IInventory {
@Override
public boolean isItemValidForSlot(int slot, @Nonnull ItemStack itemstack) {
if(slot < getSizeInventory()) {
if(inventory.get(slot) == ItemStack.EMPTY || itemstack.getCount() + inventory.get(slot).getCount() <= getInventoryStackLimit()) {
if(inventory.get(slot).isEmpty() || itemstack.getCount() + inventory.get(slot).getCount() <= getInventoryStackLimit()) {
return true;
}
}
@@ -243,7 +252,7 @@ public class TileInventory extends TileEntity implements IInventory {
NBTTagList nbttaglist = new NBTTagList();
for(int i = 0; i < inventory.getSizeInventory(); i++) {
if(inventory.getStackInSlot(i) != ItemStack.EMPTY) {
if(!inventory.getStackInSlot(i).isEmpty()) {
NBTTagCompound itemTag = new NBTTagCompound();
itemTag.setByte("Slot", (byte) i);
inventory.getStackInSlot(i).writeToNBT(itemTag);
@@ -46,12 +46,11 @@ public class JeiPlugin implements IModPlugin {
}
@Override
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry)
{
public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry){
}
@Override
public void registerIngredients(IModIngredientRegistration registry)
{
public void registerIngredients(IModIngredientRegistration registry){
}
}
@@ -12,6 +12,7 @@ import net.minecraftforge.oredict.OreDictionary;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.IntStream;
import slimeknights.mantle.Mantle;
@@ -217,11 +218,11 @@ public abstract class RecipeMatch {
NonNullList<ItemStack> nonNullStacks = NonNullList.<ItemStack> withSize(stacks.length, ItemStack.EMPTY);
for(int i = 0; i < stacks.length; i++) {
if(stacks[i] != ItemStack.EMPTY) {
if(!stacks[i].isEmpty()) {
nonNullStacks.set(i, stacks[i].copy());
}
}
this.itemStacks = nonNullStacks;
}
@@ -236,7 +237,7 @@ public abstract class RecipeMatch {
Set<Integer> needed = Sets.newHashSet();
for(int i = 0; i < itemStacks.size(); i++) {
if(itemStacks.get(i) != ItemStack.EMPTY) {
if(!itemStacks.get(i).isEmpty()) {
needed.add(i);
}
}
@@ -289,7 +290,10 @@ public abstract class RecipeMatch {
@Override
public List<ItemStack> getInputs() {
return oredictEntry;
// transform "Requires 2 Cobblestone" into "2x require 1 Cobblestone" since the oredictEntry only contains stacksize 1 usually
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
oredictEntry.forEach(stack -> IntStream.range(0, amountNeeded).forEach(i -> builder.add(stack)));
return builder.build();
}
@Override
@@ -27,10 +27,11 @@ public class RecipeMatchRegistry {
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) {
if(!stacks[i].isEmpty()) {
nonNullStacks.set(i, stacks[i].copy());
}
}
for(RecipeMatch recipe : items) {
RecipeMatch.Match match = recipe.matches(nonNullStacks);
if(match != null) {
@@ -154,7 +155,7 @@ public class RecipeMatchRegistry {
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) {
if(!in.get(i).isEmpty()) {
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 == ItemStack.EMPTY || stack.getItem() == null || !stack.hasTagCompound()) {
if(stack.isEmpty() || stack.getItem() == null || !stack.hasTagCompound()) {
return new NBTTagCompound();
}