Skip to content

Commit

Permalink
1.7.1 Update
Browse files Browse the repository at this point in the history
- Port of changes from 1.10.2
  • Loading branch information
JackyyTV committed Jan 4, 2018
1 parent f5b902c commit 03a69eb
Show file tree
Hide file tree
Showing 65 changed files with 496 additions and 938 deletions.
6 changes: 6 additions & 0 deletions src/main/java/jackyy/exchangers/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ public class Config {
//Misc
public static String[] blocksWhitelist;
public static boolean holdingEnchantment;
public static boolean unbreakingPoweredExchangers;
public static boolean useOreDictCircuits;
public static boolean doExchangersSilkTouch;

public static void readConfig() {
Configuration cfg = CommonProxy.config;
Expand Down Expand Up @@ -286,8 +288,12 @@ private static void initConfig(Configuration cfg) {
holdingEnchantment = cfg.getBoolean("Holding Enchantment", CATEGORY_MISC, true,
"If true, allows the Holding Enchantment from CoFHCore to be used in Powered Exchangers\n"
+ "Calculation formula: Base Energy + (Base Energy * Enchantment Level / 2)\n");
unbreakingPoweredExchangers = cfg.getBoolean("Unbreaking Enchantment Affects Powered Exchangers", CATEGORY_MISC, true,
"If true, allows Unbreaking Enchantment to affect Powered Exchangers");
useOreDictCircuits = cfg.getBoolean("Use OreDict Circuits", CATEGORY_MISC, false,
"If true, allows Circuits in Mekanism Exchanger recipes to use OreDict");
doExchangersSilkTouch = cfg.getBoolean("Exchangers Silk Touch", CATEGORY_MISC, true,
"If true, enables Silk Touch (gets the blocks itself rather than drops) in all Exchangers");

}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/jackyy/exchangers/ConfigGuiFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public boolean hasConfigGui() {

@Override
public GuiScreen createConfigGui(GuiScreen parentScreen) {
return null;
return new ConfigGui(parentScreen);
}

@Override
@Override @SuppressWarnings("deprecation")
public Class<? extends GuiScreen> mainConfigGuiClass() {
return ConfigGui.class;
return null;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jackyy/exchangers/Exchangers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Mod(modid = Exchangers.MODID, version = Exchangers.VERSION, name = Exchangers.MODNAME, dependencies = Exchangers.DEPENDS, guiFactory = Exchangers.GUIFACTORY, certificateFingerprint = "@FINGERPRINT@", acceptedMinecraftVersions = Exchangers.MCVERSION, useMetadata = true)
public class Exchangers {

public static final String VERSION = "1.11.2-1.7";
public static final String VERSION = "1.11.2-1.7.1";
public static final String MCVERSION = "[1.11,1.12)";
public static final String MODID = "exchangers";
public static final String MODNAME = "Exchangers";
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/jackyy/exchangers/client/Keys.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package jackyy.exchangers.client;

import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.settings.IKeyConflictContext;
import net.minecraftforge.client.settings.KeyConflictContext;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -9,7 +11,16 @@
@SideOnly(Side.CLIENT)
public class Keys {

public static final KeyBinding MODE_KEY = new KeyBinding("key.exchangermode", Keyboard.KEY_COMMA, "key.categories.exchangers");
public static final KeyBinding MODE_KEY = new KeyBinding("key.exchanger_mode", new IKeyConflictContext() {
@Override
public boolean isActive() {
return KeyConflictContext.IN_GAME.isActive();
}
@Override
public boolean conflicts(IKeyConflictContext other) {
return other == this || KeyConflictContext.IN_GAME.isActive();
}
}, Keyboard.KEY_COMMA, "key.categories.exchangers");

public static void init() {
ClientRegistry.registerKeyBinding(MODE_KEY);
Expand Down
231 changes: 126 additions & 105 deletions src/main/java/jackyy/exchangers/handler/ExchangerHandler.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/jackyy/exchangers/handler/GUIHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void onGameOverlayRender(RenderGameOverlayEvent event) {
EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity();

if (player == null || !mc.inGameHasFocus || !Minecraft.isGuiEnabled()) return;
if (player.getHeldItemMainhand() == null || !(player.getHeldItemMainhand().getItem() instanceof ItemExchangerBase)) return;
if (player.getHeldItemMainhand() == ItemStack.EMPTY || !(player.getHeldItemMainhand().getItem() instanceof ItemExchangerBase)) return;

ItemStack stack = player.getHeldItemMainhand();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jackyy.exchangers.handler;

import jackyy.exchangers.item.ItemExchangerBase;
import jackyy.exchangers.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
Expand All @@ -13,7 +12,6 @@
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.client.event.RenderWorldLastEvent;
Expand All @@ -30,8 +28,8 @@ public class RenderOverlayHandler {
public void renderWorldLastEvent(RenderWorldLastEvent event) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayerSP player = mc.player;
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
if (StackUtil.isEmpty(stack)) {
ItemStack stack = player.getHeldItemMainhand();
if (stack == ItemStack.EMPTY) {
return;
}
if ((stack.getItem() instanceof ItemExchangerBase)) {
Expand Down Expand Up @@ -118,9 +116,8 @@ public void renderOverlay(RenderWorldLastEvent evt, EntityPlayerSP player, ItemS
Block block = state.getBlock();
if ((block != null) && (block.getMaterial(state) != Material.AIR)) {
int meta = block.getMetaFromState(state);

int exId = ExchangerHandler.getTagCompound(stack).getInteger("block");
Block exBlock = Block.REGISTRY.getObjectById(exId);
String exId = ExchangerHandler.getTagCompound(stack).getString("block");
Block exBlock = Block.getBlockFromName(exId);
int exMeta = ExchangerHandler.getTagCompound(stack).getInteger("meta");
if ((exBlock == block) && (exMeta == meta)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ public static int nextID() {

public static void registerMessages(String channelName) {
INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName);

// Server side
INSTANCE.registerMessage(PacketToggleMode.class, PacketToggleMode.class, nextID(), Side.SERVER);

// Client side
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public PacketToggleMode() { }
public IMessage onMessage(PacketToggleMode message, MessageContext context) {
EntityPlayerMP playerMP = context.getServerHandler().player;
ItemStack heldItem = playerMP.getHeldItemMainhand();
if (heldItem != null && heldItem.getItem() instanceof ExchangerHandler) {
if (heldItem != ItemStack.EMPTY && heldItem.getItem() instanceof ExchangerHandler) {
ExchangerHandler exchanger = (ExchangerHandler) (heldItem.getItem());
exchanger.switchMode(playerMP, heldItem);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/jackyy/exchangers/helper/ChatHelper.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package jackyy.exchangers.helper;

import jackyy.exchangers.Exchangers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;

public class ChatHelper {

public static void msgPlayer(EntityPlayer player, String msg) {
player.sendMessage(new TextComponentString(msg));
player.sendStatusMessage(new TextComponentTranslation(Exchangers.MODID + "." + msg), true);
}

}
11 changes: 5 additions & 6 deletions src/main/java/jackyy/exchangers/helper/NBTHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@ public static int getInt(ItemStack stack, String key) {
public static int receiveEnergy(ItemStack container, int energy, int maxEnergy, boolean simulate) {
int stored = getEnergyStored(container);
int accepted = Math.min(energy, maxEnergy-stored);
if(!simulate)
{
if (!simulate) {
stored += accepted;
NBTHelper.setInt(container, "Energy", stored);
setInt(container, "Energy", stored);
}
return accepted;
}

public static int extractEnergy(ItemStack container, int energy, boolean simulate) {
int stored = getEnergyStored(container);
int extracted = Math.min(energy, stored);
if(!simulate)
{
if (!simulate) {
stored -= extracted;
NBTHelper.setInt(container, "Energy", stored);
setInt(container, "Energy", stored);
}
return extracted;
}

public static int getEnergyStored(ItemStack container) {
return getInt(container, "Energy");
}

}
2 changes: 1 addition & 1 deletion src/main/java/jackyy/exchangers/helper/StringHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static String getTierText(int tier) {
}

public static String getShiftText() {
return TextFormatting.GRAY + localize("tooltip.holdShift", TextFormatting.YELLOW.toString() + TextFormatting.ITALIC + localize("tooltip.holdShift.shift") + TextFormatting.RESET + TextFormatting.GRAY);
return TextFormatting.GRAY + localize("tooltip.hold_shift", TextFormatting.YELLOW.toString() + TextFormatting.ITALIC + localize("tooltip.hold_shift.shift") + TextFormatting.RESET + TextFormatting.GRAY);
}

public static boolean isShiftKeyDown() {
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/jackyy/exchangers/item/ItemCoreBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package jackyy.exchangers.item;

import jackyy.exchangers.Exchangers;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;

public class ItemCoreBase extends Item {

public ItemCoreBase(){
setMaxStackSize(16);
setCreativeTab(Exchangers.TAB);
}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> list) {
if (checkLoaded()) {
list.add(new ItemStack(this));
}
}

public boolean checkLoaded() {
return true;
}

}
31 changes: 31 additions & 0 deletions src/main/java/jackyy/exchangers/item/ItemExchangerBase.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
package jackyy.exchangers.item;

import jackyy.exchangers.Exchangers;
import jackyy.exchangers.handler.ExchangerHandler;
import jackyy.exchangers.helper.StringHelper;
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.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;
import java.util.List;

public class ItemExchangerBase extends ExchangerHandler {

public ItemExchangerBase(){
setMaxStackSize(1);
setCreativeTab(Exchangers.TAB);
}

@Override
public boolean showDurabilityBar(ItemStack stack) {
return stack.isItemDamaged();
}
Expand All @@ -28,4 +41,22 @@ public void addInformation(ItemStack stack, EntityPlayer player, List<String> to
}
}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> list) {
if (checkLoaded()) {
list.add(new ItemStack(this));
}
}

@Override @SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack stack) {
return false;
}

@Override
public int getItemEnchantability() {
return 20;
}

}
25 changes: 25 additions & 0 deletions src/main/java/jackyy/exchangers/item/ItemExchangerBasePowered.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,37 @@
import cofh.api.energy.IEnergyContainerItem;
import cofh.core.item.IEnchantableItem;
import jackyy.exchangers.Config;
import jackyy.exchangers.handler.ExchangerHandler;
import jackyy.exchangers.helper.EnergyHelper;
import jackyy.exchangers.helper.NBTHelper;
import jackyy.exchangers.helper.StringHelper;
import jackyy.exchangers.util.EnergyContainerItemWrapper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;
import java.util.List;

@Optional.Interface(iface = "cofh.core.item.IEnchantableItem", modid = "cofhcore")
public class ItemExchangerBasePowered extends ItemExchangerBase implements IEnergyContainerItem, IEnchantableItem {

private Enchantment holding = Enchantment.getEnchantmentByLocation("cofhcore:holding");

public ItemExchangerBasePowered(){
setNoRepair();
}

@Override
public int receiveEnergy(ItemStack container, int energy, boolean simulate) {
return NBTHelper.receiveEnergy(container, energy, getMaxEnergyStored(container), simulate);
Expand Down Expand Up @@ -68,6 +79,20 @@ public void addInformation(ItemStack stack, EntityPlayer player, List<String> to
}
}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> list) {
if (checkLoaded()) {
ItemStack empty = new ItemStack(this);
ExchangerHandler.setDefaultTagCompound(empty);
list.add(empty);
ItemStack full = new ItemStack(this);
ExchangerHandler.setDefaultTagCompound(full);
EnergyHelper.setDefaultEnergyTag(full, getMaxEnergyStored(full));
list.add(full);
}
}

@Override
public boolean isDamaged(ItemStack stack) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,20 @@

import jackyy.exchangers.Config;
import jackyy.exchangers.Exchangers;
import jackyy.exchangers.helper.EnergyHelper;
import jackyy.exchangers.item.ItemExchangerBasePowered;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import javax.annotation.Nonnull;

public class ItemConductiveIronExchanger extends ItemExchangerBasePowered {

public ItemConductiveIronExchanger(){
setRegistryName(Exchangers.MODID + ":conductive_iron_exchanger");
setUnlocalizedName(Exchangers.MODID + ".conductive_iron_exchanger");
setMaxStackSize(1);
setCreativeTab(Exchangers.TAB);
setNoRepair();
}

@SideOnly(Side.CLIENT)
Expand All @@ -43,17 +34,8 @@ public int getPerBlockUse() {
}

@Override
@SideOnly(Side.CLIENT)
public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> list) {
if (Config.enderIOModule) {
if (Loader.isModLoaded(Exchangers.EIO)) {
ItemStack empty = new ItemStack(this);
list.add(empty);
ItemStack full = new ItemStack(this);
EnergyHelper.setDefaultEnergyTag(full, getMaxEnergyStored(full));
list.add(full);
}
}
public boolean checkLoaded() {
return Config.enderIOModule && Loader.isModLoaded(Exchangers.EIO);
}

@Override
Expand Down
Loading

0 comments on commit 03a69eb

Please sign in to comment.