Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.11' into 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryLoenwind committed Dec 20, 2017
2 parents e2aa7f3 + 9659b80 commit eb13ab0
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 24 deletions.
3 changes: 3 additions & 0 deletions externalannotations/java/util/Collections.eea
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ singleton
singletonList
<T:Ljava/lang/Object;>(TT;)Ljava/util/List<TT;>;
<T:Ljava/lang/Object;>(TT;)L1java/util/List<TT;>;
singletonMap
<K:Ljava/lang/Object;V:Ljava/lang/Object;>(TK;TV;)Ljava/util/Map<TK;TV;>;
<K:Ljava/lang/Object;V:Ljava/lang/Object;>(TK;TV;)L1java/util/Map<TK;TV;>;
unmodifiableSet
<T:Ljava/lang/Object;>(Ljava/util/Set<+TT;>;)Ljava/util/Set<TT;>;
<T:Ljava/lang/Object;>(Ljava/util/Set<+TT;>;)L1java/util/Set<TT;>;
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
package com.enderio.core.client.gui;

import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.enderio.core.client.gui.widget.GhostSlot;
import com.enderio.core.client.render.RenderUtil;
import com.enderio.core.common.util.ItemUtil;
import com.google.common.collect.Lists;
import com.enderio.core.common.util.NNList;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;

