Skip to content

Commit

Permalink
Update Natura to latest forge, mappings, mantle and HWYLA version, an…
Browse files Browse the repository at this point in the history
…d require mantle 1.3.0 not 1.2.0
  • Loading branch information
alexbegt committed Jul 7, 2017
1 parent 415c0ce commit df2fa7f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 98 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Expand Up @@ -2,14 +2,14 @@ mod_version=4.3.0

minecraft_version=1.12

forge_version=14.21.0.2383
mappings_version=snapshot_20170628
forge_version=14.21.1.2397
mappings_version=snapshot_20170706

mantle_version=1.2.0.2
mantle_version=1.3.+
tconstruct_version=2.7.0.+

jei_version=4.7.+

hwyla_version=1.8.18-B32
hwyla_version=1.8.19-B33

mcmultipart_version=2.0.0_+
128 changes: 34 additions & 94 deletions src/main/java/com/progwml6/natura/plugin/waila/HUDHandlerNatura.java
Expand Up @@ -3,6 +3,8 @@
import java.lang.reflect.Method;
import java.util.List;

import javax.annotation.Nonnull;

import com.progwml6.natura.Natura;
import com.progwml6.natura.common.block.BlockNaturaDoor;
import com.progwml6.natura.nether.NaturaNether;
Expand All @@ -12,23 +14,20 @@
import com.progwml6.natura.overworld.block.crops.BlockOverworldCrops;
import com.progwml6.natura.shared.NaturaCommons;

import mcp.mobius.waila.addons.HUDHandlerBase;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaRegistrar;
import mcp.mobius.waila.cbcore.LangUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;

public class HUDHandlerNatura extends HUDHandlerBase
public class HUDHandlerNatura implements IWailaDataProvider
{
//@formatter:off
static Method getCrop;
Expand Down Expand Up @@ -63,6 +62,7 @@ public class HUDHandlerNatura extends HUDHandlerBase
static Block bloodwoodDoor = NaturaNether.bloodwoodDoor;
//@formatter:on

@Nonnull
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config)
{
Expand All @@ -85,73 +85,33 @@ public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler
return new ItemStack(block, 1, accessor.getMetadata() % 8);
}

if (config.getConfig("natura.alternatecropitem"))
{
if (block instanceof BlockOverworldCrops)
{
if (getCrop == null)
getCrop = ReflectionHelper.findMethod(BlockOverworldCrops.class, "getCrop", "getCrop");

try
{
return new ItemStack((Item) getCrop.invoke(block));
}
catch (Exception e)
{
return null;
}
}
}
else
{
// Barley crop should display Barley item
if (block == barley)
return NaturaCommons.barley.copy();
// Barley crop should display Barley item
if (block == barley)
return NaturaCommons.barley.copy();

// Cotton crop should display Cotton item
if (block == cotton)
return NaturaCommons.cotton.copy();
}
// Cotton crop should display Cotton item
if (block == cotton)
return NaturaCommons.cotton.copy();

if (config.getConfig("natura.alternatedooritem"))
{
if (block instanceof BlockNaturaDoor)
{
if (getDoor == null)
getDoor = ReflectionHelper.findMethod(BlockNaturaDoor.class, "getDoor", "getDoor");

try
{
return new ItemStack((Item) getDoor.invoke(block));
}
catch (Exception e)
{
return null;
}
}
}
else
{
// Eucalyptus Door should display Eucalyptus Door item
if (block == eucalyptusDoor)
return NaturaOverworld.eucalyptus_door.copy();
// Eucalyptus Door should display Eucalyptus Door item
if (block == eucalyptusDoor)
return NaturaOverworld.eucalyptus_door.copy();

// Hopseed Door should display Hopseed Door item
if (block == hopseedDoor)
return NaturaOverworld.hopseed_door.copy();
// Hopseed Door should display Hopseed Door item
if (block == hopseedDoor)
return NaturaOverworld.hopseed_door.copy();

// Sakura Door should display Sakura Door item
if (block == sakuraDoor)
return NaturaOverworld.sakura_door.copy();
// Sakura Door should display Sakura Door item
if (block == sakuraDoor)
return NaturaOverworld.sakura_door.copy();

// Redwood Door should display Redwood Door item
if (block == redwoodDoor)
return NaturaOverworld.redwood_door.copy();
// Redwood Door should display Redwood Door item
if (block == redwoodDoor)
return NaturaOverworld.redwood_door.copy();

// Redwood Bark Door should display Redwood Bark Door item
if (block == redwoodBarkDoor)
return NaturaOverworld.redwood_bark_door.copy();
}
// Redwood Bark Door should display Redwood Bark Door item
if (block == redwoodBarkDoor)
return NaturaOverworld.redwood_bark_door.copy();
}

if (Natura.pulseManager.isPulseLoaded(NaturaNether.PulseId))
Expand Down Expand Up @@ -181,38 +141,19 @@ public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler
return new ItemStack(block, 1, accessor.getMetadata() % 8);
}

if (config.getConfig("natura.alternatedooritem"))
{
if (block instanceof BlockNaturaDoor)
{
if (getDoor == null)
getDoor = ReflectionHelper.findMethod(BlockNaturaDoor.class, "getDoor", "getDoor");

try
{
return new ItemStack((Item) getDoor.invoke(block));
}
catch (Exception e)
{
return null;
}
}
}
else
{
// Ghostwood Door should display Ghostwood Door item
if (block == ghostwoodDoor)
return NaturaNether.ghostwood_door.copy();
// Ghostwood Door should display Ghostwood Door item
if (block == ghostwoodDoor)
return NaturaNether.ghostwood_door.copy();

// Bloodwood Bark Door should display Bloodwood Bark Door item
if (block == bloodwoodDoor)
return NaturaNether.bloodwood_door.copy();
}
// Bloodwood Bark Door should display Bloodwood Bark Door item
if (block == bloodwoodDoor)
return NaturaNether.bloodwood_door.copy();
}

return null;
}

@Nonnull
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
Expand All @@ -237,19 +178,18 @@ public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, I
return currenttip;
}

@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos)
{
if (te != null)
te.writeToNBT(tag);

return tag;
}

public static void register(IWailaRegistrar registrar)
{
registrar.addConfig("Natura", "natura.alternatecropitem");
registrar.addConfig("Natura", "natura.alternatedooritem");

IWailaDataProvider provider = new HUDHandlerNatura();

//Overworld
Expand Down

0 comments on commit df2fa7f

Please sign in to comment.