Fixed run on dedicated server.

This commit is contained in:
Dragon2488 2016-09-15 21:24:35 +07:00
parent d490759e8d
commit 0080b1a69b
44 changed files with 228 additions and 311 deletions

View file

@ -58,42 +58,23 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
//import forestry.factory.recipes.ISqueezerRecipe;
//import forestry.factory.tiles.TileCentrifuge;
//import forestry.factory.tiles.TileSqueezer;
@Mod(modid = "gregtech", name = "GregTech", version = "MC1710", useMetadata = false, dependencies = "required-after:IC2; after:Forestry; after:PFAAGeologica; after:Thaumcraft; after:Railcraft; after:appliedenergistics2; after:ThermalExpansion; after:TwilightForest; after:harvestcraft; after:magicalcrops; after:BuildCraft|Transport; after:BuildCraft|Silicon; after:BuildCraft|Factory; after:BuildCraft|Energy; after:BuildCraft|Core; after:BuildCraft|Builders; after:GalacticraftCore; after:GalacticraftMars; after:GalacticraftPlanets; after:ThermalExpansion|Transport; after:ThermalExpansion|Energy; after:ThermalExpansion|Factory; after:RedPowerCore; after:RedPowerBase; after:RedPowerMachine; after:RedPowerCompat; after:RedPowerWiring; after:RedPowerLogic; after:RedPowerLighting; after:RedPowerWorld; after:RedPowerControl; after:UndergroundBiomes;")
@Mod(modid = "gregtech", name = "GregTech", version = "MC1.10.2", useMetadata = false, dependencies = "required-after:IC2; after:Forestry; after:PFAAGeologica; after:Thaumcraft; after:Railcraft; after:appliedenergistics2; after:ThermalExpansion; after:TwilightForest; after:harvestcraft; after:magicalcrops; after:BuildCraft|Transport; after:BuildCraft|Silicon; after:BuildCraft|Factory; after:BuildCraft|Energy; after:BuildCraft|Core; after:BuildCraft|Builders; after:GalacticraftCore; after:GalacticraftMars; after:GalacticraftPlanets; after:ThermalExpansion|Transport; after:ThermalExpansion|Energy; after:ThermalExpansion|Factory; after:RedPowerCore; after:RedPowerBase; after:RedPowerMachine; after:RedPowerCompat; after:RedPowerWiring; after:RedPowerLogic; after:RedPowerLighting; after:RedPowerWorld; after:RedPowerControl; after:UndergroundBiomes;")
public class GT_Mod implements IGT_Mod {
public static final int VERSION = 509;
public static final int REQUIRED_IC2 = 624;
@Mod.Instance("gregtech")
public static GT_Mod instance;
@SidedProxy(modId = "gregtech", clientSide = "gregtech.common.GT_Client", serverSide = "gregtech.common.GT_Server")
public static GT_Proxy gregtechproxy;
public static int MAX_IC2 = Integer.MAX_VALUE; //2147483647;
public static GT_Achievements achievements;
static {
if ((509 != GregTech_API.VERSION) || (509 != GT_ModHandler.VERSION) || (509 != GT_OreDictUnificator.VERSION) || (509 != GT_Recipe.VERSION) || (509 != GT_Utility.VERSION) || (509 != GT_RecipeRegistrator.VERSION) || (509 != Element.VERSION) || (509 != Materials.VERSION) || (509 != OrePrefixes.VERSION)) {
throw new GT_ItsNotMyFaultException("One of your Mods included GregTech-API Files inside it's download, mention this to the Mod Author, who does this bad thing, and tell him/her to use reflection. I have added a Version check, to prevent Authors from breaking my Mod that way.");
@Mod.EventHandler
public void onPreLoad(FMLPreInitializationEvent aEvent) {
if (GregTech_API.sPreloadStarted) {
return;
}
}
public GT_Mod() {
try {
Class.forName("ic2.core.IC2").getField("enableOreDictCircuit").set(null, Boolean.valueOf(true));
} catch (Throwable e) {
}
try {
Class.forName("ic2.core.IC2").getField("enableCraftingBucket").set(null, Boolean.valueOf(false));
} catch (Throwable e) {
}
try {
Class.forName("ic2.core.IC2").getField("enableEnergyInStorageBlockItems").set(null, Boolean.valueOf(false));
} catch (Throwable e) {
}
GT_Values.GT = this;
GT_Values.DW = new GT_DummyWorld();
GT_Values.NW = new GT_PacketHandler();
@ -101,13 +82,6 @@ public class GT_Mod implements IGT_Mod {
Textures.BlockIcons.VOID.name();
Textures.ItemIcons.VOID.name();
}
@Mod.EventHandler
public void onPreLoad(FMLPreInitializationEvent aEvent) {
if (GregTech_API.sPreloadStarted) {
return;
}
GT_Log.out.println("GT_Mod: Replacing IC2 recipes managers");
try {

View file

@ -322,134 +322,16 @@ public class GregTech_API {
*/
public static Item constructCoolantCellItem(String aUnlocalized, String aEnglish, int aMaxStore) {
try {
return new GT_CoolantCellIC_Item(aUnlocalized, aEnglish, aMaxStore);
// return (Item)Class.forName("gregtech.api.items.GT_CoolantCellIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxStore);
return (Item) Class.forName("gregtech.api.items.GT_CoolantCellIC_Item").getConstructors()[0]
.newInstance(aUnlocalized, aEnglish, aMaxStore);
} catch (Throwable e) {/*Do nothing*/}
try {
return new GT_CoolantCell_Item(aUnlocalized, aEnglish, aMaxStore);
// return (Item)Class.forName("gregtech.api.items.GT_CoolantCell_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxStore);
return (Item) Class.forName("gregtech.api.items.GT_CoolantCell_Item").getConstructors()[0]
.newInstance(aUnlocalized, aEnglish, aMaxStore);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Generic_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", false);
}
/**
* Creates a new Energy Armor Item
*/
public static Item constructElectricArmorItem(String aUnlocalized, String aEnglish, int aCharge, int aTransfer, int aTier, int aDamageEnergyCost, int aSpecials, double aArmorAbsorbtionPercentage, boolean aChargeProvider, int aType, int aArmorIndex) {
try {
return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmorIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aDamageEnergyCost, aSpecials, aArmorAbsorbtionPercentage, aChargeProvider, aType, aArmorIndex);
} catch (Throwable e) {/*Do nothing*/}
try {
return (Item) Class.forName("gregtechmod.api.items.GT_EnergyArmor_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aDamageEnergyCost, aSpecials, aArmorAbsorbtionPercentage, aChargeProvider, aType, aArmorIndex);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Generic_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", false);
}
/**
* Creates a new Energy Battery Item
*/
public static Item constructElectricEnergyStorageItem(String aUnlocalized, String aEnglish, int aCharge, int aTransfer, int aTier, int aEmptyID, int aFullID) {
try {
return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStoreIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aEmptyID, aFullID);
} catch (Throwable e) {/*Do nothing*/}
try {
return (Item) Class.forName("gregtechmod.api.items.GT_EnergyStore_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aCharge, aTransfer, aTier, aEmptyID, aFullID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Generic_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", false);
}
/**
* Creates a new Hard Hammer Item
*/
public static GT_Tool_Item constructHardHammerItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_HardHammer_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new Crowbar Item
*/
public static GT_Tool_Item constructCrowbarItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_CrowbarRC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage);
} catch (Throwable e) {/*Do nothing*/}
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_Crowbar_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new Wrench Item
*/
public static GT_Tool_Item constructWrenchItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_Wrench_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new electric Screwdriver Item
*/
public static GT_Tool_Item constructElectricScrewdriverItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_ScrewdriverIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new electric Wrench Item
*/
public static GT_Tool_Item constructElectricWrenchItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_WrenchIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new electric Saw Item
*/
public static GT_Tool_Item constructElectricSawItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aToolQuality, float aToolStrength, int aEnergyConsumptionPerBlockBreak, int aDisChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_SawIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aToolQuality, aToolStrength, aEnergyConsumptionPerBlockBreak, aDisChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new electric Drill Item
*/
public static GT_Tool_Item constructElectricDrillItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aToolQuality, float aToolStrength, int aEnergyConsumptionPerBlockBreak, int aDisChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_DrillIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aToolQuality, aToolStrength, aEnergyConsumptionPerBlockBreak, aDisChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new electric Soldering Tool
*/
public static GT_Tool_Item constructElectricSolderingToolItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aEntityDamage, int aDisChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_SolderingToolIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aEntityDamage, aDisChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, aEntityDamage, false);
}
/**
* Creates a new empty electric Tool
*/
public static GT_Tool_Item constructEmptyElectricToolItem(String aUnlocalized, String aEnglish, int aMaxDamage, int aChargedGTID) {
try {
return (GT_Tool_Item) Class.forName("gregtechmod.api.items.GT_EmptyToolIC_Item").getConstructors()[0].newInstance(aUnlocalized, aEnglish, aMaxDamage, aChargedGTID);
} catch (Throwable e) {/*Do nothing*/}
return new gregtech.api.items.GT_Tool_Item(aUnlocalized, aEnglish, "Doesn't work as intended, this is a Bug", aMaxDamage, 0, false);
}
/**
* This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Univeral Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity

View file

@ -8,6 +8,8 @@ import gregtech.api.objects.GT_SidedTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import static gregtech.api.enums.GT_Values.RES_PATH_BLOCK;
import static gregtech.api.enums.GT_Values.RES_PATH_ITEM;
@ -561,7 +563,10 @@ public class Textures {
}
public static class CustomIcon implements IIconContainer, Runnable {
@SideOnly(Side.CLIENT)
protected TextureAtlasSprite mIcon;
protected String mIconName;
public CustomIcon(String aIconName) {
@ -570,16 +575,19 @@ public class Textures {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon() {
return mIcon;
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getOverlayIcon() {
return null;
}
@Override
@SideOnly(Side.CLIENT)
public void run() {
mIcon = GregTech_API.sBlockIcons.registerSprite(new ResourceLocation(RES_PATH_BLOCK + mIconName));
}
@ -617,6 +625,7 @@ public class Textures {
public static final ITexture[] ERROR_RENDERING = new ITexture[]{new GT_RenderedTexture(RENDERING_ERROR)};
@SideOnly(Side.CLIENT)
protected TextureAtlasSprite mIcon, mOverlay;
private ItemIcons() {
@ -624,23 +633,29 @@ public class Textures {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon() {
return mIcon;
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getOverlayIcon() {
return mOverlay;
}
@Override
@SideOnly(Side.CLIENT)
public void run() {
mIcon = GregTech_API.sBlockIcons.registerSprite(new ResourceLocation(RES_PATH_ITEM + "iconsets/" + this));
mOverlay = GregTech_API.sBlockIcons.registerSprite(new ResourceLocation(RES_PATH_ITEM + "iconsets/" + this + "_OVERLAY"));
}
public static class CustomIcon implements IIconContainer, Runnable {
@SideOnly(Side.CLIENT)
protected TextureAtlasSprite mIcon, mOverlay;
protected String mIconName;
public CustomIcon(String aIconName) {
@ -649,16 +664,19 @@ public class Textures {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon() {
return mIcon;
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getOverlayIcon() {
return mOverlay;
}
@Override
@SideOnly(Side.CLIENT)
public void run() {
System.out.println("Register icon " + mIconName);
mIcon = GregTech_API.sBlockIcons.registerSprite(new ResourceLocation(RES_PATH_ITEM + mIconName));

View file

@ -2,16 +2,20 @@ package gregtech.api.interfaces;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IIconContainer {
/**
* @return A regular Icon.
*/
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon();
/**
* @return Icon of the Overlay (or null if there is no Icon)
*/
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getOverlayIcon();
}

View file

@ -4,11 +4,14 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public interface ITexture {
@SideOnly(Side.CLIENT)
public List<BakedQuad> getQuads(Block aBlock, BlockPos blockPos, EnumFacing side, float offset);
public boolean isValidTexture();

View file

@ -232,7 +232,6 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor, IIc
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item aItem, CreativeTabs var2, List<ItemStack> var3) {
ItemStack tCharged = new ItemStack(this, 1), tUncharged = new ItemStack(this, 1, getMaxDamage());
GT_ModHandler.chargeElectricItem(tCharged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false);
@ -336,6 +335,7 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor, IIc
}
@Override
@SideOnly(Side.CLIENT)
public IIconContainer getIconContainer(ItemStack itemStack) {
return new IIconContainer() {
@Override

View file

@ -35,6 +35,8 @@ import net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.IForgeRegistryEntry;
import net.minecraftforge.fml.common.registry.PersistentRegistryManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.lang.reflect.Method;
import java.util.List;
@ -48,6 +50,8 @@ import static gregtech.api.enums.GT_Values.RES_PATH_ITEM;
public class GT_Generic_Item extends Item implements IProjectileItem, IIconRegister, IItemIconProvider {
private final String mName, mTooltip;
@SideOnly(Side.CLIENT)
protected TextureAtlasSprite mIcon;
public GT_Generic_Item(String aUnlocalized, String aEnglish, String aEnglishTooltip) {
@ -82,8 +86,8 @@ public class GT_Generic_Item extends Item implements IProjectileItem, IIconRegis
return getHasSubtypes() ? mName + "." + getDamage(aStack) : mName;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(TextureMap aIconRegister) {
mIcon = aIconRegister.registerSprite(new ResourceLocation(RES_PATH_ITEM + (GT_Config.troll ? "troll" : mName)));
}
@ -149,6 +153,7 @@ public class GT_Generic_Item extends Item implements IProjectileItem, IIconRegis
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
if(this instanceof IItemIconContainerProvider) {
IItemIconContainerProvider iItemIconContainerProvider = (IItemIconContainerProvider) this;
@ -167,6 +172,7 @@ public class GT_Generic_Item extends Item implements IProjectileItem, IIconRegis
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderPasses(ItemStack stack) {
if(this instanceof IItemIconContainerProvider) {
return 1;

View file

@ -1,19 +1,16 @@
package gregtech.api.items;
import gregtech.common.render.newitems.IItemIconContainerProvider;
import gregtech.common.render.IColorMultiplier;
import gregtech.common.render.IIconRegister;
import gregtech.common.render.newitems.IItemIconProvider;
import ic2.api.item.IElectricItem;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
@ -22,7 +19,6 @@ import gregtech.api.enums.Materials;
import gregtech.api.enums.SubTag;
import gregtech.api.enums.TC_Aspects.TC_AspectStack;
import gregtech.api.interfaces.IFoodStat;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.IItemBehaviour;
import gregtech.api.interfaces.IItemContainer;
import gregtech.api.objects.ItemData;
@ -55,7 +51,7 @@ import static gregtech.api.enums.GT_Values.*;
* <p/>
* These Items can also have special RightClick abilities, electric Charge or even be set to become a Food alike Item.
*/
public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements IElectricItem, IItemIconProvider, IIconRegister, IItemColor {
public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements IElectricItem, IItemIconProvider, IIconRegister, IColorMultiplier {
/**
* All instances of this Item Class are listed here.
* This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true.
@ -69,7 +65,9 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
public final short mOffset, mItemAmount;
public final BitSet mEnabledItems;
public final BitSet mVisibleItems;
public final TextureAtlasSprite[][] mIconList;
@SideOnly(Side.CLIENT)
public TextureAtlasSprite[][] mIconList;
public final HashMap<Short, IFoodStat> mFoodStats = new HashMap<Short, IFoodStat>();
public final HashMap<Short, Long[]> mElectricStats = new HashMap<Short, Long[]>();
@ -91,7 +89,6 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
mOffset = (short) Math.min(32766, aOffset);
mItemAmount = (short) Math.min(aItemAmount, 32766 - mOffset);
mIconList = new TextureAtlasSprite[aItemAmount][1];
sInstances.put(getUnlocalizedName(), this);
}
@ -172,11 +169,6 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
return null;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
return GT_LanguageManager.getTranslation(getUnlocalizedName(stack) + ".name");
}
/**
* Sets a Food Behavior for the Item.
*
@ -221,12 +213,19 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
if (aMaxCharge == 0) mElectricStats.remove((short) aMetaValue);
else {
mElectricStats.put((short) aMetaValue, new Long[]{aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData});
if (aMetaValue >= mOffset && aUseAnimations)
mIconList[aMetaValue - mOffset] = Arrays.copyOf(mIconList[aMetaValue - mOffset], Math.max(9, mIconList[aMetaValue - mOffset].length));
if(FMLCommonHandler.instance().getSide().isClient()) {
setIconElectricStats(aMetaValue, aUseAnimations);
}
}
return this;
}
@SideOnly(Side.CLIENT)
public void setIconElectricStats(int aMetaValue, boolean aUseAnimations) {
if (aMetaValue >= mOffset && aUseAnimations)
mIconList[aMetaValue - mOffset] = Arrays.copyOf(mIconList[aMetaValue - mOffset], Math.max(9, mIconList[aMetaValue - mOffset].length));
}
/**
* @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765]
* @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior)
@ -246,6 +245,7 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return makeColor(getRGBa(stack, tintIndex));
}
@ -269,6 +269,7 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
double maxCharge = getMaxCharge(stack);
if(maxCharge != 0) {
@ -340,7 +341,8 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements
@Override
@SideOnly(Side.CLIENT)
public final void registerIcons(TextureMap aIconRegister) {
System.out.println("Register icons");
System.out.println("Registering item icons");
mIconList = new TextureAtlasSprite[mItemAmount][1];
for (short i = 0, j = (short) mEnabledItems.length(); i < j; i++)
if (mEnabledItems.get(i)) {
for (byte k = 1; k < mIconList[i].length; k++) {

View file

@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
@ -115,6 +114,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item {
* @param aMaterial the Material
* @return an Icon Container for the Item Display.
*/
@SideOnly(Side.CLIENT)
public final IIconContainer getIconContainer(int aMetaData, Materials aMaterial) {
return aMaterial.mIconSet.mTextures[mGeneratedPrefixList[aMetaData / 1000].mTextureIndex];
}
@ -156,6 +156,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item {
super.getSubItems(var1, aCreativeTab, aList);
}
@SideOnly(Side.CLIENT)
public final IIconContainer getMaterialIcon(int aMetaData) {
Materials tMaterial = GregTech_API.sGeneratedMaterials[aMetaData % 1000];
if (tMaterial == null) return null;
@ -165,6 +166,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
int tDamage = stack.getItemDamage();
if (tDamage < 32000) {
@ -180,6 +182,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item {
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderPasses(ItemStack stack) {
return stack.getItemDamage() < 32000 ? 1 : 0 ;
}

View file

@ -4,10 +4,8 @@ import forestry.api.arboriculture.IToolGrafter;
import gregtech.api.GregTech_API;
import gregtech.api.enchants.Enchantment_Radioactivity;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.GT_Values.*;
import gregtech.api.enums.Materials;
import gregtech.api.enums.TC_Aspects.TC_AspectStack;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.IDamagableItem;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.IToolStats;
@ -15,10 +13,9 @@ import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import gregtech.common.render.IColorMultiplier;
import gregtech.common.render.newitems.IItemIconProvider;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
@ -28,7 +25,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumAction;
@ -51,7 +47,6 @@ import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
@ -69,7 +64,7 @@ import java.util.Random;
//@Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft"),
//@Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO")
})
public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IDamagableItem, IToolGrafter, IItemIconProvider, IItemColor {//, IToolGrafter, IToolCrowbar, IToolWrench, ITool {
public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IDamagableItem, IToolGrafter, IItemIconProvider, IColorMultiplier {//, IToolGrafter, IToolCrowbar, IToolWrench, ITool {
/**
* All instances of this Item Class are listed here.
* This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true.
@ -696,6 +691,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
IToolStats toolStats = getToolStats(stack);
switch (tintIndex) {
@ -729,6 +725,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
IToolStats toolStats = getToolStats(stack);
IIconContainer head = toolStats.getIcon(true, stack);
@ -749,11 +746,13 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderPasses(ItemStack stack) {
return 3;
}
@Override
@SideOnly(Side.CLIENT)
public boolean isHandheld(ItemStack stack) {
return true;
}

View file

@ -1,5 +1,6 @@
package gregtech.api.net;
import gregtech.GT_Mod;
import gregtech.common.blocks.GT_Packet_Ores;
import net.minecraft.world.World;
import net.minecraftforge.fml.client.FMLClientHandler;
@ -37,7 +38,7 @@ public class GT_PacketHandler extends SimpleNetworkWrapper {
if(ctx.side == Side.SERVER) {
message.process(ctx.getServerHandler().playerEntity.worldObj);
} else {
message.process(FMLClientHandler.instance().getWorldClient());
message.process(GT_Mod.gregtechproxy.getThePlayer().worldObj);
}
return null;
}

View file

@ -11,6 +11,8 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.awt.*;
import java.util.Collections;
@ -43,6 +45,7 @@ public class GT_CopiedBlockTexture implements ITexture {
this(aBlock, aSide, aMeta, null);
}
@SideOnly(Side.CLIENT)
public static TextureAtlasSprite getSide(Block aBlock, int aMeta, EnumFacing side) {
if (aBlock instanceof IBlockIconProvider) {
IBlockIconProvider iconProvider = ((IBlockIconProvider) aBlock);
@ -53,6 +56,7 @@ public class GT_CopiedBlockTexture implements ITexture {
}
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> getQuads(Block aBlock, BlockPos blockPos, EnumFacing side, float offset) {
TextureAtlasSprite sprite = getSide(mBlock, mMeta, EnumFacing.VALUES[mSide]);
if(sprite != null) {

View file

@ -5,6 +5,8 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
@ -22,6 +24,7 @@ public class GT_MultiTexture implements ITexture {
}
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> getQuads(Block aBlock, BlockPos blockPos, EnumFacing side, float offset) {
ArrayList<BakedQuad> quads = new ArrayList<>();
for(int index = 0; index < mTextures.length; index++) {

View file

@ -11,6 +11,8 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.awt.*;
import java.util.ArrayList;
@ -56,6 +58,7 @@ public class GT_RenderedTexture implements ITexture {
}
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> getQuads(Block aBlock, BlockPos blockPos, EnumFacing side, float offset) {
ArrayList<BakedQuad> quads = new ArrayList<>();
TextureAtlasSprite sprite = mIconContainer.getIcon();

View file

@ -8,6 +8,8 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.awt.*;
import java.util.*;
@ -46,6 +48,7 @@ public class GT_SidedTexture implements ITexture {
}
@Override
@SideOnly(Side.CLIENT)
public List<BakedQuad> getQuads(Block aBlock, BlockPos blockPos, EnumFacing side, float offset) {
return new GT_RenderedTexture(mIconContainer[side.getIndex()], mRGBa)
.getQuads(aBlock, blockPos, side, offset);

View file

@ -1,16 +1,17 @@
package gregtech.api.util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.*;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.translation.*;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import gregtech.api.GregTech_API;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.Locale;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -20,10 +21,8 @@ import java.util.Map.Entry;
import static gregtech.api.enums.GT_Values.E;
@SideOnly(Side.CLIENT)
public class GT_LanguageManager implements IResourceManagerReloadListener {
public class GT_LanguageManager {
public static GT_LanguageManager INSTANCE = new GT_LanguageManager();
private GT_LanguageManager() {}
public static final HashMap<String, String>
@ -66,11 +65,15 @@ public class GT_LanguageManager implements IResourceManagerReloadListener {
}
public static String getTranslation(String aKey) {
if (aKey == null) return E;
if(LOCALIZATION.containsKey(aKey)) {
return LOCALIZATION.get(aKey);
if (aKey == null) {
return E;
}
return I18n.format(aKey);
if(LOCALIZATION.containsKey(aKey) &&
!LOCALIZATION.get(aKey).equals(
net.minecraft.util.text.translation.I18n.translateToLocal(aKey))) {
injectAllLocales();
}
return net.minecraft.util.text.translation.I18n.translateToLocal(aKey);
}
public static String getTranslation(String aKey, String aSeperator) {
@ -82,29 +85,27 @@ public class GT_LanguageManager implements IResourceManagerReloadListener {
return rTranslation;
}
public static String getTranslateableItemStackName(ItemStack aStack) {
if (GT_Utility.isStackInvalid(aStack)) return "null";
NBTTagCompound tNBT = aStack.getTagCompound();
if (tNBT != null && tNBT.hasKey("display")) {
String tName = tNBT.getCompoundTag("display").getString("Name");
if (GT_Utility.isStringValid(tName)) {
return tName;
}
public static void injectAllLocales() {
injectCommonLocales();
if(FMLCommonHandler.instance().getSide().isClient()) {
injectClientLocales();
}
return aStack.getUnlocalizedName() + ".name";
GT_Log.out.println("Localization injected.");
}
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
Locale i18nLocale = ObfuscationReflectionHelper.getPrivateValue(I18n.class, null, 0);
Map<String, String> properties = ObfuscationReflectionHelper.getPrivateValue(Locale.class, i18nLocale, 2);
public static void injectCommonLocales() {
LanguageMap languageMap = ObfuscationReflectionHelper.getPrivateValue(net.minecraft.util.text.translation.I18n.class, null, 0);
Map<String, String> properties2 = ObfuscationReflectionHelper.getPrivateValue(LanguageMap.class, languageMap, 3);
properties.putAll(LOCALIZATION);
properties2.putAll(LOCALIZATION);
GT_Log.out.println("Resource manager reloaded. Localization injected.");
}
@SideOnly(Side.CLIENT)
public static void injectClientLocales() {
Locale i18nLocale = ObfuscationReflectionHelper.getPrivateValue(I18n.class, null, 0);
Map<String, String> properties = ObfuscationReflectionHelper.getPrivateValue(Locale.class, i18nLocale, 2);
properties.putAll(LOCALIZATION);
}
}

View file

@ -5,7 +5,6 @@
package gregtech.common;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.*;
import gregtech.api.util.GT_LanguageManager;
@ -22,10 +21,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.net.URL;
import java.util.*;
@ -33,10 +33,11 @@ import java.util.*;
// Referenced classes of package gregtech.common:
// GT_Proxy
@SideOnly(Side.CLIENT)
public class GT_Client extends GT_Proxy
implements Runnable {
private final HashSet mCapeList = new HashSet<>();
private final HashSet<String> mCapeList = new HashSet<>();
private final GT_CapeRenderer mCapeRenderer;
private final List<Materials> mPosR;
private final List<Materials> mPosG;
@ -158,8 +159,6 @@ public class GT_Client extends GT_Proxy
public void onLoad() {
super.onLoad();
//new GT_MetaGenerated_Tool_Renderer(); TODO tools repair
RenderingRegistry.registerEntityRenderingHandler(GT_Entity_Arrow.class, manager -> {
return new GT_Renderer_Entity_Arrow(GT_Entity_Arrow.class, "arrow", manager);
});
@ -167,7 +166,6 @@ public class GT_Client extends GT_Proxy
RenderingRegistry.registerEntityRenderingHandler(GT_Entity_Arrow.class, manager -> {
return new GT_Renderer_Entity_Arrow(GT_Entity_Arrow_Potion.class, "arrow_potions", manager);
});
}
@ -180,14 +178,15 @@ public class GT_Client extends GT_Proxy
TextureSet.SET_DIAMOND.getClass();
new GT_IIconProvider_Item_Model();
IReloadableResourceManager resourceManager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
resourceManager.registerReloadListener(GT_LanguageManager.INSTANCE);
}
public void run() {
downloadStuff();
}
public void downloadStuff() {
try {
GT_Log.out.println("GT_Mod: Downloading Cape List.");
@SuppressWarnings("resource")
Scanner tScanner = new Scanner(new URL("http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt").openStream());
while (tScanner.hasNextLine()) {
String tName = tScanner.nextLine();
@ -195,51 +194,31 @@ public class GT_Client extends GT_Proxy
this.mCapeList.add(tName.toLowerCase());
}
}
} catch (Throwable e) {
}
} catch (Throwable e) {}
try {
GT_Log.out.println("GT_Mod: Downloading News.");
@SuppressWarnings("resource")
Scanner tScanner = new Scanner(new URL("http://files.minecraftforge.net/maven/com/gregoriust/gregtech/message.txt").openStream());
while (tScanner.hasNextLine()) {
this.mMessage = (this.mMessage + tScanner.nextLine() + " ");
}
} catch (Throwable e) {
}
} catch (Throwable e) {}
}
@SubscribeEvent
public void onPlayerTickEventClient(TickEvent.PlayerTickEvent aEvent) {
if ((!aEvent.player.isDead) && (aEvent.phase == TickEvent.Phase.END) && (aEvent.side.isClient())) {
if ((this.isFirstClientPlayerTick) && (aEvent.player == GT_Values.GT.getThePlayer())) {
this.isFirstClientPlayerTick = false;
if ((this.mMessage.length() > 5) && (GregTech_API.sSpecialFile.get(ConfigCategories.news, this.mMessage, true))) {
aEvent.player.addChatComponentMessage(new TextComponentString(this.mMessage));
}
try {
int tVersion = Integer.parseInt(((String) Class.forName("ic2.core.IC2").getField("VERSION").get(null)).substring(4, 7));
if (GT_Values.D1) {
GT_Log.out.println("Industrialcraft Version: " + tVersion);
}
if (tVersion < 624) {
aEvent.player.addChatComponentMessage(new TextComponentString("GregTech: Please update your IndustrialCraft here:"));
aEvent.player.addChatComponentMessage(new TextComponentString("ic2api.player.to:8080/job/IC2_experimental/" + (GT_Mod.MAX_IC2 < Integer.MAX_VALUE ? GT_Mod.MAX_IC2 : 624) + "/"));
} else if (tVersion > GT_Mod.MAX_IC2) {
aEvent.player.addChatComponentMessage(new TextComponentString("GregTech: Please downgrade your IndustrialCraft here:"));
aEvent.player.addChatComponentMessage(new TextComponentString("ic2api.player.to:8080/job/IC2_experimental/" + GT_Mod.MAX_IC2 + "/"));
}
} catch (Throwable e) {
aEvent.player.addChatComponentMessage(new TextComponentString("GregTech: Please get the recommended Version of IndustrialCraft here:"));
aEvent.player.addChatComponentMessage(new TextComponentString("ic2api.player.to:8080/job/IC2_experimental/" + (GT_Mod.MAX_IC2 < Integer.MAX_VALUE ? GT_Mod.MAX_IC2 : 624) + "/"));
}
}
}
}
@SubscribeEvent
/*@SubscribeEvent
public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) {
/*if (GT_Utility.isStackValid(aEvent.currentItem)) {
if (GT_Utility.isStackValid(aEvent.currentItem)) {
Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ);
TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ);
try {
@ -257,9 +236,8 @@ public class GT_Client extends GT_Proxy
e.printStackTrace(GT_Log.err);
}
}
}*/
//FIXME
}
}
}*/
@SubscribeEvent
public void receiveRenderEvent(net.minecraftforge.client.event.RenderPlayerEvent.Pre aEvent) {

View file

@ -1,21 +1,16 @@
package gregtech.common.blocks;
import gregtech.api.enums.Dyes;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Textures;
import gregtech.api.objects.GT_CopiedBlockTexture;
import gregtech.api.util.GT_LanguageManager;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
public class GT_Block_Casings1 extends GT_Block_Casings_Abstract implements IBlockColor {
public class GT_Block_Casings1 extends GT_Block_Casings_Abstract {
public GT_Block_Casings1() {
super(GT_Item_Casings1.class, "gt.blockcasings", GT_Material_Casings.INSTANCE);
for (byte i = 0; i < 16; i = (byte) (i + 1)) {
@ -56,6 +51,8 @@ public class GT_Block_Casings1 extends GT_Block_Casings_Abstract implements IBlo
ItemList.Casing_Coil_Superconductor.set(new ItemStack(this, 1, 15));
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
if ((aMeta >= 0) && (aMeta < 16)) {
switch (aMeta) {
@ -84,10 +81,10 @@ public class GT_Block_Casings1 extends GT_Block_Casings_Abstract implements IBlo
}
@Override
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
int metadata = state.getValue(METADATA);
return metadata > 9 ? Dyes._NULL.getRGBAInt() : Dyes.MACHINE_METAL.getRGBAInt();
}
//@Override
//public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
// int metadata = state.getValue(METADATA);
// return metadata > 9 ? Dyes._NULL.getRGBAInt() : Dyes.MACHINE_METAL.getRGBAInt();
//}
}

View file

@ -12,6 +12,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class GT_Block_Casings2 extends GT_Block_Casings_Abstract {
@ -55,6 +57,7 @@ public class GT_Block_Casings2 extends GT_Block_Casings_Abstract {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
switch (aMeta) {
case 0:

View file

@ -7,6 +7,8 @@ import gregtech.api.util.GT_LanguageManager;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class GT_Block_Casings3 extends GT_Block_Casings_Abstract {
@ -50,6 +52,7 @@ public class GT_Block_Casings3 extends GT_Block_Casings_Abstract {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
switch (aMeta) {
case 0:

View file

@ -56,6 +56,7 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
switch (aMeta) {
case 0:
@ -94,6 +95,7 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract {
return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
}
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getTurbineCasing(int meta, int iconIndex, boolean active) {
switch (meta) {
case 9:

View file

@ -2,17 +2,13 @@ package gregtech.common.blocks;
import com.google.common.collect.Lists;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Dyes;
import gregtech.api.items.GT_Generic_Block;
import gregtech.api.util.GT_LanguageManager;
import gregtech.common.render.IIconRegister;
import gregtech.common.render.newblocks.IBlockIconProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@ -28,7 +24,6 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.List;
public abstract class GT_Block_Casings_Abstract extends GT_Generic_Block implements IBlockIconProvider {

View file

@ -16,6 +16,8 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
@ -60,6 +62,7 @@ public class GT_Block_Concretes extends GT_Block_Stones_Abstract {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
if ((aMeta >= 0) && (aMeta < 16)) {
return gregtech.api.enums.Textures.BlockIcons.CONCRETES[aMeta].getIcon();

View file

@ -13,6 +13,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class GT_Block_Granites extends GT_Block_Stones_Abstract {
@ -59,6 +61,7 @@ public class GT_Block_Granites extends GT_Block_Stones_Abstract {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
if ((aMeta >= 0) && (aMeta < 16)) {
return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon();

View file

@ -1,8 +1,6 @@
package gregtech.common.blocks;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.IDebugableBlock;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
@ -17,12 +15,9 @@ import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import gregtech.common.render.IIconRegister;
import gregtech.common.render.newblocks.ITextureBlockIconProvider;
import gregtech.common.render.newitems.GT_IIconProvider_Item_Model;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
@ -35,7 +30,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
@ -46,7 +40,6 @@ import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

View file

@ -12,6 +12,8 @@ import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_OreDictUnificator;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class GT_Block_Metal extends GT_Block_Storage implements IBlockIconProvider {
public Materials[] mMats;
@ -30,6 +32,7 @@ public class GT_Block_Metal extends GT_Block_Storage implements IBlockIconProvid
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aDamage) {
if ((aDamage >= 0) && (aDamage < 16) && aDamage < mMats.length) {
return mBlockIcons[aDamage].getIcon();

View file

@ -37,6 +37,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.ArrayList;
@ -199,12 +201,14 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements
}
@Override
@SideOnly(Side.CLIENT)
public ITexture[] getTexture(World world, BlockPos blockPos, IExtendedBlockState blockState, EnumFacing side) {
GT_TileEntity_Ores oreTile = (GT_TileEntity_Ores) world.getTileEntity(blockPos);
return oreTile.getTexture(this, (byte) side.getIndex());
}
@Override
@SideOnly(Side.CLIENT)
public ITexture[] getItemblockTexture(EntityPlayer player, ItemStack itemStack, EnumFacing side) {
int mMetaData = itemStack.getItemDamage();
Materials aMaterial = GregTech_API.sGeneratedMaterials[(mMetaData % 1000)];

View file

@ -88,6 +88,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block implements IBlockIconP
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
if ((aMeta >= 0) && (aMeta < 16)) {
switch (aMeta) {

View file

@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class GT_Block_Stones extends GT_Block_Stones_Abstract implements IBlockIconProvider {
public GT_Block_Stones() {
@ -62,6 +64,7 @@ public class GT_Block_Stones extends GT_Block_Stones_Abstract implements IBlockI
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
if ((aMeta >= 0) && (aMeta < 16)) {
return gregtech.api.enums.Textures.BlockIcons.STONES[aMeta].getIcon();

View file

@ -102,6 +102,7 @@ public abstract class GT_Block_Stones_Abstract extends GT_Generic_Block implemen
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(EnumFacing aSide, int aMeta) {
if ((aMeta >= 0) && (aMeta < 16)) {
return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon();

View file

@ -10,7 +10,6 @@ import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
@ -23,11 +22,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import java.awt.*;
import java.util.List;
public class GT_Item_Machines
extends ItemBlock implements IItemColor {
public class GT_Item_Machines extends ItemBlock {
public GT_Item_Machines(Block par1) {
super(par1);
setMaxDamage(0);
@ -162,8 +159,4 @@ public class GT_Item_Machines
return true;
}
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return Color.WHITE.getRGB();
}
}

View file

@ -13,8 +13,8 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class GT_Item_Ores
extends ItemBlock {
public class GT_Item_Ores extends ItemBlock {
public GT_Item_Ores(Block par1) {
super(par1);
setMaxDamage(0);

View file

@ -1,28 +1,25 @@
package gregtech.common.items;
import gregtech.api.interfaces.IIconContainer;
import gregtech.common.render.newitems.IItemIconContainerProvider;
import gregtech.common.render.newitems.IItemIconProvider;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.items.GT_Generic_Item;
import gregtech.api.util.GT_Utility;
import gregtech.common.render.IColorMultiplier;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.creativetab.CreativeTabs;
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.text.TextFormatting;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class GT_FluidDisplayItem extends GT_Generic_Item implements IItemColor {
public class GT_FluidDisplayItem extends GT_Generic_Item implements IColorMultiplier {
public GT_FluidDisplayItem() {
super("GregTech_FluidDisplay", "Fluid Display", null);
ItemList.Display_Fluid.set(this);
@ -48,12 +45,14 @@ public class GT_FluidDisplayItem extends GT_Generic_Item implements IItemColor {
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
Fluid tFluid = FluidRegistry.getFluid(stack.getItemDamage());
return GT_Utility.getTexture(tFluid.getStill());
}
@Override
@SideOnly(Side.CLIENT)
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
Fluid tFluid = FluidRegistry.getFluid(stack.getItemDamage());
return tFluid == null ? 16777215 : tFluid.getColor();

View file

@ -10,6 +10,7 @@ import gregtech.api.enums.Materials;
import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import gregtech.common.render.IColorMultiplier;
import gregtech.common.render.IIconRegister;
import gregtech.common.render.newitems.IItemIconProvider;
import net.minecraft.client.renderer.color.IItemColor;
@ -27,9 +28,9 @@ import java.util.List;
import static gregtech.api.enums.GT_Values.MOD_ID;
public class ItemComb extends Item implements IItemIconProvider, IIconRegister, IItemColor {
@SideOnly(Side.CLIENT)
public class ItemComb extends Item implements IItemIconProvider, IIconRegister, IColorMultiplier {
@SideOnly(Side.CLIENT)
private TextureAtlasSprite itemIcon, secondIcon;
public ItemComb() {
@ -72,6 +73,7 @@ public class ItemComb extends Item implements IItemIconProvider, IIconRegister,
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
return (pass == 0) ? itemIcon : secondIcon;
}

View file

@ -40,6 +40,7 @@ public class ModularArmor_Item extends ItemArmor implements ISpecialArmor, IIcon
private static final Potion NIGHT_VISION = Potion.getPotionFromResourceLocation("night_vision");
@SideOnly(Side.CLIENT)
private TextureAtlasSprite itemIcon;
public String mName;
@ -380,6 +381,7 @@ public class ModularArmor_Item extends ItemArmor implements ISpecialArmor, IIcon
}
@Override
@SideOnly(Side.CLIENT)
public TextureAtlasSprite getIcon(ItemStack stack, int pass) {
return itemIcon;
}

View file

@ -4,11 +4,14 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Collection;
public class GT_CapeRenderer
extends RenderPlayer {
@SideOnly(Side.CLIENT)
public class GT_CapeRenderer extends RenderPlayer {
private final ResourceLocation[] mCapes = {new ResourceLocation("gregtech:textures/BrainTechCape.png"), new ResourceLocation("gregtech:textures/GregTechCape.png"), new ResourceLocation("gregtech:textures/MrBrainCape.png"), new ResourceLocation("gregtech:textures/GregoriusCape.png")};
private final Collection<String> mCapeList;

View file

@ -6,7 +6,10 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraft.client.renderer.entity.RenderArrow;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GT_Renderer_Entity_Arrow extends RenderArrow {
private final ResourceLocation mTexture;

View file

@ -0,0 +1,12 @@
package gregtech.common.render;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IColorMultiplier {
@SideOnly(Side.CLIENT)
int getColorFromItemstack(ItemStack stack, int tintIndex);
}

View file

@ -1,9 +1,12 @@
package gregtech.common.render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IIconRegister {
@SideOnly(Side.CLIENT)
void registerIcons(TextureMap textureMap);
}

View file

@ -21,12 +21,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@SideOnly(Side.CLIENT)
public class BlockRenderer {
public static boolean shouldHook(IBlockState blockState) {

View file

@ -5,7 +5,10 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderUtil {
public static BakedQuad renderSide(VertexFormat vertexFormat, TextureAtlasSprite sprite, EnumFacing side, int tint, float offset, int color, boolean hideSiding) {

View file

@ -2,10 +2,10 @@ package gregtech.common.render.newitems;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import gregtech.api.GregTech_API;
import gregtech.common.render.newblocks.BlockRenderer;
import gregtech.common.render.IColorMultiplier;
import gregtech.common.render.IIconRegister;
import gregtech.common.render.newblocks.BlockRenderer;
import gregtech.common.render.newblocks.IBlockIconProvider;
import gregtech.common.render.newblocks.ITextureBlockIconProvider;
import net.minecraft.block.Block;
@ -25,18 +25,17 @@ import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.model.ItemLayerModel;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable;
import javax.vecmath.Vector4f;
@ -47,7 +46,6 @@ public class GT_IIconProvider_Item_Model implements IBakedModel {
private static final ModelResourceLocation RESOURCE_LOCATION = new ModelResourceLocation("gregtech", "IItemIconProvider");
private TextureAtlasSprite missingno;
private ItemStack itemStack;
private VertexFormat vertexFormat;
@ -84,22 +82,18 @@ public class GT_IIconProvider_Item_Model implements IBakedModel {
if(item instanceof IIconRegister) {
((IIconRegister) item).registerIcons(pre.getMap());
}
if(item instanceof IItemColor) {
itemColors.registerItemColorHandler((IItemColor) item, item);
if(item instanceof IColorMultiplier) {
IColorMultiplier colorMultiplier = (IColorMultiplier) item;
itemColors.registerItemColorHandler(colorMultiplier::getColorFromItemstack, item);
}
}
BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
for(ResourceLocation blockId : Block.REGISTRY.getKeys()) {
Block block = Block.REGISTRY.getObject(blockId);
if(block instanceof IIconRegister) {
((IIconRegister) block).registerIcons(pre.getMap());
}
if(block instanceof IBlockColor) {
blockColors.registerBlockColorHandler((IBlockColor) block, block);
}
}
missingno = pre.getMap().getMissingSprite();
System.out.println("GT_Mod: Finished Item Icon Load Phase");
System.out.println("GT_Mod: Finished Icon Load Phase");
}
@SubscribeEvent

View file

@ -10,6 +10,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public interface IItemIconContainerProvider extends IItemIconProvider {
@Override
@SideOnly(Side.CLIENT)
default TextureAtlasSprite getIcon(ItemStack stack, int pass) {
IIconContainer iconContainer = getIconContainer(stack);
if(iconContainer != null) {
@ -24,10 +25,12 @@ public interface IItemIconContainerProvider extends IItemIconProvider {
}
@Override
@SideOnly(Side.CLIENT)
default int getRenderPasses(ItemStack stack) {
return 1;
}
@SideOnly(Side.CLIENT)
IIconContainer getIconContainer(ItemStack itemStack);
}

View file

@ -5,15 +5,17 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public interface IItemIconProvider {
@SideOnly(Side.CLIENT)
TextureAtlasSprite getIcon(ItemStack stack, int pass);
@SideOnly(Side.CLIENT)
default int getRenderPasses(ItemStack stack) {
return 0;
}
@SideOnly(Side.CLIENT)
default boolean isHandheld(ItemStack stack) {
return false;
}