public class GhostSlotHandler {

protected final @Nonnull List<GhostSlot> ghostSlots = Lists.newArrayList();
protected final @Nonnull NNList<GhostSlot> ghostSlots = new NNList<GhostSlot>();
protected @Nullable GhostSlot hoverGhostSlot;

public GhostSlotHandler() {
Expand All @@ -25,7 +23,7 @@ public GhostSlotHandler() {
// GhostSlot managing

@Nonnull
public List<GhostSlot> getGhostSlots() {
public NNList<GhostSlot> getGhostSlots() {
return ghostSlots;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ protected void drawFakeItemsStart() {
RenderHelper.enableGUIStandardItemLighting();
}

protected void drawFakeItemStack(int x, int y, @Nonnull ItemStack stack) {
public void drawFakeItemStack(int x, int y, @Nonnull ItemStack stack) {
itemRender.renderItemAndEffectIntoGUI(stack, x, y);
GlStateManager.enableAlpha();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.enderio.core.api.client.gui.IResourceTooltipProvider;
import com.enderio.core.common.Handlers.Handler;
import com.enderio.core.common.util.ItemUtil;
import com.enderio.core.common.util.NNList;
import com.google.common.collect.Lists;

import net.minecraft.block.Block;
Expand Down Expand Up @@ -83,6 +84,50 @@ public static void addTooltip(ItemTooltipEvent evt) {
}
}

public static NNList<String> getAllTooltips(ItemStack stack) {
NNList<String> list = new NNList<>();

if (stack.getItem() instanceof IAdvancedTooltipProvider) {
IAdvancedTooltipProvider tt = (IAdvancedTooltipProvider) stack.getItem();
tt.addCommonEntries(stack, Minecraft.getMinecraft().player, list, false);
tt.addBasicEntries(stack, Minecraft.getMinecraft().player, list, false);
tt.addDetailedEntries(stack, Minecraft.getMinecraft().player, list, false);
return list;
} else if (stack.getItem() instanceof IResourceTooltipProvider) {
String name = ((IResourceTooltipProvider) stack.getItem()).getUnlocalizedNameForTooltip(stack);
addCommonTooltipFromResources(list, name);
addBasicTooltipFromResources(list, name);
addDetailedTooltipFromResources(list, name);
return list;
}

Block blk = Block.getBlockFromItem(stack.getItem());
if (blk instanceof IAdvancedTooltipProvider) {
IAdvancedTooltipProvider tt = (IAdvancedTooltipProvider) blk;
tt.addCommonEntries(stack, Minecraft.getMinecraft().player, list, false);
tt.addBasicEntries(stack, Minecraft.getMinecraft().player, list, false);
tt.addDetailedEntries(stack, Minecraft.getMinecraft().player, list, false);
return list;
} else if (blk instanceof IResourceTooltipProvider) {
IResourceTooltipProvider tt = (IResourceTooltipProvider) blk;
String name = tt.getUnlocalizedNameForTooltip(stack);
addCommonTooltipFromResources(list, name);
addBasicTooltipFromResources(list, name);
addDetailedTooltipFromResources(list, name);
return list;
}

for (ITooltipCallback callback : callbacks) {
if (callback.shouldHandleItem(stack)) {
callback.addCommonEntries(stack, Minecraft.getMinecraft().player, list, false);
callback.addBasicEntries(stack, Minecraft.getMinecraft().player, list, false);
callback.addDetailedEntries(stack, Minecraft.getMinecraft().player, list, false);
}
}

return list;
}

public static void addDurabilityTooltip(@Nonnull List<String> toolTip, @Nonnull ItemStack itemStack) {
if (!itemStack.isItemStackDamageable()) {
return;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/enderio/core/common/BlockEnder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -255,4 +256,11 @@ public Class<? extends T> getTeClass() {
return teClass;
}

// wrapper because vanilla null-annotations are wrong
@SuppressWarnings("null")
@Override
public @Nonnull Block setCreativeTab(@Nullable CreativeTabs tab) {
return super.setCreativeTab(tab);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.google.common.collect.Lists;

import net.minecraft.block.Block;
import net.minecraft.block.BlockBeetroot;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockNetherWart;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -69,8 +72,25 @@ public void init() {
if (mcblock == null) {
throw new RuntimeException("invalid block specifier '" + block + "' received in IMV message from another mod");
}
grownState = mcblock.getStateFromMeta(meta);
resetState = mcblock.getStateFromMeta(resetMeta);
if (mcblock instanceof BlockBeetroot) { // BlockBeetroot extends BlockCrops
meta = 3;
resetMeta = 0;
grownState = mcblock.getDefaultState().withProperty(BlockBeetroot.BEETROOT_AGE, 3);
resetState = mcblock.getDefaultState().withProperty(BlockBeetroot.BEETROOT_AGE, 0);
} else if (mcblock instanceof BlockCrops) {
meta = ((BlockCrops) mcblock).getMaxAge();
resetMeta = 0;
grownState = mcblock.getDefaultState().withProperty(BlockCrops.AGE, ((BlockCrops) mcblock).getMaxAge());
resetState = mcblock.getDefaultState().withProperty(BlockCrops.AGE, 0);
} else if (mcblock instanceof BlockNetherWart) {
meta = 3;
resetMeta = 0;
grownState = mcblock.getDefaultState().withProperty(BlockNetherWart.AGE, 3);
resetState = mcblock.getDefaultState().withProperty(BlockNetherWart.AGE, 0);
} else {
grownState = mcblock.getStateFromMeta(meta);
resetState = mcblock.getStateFromMeta(resetMeta);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.objectweb.asm.tree.VarInsnNode;

import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion;
import net.minecraftforge.fml.relauncher.Side;

import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.GETFIELD;
Expand Down Expand Up @@ -95,9 +97,30 @@ protected static abstract class Transform {
static final String extendedBlockStorageClass = "net.minecraft.world.chunk.storage.ExtendedBlockStorage";
static final ObfSafeName isEmptyMethod = new ObfSafeName("isEmpty", "func_76663_a");

private final boolean inDev = System.getProperty("INDEV") != null;

@Override
public byte[] transform(String name, String transformedName, byte[] basicClass) {

if (inDev && FMLLaunchHandler.side() == Side.SERVER) {
// Eclipse's compiler suffers from https://bugs.openjdk.java.net/browse/JDK-6695379
// Filter out methods that are known to be effected from this in a declared development environment only.
// When compiled with a proper compiler, this will not be needed.
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(basicClass);
classReader.accept(classNode, 0);
Iterator<MethodNode> methods = classNode.methods.iterator();
while (methods.hasNext()) {
MethodNode methodNode = methods.next();
if (methodNode.name.equals("getClientGuiElement") && methodNode.desc.contains("GuiScreen")) {
methods.remove();
}
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
classNode.accept(cw);
basicClass = cw.toByteArray();
}

// "Light data eaten instead of sent to client" fix (MC-80966)
if (transformedName.equals(extendedBlockStorageClass)) {
return transform(basicClass, extendedBlockStorageClass, isEmptyMethod, new Transform() {
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/enderio/core/common/util/FluidUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class FluidUtil {
return null;
}

public static @Nullable IFluidHandler getFluidHandlerCapability(@Nonnull ItemStack stack) {
public static @Nullable IFluidHandlerItem getFluidHandlerCapability(@Nonnull ItemStack stack) {
if (stack.hasCapability(getFluidItemCapability(), null)) {
return stack.getCapability(getFluidItemCapability(), null);
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public static FluidStack getFluidTypeFromItem(@Nonnull ItemStack stack) {

ItemStack copy = stack.copy();
copy.setCount(1);
IFluidHandler handler = getFluidHandlerCapability(copy);
IFluidHandlerItem handler = getFluidHandlerCapability(copy);
if (handler != null) {
return handler.drain(Fluid.BUCKET_VOLUME, false);
}
Expand All @@ -110,15 +110,19 @@ public static FluidStack getFluidTypeFromItem(@Nonnull ItemStack stack) {
}

public static boolean isFluidContainer(@Nonnull ItemStack stack) {
return isFluidContainer(stack, null);
return getFluidHandlerCapability(stack) != null;
}

public static boolean isFluidContainer(@Nonnull ICapabilityProvider provider, @Nullable EnumFacing side) {
if (provider instanceof ItemStack) {
Log.warn("isFluidContainer(ICapabilityProvider, EnumFacing) is not for ItemStacks");
return isFluidContainer((ItemStack) provider);
}
return getFluidHandlerCapability(provider, side) != null;
}

public static boolean hasEmptyCapacity(@Nonnull ItemStack stack) {
IFluidHandler handler = getFluidHandlerCapability(stack);
IFluidHandlerItem handler = getFluidHandlerCapability(stack);
if (handler == null) {
return false;
}
Expand All @@ -143,7 +147,7 @@ public static boolean hasEmptyCapacity(@Nonnull ItemStack stack) {

ItemStack filledStack = target.copy();
filledStack.setCount(1);
IFluidHandler handler = getFluidHandlerCapability(filledStack);
IFluidHandlerItem handler = getFluidHandlerCapability(filledStack);
if (handler == null) {
return new FluidAndStackResult(ItemStack.EMPTY, null, target, source);
}
Expand All @@ -153,9 +157,7 @@ public static boolean hasEmptyCapacity(@Nonnull ItemStack stack) {
return new FluidAndStackResult(ItemStack.EMPTY, null, target, source);
}

if (handler instanceof IFluidHandlerItem) {
filledStack = ((IFluidHandlerItem) handler).getContainer();
}
filledStack = handler.getContainer();

FluidStack resultFluid = source.copy();
resultFluid.amount = filledAmount;
Expand All @@ -180,7 +182,7 @@ public static boolean hasEmptyCapacity(@Nonnull ItemStack stack) {

ItemStack emptiedStack = source.copy();
emptiedStack.setCount(1);
IFluidHandler handler = getFluidHandlerCapability(emptiedStack);
IFluidHandlerItem handler = getFluidHandlerCapability(emptiedStack);
if (handler == null) {
return new FluidAndStackResult(null, ItemStack.EMPTY, target, source);
}
Expand All @@ -199,9 +201,7 @@ public static boolean hasEmptyCapacity(@Nonnull ItemStack stack) {
return new FluidAndStackResult(ItemStack.EMPTY, null, source, target);
}

if (handler instanceof IFluidHandlerItem) {
emptiedStack = ((IFluidHandlerItem) handler).getContainer();
}
emptiedStack = handler.getContainer();

ItemStack remainderStack = source.copy();
remainderStack.shrink(1);
Expand All @@ -218,7 +218,7 @@ public static boolean hasEmptyCapacity(@Nonnull ItemStack stack) {
if (source.isEmpty()) {
return result;
}
IFluidHandler handler = getFluidHandlerCapability(source);
IFluidHandlerItem handler = getFluidHandlerCapability(source);
if (handler == null) {
return result;
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/assets/endercore/config/cropConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
[
{
"seed":"minecraft:wheat_seeds",
"block":"minecraft:wheat"
"block":"minecraft:wheat",
"meta":7
},
{
"seed":"minecraft:carrot",
"block":"minecraft:carrots"
"block":"minecraft:carrots",
"meta":7
},
{
"seed":"minecraft:potato",
"block":"minecraft:potatoes"
"block":"minecraft:potatoes",
"meta":7
},
{
"seed":"minecraft:beetroot_seeds",
Expand Down

0 comments on commit eb13ab0

Please sign in to comment.