Skip to content

Commit

Permalink
Update to 1.11 / 1.11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
freneticfeline committed Jun 30, 2017
1 parent 5186e93 commit 6c5e0a0
Show file tree
Hide file tree
Showing 17 changed files with 240 additions and 187 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.11-2.1
=======
Updated for 1.11 / 1.11.2

1.10-2.1
=======
Updated for 1.10 / 1.10.2
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ buildscript {

apply plugin: 'net.minecraftforge.gradle.forge'

version = "1.10-2.1"
version = "1.11-2.1"
group = "net.unladenswallow.minecraft.emeraldmaterial" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "mod_ffMOreUsableMaterials_forge"

minecraft {
version = "1.10.2-12.18.1.2011"
version = "1.11.2-13.20.0.2228"
runDir = "eclipse"

// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20160518"
mappings = "snapshot_20161220"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
*/
public class EMEventHandler {

private static final int FIRST_ARMOR_INVENTORY_SLOT = 36;

/* private Enchantment[] toolEnchantments =
{ Enchantment.fortune, Enchantment.silkTouch, Enchantment.efficiency, Enchantment.unbreaking };
private Enchantment[] armorEnchantments =
Expand All @@ -42,7 +40,7 @@ public class EMEventHandler {
@SubscribeEvent
public void onItemCraftedEvent(ItemCraftedEvent event) {
if (event.crafting != null
&& !event.player.worldObj.isRemote
&& !event.player.world.isRemote
&& (event.crafting.getItem() instanceof ItemCustomBow
|| event.crafting.getItem() instanceof ItemCustomArmor
|| event.crafting.getItem() instanceof ItemTool
Expand All @@ -52,7 +50,7 @@ public void onItemCraftedEvent(ItemCraftedEvent event) {
){
// EMLogger.info("EMEventhandler onItemCraftedEvent: Crafting a lapis item: %s [worldTime = %d]",
// event.crafting.getDisplayName(), event.player.worldObj.getWorldTime());
EnchantmentHelper.addRandomEnchantment(event.player.worldObj.rand, event.crafting, 1, false);
EnchantmentHelper.addRandomEnchantment(event.player.world.rand, event.crafting, 1, false);
// TODO: Figure out how to do this so that server and client are in sync
// ((EntityPlayerMP)(event.player)).playerNetServerHandler.sendPacket(new S43PacketCamera());
}
Expand All @@ -77,7 +75,7 @@ public void onLivingAttackEvent(LivingHurtEvent event) {
// EMLogger.info("EMEventHandler onLivingAttackEvent: tick = %d; DOArmor reduced %s damage to %f",
// event.entityLiving.worldObj.getWorldTime(), event.source.getDamageType(), newDamage);
}
if (event.getSource().isExplosion() || event.getSource() == DamageSource.onFire) {
if (event.getSource().isExplosion() || event.getSource() == DamageSource.ON_FIRE) {
// Each Obsidian Armor piece reduces onFire and explosion damage by 22%. A full set results
// in near immunity to onFire and explosions. Standing in fire and lava will still damage.
if (numObsidianArmorPieces > 0) {
Expand All @@ -86,7 +84,7 @@ public void onLivingAttackEvent(LivingHurtEvent event) {
// event.entityLiving.worldObj.getWorldTime(), event.source.getDamageType(), newDamage);
}
}
if (event.getSource() == DamageSource.lava) {
if (event.getSource() == DamageSource.LAVA) {
// Each Obsidian Armor piece reduces lava damage by 15%.
if (numObsidianArmorPieces > 0) {
newDamage = newDamage - ((float)numObsidianArmorPieces * 0.15f * newDamage);
Expand All @@ -103,10 +101,11 @@ public void onLivingAttackEvent(LivingHurtEvent event) {
}

private int getNumMatchingArmorPieces(EntityPlayer player, ArmorMaterial armorMaterial) {
return (inventorySlotContainsArmor(player.inventory, FIRST_ARMOR_INVENTORY_SLOT, armorMaterial) ? 1 : 0)
+ (inventorySlotContainsArmor(player.inventory, FIRST_ARMOR_INVENTORY_SLOT+1, armorMaterial) ? 1 : 0)
+ (inventorySlotContainsArmor(player.inventory, FIRST_ARMOR_INVENTORY_SLOT+2, armorMaterial) ? 1 : 0)
+ (inventorySlotContainsArmor(player.inventory, FIRST_ARMOR_INVENTORY_SLOT+3, armorMaterial) ? 1 : 0);
int firstArmorInventorySlot = player.inventory.mainInventory.size();
return (inventorySlotContainsArmor(player.inventory, firstArmorInventorySlot, armorMaterial) ? 1 : 0)
+ (inventorySlotContainsArmor(player.inventory, firstArmorInventorySlot+1, armorMaterial) ? 1 : 0)
+ (inventorySlotContainsArmor(player.inventory, firstArmorInventorySlot+2, armorMaterial) ? 1 : 0)
+ (inventorySlotContainsArmor(player.inventory, firstArmorInventorySlot+3, armorMaterial) ? 1 : 0);
}

private boolean inventorySlotContainsArmor(InventoryPlayer inventory, int inventorySlot, ArmorMaterial armorMaterial) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ItemMaterials {
static {
emeraldToolMaterial.setRepairItem(new ItemStack(Items.EMERALD));
emeraldBroadswordMaterial.setRepairItem(new ItemStack(Items.EMERALD));
emeraldArmorMaterial.customCraftingMaterial = Items.EMERALD;
emeraldArmorMaterial.setRepairItem(new ItemStack(Items.EMERALD));
}

public static ToolMaterial obsidianToolMaterial = EnumHelper.addToolMaterial(
Expand Down Expand Up @@ -67,7 +67,7 @@ public class ItemMaterials {
static {
obsidianToolMaterial.setRepairItem(new ItemStack(ModEmeraldMaterial.obsidianIngot));
obsidianBroadswordMaterial.setRepairItem(new ItemStack(ModEmeraldMaterial.obsidianIngot));
obsidianArmorMaterial.customCraftingMaterial = ModEmeraldMaterial.obsidianIngot;
obsidianArmorMaterial.setRepairItem(new ItemStack(ModEmeraldMaterial.obsidianIngot));
}

public static ToolMaterial lapisToolMaterial = EnumHelper.addToolMaterial(
Expand Down Expand Up @@ -97,7 +97,7 @@ public class ItemMaterials {
static {
lapisToolMaterial.setRepairItem(new ItemStack(Items.DYE, 1, 4));
lapisBroadswordMaterial.setRepairItem(new ItemStack(Items.DYE, 1, 4));
lapisArmorMaterial.customCraftingMaterial = (new ItemStack(Items.DYE, 1, 4)).getItem();
lapisArmorMaterial.setRepairItem(new ItemStack(Items.DYE, 1, 4));
}

public static ToolMaterial redstoneToolMaterial = EnumHelper.addToolMaterial(
Expand Down Expand Up @@ -127,7 +127,7 @@ public class ItemMaterials {
static {
redstoneToolMaterial.setRepairItem(new ItemStack(Items.REDSTONE));
redstoneBroadswordMaterial.setRepairItem(new ItemStack(Items.REDSTONE));
redstoneArmorMaterial.customCraftingMaterial = Items.REDSTONE;
redstoneArmorMaterial.setRepairItem(new ItemStack(Items.REDSTONE));
}

/* This is a copy of ToolMaterial.GOLD values with damage increased by 1.0 */
Expand Down Expand Up @@ -199,7 +199,7 @@ public class ItemMaterials {
static {
diamondObsidianToolMaterial.setRepairItem(new ItemStack(ModEmeraldMaterial.diamondObsidianIngot));
diamondObsidianBroadswordMaterial.setRepairItem(new ItemStack(ModEmeraldMaterial.diamondObsidianIngot));
diamondObsidianArmorMaterial.customCraftingMaterial = ModEmeraldMaterial.diamondObsidianIngot;
diamondObsidianArmorMaterial.setRepairItem(new ItemStack(ModEmeraldMaterial.diamondObsidianIngot));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import net.unladenswallow.minecraft.emeraldmaterial.item.ItemGoldBow;


@Mod(modid = ModEmeraldMaterial.MODID, useMetadata = true, acceptedMinecraftVersions="[1.10,1.11)", acceptableRemoteVersions="1.10,1.11)")
@Mod(modid = ModEmeraldMaterial.MODID, useMetadata = true, acceptedMinecraftVersions="[1.11,1.12)", acceptableRemoteVersions="1.10,1.11)")
public class ModEmeraldMaterial {

public static final String MODID = "mod_emeraldmaterial";
Expand Down Expand Up @@ -221,10 +221,12 @@ public void preInit(FMLPreInitializationEvent preInitEvent) {
.setCreativeTab(CreativeTabs.MATERIALS);

/* ************** Emerald Items and Blocks ********************* */
emeraldHelmet = new ItemCustomArmor("emerald_helmet", 1, EntityEquipmentSlot.HEAD, ItemMaterials.emeraldArmorMaterial, MobEffects.SPEED);
emeraldChest = new ItemCustomArmor("emerald_chest", 1, EntityEquipmentSlot.CHEST, ItemMaterials.emeraldArmorMaterial, MobEffects.SPEED);
emeraldPants = new ItemCustomArmor("emerald_pants", 2, EntityEquipmentSlot.LEGS, ItemMaterials.emeraldArmorMaterial, MobEffects.SPEED);
emeraldBoots = new ItemCustomArmor("emerald_boots", 1, EntityEquipmentSlot.FEET, ItemMaterials.emeraldArmorMaterial, MobEffects.SPEED);
emeraldHelmet = new ItemCustomArmor("emerald_helmet", 1, EntityEquipmentSlot.HEAD, ItemMaterials.emeraldArmorMaterial, null);
emeraldChest = new ItemCustomArmor("emerald_chest", 1, EntityEquipmentSlot.CHEST, ItemMaterials.emeraldArmorMaterial, null);
emeraldPants = new ItemCustomArmor("emerald_pants", 2, EntityEquipmentSlot.LEGS, ItemMaterials.emeraldArmorMaterial, null);
emeraldBoots = new ItemCustomArmor("emerald_boots", 1, EntityEquipmentSlot.FEET, ItemMaterials.emeraldArmorMaterial, null);
((ItemCustomArmor)emeraldHelmet).addFullSetEffect(MobEffects.SPEED);
((ItemCustomArmor)emeraldHelmet).addFullSetEffect(MobEffects.HASTE);

emeraldSword = (new ItemSword(ItemMaterials.emeraldToolMaterial))
.setUnlocalizedName("emerald_sword")
Expand Down Expand Up @@ -350,10 +352,12 @@ public void preInit(FMLPreInitializationEvent preInitEvent) {


/* ************** Lapis Items and Blocks ********************* */
lapisHelmet = new ItemCustomArmor("lapis_helmet", 1, EntityEquipmentSlot.HEAD, ItemMaterials.lapisArmorMaterial, MobEffects.WATER_BREATHING);
lapisHelmet = new ItemCustomArmor("lapis_helmet", 1, EntityEquipmentSlot.HEAD, ItemMaterials.lapisArmorMaterial, null);
lapisChest = new ItemCustomArmor("lapis_chest", 1, EntityEquipmentSlot.CHEST, ItemMaterials.lapisArmorMaterial, null);
lapisPants = new ItemCustomArmor("lapis_pants", 2, EntityEquipmentSlot.LEGS, ItemMaterials.lapisArmorMaterial, null);
lapisBoots = new ItemCustomArmor("lapis_boots", 1, EntityEquipmentSlot.FEET, ItemMaterials.lapisArmorMaterial, null);
((ItemCustomArmor)lapisHelmet).addFullSetEffect(MobEffects.WATER_BREATHING);
((ItemCustomArmor)lapisHelmet).addFullSetEffect(MobEffects.LUCK);

lapisAxe = new ItemCustomAxe(ItemMaterials.lapisToolMaterial, "lapis_axe");
lapisHoe = new ItemCustomHoe(ItemMaterials.lapisToolMaterial, "lapis_hoe");
Expand Down Expand Up @@ -409,10 +413,11 @@ public void preInit(FMLPreInitializationEvent preInitEvent) {


/* ************** Redstone Items and Blocks ********************* */
redstoneHelmet = new ItemCustomArmor("redstone_helmet", 1, EntityEquipmentSlot.HEAD, ItemMaterials.redstoneArmorMaterial, MobEffects.NIGHT_VISION);
redstoneHelmet = new ItemCustomArmor("redstone_helmet", 1, EntityEquipmentSlot.HEAD, ItemMaterials.redstoneArmorMaterial, null);
redstoneChest = new ItemCustomArmor("redstone_chest", 1, EntityEquipmentSlot.CHEST, ItemMaterials.redstoneArmorMaterial, null);
redstonePants = new ItemCustomArmor("redstone_pants", 2, EntityEquipmentSlot.LEGS, ItemMaterials.redstoneArmorMaterial, null);
redstoneBoots = new ItemCustomArmor("redstone_boots", 1, EntityEquipmentSlot.FEET, ItemMaterials.redstoneArmorMaterial, null);
((ItemCustomArmor)redstoneHelmet).addFullSetEffect(MobEffects.NIGHT_VISION);

redstoneAxe = new ItemCustomAxe(ItemMaterials.redstoneToolMaterial, "redstone_axe");
redstoneHoe = new ItemCustomHoe(ItemMaterials.redstoneToolMaterial, "redstone_hoe");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package net.unladenswallow.minecraft.emeraldmaterial.block;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockWall;
Expand All @@ -12,6 +10,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
Expand Down Expand Up @@ -42,18 +41,21 @@ public BlockCustomWall(Block sourceBlock, String unlocalizedName)
}

/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
* Base class has two blocks with the same ID but different meta (normal and mossy),
* but we only have one. So we need to override this method to prevent a non-existent
* variant from displaying in the inventory.
*/
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, @SuppressWarnings("rawtypes") List list)
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list)
{
list.add(new ItemStack(itemIn, 1, 0));
}

/**
* Get the damage value that this Block should drop
*/
@Override
public int damageDropped(IBlockState state)
{
return 0;
Expand All @@ -62,6 +64,7 @@ public int damageDropped(IBlockState state)
/**
* Convert the given metadata into a BlockState for this Block
*/
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState();
Expand All @@ -70,6 +73,7 @@ public IBlockState getStateFromMeta(int meta)
/**
* Convert the BlockState into the correct metadata value
*/
@Override
public int getMetaFromState(IBlockState state)
{
return 0;
Expand All @@ -79,6 +83,7 @@ public int getMetaFromState(IBlockState state)
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
boolean flag = this.canConnectTo(worldIn, pos.north());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package net.unladenswallow.minecraft.emeraldmaterial.item;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
Expand All @@ -8,24 +11,37 @@
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.unladenswallow.minecraft.emeraldmaterial.EMLogger;

public class ItemCustomArmor extends ItemArmor {

private Potion fullSetEffect = null;
private List<ArmorEffect> fullSetEffects = new ArrayList<ArmorEffect>();

public ItemCustomArmor(String unlocalizedName, int renderIndex, EntityEquipmentSlot armorType, ArmorMaterial material, Potion fullSetEffect) {
super(material, renderIndex, armorType);
this.setMaxStackSize(1);
this.setCreativeTab(CreativeTabs.COMBAT);
this.setUnlocalizedName(unlocalizedName);
this.setRegistryName(unlocalizedName);
this.fullSetEffect = fullSetEffect;
if (fullSetEffect != null) {
this.addFullSetEffect(fullSetEffect);
}
}

public void addFullSetEffect(Potion effect, int amplifier) {
fullSetEffects.add(new ArmorEffect(effect, amplifier));
}

public void addFullSetEffect(Potion effect) {
this.addFullSetEffect(effect, 0);
}

@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if (this.fullSetEffect != null && playerIsWearingFullSet(player)) {
this.effectPlayer(player, this.fullSetEffect, 0);
if (!this.fullSetEffects.isEmpty() && playerIsWearingFullSet(player)) {
for (ArmorEffect effect : fullSetEffects) {
this.affectPlayer(player, effect.getEffect(), effect.getAmplifier());
}
}
}

Expand All @@ -37,15 +53,39 @@ && playerIsWearingInSlot(player, 3)
);
}

private boolean playerIsWearingInSlot(EntityPlayer player, int slot) {
return player.inventory.armorItemInSlot(slot) != null
&& player.inventory.armorItemInSlot(slot).getItem() instanceof ItemArmor
&& ((ItemArmor)(player.inventory.armorItemInSlot(slot).getItem())).getArmorMaterial() == this.getArmorMaterial();
private boolean playerIsWearingInSlot(EntityPlayer player, int armorSlot) {
// As of 1.11, InventoryPlayer.armorItemInSlot() is ClientSide only
int inventorySlot = player.inventory.mainInventory.size() + armorSlot;
ItemStack stackInSlot = player.inventory.getStackInSlot(inventorySlot);
return stackInSlot != null
&& stackInSlot.getItem() instanceof ItemArmor
&& ((ItemArmor)(stackInSlot.getItem())).getArmorMaterial() == this.getArmorMaterial();
}

private void affectPlayer(EntityPlayer player, Potion potion, int amplifier) {
//Always effect for 20 seconds, then refresh
if (player.getActivePotionEffect(potion) == null || player.getActivePotionEffect(potion).getDuration() <= 200)
player.addPotionEffect(new PotionEffect(potion, 399, amplifier, true, false));
}

private void effectPlayer(EntityPlayer player, Potion potion, int amplifier) {
//Always effect for 8 seconds, then refresh
if (player.getActivePotionEffect(potion) == null || player.getActivePotionEffect(potion).getDuration() <= 1)
player.addPotionEffect(new PotionEffect(potion, 159, amplifier, true, false));
private class ArmorEffect {
private Potion effect;
public ArmorEffect(Potion effect, int amplifier) {
this.effect = effect;
this.amplifier = amplifier;
}
private int amplifier;
public Potion getEffect() {
return effect;
}
public void setEffect(Potion effect) {
this.effect = effect;
}
public int getAmplifier() {
return amplifier;
}
public void setAmplifier(int amplifier) {
this.amplifier = amplifier;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBas

if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(entityarrow);
worldIn.spawnEntity(entityarrow);
}
}
}
Expand Down
Loading

0 comments on commit 6c5e0a0

Please sign in to comment.