GT5-Unofficial/src/main/java/gregtech/common/GT_Client.java

402 lines
18 KiB
Java
Raw Normal View History

2015-04-23 16:14:22 +00:00
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: GT_Client.java
package gregtech.common;
2016-12-17 09:12:14 +00:00
import codechicken.lib.vec.Rotation;
2015-04-23 16:14:22 +00:00
import gregtech.api.GregTech_API;
2016-12-17 09:12:14 +00:00
import gregtech.api.enums.Materials;
import gregtech.api.enums.TextureSet;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.tileentity.ICoverable;
import gregtech.api.interfaces.tileentity.ITurnable;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
2015-10-22 02:06:25 +00:00
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
2015-04-23 16:14:22 +00:00
import gregtech.common.entities.GT_Entity_Arrow;
import gregtech.common.entities.GT_Entity_Arrow_Potion;
import gregtech.common.render.*;
2016-12-17 09:12:14 +00:00
import ic2.api.tile.IWrenchable;
import net.minecraft.block.Block;
2015-04-23 16:14:22 +00:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
2015-04-23 16:14:22 +00:00
import net.minecraft.entity.player.EntityPlayer;
2016-12-17 09:12:14 +00:00
import net.minecraft.init.Blocks;
2015-04-23 16:14:22 +00:00
import net.minecraft.item.ItemStack;
2016-12-17 09:12:14 +00:00
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
2015-04-23 16:14:22 +00:00
import net.minecraft.world.World;
2016-12-17 09:12:14 +00:00
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
2016-09-15 14:24:35 +00:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2016-12-17 09:12:14 +00:00
import org.lwjgl.opengl.GL11;
2015-04-23 16:14:22 +00:00
2015-10-22 02:06:25 +00:00
import java.net.URL;
import java.util.*;
2015-04-23 16:14:22 +00:00
// Referenced classes of package gregtech.common:
// GT_Proxy
2016-09-15 14:24:35 +00:00
@SideOnly(Side.CLIENT)
2015-04-23 16:14:22 +00:00
public class GT_Client extends GT_Proxy
2015-10-22 02:06:25 +00:00
implements Runnable {
2015-04-23 16:14:22 +00:00
2016-12-17 09:12:14 +00:00
private static List<Block> ROTATABLE_VANILLA_BLOCKS;
static {
ROTATABLE_VANILLA_BLOCKS = Arrays.asList(Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.FURNACE, Blocks.LIT_FURNACE,
Blocks.DROPPER, Blocks.DISPENSER, Blocks.CHEST, Blocks.TRAPPED_CHEST, Blocks.ENDER_CHEST, Blocks.HOPPER,
Blocks.PUMPKIN, Blocks.LIT_PUMPKIN);
}
2016-09-15 14:24:35 +00:00
private final HashSet<String> mCapeList = new HashSet<>();
private final List<Materials> mPosR;
private final List<Materials> mPosG;
private final List<Materials> mPosB;
private final List<Materials> mPosA = new ArrayList<>();
private final List<Materials> mNegR;
private final List<Materials> mNegG;
private final List<Materials> mNegB;
private final List<Materials> mNegA = new ArrayList<>();
private final List<Materials> mMoltenPosR;
private final List<Materials> mMoltenPosG;
private final List<Materials> mMoltenPosB;
private final List<Materials> mMoltenPosA = new ArrayList<>();
private final List<Materials> mMoltenNegR;
private final List<Materials> mMoltenNegG;
private final List<Materials> mMoltenNegB;
private final List<Materials> mMoltenNegA = new ArrayList<>();
2015-10-22 02:06:25 +00:00
private long mAnimationTick;
private boolean mAnimationDirection;
2015-10-22 02:06:25 +00:00
public GT_Client() {
2015-04-23 16:14:22 +00:00
mAnimationTick = 0L;
mAnimationDirection = false;
2016-12-17 09:12:14 +00:00
mPosR = Arrays.asList( /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force,
Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone);
mPosG = Arrays.asList( /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force,
Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth);
mPosB = Arrays.asList( /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis,
Materials.InfusedWater, Materials.Thaumium);
mNegR = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar);
mNegG = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar);
mNegB = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar);
mMoltenPosR = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force,
Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone);
mMoltenPosG = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force,
Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth);
mMoltenPosB = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis,
Materials.InfusedWater, Materials.Thaumium);
mMoltenNegR = Arrays.asList(Materials.InfusedEntropy);
mMoltenNegG = Arrays.asList(Materials.InfusedEntropy);
mMoltenNegB = Arrays.asList(Materials.InfusedEntropy);
2015-04-23 16:14:22 +00:00
}
2016-12-17 09:12:14 +00:00
private static void drawGrid(DrawBlockHighlightEvent aEvent) {
2015-10-22 02:06:25 +00:00
GL11.glPushMatrix();
2016-12-17 09:12:14 +00:00
EntityPlayer player = aEvent.getPlayer();
float partialTicks = aEvent.getPartialTicks();
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
BlockPos pos = aEvent.getTarget().getBlockPos();
GL11.glTranslated(-d0, -d1, -d2);
GL11.glTranslated(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
Rotation.sideRotations[aEvent.getTarget().sideHit.getIndex()].glApply();
2015-10-22 02:06:25 +00:00
GL11.glTranslated(0.0D, -0.501D, 0.0D);
GL11.glLineWidth(2.0F);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F);
GL11.glBegin(1);
GL11.glVertex3d(0.5D, 0.0D, -0.25D);
GL11.glVertex3d(-0.5D, 0.0D, -0.25D);
GL11.glVertex3d(0.5D, 0.0D, 0.25D);
GL11.glVertex3d(-0.5D, 0.0D, 0.25D);
GL11.glVertex3d(0.25D, 0.0D, -0.5D);
GL11.glVertex3d(0.25D, 0.0D, 0.5D);
GL11.glVertex3d(-0.25D, 0.0D, -0.5D);
GL11.glVertex3d(-0.25D, 0.0D, 0.5D);
GL11.glEnd();
GL11.glPopMatrix();
2016-12-17 09:12:14 +00:00
}
2015-10-22 02:06:25 +00:00
public boolean isServerSide() {
return true;
}
public boolean isClientSide() {
return true;
}
public boolean isBukkitSide() {
return false;
}
public EntityPlayer getThePlayer() {
return Minecraft.getMinecraft().thePlayer;
}
public void onPreLoad() {
2015-04-23 16:14:22 +00:00
super.onPreLoad();
String arr$[] = {
2015-10-22 02:06:25 +00:00
"renadi", "hanakocz", "MysteryDump", "Flaver4", "x_Fame", "Peluche321", "Goshen_Ithilien", "manf", "Bimgo", "leagris",
"IAmMinecrafter02", "Cerous", "Devilin_Pixy", "Bkarlsson87", "BadAlchemy", "CaballoCraft", "melanclock", "Resursator", "demanzke", "AndrewAmmerlaan",
"Deathlycraft", "Jirajha", "Axlegear", "kei_kouma", "Dracion", "dungi", "Dorfschwein", "Zero Tw0", "mattiagraz85", "sebastiank30",
"Plem", "invultri", "grillo126", "malcanteth", "Malevolence_", "Nicholas_Manuel", "Sirbab", "kehaan", "bpgames123", "semig0d",
"9000bowser", "Sovereignty89", "Kris1432", "xander_cage_", "samuraijp", "bsaa", "SpwnX", "tworf", "Kadah", "kanni",
"Stute", "Hegik", "Onlyme", "t3hero", "Hotchi", "jagoly", "Nullav", "BH5432", "Sibmer", "inceee",
"foxxx0", "Hartok", "TMSama", "Shlnen", "Carsso", "zessirb", "meep310", "Seldron", "yttr1um", "hohounk",
"freebug", "Sylphio", "jmarler", "Saberawr", "r00teniy", "Neonbeta", "yinscape", "voooon24", "Quintine", "peach774",
"lepthymo", "bildeman", "Kremnari", "Aerosalo", "OndraSter", "oscares91", "mr10movie", "Daxx367x2", "EGERTRONx", "aka13_404",
"Abouttabs", "Johnstaal", "djshiny99", "megatronp", "DZCreeper", "Kane_Hart", "Truculent", "vidplace7", "simon6689", "MomoNasty",
"UnknownXLV", "goreacraft", "Fluttermine", "Daddy_Cecil", "MrMaleficus", "TigersFangs", "cublikefoot", "chainman564", "NikitaBuker", "Misha999777",
"25FiveDetail", "AntiCivilBoy", "michaelbrady", "xXxIceFirexXx", "Speedynutty68", "GarretSidzaka", "HallowCharm977", "mastermind1919", "The_Hypersonic", "diamondguy2798",
"zF4ll3nPr3d4t0r", "CrafterOfMines57", "XxELIT3xSNIP3RxX", "SuterusuKusanagi", "xavier0014", "adamros", "alexbegt", "Archengius"
2015-04-23 16:14:22 +00:00
};
for (String tName : arr$) {
2015-04-23 16:14:22 +00:00
mCapeList.add(tName.toLowerCase());
}
new Thread(this).start();
2015-04-23 16:14:22 +00:00
}
2015-10-22 02:06:25 +00:00
public void onLoad() {
super.onLoad();
RenderingRegistry.registerEntityRenderingHandler(GT_Entity_Arrow.class, manager -> {
return new GT_Renderer_Entity_Arrow(manager, GT_Entity_Arrow.class, "arrow");
});
RenderingRegistry.registerEntityRenderingHandler(GT_Entity_Arrow.class, manager -> {
return new GT_Renderer_Entity_Arrow(manager, GT_Entity_Arrow_Potion.class, "arrow_potions");
});
2015-10-22 02:06:25 +00:00
}
//Models init
2015-10-22 02:06:25 +00:00
public void onPostLoad() {
2015-04-23 16:14:22 +00:00
super.onPostLoad();
Textures.BlockIcons.BASALT_BRICKS.getClass();
Textures.ItemIcons.BUTCHERYKNIFE.getClass();
TextureSet.SET_DIAMOND.getClass();
RenderBlocks.INSTANCE.init();
RenderGeneratedOres.INSTANCE.init();
GT_Renderer_Block.INSTANCE.init();
ItemRenderer.INSTANCE.init();
RenderManager manager = Minecraft.getMinecraft().getRenderManager();
Map<String, RenderPlayer> map = manager.getSkinMap();
map.get("default").addLayer(new GT_CapeRendererLayer(mCapeList, map.get("default")));
map.get("slim").addLayer(new GT_CapeRendererLayer(mCapeList, map.get("slim")));
}
2015-04-23 16:14:22 +00:00
2015-10-22 02:06:25 +00:00
public void run() {
2016-09-15 14:24:35 +00:00
downloadStuff();
}
public void downloadStuff() {
2015-10-22 02:06:25 +00:00
try {
GT_Log.out.println("GT_Mod: Downloading Cape List.");
2016-07-10 18:28:35 +00:00
Scanner tScanner = new Scanner(new URL("http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt").openStream());
2015-10-22 02:06:25 +00:00
while (tScanner.hasNextLine()) {
String tName = tScanner.nextLine();
if (!this.mCapeList.contains(tName.toLowerCase())) {
this.mCapeList.add(tName.toLowerCase());
}
}
2016-09-15 14:24:35 +00:00
} catch (Throwable e) {}
2015-04-23 16:14:22 +00:00
}
2015-10-22 02:06:25 +00:00
@SubscribeEvent
public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) {
if(aEvent.getPlayer() != null && aEvent.getTarget().typeOfHit == RayTraceResult.Type.BLOCK &&
aEvent.getTarget().getBlockPos() != null) {
EntityPlayer aPlayer = aEvent.getPlayer();
ItemStack currentItem = aPlayer.getHeldItemMainhand();
BlockPos aPos = aEvent.getTarget().getBlockPos();
Block block = aPlayer.worldObj.getBlockState(aPos).getBlock();
if (GT_Utility.isStackValid(currentItem)) {
TileEntity aTileEntity = aPlayer.worldObj.getTileEntity(aPos);
if (((aTileEntity instanceof BaseMetaPipeEntity)) && (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.getTarget().sideHit.getIndex()) == 0) && ((GT_Utility.isStackInList(currentItem, GregTech_API.sCoverItems.keySet())) || (GT_Utility.isStackInList(currentItem, GregTech_API.sCrowbarList)) || (GT_Utility.isStackInList(currentItem, GregTech_API.sScrewdriverList)))) {
drawGrid(aEvent);
}
else if ((aTileEntity instanceof ITurnable || aTileEntity instanceof IWrenchable || ROTATABLE_VANILLA_BLOCKS.contains(block)) && GT_Utility.isStackInList(currentItem, GregTech_API.sWrenchList)) {
drawGrid(aEvent);
}
2015-10-22 02:06:25 +00:00
}
2016-09-15 14:24:35 +00:00
}
2016-12-17 09:12:14 +00:00
}
2015-04-23 16:14:22 +00:00
@SubscribeEvent
public void onClientTickEvent(net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent aEvent) {
if (aEvent.phase == net.minecraftforge.fml.common.gameevent.TickEvent.Phase.END) {
2015-04-23 16:14:22 +00:00
mAnimationTick++;
2015-10-22 02:06:25 +00:00
if (mAnimationTick % 50L == 0L)
2015-04-23 16:14:22 +00:00
mAnimationDirection = !mAnimationDirection;
int tDirection = mAnimationDirection ? 1 : -1;
for (Materials tMaterial : mPosR) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[0] += tDirection;
}
for (Materials tMaterial : mPosG) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[1] += tDirection;
}
for (Materials tMaterial : mPosB) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[2] += tDirection;
}
for (Materials tMaterial : mPosA) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[3] += tDirection;
}
for (Materials tMaterial : mNegR) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[0] -= tDirection;
}
for (Materials tMaterial : mNegG) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[1] -= tDirection;
}
for (Materials tMaterial : mNegB) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[2] -= tDirection;
}
for (Materials tMaterial : mNegA) {
2015-04-23 16:14:22 +00:00
tMaterial.mRGBa[3] -= tDirection;
}
for (Materials tMaterial : mMoltenPosR) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[0] += tDirection;
}
for (Materials tMaterial : mMoltenPosG) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[1] += tDirection;
}
for (Materials tMaterial : mMoltenPosB) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[2] += tDirection;
}
for (Materials tMaterial : mMoltenPosA) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[3] += tDirection;
}
for (Materials tMaterial : mMoltenNegR) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[0] -= tDirection;
}
for (Materials tMaterial : mMoltenNegG) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[1] -= tDirection;
}
for (Materials tMaterial : mMoltenNegB) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[2] -= tDirection;
}
for (Materials tMaterial : mMoltenNegA) {
2015-04-23 16:14:22 +00:00
tMaterial.mMoltenRGBa[3] -= tDirection;
}
}
}
2015-10-22 02:06:25 +00:00
public void doSonictronSound(ItemStack aStack, World aWorld, double aX, double aY, double aZ) {
if (GT_Utility.isStackInvalid(aStack))
2015-04-23 16:14:22 +00:00
return;
String tString = "note.harp";
int i = 0;
int j = mSoundItems.size();
2015-10-22 02:06:25 +00:00
do {
if (i >= j)
2015-04-23 16:14:22 +00:00
break;
if (GT_Utility.areStacksEqual(mSoundItems.get(i), aStack)) {
tString = mSoundNames.get(i);
2015-04-23 16:14:22 +00:00
break;
}
i++;
2015-10-22 02:06:25 +00:00
} while (true);
if (tString.startsWith("random.explode"))
if (aStack.stackSize == 3)
2015-04-23 16:14:22 +00:00
tString = "random.fuse";
2015-10-22 02:06:25 +00:00
else if (aStack.stackSize == 2)
2015-04-23 16:14:22 +00:00
tString = "random.old_explode";
2015-10-22 02:06:25 +00:00
if (tString.startsWith("streaming."))
switch (aStack.stackSize) {
case 1: // '\001'
tString = (new StringBuilder()).append(tString).append("13").toString();
break;
case 2: // '\002'
tString = (new StringBuilder()).append(tString).append("cat").toString();
break;
case 3: // '\003'
tString = (new StringBuilder()).append(tString).append("blocks").toString();
break;
case 4: // '\004'
tString = (new StringBuilder()).append(tString).append("chirp").toString();
break;
case 5: // '\005'
tString = (new StringBuilder()).append(tString).append("far").toString();
break;
case 6: // '\006'
tString = (new StringBuilder()).append(tString).append("mall").toString();
break;
case 7: // '\007'
tString = (new StringBuilder()).append(tString).append("mellohi").toString();
break;
case 8: // '\b'
tString = (new StringBuilder()).append(tString).append("stal").toString();
break;
case 9: // '\t'
tString = (new StringBuilder()).append(tString).append("strad").toString();
break;
case 10: // '\n'
tString = (new StringBuilder()).append(tString).append("ward").toString();
break;
case 11: // '\013'
tString = (new StringBuilder()).append(tString).append("11").toString();
break;
case 12: // '\f'
tString = (new StringBuilder()).append(tString).append("wait").toString();
break;
default:
tString = (new StringBuilder()).append(tString).append("wherearewenow").toString();
break;
2015-04-23 16:14:22 +00:00
}
2016-12-26 00:55:20 +00:00
//TODO FIXME
//if (tString.startsWith("streaming."))
2016-12-26 00:55:20 +00:00
//aWorld.playRecord(tString.substring(10, tString.length()), (int) aX, (int) aY, (int) aZ);
//else
2016-12-26 00:55:20 +00:00
//aWorld.playSound(aX, aY, aZ, tString, 3F, tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F, false);
2015-04-23 16:14:22 +00:00
}
}