Added Minecraft Classic src
BIN
resources/2char.png
Normal file
After Width: | Height: | Size: 318 B |
2
resources/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,2 @@
|
|||
Manifest-Version: 1.0
|
||||
|
BIN
resources/armor/chain.png
Normal file
After Width: | Height: | Size: 364 B |
BIN
resources/armor/plate.png
Normal file
After Width: | Height: | Size: 742 B |
BIN
resources/char.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
resources/clouds.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
resources/default.gif
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
resources/default.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/dirt.png
Normal file
After Width: | Height: | Size: 1011 B |
144
resources/glsl/core.glsl
Normal file
|
@ -0,0 +1,144 @@
|
|||
|
||||
// eaglercraft opengl 1.3 emulation
|
||||
// copyright (c) 2020 calder young
|
||||
// creative commons BY-NC 4.0
|
||||
|
||||
#line 7
|
||||
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
precision highp float;
|
||||
|
||||
uniform mat4 matrix_m;
|
||||
uniform mat4 matrix_p;
|
||||
uniform mat4 matrix_t;
|
||||
|
||||
#ifdef CC_VERT
|
||||
|
||||
in vec3 a_position;
|
||||
#ifdef CC_a_texture0
|
||||
in vec2 a_texture0;
|
||||
#endif
|
||||
#ifdef CC_a_color
|
||||
in vec4 a_color;
|
||||
#endif
|
||||
#ifdef CC_a_normal
|
||||
in vec4 a_normal;
|
||||
#endif
|
||||
|
||||
#ifdef CC_fog
|
||||
out vec4 v_position;
|
||||
#endif
|
||||
#ifdef CC_a_color
|
||||
out vec4 v_color;
|
||||
#endif
|
||||
#ifdef CC_a_normal
|
||||
out vec4 v_normal;
|
||||
#endif
|
||||
#ifdef CC_a_texture0
|
||||
out vec2 v_texture0;
|
||||
#endif
|
||||
|
||||
void main(){
|
||||
vec4 pos = matrix_m * vec4(a_position, 1.0);
|
||||
#ifdef CC_fog
|
||||
v_position = pos;
|
||||
#endif
|
||||
#ifdef CC_a_color
|
||||
v_color = a_color;
|
||||
#endif
|
||||
#ifdef CC_a_normal
|
||||
v_normal = a_normal;
|
||||
#endif
|
||||
#ifdef CC_a_texture0
|
||||
v_texture0 = a_texture0;
|
||||
#endif
|
||||
gl_Position = matrix_p * pos;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CC_FRAG
|
||||
|
||||
#ifdef CC_unit0
|
||||
uniform sampler2D tex0;
|
||||
#ifndef CC_a_texture0
|
||||
uniform vec2 texCoordV0;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CC_lighting
|
||||
uniform vec3 light0Pos;
|
||||
uniform vec3 light1Pos;
|
||||
uniform vec3 normalUniform;
|
||||
#endif
|
||||
#ifdef CC_fog
|
||||
uniform vec4 fogColor;
|
||||
uniform int fogMode;
|
||||
uniform float fogStart;
|
||||
uniform float fogEnd;
|
||||
uniform float fogDensity;
|
||||
uniform float fogPremultiply;
|
||||
#endif
|
||||
uniform vec4 colorUniform;
|
||||
#ifdef CC_alphatest
|
||||
uniform float alphaTestF;
|
||||
#endif
|
||||
|
||||
#ifdef CC_fog
|
||||
in vec4 v_position;
|
||||
#endif
|
||||
#ifdef CC_a_color
|
||||
in vec4 v_color;
|
||||
#endif
|
||||
#ifdef CC_a_normal
|
||||
in vec4 v_normal;
|
||||
#endif
|
||||
#ifdef CC_a_texture0
|
||||
in vec2 v_texture0;
|
||||
#endif
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(){
|
||||
#ifdef CC_a_color
|
||||
vec4 color = colorUniform * v_color;
|
||||
#else
|
||||
vec4 color = colorUniform;
|
||||
#endif
|
||||
|
||||
#ifdef CC_unit0
|
||||
#ifdef CC_a_texture0
|
||||
color *= texture(tex0, (matrix_t * vec4(v_texture0, 0.0, 1.0)).xy).rgba;
|
||||
#else
|
||||
color *= texture(tex0, (matrix_t * vec4(texCoordV0, 0.0, 1.0)).xy).rgba;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CC_alphatest
|
||||
if(color.a < alphaTestF){
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CC_lighting
|
||||
#ifdef CC_a_normal
|
||||
vec3 normal = ((v_normal.xyz - 0.5) * 2.0);
|
||||
#else
|
||||
vec3 normal = normalUniform;
|
||||
#endif
|
||||
normal = normalize(mat3(matrix_m) * normal);
|
||||
float ins = max(dot(normal, -light0Pos), 0.0) + max(dot(normal, -light1Pos), 0.0);
|
||||
color.rgb *= min((0.4 + ins * 0.6), 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef CC_fog
|
||||
float dist = sqrt(dot(v_position, v_position));
|
||||
float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - pow(2.718, -(fogDensity * dist)), 0.0, 1.0);
|
||||
color.rgb = mix(color.rgb, fogColor.xyz, i * fogColor.a);
|
||||
#endif
|
||||
|
||||
fragColor = color;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
255
resources/glsl/fxaa.glsl
Normal file
|
@ -0,0 +1,255 @@
|
|||
#line 0
|
||||
|
||||
precision lowp int;
|
||||
precision lowp sampler2D;
|
||||
precision lowp float;
|
||||
|
||||
in vec2 pos;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
#define FXAA_PC 1
|
||||
#define FXAA_GLSL_130 1
|
||||
#define FXAA_FAST_PIXEL_OFFSET 0
|
||||
#define FXAA_GATHER4_ALPHA 0
|
||||
|
||||
#ifndef FXAA_GREEN_AS_LUMA
|
||||
// For those using non-linear color,
|
||||
// and either not able to get luma in alpha, or not wanting to,
|
||||
// this enables FXAA to run using green as a proxy for luma.
|
||||
// So with this enabled, no need to pack luma in alpha.
|
||||
//
|
||||
// This will turn off AA on anything which lacks some amount of green.
|
||||
// Pure red and blue or combination of only R and B, will get no AA.
|
||||
//
|
||||
// Might want to lower the settings for both,
|
||||
// fxaaConsoleEdgeThresholdMin
|
||||
// fxaaQualityEdgeThresholdMin
|
||||
// In order to insure AA does not get turned off on colors
|
||||
// which contain a minor amount of green.
|
||||
//
|
||||
// 1 = On.
|
||||
// 0 = Off.
|
||||
//
|
||||
#define FXAA_GREEN_AS_LUMA 1
|
||||
#endif
|
||||
|
||||
#ifndef FXAA_DISCARD
|
||||
// 1 = Use discard on pixels which don't need AA.
|
||||
// 0 = Return unchanged color on pixels which don't need AA.
|
||||
#define FXAA_DISCARD 0
|
||||
#endif
|
||||
|
||||
/*============================================================================
|
||||
API PORTING
|
||||
============================================================================*/
|
||||
#define FxaaBool bool
|
||||
#define FxaaDiscard discard
|
||||
#define FxaaFloat float
|
||||
#define FxaaFloat2 vec2
|
||||
#define FxaaFloat3 vec3
|
||||
#define FxaaFloat4 vec4
|
||||
#define FxaaHalf float
|
||||
#define FxaaHalf2 vec2
|
||||
#define FxaaHalf3 vec3
|
||||
#define FxaaHalf4 vec4
|
||||
#define FxaaInt2 ivec2
|
||||
#define FxaaSat(x) clamp(x, 0.0, 1.0)
|
||||
#define FxaaTex sampler2D
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#define FxaaTexTop(t, p) texture(t, p)
|
||||
|
||||
/*============================================================================
|
||||
GREEN AS LUMA OPTION SUPPORT FUNCTION
|
||||
============================================================================*/
|
||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
||||
// TODO Luma
|
||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz, vec3(0.299, 0.587, 0.114)); }
|
||||
#else
|
||||
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
|
||||
#endif
|
||||
|
||||
/*============================================================================
|
||||
FXAA3 CONSOLE - PC VERSION
|
||||
============================================================================*/
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat4 FxaaPixelShader(
|
||||
// See FXAA Quality FxaaPixelShader() source for docs on Inputs!
|
||||
//
|
||||
// Use noperspective interpolation here (turn off perspective interpolation).
|
||||
// {xy} = center of pixel
|
||||
FxaaFloat2 pos,
|
||||
//
|
||||
// Used only for FXAA Console, and not used on the 360 version.
|
||||
// Use noperspective interpolation here (turn off perspective interpolation).
|
||||
// {xy__} = upper left of pixel
|
||||
// {__zw} = lower right of pixel
|
||||
FxaaFloat4 fxaaConsolePosPos,
|
||||
//
|
||||
// Input color texture.
|
||||
// {rgb_} = color in linear or perceptual color space
|
||||
// if (FXAA_GREEN_AS_LUMA == 0)
|
||||
// {___a} = luma in perceptual color space (not linear)
|
||||
FxaaTex tex,
|
||||
//
|
||||
// Only used on FXAA Console.
|
||||
// This must be from a constant/uniform.
|
||||
// This effects sub-pixel AA quality and inversely sharpness.
|
||||
// Where N ranges between,
|
||||
// N = 0.50 (default)
|
||||
// N = 0.33 (sharper)
|
||||
// {x___} = -N/screenWidthInPixels
|
||||
// {_y__} = -N/screenHeightInPixels
|
||||
// {__z_} = N/screenWidthInPixels
|
||||
// {___w} = N/screenHeightInPixels
|
||||
FxaaFloat4 fxaaConsoleRcpFrameOpt,
|
||||
//
|
||||
// Only used on FXAA Console.
|
||||
// Not used on 360, but used on PS3 and PC.
|
||||
// This must be from a constant/uniform.
|
||||
// {x___} = -2.0/screenWidthInPixels
|
||||
// {_y__} = -2.0/screenHeightInPixels
|
||||
// {__z_} = 2.0/screenWidthInPixels
|
||||
// {___w} = 2.0/screenHeightInPixels
|
||||
FxaaFloat4 fxaaConsoleRcpFrameOpt2,
|
||||
//
|
||||
// Only used on FXAA Console.
|
||||
// This used to be the FXAA_CONSOLE__EDGE_SHARPNESS define.
|
||||
// It is here now to allow easier tuning.
|
||||
// This does not effect PS3, as this needs to be compiled in.
|
||||
// Use FXAA_CONSOLE__PS3_EDGE_SHARPNESS for PS3.
|
||||
// Due to the PS3 being ALU bound,
|
||||
// there are only three safe values here: 2 and 4 and 8.
|
||||
// These options use the shaders ability to a free *|/ by 2|4|8.
|
||||
// For all other platforms can be a non-power of two.
|
||||
// 8.0 is sharper (default!!!)
|
||||
// 4.0 is softer
|
||||
// 2.0 is really soft (good only for vector graphics inputs)
|
||||
FxaaFloat fxaaConsoleEdgeSharpness,
|
||||
//
|
||||
// Only used on FXAA Console.
|
||||
// This used to be the FXAA_CONSOLE__EDGE_THRESHOLD define.
|
||||
// It is here now to allow easier tuning.
|
||||
// This does not effect PS3, as this needs to be compiled in.
|
||||
// Use FXAA_CONSOLE__PS3_EDGE_THRESHOLD for PS3.
|
||||
// Due to the PS3 being ALU bound,
|
||||
// there are only two safe values here: 1/4 and 1/8.
|
||||
// These options use the shaders ability to a free *|/ by 2|4|8.
|
||||
// The console setting has a different mapping than the quality setting.
|
||||
// Other platforms can use other values.
|
||||
// 0.125 leaves less aliasing, but is softer (default!!!)
|
||||
// 0.25 leaves more aliasing, and is sharper
|
||||
FxaaFloat fxaaConsoleEdgeThreshold,
|
||||
//
|
||||
// Only used on FXAA Console.
|
||||
// This used to be the FXAA_CONSOLE__EDGE_THRESHOLD_MIN define.
|
||||
// It is here now to allow easier tuning.
|
||||
// Trims the algorithm from processing darks.
|
||||
// The console setting has a different mapping than the quality setting.
|
||||
// This does not apply to PS3,
|
||||
// PS3 was simplified to avoid more shader instructions.
|
||||
// 0.06 - faster but more aliasing in darks
|
||||
// 0.05 - default
|
||||
// 0.04 - slower and less aliasing in darks
|
||||
// Special notes when using FXAA_GREEN_AS_LUMA,
|
||||
// Likely want to set this to zero.
|
||||
// As colors that are mostly not-green
|
||||
// will appear very dark in the green channel!
|
||||
// Tune by looking at mostly non-green content,
|
||||
// then start at zero and increase until aliasing is a problem.
|
||||
FxaaFloat fxaaConsoleEdgeThresholdMin
|
||||
) {
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat lumaNw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xy));
|
||||
FxaaFloat lumaSw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xw));
|
||||
FxaaFloat lumaNe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zy));
|
||||
FxaaFloat lumaSe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zw));
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat4 rgbyM = FxaaTexTop(tex, pos.xy);
|
||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
||||
// TODO Luma
|
||||
FxaaFloat lumaM = FxaaLuma(rgbyM);
|
||||
#else
|
||||
FxaaFloat lumaM = rgbyM.y;
|
||||
#endif
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat lumaMaxNwSw = max(lumaNw, lumaSw);
|
||||
lumaNe += 1.0/384.0;
|
||||
FxaaFloat lumaMinNwSw = min(lumaNw, lumaSw);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat lumaMaxNeSe = max(lumaNe, lumaSe);
|
||||
FxaaFloat lumaMinNeSe = min(lumaNe, lumaSe);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat lumaMax = max(lumaMaxNeSe, lumaMaxNwSw);
|
||||
FxaaFloat lumaMin = min(lumaMinNeSe, lumaMinNwSw);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat lumaMaxScaled = lumaMax * fxaaConsoleEdgeThreshold;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat lumaMinM = min(lumaMin, lumaM);
|
||||
FxaaFloat lumaMaxScaledClamped = max(fxaaConsoleEdgeThresholdMin, lumaMaxScaled);
|
||||
FxaaFloat lumaMaxM = max(lumaMax, lumaM);
|
||||
FxaaFloat dirSwMinusNe = lumaSw - lumaNe;
|
||||
FxaaFloat lumaMaxSubMinM = lumaMaxM - lumaMinM;
|
||||
FxaaFloat dirSeMinusNw = lumaSe - lumaNw;
|
||||
if(lumaMaxSubMinM < lumaMaxScaledClamped)
|
||||
{
|
||||
#if (FXAA_DISCARD == 1)
|
||||
FxaaDiscard;
|
||||
#else
|
||||
return rgbyM;
|
||||
#endif
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat2 dir;
|
||||
dir.x = dirSwMinusNe + dirSeMinusNw;
|
||||
dir.y = dirSwMinusNe - dirSeMinusNw;
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat2 dir1 = normalize(dir.xy);
|
||||
FxaaFloat4 rgbyN1 = FxaaTexTop(tex, pos.xy - dir1 * fxaaConsoleRcpFrameOpt.zw);
|
||||
FxaaFloat4 rgbyP1 = FxaaTexTop(tex, pos.xy + dir1 * fxaaConsoleRcpFrameOpt.zw);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * fxaaConsoleEdgeSharpness;
|
||||
FxaaFloat2 dir2 = clamp(dir1.xy / dirAbsMinTimesC, -2.0, 2.0);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat2 dir2x = dir2 * fxaaConsoleRcpFrameOpt2.zw;
|
||||
FxaaFloat4 rgbyN2 = FxaaTexTop(tex, pos.xy - dir2x);
|
||||
FxaaFloat4 rgbyP2 = FxaaTexTop(tex, pos.xy + dir2x);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
FxaaFloat4 rgbyA = rgbyN1 + rgbyP1;
|
||||
FxaaFloat4 rgbyB = ((rgbyN2 + rgbyP2) * 0.25) + (rgbyA * 0.25);
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#if (FXAA_GREEN_AS_LUMA == 0)
|
||||
// TODO Luma
|
||||
float lumaB = FxaaLuma(rgbyB);
|
||||
#else
|
||||
float lumaB = rgbyB.y;
|
||||
#endif
|
||||
if((lumaB < lumaMin) || (lumaB > lumaMax))
|
||||
rgbyB.xyz = rgbyA.xyz * 0.5;
|
||||
//
|
||||
return rgbyB;
|
||||
}
|
||||
/*==========================================================================*/
|
||||
|
||||
uniform sampler2D f_color;
|
||||
|
||||
uniform vec2 screenSize;
|
||||
|
||||
#define edgeSharpness 7.0
|
||||
#define edgeThreshold 0.1
|
||||
#define edgeThresholdMin 0.005
|
||||
|
||||
void main(){
|
||||
vec4 posPos;
|
||||
posPos.xy = pos - (0.6 / screenSize);
|
||||
posPos.zw = pos + (0.6 / screenSize);
|
||||
vec4 rcpFrameOpt;
|
||||
rcpFrameOpt.xy = vec2(-0.50, -0.50) / screenSize;
|
||||
rcpFrameOpt.zw = vec2( 0.50, 0.50) / screenSize;
|
||||
vec4 rcpFrameOpt2;
|
||||
rcpFrameOpt2.xy = vec2(-2.0, -2.0) / screenSize;
|
||||
rcpFrameOpt2.zw = vec2( 2.0, 2.0) / screenSize;
|
||||
|
||||
fragColor = vec4(FxaaPixelShader(pos, posPos, f_color, rcpFrameOpt, rcpFrameOpt2, edgeSharpness, edgeThreshold, edgeThresholdMin).rgb, 1.0);
|
||||
}
|
25
resources/glsl/occl.glsl
Normal file
|
@ -0,0 +1,25 @@
|
|||
#line 2
|
||||
|
||||
precision highp int;
|
||||
precision highp sampler2D;
|
||||
precision highp float;
|
||||
|
||||
#ifdef CC_VERT
|
||||
uniform mat4 matrix_m;
|
||||
uniform mat4 matrix_p;
|
||||
|
||||
in vec3 a_vert;
|
||||
|
||||
void main(){
|
||||
gl_Position = (matrix_p * (matrix_m * vec4(a_vert, 1.0)));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CC_FRAG
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main(){
|
||||
fragColor = vec4(1.0);
|
||||
}
|
||||
#endif
|
13
resources/glsl/pvert.glsl
Normal file
|
@ -0,0 +1,13 @@
|
|||
#line 0
|
||||
|
||||
precision lowp int;
|
||||
precision lowp sampler2D;
|
||||
precision lowp float;
|
||||
|
||||
in vec2 a_pos;
|
||||
|
||||
out vec2 pos;
|
||||
|
||||
void main(){
|
||||
gl_Position = vec4((pos = a_pos) * 2.0 - 1.0, 0.0, 1.0);
|
||||
}
|
BIN
resources/grass.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
resources/gui/gui.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
resources/gui/icons.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
resources/item/arrows.png
Normal file
After Width: | Height: | Size: 322 B |
BIN
resources/item/sign.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
resources/mob/creeper.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
resources/mob/pig.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
resources/mob/sheep.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
resources/mob/sheep_fur.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
resources/mob/skeleton.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
resources/mob/spider.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
resources/mob/zombie.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
0
resources/null
Normal file
BIN
resources/particles.png
Normal file
After Width: | Height: | Size: 574 B |
BIN
resources/rain.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
resources/terrain.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
resources/water.png
Normal file
After Width: | Height: | Size: 306 B |
13
src/main/java/com/mojang/minecraft/ChatLine.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
public class ChatLine
|
||||
{
|
||||
public ChatLine(String message)
|
||||
{
|
||||
this.message = message;
|
||||
this.time = 0;
|
||||
}
|
||||
|
||||
public String message;
|
||||
public int time;
|
||||
}
|
477
src/main/java/com/mojang/minecraft/Entity.java
Normal file
|
@ -0,0 +1,477 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.level.BlockMap;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.liquid.LiquidType;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.level.tile.Tile$SoundType;
|
||||
import com.mojang.minecraft.model.Vec3D;
|
||||
import com.mojang.minecraft.net.PositionUpdate;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import com.mojang.util.MathHelper;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class Entity implements Serializable {
|
||||
|
||||
public static final long serialVersionUID = 0L;
|
||||
public Level level;
|
||||
public float xo;
|
||||
public float yo;
|
||||
public float zo;
|
||||
public float x;
|
||||
public float y;
|
||||
public float z;
|
||||
public float xd;
|
||||
public float yd;
|
||||
public float zd;
|
||||
public float yRot;
|
||||
public float xRot;
|
||||
public float yRotO;
|
||||
public float xRotO;
|
||||
public AABB bb;
|
||||
public boolean onGround = false;
|
||||
public boolean horizontalCollision = false;
|
||||
public boolean collision = false;
|
||||
public boolean slide = true;
|
||||
public boolean removed = false;
|
||||
public float heightOffset = 0.0F;
|
||||
public float bbWidth = 0.6F;
|
||||
public float bbHeight = 1.8F;
|
||||
public float walkDistO = 0.0F;
|
||||
public float walkDist = 0.0F;
|
||||
public boolean makeStepSound = true;
|
||||
public float fallDistance = 0.0F;
|
||||
private int nextStep = 1;
|
||||
public BlockMap blockMap;
|
||||
public float xOld;
|
||||
public float yOld;
|
||||
public float zOld;
|
||||
public int textureId = 0;
|
||||
public float ySlideOffset = 0.0F;
|
||||
public float footSize = 0.0F;
|
||||
public boolean noPhysics = false;
|
||||
public float pushthrough = 0.0F;
|
||||
public boolean hovered = false;
|
||||
|
||||
|
||||
public Entity(Level var1) {
|
||||
this.level = var1;
|
||||
this.setPos(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public void resetPos() {
|
||||
if(this.level != null) {
|
||||
float var1 = (float)this.level.xSpawn + 0.5F;
|
||||
float var2 = (float)this.level.ySpawn;
|
||||
|
||||
for(float var3 = (float)this.level.zSpawn + 0.5F; var2 > 0.0F; ++var2) {
|
||||
this.setPos(var1, var2, var3);
|
||||
if(this.level.getCubes(this.bb).size() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.xd = this.yd = this.zd = 0.0F;
|
||||
this.yRot = this.level.rotSpawn;
|
||||
this.xRot = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
this.removed = true;
|
||||
}
|
||||
|
||||
public void setSize(float var1, float var2) {
|
||||
this.bbWidth = var1;
|
||||
this.bbHeight = var2;
|
||||
}
|
||||
|
||||
public void setPos(PositionUpdate var1) {
|
||||
if(var1.position) {
|
||||
this.setPos(var1.x, var1.y, var1.z);
|
||||
} else {
|
||||
this.setPos(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
if(var1.rotation) {
|
||||
this.setRot(var1.yaw, var1.pitch);
|
||||
} else {
|
||||
this.setRot(this.yRot, this.xRot);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRot(float var1, float var2) {
|
||||
this.yRot = var1;
|
||||
this.xRot = var2;
|
||||
}
|
||||
|
||||
public void setPos(float var1, float var2, float var3) {
|
||||
this.x = var1;
|
||||
this.y = var2;
|
||||
this.z = var3;
|
||||
float var4 = this.bbWidth / 2.0F;
|
||||
float var5 = this.bbHeight / 2.0F;
|
||||
this.bb = new AABB(var1 - var4, var2 - var5, var3 - var4, var1 + var4, var2 + var5, var3 + var4);
|
||||
}
|
||||
|
||||
public void turn(float var1, float var2) {
|
||||
float var3 = this.xRot;
|
||||
float var4 = this.yRot;
|
||||
this.yRot = (float)((double)this.yRot + (double)var1 * 0.15D);
|
||||
this.xRot = (float)((double)this.xRot - (double)var2 * 0.15D);
|
||||
if(this.xRot < -90.0F) {
|
||||
this.xRot = -90.0F;
|
||||
}
|
||||
|
||||
if(this.xRot > 90.0F) {
|
||||
this.xRot = 90.0F;
|
||||
}
|
||||
|
||||
this.xRotO += this.xRot - var3;
|
||||
this.yRotO += this.yRot - var4;
|
||||
}
|
||||
|
||||
public void interpolateTurn(float var1, float var2) {
|
||||
this.yRot = (float)((double)this.yRot + (double)var1 * 0.15D);
|
||||
this.xRot = (float)((double)this.xRot - (double)var2 * 0.15D);
|
||||
if(this.xRot < -90.0F) {
|
||||
this.xRot = -90.0F;
|
||||
}
|
||||
|
||||
if(this.xRot > 90.0F) {
|
||||
this.xRot = 90.0F;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
this.walkDistO = this.walkDist;
|
||||
this.xo = this.x;
|
||||
this.yo = this.y;
|
||||
this.zo = this.z;
|
||||
this.xRotO = this.xRot;
|
||||
this.yRotO = this.yRot;
|
||||
}
|
||||
|
||||
public boolean isFree(float var1, float var2, float var3, float var4) {
|
||||
AABB var5 = this.bb.grow(var4, var4, var4).cloneMove(var1, var2, var3);
|
||||
return this.level.getCubes(var5).size() > 0?false:!this.level.containsAnyLiquid(var5);
|
||||
}
|
||||
|
||||
public boolean isFree(float var1, float var2, float var3) {
|
||||
AABB var4 = this.bb.cloneMove(var1, var2, var3);
|
||||
return this.level.getCubes(var4).size() > 0?false:!this.level.containsAnyLiquid(var4);
|
||||
}
|
||||
|
||||
public void move(float var1, float var2, float var3) {
|
||||
if(this.noPhysics) {
|
||||
this.bb.move(var1, var2, var3);
|
||||
this.x = (this.bb.x0 + this.bb.x1) / 2.0F;
|
||||
this.y = this.bb.y0 + this.heightOffset - this.ySlideOffset;
|
||||
this.z = (this.bb.z0 + this.bb.z1) / 2.0F;
|
||||
} else {
|
||||
float var4 = this.x;
|
||||
float var5 = this.z;
|
||||
float var6 = var1;
|
||||
float var7 = var2;
|
||||
float var8 = var3;
|
||||
AABB var9 = this.bb.copy();
|
||||
ArrayList var10 = this.level.getCubes(this.bb.expand(var1, var2, var3));
|
||||
|
||||
for(int var11 = 0; var11 < var10.size(); ++var11) {
|
||||
var2 = ((AABB)var10.get(var11)).clipYCollide(this.bb, var2);
|
||||
}
|
||||
|
||||
this.bb.move(0.0F, var2, 0.0F);
|
||||
if(!this.slide && var7 != var2) {
|
||||
var3 = 0.0F;
|
||||
var2 = 0.0F;
|
||||
var1 = 0.0F;
|
||||
}
|
||||
|
||||
boolean var16 = this.onGround || var7 != var2 && var7 < 0.0F;
|
||||
|
||||
int var12;
|
||||
for(var12 = 0; var12 < var10.size(); ++var12) {
|
||||
var1 = ((AABB)var10.get(var12)).clipXCollide(this.bb, var1);
|
||||
}
|
||||
|
||||
this.bb.move(var1, 0.0F, 0.0F);
|
||||
if(!this.slide && var6 != var1) {
|
||||
var3 = 0.0F;
|
||||
var2 = 0.0F;
|
||||
var1 = 0.0F;
|
||||
}
|
||||
|
||||
for(var12 = 0; var12 < var10.size(); ++var12) {
|
||||
var3 = ((AABB)var10.get(var12)).clipZCollide(this.bb, var3);
|
||||
}
|
||||
|
||||
this.bb.move(0.0F, 0.0F, var3);
|
||||
if(!this.slide && var8 != var3) {
|
||||
var3 = 0.0F;
|
||||
var2 = 0.0F;
|
||||
var1 = 0.0F;
|
||||
}
|
||||
|
||||
float var17;
|
||||
float var18;
|
||||
if(this.footSize > 0.0F && var16 && this.ySlideOffset < 0.05F && (var6 != var1 || var8 != var3)) {
|
||||
var18 = var1;
|
||||
var17 = var2;
|
||||
float var13 = var3;
|
||||
var1 = var6;
|
||||
var2 = this.footSize;
|
||||
var3 = var8;
|
||||
AABB var14 = this.bb.copy();
|
||||
this.bb = var9.copy();
|
||||
var10 = this.level.getCubes(this.bb.expand(var6, var2, var8));
|
||||
|
||||
int var15;
|
||||
for(var15 = 0; var15 < var10.size(); ++var15) {
|
||||
var2 = ((AABB)var10.get(var15)).clipYCollide(this.bb, var2);
|
||||
}
|
||||
|
||||
this.bb.move(0.0F, var2, 0.0F);
|
||||
if(!this.slide && var7 != var2) {
|
||||
var3 = 0.0F;
|
||||
var2 = 0.0F;
|
||||
var1 = 0.0F;
|
||||
}
|
||||
|
||||
for(var15 = 0; var15 < var10.size(); ++var15) {
|
||||
var1 = ((AABB)var10.get(var15)).clipXCollide(this.bb, var1);
|
||||
}
|
||||
|
||||
this.bb.move(var1, 0.0F, 0.0F);
|
||||
if(!this.slide && var6 != var1) {
|
||||
var3 = 0.0F;
|
||||
var2 = 0.0F;
|
||||
var1 = 0.0F;
|
||||
}
|
||||
|
||||
for(var15 = 0; var15 < var10.size(); ++var15) {
|
||||
var3 = ((AABB)var10.get(var15)).clipZCollide(this.bb, var3);
|
||||
}
|
||||
|
||||
this.bb.move(0.0F, 0.0F, var3);
|
||||
if(!this.slide && var8 != var3) {
|
||||
var3 = 0.0F;
|
||||
var2 = 0.0F;
|
||||
var1 = 0.0F;
|
||||
}
|
||||
|
||||
if(var18 * var18 + var13 * var13 >= var1 * var1 + var3 * var3) {
|
||||
var1 = var18;
|
||||
var2 = var17;
|
||||
var3 = var13;
|
||||
this.bb = var14.copy();
|
||||
} else {
|
||||
this.ySlideOffset = (float)((double)this.ySlideOffset + 0.5D);
|
||||
}
|
||||
}
|
||||
|
||||
this.horizontalCollision = var6 != var1 || var8 != var3;
|
||||
this.onGround = var7 != var2 && var7 < 0.0F;
|
||||
this.collision = this.horizontalCollision || var7 != var2;
|
||||
if(this.onGround) {
|
||||
if(this.fallDistance > 0.0F) {
|
||||
this.causeFallDamage(this.fallDistance);
|
||||
this.fallDistance = 0.0F;
|
||||
}
|
||||
} else if(var2 < 0.0F) {
|
||||
this.fallDistance -= var2;
|
||||
}
|
||||
|
||||
if(var6 != var1) {
|
||||
this.xd = 0.0F;
|
||||
}
|
||||
|
||||
if(var7 != var2) {
|
||||
this.yd = 0.0F;
|
||||
}
|
||||
|
||||
if(var8 != var3) {
|
||||
this.zd = 0.0F;
|
||||
}
|
||||
|
||||
this.x = (this.bb.x0 + this.bb.x1) / 2.0F;
|
||||
this.y = this.bb.y0 + this.heightOffset - this.ySlideOffset;
|
||||
this.z = (this.bb.z0 + this.bb.z1) / 2.0F;
|
||||
var18 = this.x - var4;
|
||||
var17 = this.z - var5;
|
||||
this.walkDist = (float)((double)this.walkDist + (double)MathHelper.sqrt(var18 * var18 + var17 * var17) * 0.6D);
|
||||
if(this.makeStepSound) {
|
||||
int var19 = this.level.getTile((int)this.x, (int)(this.y - 0.2F - this.heightOffset), (int)this.z);
|
||||
if(this.walkDist > (float)this.nextStep && var19 > 0) {
|
||||
++this.nextStep;
|
||||
Tile$SoundType var20;
|
||||
if((var20 = Block.blocks[var19].stepsound) != Tile$SoundType.none) {
|
||||
this.playSound("step." + var20.name, var20.getVolume() * 0.75F, var20.getPitch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.ySlideOffset *= 0.4F;
|
||||
}
|
||||
}
|
||||
|
||||
protected void causeFallDamage(float var1) {}
|
||||
|
||||
public boolean isInWater() {
|
||||
return this.level.containsLiquid(this.bb.grow(0.0F, -0.4F, 0.0F), LiquidType.WATER);
|
||||
}
|
||||
|
||||
public boolean isUnderWater() {
|
||||
int var1;
|
||||
return (var1 = this.level.getTile((int)this.x, (int)(this.y + 0.12F), (int)this.z)) != 0?Block.blocks[var1].getLiquidType().equals(LiquidType.WATER):false;
|
||||
}
|
||||
|
||||
public boolean isInLava() {
|
||||
return this.level.containsLiquid(this.bb.grow(0.0F, -0.4F, 0.0F), LiquidType.LAVA);
|
||||
}
|
||||
|
||||
public void moveRelative(float var1, float var2, float var3) {
|
||||
float var4;
|
||||
if((var4 = MathHelper.sqrt(var1 * var1 + var2 * var2)) >= 0.01F) {
|
||||
if(var4 < 1.0F) {
|
||||
var4 = 1.0F;
|
||||
}
|
||||
|
||||
var4 = var3 / var4;
|
||||
var1 *= var4;
|
||||
var2 *= var4;
|
||||
var3 = MathHelper.sin(this.yRot * 3.1415927F / 180.0F);
|
||||
var4 = MathHelper.cos(this.yRot * 3.1415927F / 180.0F);
|
||||
this.xd += var1 * var4 - var2 * var3;
|
||||
this.zd += var2 * var4 + var1 * var3;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLit() {
|
||||
int var1 = (int)this.x;
|
||||
int var2 = (int)this.y;
|
||||
int var3 = (int)this.z;
|
||||
return this.level.isLit(var1, var2, var3);
|
||||
}
|
||||
|
||||
public float getBrightness(float var1) {
|
||||
int var4 = (int)this.x;
|
||||
int var2 = (int)(this.y + this.heightOffset / 2.0F - 0.5F);
|
||||
int var3 = (int)this.z;
|
||||
return this.level.getBrightness(var4, var2, var3);
|
||||
}
|
||||
|
||||
public void render(TextureManager var1, float var2) {}
|
||||
|
||||
public void setLevel(Level var1) {
|
||||
this.level = var1;
|
||||
}
|
||||
|
||||
public void playSound(String var1, float var2, float var3) {
|
||||
this.level.playSound(var1, this, var2, var3);
|
||||
}
|
||||
|
||||
public void moveTo(float var1, float var2, float var3, float var4, float var5) {
|
||||
this.xo = this.x = var1;
|
||||
this.yo = this.y = var2;
|
||||
this.zo = this.z = var3;
|
||||
this.yRot = var4;
|
||||
this.xRot = var5;
|
||||
this.setPos(var1, var2, var3);
|
||||
}
|
||||
|
||||
public float distanceTo(Entity var1) {
|
||||
float var2 = this.x - var1.x;
|
||||
float var3 = this.y - var1.y;
|
||||
float var4 = this.z - var1.z;
|
||||
return MathHelper.sqrt(var2 * var2 + var3 * var3 + var4 * var4);
|
||||
}
|
||||
|
||||
public float distanceTo(float var1, float var2, float var3) {
|
||||
var1 = this.x - var1;
|
||||
var2 = this.y - var2;
|
||||
float var4 = this.z - var3;
|
||||
return MathHelper.sqrt(var1 * var1 + var2 * var2 + var4 * var4);
|
||||
}
|
||||
|
||||
public float distanceToSqr(Entity var1) {
|
||||
float var2 = this.x - var1.x;
|
||||
float var3 = this.y - var1.y;
|
||||
float var4 = this.z - var1.z;
|
||||
return var2 * var2 + var3 * var3 + var4 * var4;
|
||||
}
|
||||
|
||||
public void playerTouch(Entity var1) {}
|
||||
|
||||
public void push(Entity var1) {
|
||||
float var2 = var1.x - this.x;
|
||||
float var3 = var1.z - this.z;
|
||||
float var4;
|
||||
if((var4 = var2 * var2 + var3 * var3) >= 0.01F) {
|
||||
var4 = MathHelper.sqrt(var4);
|
||||
var2 /= var4;
|
||||
var3 /= var4;
|
||||
var2 /= var4;
|
||||
var3 /= var4;
|
||||
var2 *= 0.05F;
|
||||
var3 *= 0.05F;
|
||||
var2 *= 1.0F - this.pushthrough;
|
||||
var3 *= 1.0F - this.pushthrough;
|
||||
this.push(-var2, 0.0F, -var3);
|
||||
var1.push(var2, 0.0F, var3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void push(float var1, float var2, float var3) {
|
||||
this.xd += var1;
|
||||
this.yd += var2;
|
||||
this.zd += var3;
|
||||
}
|
||||
|
||||
public void hurt(Entity var1, int var2) {}
|
||||
|
||||
public boolean intersects(float var1, float var2, float var3, float var4, float var5, float var6) {
|
||||
return this.bb.intersects(var1, var2, var3, var4, var5, var6);
|
||||
}
|
||||
|
||||
public boolean isPickable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPushable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isShootable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void awardKillScore(Entity var1, int var2) {}
|
||||
|
||||
public boolean shouldRender(Vec3D var1) {
|
||||
float var2 = this.x - var1.x;
|
||||
float var3 = this.y - var1.y;
|
||||
float var4 = this.z - var1.z;
|
||||
var4 = var2 * var2 + var3 * var3 + var4 * var4;
|
||||
return this.shouldRenderAtSqrDistance(var4);
|
||||
}
|
||||
|
||||
public boolean shouldRenderAtSqrDistance(float var1) {
|
||||
float var2 = this.bb.getSize() * 64.0F;
|
||||
return var1 < var2 * var2;
|
||||
}
|
||||
|
||||
public int getTexture() {
|
||||
return this.textureId;
|
||||
}
|
||||
|
||||
public boolean isCreativeModeAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void renderHover(TextureManager var1, float var2) {}
|
||||
}
|
287
src/main/java/com/mojang/minecraft/GameSettings.java
Normal file
|
@ -0,0 +1,287 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.mojang.minecraft.gamemode.*;
|
||||
import com.mojang.minecraft.player.Inventory;
|
||||
|
||||
public final class GameSettings
|
||||
{
|
||||
public GameSettings(Minecraft minecraft, File minecraftFolder)
|
||||
{
|
||||
bindings = new KeyBinding[] {forwardKey, leftKey, backKey, rightKey, jumpKey, buildKey, chatKey, toggleFogKey, saveLocationKey, loadLocationKey};
|
||||
|
||||
settingCount = 8;
|
||||
|
||||
this.minecraft = minecraft;
|
||||
|
||||
settingsFile = new File(minecraftFolder, "options.txt");
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
private static final String[] renderDistances = new String[]{"FAR", "NORMAL", "SHORT", "TINY"};
|
||||
public boolean music = true;
|
||||
public boolean sound = true;
|
||||
public boolean invertMouse = false;
|
||||
public boolean showFrameRate = false;
|
||||
public int viewDistance = 0;
|
||||
public boolean viewBobbing = true;
|
||||
public boolean anaglyph = false;
|
||||
public boolean limitFramerate = false;
|
||||
public boolean ofBetterGrass = false;
|
||||
public boolean ofFastMath = true;
|
||||
public boolean ofSmoothFPS = false;
|
||||
public boolean gamemode = false;
|
||||
public boolean randomDrops = false;
|
||||
public KeyBinding forwardKey = new KeyBinding("Forward", 17);
|
||||
public KeyBinding leftKey = new KeyBinding("Left", 30);
|
||||
public KeyBinding backKey = new KeyBinding("Back", 31);
|
||||
public KeyBinding rightKey = new KeyBinding("Right", 32);
|
||||
public KeyBinding jumpKey = new KeyBinding("Jump", 57);
|
||||
public KeyBinding buildKey = new KeyBinding("Build", 48);
|
||||
public KeyBinding chatKey = new KeyBinding("Chat", 20);
|
||||
public KeyBinding toggleFogKey = new KeyBinding("Toggle fog", 33);
|
||||
public KeyBinding saveLocationKey = new KeyBinding("Save location", 28);
|
||||
public KeyBinding loadLocationKey = new KeyBinding("Load location", 19);
|
||||
public KeyBinding[] bindings;
|
||||
private Minecraft minecraft;
|
||||
private File settingsFile;
|
||||
public int settingCount;
|
||||
|
||||
public String getBinding(int key)
|
||||
{
|
||||
return bindings[key].name + ": " + Keyboard.getKeyName(bindings[key].key);
|
||||
}
|
||||
|
||||
public void setBinding(int key, int keyID)
|
||||
{
|
||||
bindings[key].key = keyID;
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public void toggleSetting(int setting, int fogValue)
|
||||
{
|
||||
if(setting == 0)
|
||||
{
|
||||
music = !music;
|
||||
}
|
||||
|
||||
if(setting == 1)
|
||||
{
|
||||
sound = !sound;
|
||||
}
|
||||
|
||||
if(setting == 2)
|
||||
{
|
||||
invertMouse = !invertMouse;
|
||||
}
|
||||
|
||||
if(setting == 3)
|
||||
{
|
||||
showFrameRate = !showFrameRate;
|
||||
}
|
||||
|
||||
if(setting == 4)
|
||||
{
|
||||
viewDistance = viewDistance + fogValue & 3;
|
||||
}
|
||||
|
||||
if(setting == 5)
|
||||
{
|
||||
viewBobbing = !viewBobbing;
|
||||
}
|
||||
|
||||
if(setting == 6)
|
||||
{
|
||||
minecraft.levelRenderer.refresh();
|
||||
anaglyph = !anaglyph;
|
||||
minecraft.levelRenderer.refresh();
|
||||
}
|
||||
|
||||
if(setting == 7)
|
||||
{
|
||||
limitFramerate = !limitFramerate;
|
||||
}
|
||||
|
||||
if(setting == 8) {
|
||||
ofBetterGrass = !ofBetterGrass;
|
||||
minecraft.levelRenderer.refresh();
|
||||
}
|
||||
|
||||
if(setting == 9) {
|
||||
ofFastMath = !ofFastMath;
|
||||
minecraft.levelRenderer.refresh();
|
||||
}
|
||||
|
||||
if(setting == 11) {
|
||||
if(gamemode) {
|
||||
GameMode game = new SurvivalGameMode(minecraft);
|
||||
game.apply(minecraft.level);
|
||||
game.apply(minecraft.player);
|
||||
minecraft.gamemode = game;
|
||||
} else {
|
||||
GameMode game = new CreativeGameMode(minecraft);
|
||||
game.apply(minecraft.level);
|
||||
game.apply(minecraft.player);
|
||||
minecraft.gamemode = game;
|
||||
}
|
||||
gamemode = !gamemode;
|
||||
}
|
||||
|
||||
if(setting == 12) {
|
||||
randomDrops = !randomDrops;
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public String getSetting(int id)
|
||||
{
|
||||
return id == 0 ? "Music: " + (music ? "ON" : "OFF")
|
||||
: (id == 1 ? "Sound: " + (sound ? "ON" : "OFF")
|
||||
: (id == 2 ? "Invert mouse: " + (invertMouse ? "ON" : "OFF")
|
||||
: (id == 3 ? "Show FPS: " + (showFrameRate ? "ON" : "OFF")
|
||||
: (id == 4 ? "Render distance: " + renderDistances[viewDistance]
|
||||
: (id == 5 ? "View bobbing: " + (viewBobbing ? "ON" : "OFF")
|
||||
: (id == 6 ? "3d anaglyph: " + (anaglyph ? "ON" : "OFF")
|
||||
: (id == 7 ? "Limit framerate: " + (limitFramerate ? "ON" : "OFF")
|
||||
: (id == 8 ? "Better Grass: " + (ofBetterGrass ? "ON" : "OFF")
|
||||
: (id == 9 ? "Fast Math: " + (ofFastMath ? "ON" : "OFF")
|
||||
: (id == 10 ? "Smooth FPS: " + (ofSmoothFPS ? "ON" : "OFF")
|
||||
: (id == 11 ? "GameMode: " + (gamemode ? "Creative" : "Survival")
|
||||
: (id == 12 ? "Random Drops: " + (randomDrops ? "ON": "OFF")
|
||||
: ""))))))))))));
|
||||
}
|
||||
|
||||
private void load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(settingsFile.exists())
|
||||
{
|
||||
FileReader fileReader = new FileReader(settingsFile);
|
||||
BufferedReader reader = new BufferedReader(fileReader);
|
||||
|
||||
String line = null;
|
||||
|
||||
while((line = reader.readLine()) != null)
|
||||
{
|
||||
String[] setting = line.split(":");
|
||||
|
||||
if(setting[0].equals("music"))
|
||||
{
|
||||
music = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("sound"))
|
||||
{
|
||||
sound = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("invertYMouse"))
|
||||
{
|
||||
invertMouse = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("showFrameRate"))
|
||||
{
|
||||
showFrameRate = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("viewDistance"))
|
||||
{
|
||||
viewDistance = Integer.parseInt(setting[1]);
|
||||
}
|
||||
|
||||
if(setting[0].equals("bobView"))
|
||||
{
|
||||
viewBobbing = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("anaglyph3d"))
|
||||
{
|
||||
anaglyph = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("limitFramerate"))
|
||||
{
|
||||
limitFramerate = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("ofBetterGrass"))
|
||||
{
|
||||
ofBetterGrass = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("ofFastMath"))
|
||||
{
|
||||
ofFastMath = setting[1].equals("true");
|
||||
}
|
||||
|
||||
if(setting[0].equals("ofSmoothFPS"))
|
||||
{
|
||||
ofSmoothFPS = setting[1].equals("true");
|
||||
}
|
||||
|
||||
for(int index = 0; index < this.bindings.length; index++)
|
||||
{
|
||||
if(setting[0].equals("key_" + bindings[index].name))
|
||||
{
|
||||
bindings[index].key = Integer.parseInt(setting[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reader.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to load options");
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void save()
|
||||
{
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter(this.settingsFile);
|
||||
PrintWriter writer = new PrintWriter(fileWriter);
|
||||
|
||||
writer.println("music:" + music);
|
||||
writer.println("sound:" + sound);
|
||||
writer.println("invertYMouse:" + invertMouse);
|
||||
writer.println("showFrameRate:" + showFrameRate);
|
||||
writer.println("viewDistance:" + viewDistance);
|
||||
writer.println("bobView:" + viewBobbing);
|
||||
writer.println("anaglyph3d:" + anaglyph);
|
||||
writer.println("limitFramerate:" + limitFramerate);
|
||||
writer.println("ofBetterGrass:" + ofBetterGrass);
|
||||
writer.println("ofFastMath:" + ofFastMath);
|
||||
writer.println("ofSmoothFPS:" + ofSmoothFPS);
|
||||
|
||||
for(int binding = 0; binding < bindings.length; binding++)
|
||||
{
|
||||
writer.println("key_" + bindings[binding].name + ":" + bindings[binding].key);
|
||||
}
|
||||
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Failed to save options");
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
13
src/main/java/com/mojang/minecraft/KeyBinding.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
public class KeyBinding
|
||||
{
|
||||
public KeyBinding(String name, int key)
|
||||
{
|
||||
this.name = name;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String name;
|
||||
public int key;
|
||||
}
|
16
src/main/java/com/mojang/minecraft/Minecraft$OS.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
public enum Minecraft$OS
|
||||
{
|
||||
linux("linux", 0),
|
||||
solaris("solaris", 1),
|
||||
windows("windows", 2),
|
||||
macos("macos", 3),
|
||||
unknown("unknown", 4);
|
||||
|
||||
private static final Minecraft$OS[] values = new Minecraft$OS[] {linux, solaris, windows, macos, unknown};
|
||||
|
||||
private Minecraft$OS(String name, int id)
|
||||
{
|
||||
}
|
||||
}
|
1804
src/main/java/com/mojang/minecraft/Minecraft.java
Normal file
32
src/main/java/com/mojang/minecraft/MinecraftApplet$1.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import java.awt.Canvas;
|
||||
|
||||
// MinecraftCanvas
|
||||
public class MinecraftApplet$1 extends Canvas
|
||||
{
|
||||
public MinecraftApplet$1(MinecraftApplet minecraftApplet)
|
||||
{
|
||||
this.applet = minecraftApplet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addNotify()
|
||||
{
|
||||
super.addNotify();
|
||||
|
||||
applet.startGameThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeNotify()
|
||||
{
|
||||
applet.stopGameThread();
|
||||
|
||||
super.removeNotify();
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private MinecraftApplet applet;
|
||||
}
|
115
src/main/java/com/mojang/minecraft/MinecraftApplet.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Canvas;
|
||||
|
||||
public class MinecraftApplet extends Applet
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Canvas canvas;
|
||||
private Minecraft minecraft;
|
||||
|
||||
private Thread thread = null;
|
||||
|
||||
public void init()
|
||||
{
|
||||
canvas = new MinecraftApplet$1(this);
|
||||
|
||||
boolean fullscreen = false;
|
||||
|
||||
if(getParameter("fullscreen") != null)
|
||||
{
|
||||
fullscreen = getParameter("fullscreen").equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
minecraft = new Minecraft(canvas, this, getWidth(), getHeight(), fullscreen);
|
||||
|
||||
minecraft.host = getDocumentBase().getHost();
|
||||
|
||||
if(getDocumentBase().getPort() > 0)
|
||||
{
|
||||
minecraft.host = minecraft.host + ":" + getDocumentBase().getPort();
|
||||
}
|
||||
|
||||
if(getParameter("username") != null && getParameter("sessionid") != null)
|
||||
{
|
||||
minecraft.session = new SessionData(getParameter("username"), getParameter("sessionid"));
|
||||
|
||||
if(getParameter("mppass") != null)
|
||||
{
|
||||
minecraft.session.mppass = getParameter("mppass");
|
||||
}
|
||||
|
||||
// TODO: Not tested.
|
||||
minecraft.session.haspaid = getParameter("haspaid").equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
if(getParameter("loadmap_user") != null && getParameter("loadmap_id") != null)
|
||||
{
|
||||
minecraft.levelName = getParameter("loadmap_user");
|
||||
minecraft.levelId = Integer.parseInt(getParameter("loadmap_id"));
|
||||
} else if(getParameter("server") != null && getParameter("port") != null) {
|
||||
String server = getParameter("server");
|
||||
int port = Integer.parseInt(getParameter("port"));
|
||||
|
||||
minecraft.server = server;
|
||||
minecraft.port = port;
|
||||
}
|
||||
|
||||
minecraft.levelLoaded = true;
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
add(canvas, "Center");
|
||||
|
||||
canvas.setFocusable(true);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
public void startGameThread()
|
||||
{
|
||||
if(thread == null)
|
||||
{
|
||||
thread = new Thread(minecraft);
|
||||
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
minecraft.waiting = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
minecraft.waiting = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
stopGameThread();
|
||||
}
|
||||
|
||||
public void stopGameThread()
|
||||
{
|
||||
if(thread != null)
|
||||
{
|
||||
minecraft.running = false;
|
||||
|
||||
try {
|
||||
thread.join(1000L);
|
||||
} catch (InterruptedException var3) {
|
||||
minecraft.shutdown();
|
||||
}
|
||||
|
||||
thread = null;
|
||||
}
|
||||
}
|
||||
}
|
37
src/main/java/com/mojang/minecraft/MovingObjectPosition.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.model.Vec3D;
|
||||
|
||||
public class MovingObjectPosition
|
||||
{
|
||||
public MovingObjectPosition(int x, int y, int z, int side, Vec3D blockPos)
|
||||
{
|
||||
entityPos = 0;
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
this.face = side;
|
||||
|
||||
vec = new Vec3D(blockPos.x, blockPos.y, blockPos.z);
|
||||
}
|
||||
|
||||
public MovingObjectPosition(Entity entity)
|
||||
{
|
||||
entityPos = 1;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public int entityPos;
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
|
||||
public int face;
|
||||
|
||||
public Vec3D vec;
|
||||
|
||||
public Entity entity;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.Minecraft$OS;
|
||||
|
||||
// $FF: synthetic class
|
||||
final class OperatingSystemLookup {
|
||||
|
||||
// $FF: synthetic field
|
||||
static final int[] lookup = new int[Minecraft$OS.values().length];
|
||||
|
||||
|
||||
static {
|
||||
try {
|
||||
lookup[Minecraft$OS.linux.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError var3) {
|
||||
;
|
||||
}
|
||||
|
||||
try {
|
||||
lookup[Minecraft$OS.solaris.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError var2) {
|
||||
;
|
||||
}
|
||||
|
||||
try {
|
||||
lookup[Minecraft$OS.windows.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError var1) {
|
||||
;
|
||||
}
|
||||
|
||||
try {
|
||||
lookup[Minecraft$OS.macos.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError var0) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
99
src/main/java/com/mojang/minecraft/ProgressBarDisplay.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.StopGameException;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class ProgressBarDisplay {
|
||||
|
||||
private String text = "";
|
||||
private Minecraft minecraft;
|
||||
private String title = "";
|
||||
private long start = System.currentTimeMillis();
|
||||
|
||||
|
||||
public ProgressBarDisplay(Minecraft var1) {
|
||||
this.minecraft = var1;
|
||||
}
|
||||
|
||||
public final void setTitle(String var1) {
|
||||
if(!this.minecraft.running) {
|
||||
throw new StopGameException();
|
||||
} else {
|
||||
this.title = var1;
|
||||
int var3 = this.minecraft.width * 240 / this.minecraft.height;
|
||||
int var2 = this.minecraft.height * 240 / this.minecraft.height;
|
||||
GL11.glClear(256);
|
||||
GL11.glMatrixMode(5889);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glOrtho(0.0D, (double)var3, (double)var2, 0.0D, 100.0D, 300.0D);
|
||||
GL11.glMatrixMode(5888);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(0.0F, 0.0F, -200.0F);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setText(String var1) {
|
||||
if(!this.minecraft.running) {
|
||||
throw new StopGameException();
|
||||
} else {
|
||||
this.text = var1;
|
||||
this.setProgress(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setProgress(int var1) {
|
||||
if(!this.minecraft.running) {
|
||||
throw new StopGameException();
|
||||
} else {
|
||||
long var2;
|
||||
if((var2 = System.currentTimeMillis()) - this.start < 0L || var2 - this.start >= 20L) {
|
||||
this.start = var2;
|
||||
int var4 = this.minecraft.width * 240 / this.minecraft.height;
|
||||
int var5 = this.minecraft.height * 240 / this.minecraft.height;
|
||||
GL11.glClear(16640);
|
||||
ShapeRenderer var6 = ShapeRenderer.instance;
|
||||
int var7 = this.minecraft.textureManager.load("/dirt.png");
|
||||
GL11.glBindTexture(3553, var7);
|
||||
float var10 = 32.0F;
|
||||
var6.begin();
|
||||
var6.color(4210752);
|
||||
var6.vertexUV(0.0F, (float)var5, 0.0F, 0.0F, (float)var5 / var10);
|
||||
var6.vertexUV((float)var4, (float)var5, 0.0F, (float)var4 / var10, (float)var5 / var10);
|
||||
var6.vertexUV((float)var4, 0.0F, 0.0F, (float)var4 / var10, 0.0F);
|
||||
var6.vertexUV(0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
|
||||
var6.end();
|
||||
if(var1 >= 0) {
|
||||
var7 = var4 / 2 - 50;
|
||||
int var8 = var5 / 2 + 16;
|
||||
GL11.glDisable(3553);
|
||||
var6.begin();
|
||||
var6.color(8421504);
|
||||
var6.vertex((float)var7, (float)var8, 0.0F);
|
||||
var6.vertex((float)var7, (float)(var8 + 2), 0.0F);
|
||||
var6.vertex((float)(var7 + 100), (float)(var8 + 2), 0.0F);
|
||||
var6.vertex((float)(var7 + 100), (float)var8, 0.0F);
|
||||
var6.color(8454016);
|
||||
var6.vertex((float)var7, (float)var8, 0.0F);
|
||||
var6.vertex((float)var7, (float)(var8 + 2), 0.0F);
|
||||
var6.vertex((float)(var7 + var1), (float)(var8 + 2), 0.0F);
|
||||
var6.vertex((float)(var7 + var1), (float)var8, 0.0F);
|
||||
var6.end();
|
||||
GL11.glEnable(3553);
|
||||
}
|
||||
|
||||
this.minecraft.fontRenderer.render(this.title, (var4 - this.minecraft.fontRenderer.getWidth(this.title)) / 2, var5 / 2 - 4 - 16, 16777215);
|
||||
this.minecraft.fontRenderer.render(this.text, (var4 - this.minecraft.fontRenderer.getWidth(this.text)) / 2, var5 / 2 - 4 + 8, 16777215);
|
||||
Display.update();
|
||||
|
||||
try {
|
||||
Thread.yield();
|
||||
} catch (Exception var9) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
244
src/main/java/com/mojang/minecraft/ResourceDownloadThread.java
Normal file
|
@ -0,0 +1,244 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ResourceDownloadThread extends Thread
|
||||
{
|
||||
public ResourceDownloadThread(File minecraftFolder, Minecraft minecraft)
|
||||
{
|
||||
this.minecraft = minecraft;
|
||||
|
||||
this.setName("Resource download thread");
|
||||
this.setDaemon(true);
|
||||
|
||||
dir = new File(minecraftFolder, "resources/");
|
||||
|
||||
if(!dir.exists() && !dir.mkdirs())
|
||||
{
|
||||
throw new RuntimeException("The working directory could not be created: " + dir);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
|
||||
URL base = new URL("http://dl.dropbox.com/u/40737374/minecraft_resources/");
|
||||
URL url = new URL(base, "resources/");
|
||||
|
||||
URLConnection con = url.openConnection();
|
||||
|
||||
con.setConnectTimeout(20000);
|
||||
|
||||
reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
|
||||
String line = null;
|
||||
|
||||
while((line = reader.readLine()) != null)
|
||||
{
|
||||
list.add(line);
|
||||
}
|
||||
|
||||
reader.close();
|
||||
|
||||
/*for(String s : list)
|
||||
{
|
||||
try {
|
||||
String split[] = s.split(",");
|
||||
int size = Integer.parseInt(split[1]);
|
||||
File file = new File(dir, split[0]);
|
||||
|
||||
if(!file.exists() || file.length() != size)
|
||||
{
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
} catch(SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
URL url1 = new URL(base, split[0].replaceAll(" ", "%20"));
|
||||
|
||||
download(url1, file, size);
|
||||
} else {
|
||||
int index = split[0].indexOf("/");
|
||||
|
||||
if(split[0].substring(0, index).equalsIgnoreCase("sound"))
|
||||
{
|
||||
minecraft.sound.registerSound(file, split[0].substring(index + 1, split[0].length() - 4).replaceAll("[1-9]", "").replaceAll("/", "."));
|
||||
//this.mc.audio.registerSound(split[0].substring(index + 1, split[0].length() - 4).replaceAll("[1-9]", "").replaceAll("/", "."), file.toURI().toURL(), true);
|
||||
} else if (split[0].substring(0, index).equalsIgnoreCase("music")) {
|
||||
if(split[0].contains("sweden"))
|
||||
{
|
||||
//this.mc.audio.registerMusic("menu", file.toURI().toURL(), true);
|
||||
}
|
||||
|
||||
//this.mc.audio.registerMusic("bg", file.toURI().toURL(), true);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!this.running) return;
|
||||
}*/
|
||||
|
||||
for(String s : list)
|
||||
{
|
||||
String split[] = s.split(",");
|
||||
int size = Integer.parseInt(split[1]);
|
||||
File file = new File(dir, split[0]);
|
||||
|
||||
File musicFolder = new File(dir, "music");
|
||||
|
||||
if(!file.exists() || file.length() != size)
|
||||
{
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
} catch(SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
URL url1 = new URL(base, split[0].replaceAll(" ", "%20"));
|
||||
|
||||
if(file.getPath().contains("music"))
|
||||
{
|
||||
if(file.getName().equals("minecraft.ogg") && !new File(musicFolder, "calm1.ogg").exists())
|
||||
{
|
||||
download(url1, file, size);
|
||||
} else if(file.getName().equals("clark.ogg") && !new File(musicFolder, "calm2.ogg").exists()) {
|
||||
download(url1, file, size);
|
||||
} else if(file.getName().equals("sweden.ogg") && !new File(musicFolder, "calm3.ogg").exists()) {
|
||||
download(url1, file, size);
|
||||
}
|
||||
} else {
|
||||
download(url1, file, size);
|
||||
}
|
||||
}
|
||||
|
||||
File minecraftOGG = new File(musicFolder, "minecraft.ogg");
|
||||
File clarkOGG = new File(musicFolder, "clark.ogg");
|
||||
File swedenOGG = new File(musicFolder, "sweden.ogg");
|
||||
|
||||
minecraftOGG.renameTo(new File(musicFolder, "calm1.ogg"));
|
||||
clarkOGG.renameTo(new File(musicFolder, "calm2.ogg"));
|
||||
swedenOGG.renameTo(new File(musicFolder, "calm3.ogg"));
|
||||
}
|
||||
|
||||
File soundsFolder = new File(dir, "sound");
|
||||
File stepsFolder = new File(soundsFolder, "step");
|
||||
|
||||
for(int i = 1; i <= 4; i++)
|
||||
{
|
||||
minecraft.sound.registerSound(new File(stepsFolder, "grass" + i + ".ogg"), "step/grass" + i + ".ogg");
|
||||
minecraft.sound.registerSound(new File(stepsFolder, "gravel" + i + ".ogg"), "step/gravel" + i + ".ogg");
|
||||
minecraft.sound.registerSound(new File(stepsFolder, "stone" + i + ".ogg"), "step/stone" + i + ".ogg");
|
||||
minecraft.sound.registerSound(new File(stepsFolder, "wood" + i + ".ogg"), "step/wood" + i + ".ogg");
|
||||
}
|
||||
|
||||
File musicFolder = new File(dir, "music");
|
||||
|
||||
for(int i = 1; i <= 3; i++)
|
||||
{
|
||||
minecraft.sound.registerMusic("calm" + i + ".ogg", new File(musicFolder, "calm" + i + ".ogg"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null)
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
this.finished = true;
|
||||
}
|
||||
|
||||
private File dir;
|
||||
private Minecraft minecraft;
|
||||
boolean running = false;
|
||||
|
||||
private boolean finished = false;
|
||||
private int progress = 0;
|
||||
|
||||
private void download(URL url, File file, int size)
|
||||
{
|
||||
System.out.println("Downloading: " + file.getName() + "...");
|
||||
|
||||
//minecraft.progressBar.setText(file.getName());
|
||||
|
||||
DataInputStream in = null;
|
||||
DataOutputStream out = null;
|
||||
|
||||
try
|
||||
{
|
||||
byte[] data = new byte[4096];
|
||||
|
||||
in = new DataInputStream(url.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
out = new DataOutputStream(fos);
|
||||
|
||||
int done = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int length = in.read(data);
|
||||
|
||||
if(length < 0)
|
||||
{
|
||||
in.close();
|
||||
out.close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
out.write(data, 0, length);
|
||||
|
||||
done += length;
|
||||
progress = (int)(((double)done / (double)size) * 100);
|
||||
} while(!running);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try
|
||||
{
|
||||
if(in != null)
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
|
||||
if(out != null)
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//minecraft.progressBar.setText("");
|
||||
progress = 0;
|
||||
|
||||
System.out.println("Downloaded: " + file.getName());
|
||||
}
|
||||
|
||||
public boolean isFinished()
|
||||
{
|
||||
return finished;
|
||||
}
|
||||
|
||||
public int getProgress()
|
||||
{
|
||||
return progress;
|
||||
}
|
||||
}
|
66
src/main/java/com/mojang/minecraft/SessionData.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class SessionData {
|
||||
|
||||
public static List allowedBlocks;
|
||||
public String username;
|
||||
public String sessionId;
|
||||
public String mppass;
|
||||
public boolean haspaid;
|
||||
|
||||
|
||||
public SessionData(String var1, String var2) {
|
||||
this.username = var1;
|
||||
this.sessionId = var2;
|
||||
}
|
||||
|
||||
static {
|
||||
(allowedBlocks = new ArrayList()).add(Block.STONE);
|
||||
allowedBlocks.add(Block.COBBLESTONE);
|
||||
allowedBlocks.add(Block.BRICK);
|
||||
allowedBlocks.add(Block.DIRT);
|
||||
allowedBlocks.add(Block.WOOD);
|
||||
allowedBlocks.add(Block.LOG);
|
||||
allowedBlocks.add(Block.LEAVES);
|
||||
allowedBlocks.add(Block.GLASS);
|
||||
allowedBlocks.add(Block.SLAB);
|
||||
allowedBlocks.add(Block.MOSSY_COBBLESTONE);
|
||||
allowedBlocks.add(Block.SAPLING);
|
||||
allowedBlocks.add(Block.DANDELION);
|
||||
allowedBlocks.add(Block.ROSE);
|
||||
allowedBlocks.add(Block.BROWN_MUSHROOM);
|
||||
allowedBlocks.add(Block.RED_MUSHROOM);
|
||||
allowedBlocks.add(Block.SAND);
|
||||
allowedBlocks.add(Block.GRAVEL);
|
||||
allowedBlocks.add(Block.SPONGE);
|
||||
allowedBlocks.add(Block.RED_WOOL);
|
||||
allowedBlocks.add(Block.ORANGE_WOOL);
|
||||
allowedBlocks.add(Block.YELLOW_WOOL);
|
||||
allowedBlocks.add(Block.LIME_WOOL);
|
||||
allowedBlocks.add(Block.GREEN_WOOL);
|
||||
allowedBlocks.add(Block.AQUA_GREEN_WOOL);
|
||||
allowedBlocks.add(Block.CYAN_WOOL);
|
||||
allowedBlocks.add(Block.BLUE_WOOL);
|
||||
allowedBlocks.add(Block.PURPLE_WOOL);
|
||||
allowedBlocks.add(Block.INDIGO_WOOL);
|
||||
allowedBlocks.add(Block.VIOLET_WOOL);
|
||||
allowedBlocks.add(Block.MAGENTA_WOOL);
|
||||
allowedBlocks.add(Block.PINK_WOOL);
|
||||
allowedBlocks.add(Block.BLACK_WOOL);
|
||||
allowedBlocks.add(Block.GRAY_WOOL);
|
||||
allowedBlocks.add(Block.WHITE_WOOL);
|
||||
allowedBlocks.add(Block.COAL_ORE);
|
||||
allowedBlocks.add(Block.IRON_ORE);
|
||||
allowedBlocks.add(Block.GOLD_ORE);
|
||||
allowedBlocks.add(Block.IRON_BLOCK);
|
||||
allowedBlocks.add(Block.GOLD_BLOCK);
|
||||
allowedBlocks.add(Block.BOOKSHELF);
|
||||
allowedBlocks.add(Block.TNT);
|
||||
allowedBlocks.add(Block.OBSIDIAN);
|
||||
allowedBlocks.add(Block.BEDROCK);
|
||||
}
|
||||
}
|
51
src/main/java/com/mojang/minecraft/SkinDownloadThread.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
import com.mojang.minecraft.player.Player;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class SkinDownloadThread extends Thread
|
||||
{
|
||||
public SkinDownloadThread(Minecraft minecraft)
|
||||
{
|
||||
super();
|
||||
|
||||
this.minecraft = minecraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(minecraft.session != null)
|
||||
{
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
try {
|
||||
connection = (HttpURLConnection)new URL("http://www.minecraft.net/skin/" + minecraft.session.username + ".png").openConnection();
|
||||
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(false);
|
||||
|
||||
connection.connect();
|
||||
|
||||
if(connection.getResponseCode() != 404)
|
||||
{
|
||||
Player.newTexture = ImageIO.read(connection.getInputStream());
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
} finally {
|
||||
if(connection != null)
|
||||
{
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Minecraft minecraft;
|
||||
}
|
27
src/main/java/com/mojang/minecraft/SleepForeverThread.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
public class SleepForeverThread extends Thread
|
||||
{
|
||||
public SleepForeverThread(Minecraft minecraft)
|
||||
{
|
||||
setDaemon(true);
|
||||
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
try {
|
||||
while(true)
|
||||
{
|
||||
Thread.sleep(2147483647L);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
public class StopGameException extends Error
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
21
src/main/java/com/mojang/minecraft/Timer.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package com.mojang.minecraft;
|
||||
|
||||
public class Timer
|
||||
{
|
||||
public Timer(float tps)
|
||||
{
|
||||
this.tps = tps;
|
||||
lastSysClock = System.currentTimeMillis();
|
||||
lastHRClock = System.nanoTime() / 1000000L;
|
||||
}
|
||||
|
||||
float tps;
|
||||
double lastHR;
|
||||
public int elapsedTicks;
|
||||
public float delta;
|
||||
public float speed = 1.0F;
|
||||
public float elapsedDelta = 0.0F;
|
||||
long lastSysClock;
|
||||
long lastHRClock;
|
||||
double adjustment = 1.0D;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.mojang.minecraft.gamemode;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.SessionData;
|
||||
import com.mojang.minecraft.gui.BlockSelectScreen;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.player.Player;
|
||||
|
||||
public class CreativeGameMode extends GameMode
|
||||
{
|
||||
public CreativeGameMode(Minecraft minecraft)
|
||||
{
|
||||
super(minecraft);
|
||||
|
||||
instantBreak = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Level level)
|
||||
{
|
||||
super.apply(level);
|
||||
|
||||
level.removeAllNonCreativeModeEntities();
|
||||
|
||||
level.creativeMode = true;
|
||||
level.growTrees = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
BlockSelectScreen blockSelectScreen = new BlockSelectScreen();
|
||||
|
||||
minecraft.setCurrentScreen(blockSelectScreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSurvival()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Player player)
|
||||
{
|
||||
for(int slot = 0; slot < 9; slot++)
|
||||
{
|
||||
player.inventory.count[slot] = 1;
|
||||
|
||||
if(player.inventory.slots[slot] <= 0)
|
||||
{
|
||||
player.inventory.slots[slot] = ((Block)SessionData.allowedBlocks.get(slot)).id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
108
src/main/java/com/mojang/minecraft/gamemode/GameMode.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package com.mojang.minecraft.gamemode;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.level.tile.Tile$SoundType;
|
||||
import com.mojang.minecraft.player.Player;
|
||||
|
||||
public class GameMode
|
||||
{
|
||||
public GameMode(Minecraft minecraft)
|
||||
{
|
||||
this.minecraft = minecraft;
|
||||
|
||||
instantBreak = false;
|
||||
}
|
||||
|
||||
public Minecraft minecraft;
|
||||
|
||||
public boolean instantBreak;
|
||||
|
||||
public void apply(Level level)
|
||||
{
|
||||
level.creativeMode = false;
|
||||
level.growTrees = true;
|
||||
}
|
||||
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
public void hitBlock(int x, int y, int z)
|
||||
{
|
||||
this.breakBlock(x, y, z);
|
||||
}
|
||||
|
||||
public boolean canPlace(int block)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void breakBlock(int x, int y, int z)
|
||||
{
|
||||
Level level = minecraft.level;
|
||||
Block block = Block.blocks[level.getTile(x, y, z)];
|
||||
|
||||
boolean success = level.netSetTile(x, y, z, 0);
|
||||
|
||||
if(block != null && success)
|
||||
{
|
||||
if(minecraft.isOnline())
|
||||
{
|
||||
minecraft.networkManager.sendBlockChange(x, y, z, 0, minecraft.player.inventory.getSelected());
|
||||
}
|
||||
|
||||
if(block.stepsound != Tile$SoundType.none)
|
||||
{
|
||||
level.playSound("step." + block.stepsound.name, (float)x, (float)y, (float)z, (block.stepsound.getVolume() + 1.0F) / 2.0F, block.stepsound.getPitch() * 0.8F);
|
||||
}
|
||||
|
||||
block.spawnBreakParticles(level, x, y, z, minecraft.particleManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void hitBlock(int x, int y, int z, int side)
|
||||
{
|
||||
}
|
||||
|
||||
public void resetHits()
|
||||
{
|
||||
}
|
||||
|
||||
public void applyCracks(float time)
|
||||
{
|
||||
}
|
||||
|
||||
public float getReachDistance()
|
||||
{
|
||||
return 5.0F;
|
||||
}
|
||||
|
||||
public boolean useItem(Player player, int type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void preparePlayer(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
public void spawnMob()
|
||||
{
|
||||
}
|
||||
|
||||
public void prepareLevel(Level level)
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isSurvival()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void apply(Player player)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
package com.mojang.minecraft.gamemode;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.MobSpawner;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.mob.Mob;
|
||||
import com.mojang.minecraft.player.Player;
|
||||
|
||||
public final class SurvivalGameMode extends GameMode
|
||||
{
|
||||
public SurvivalGameMode(Minecraft minecraft)
|
||||
{
|
||||
super(minecraft);
|
||||
}
|
||||
|
||||
private int hitX;
|
||||
private int hitY;
|
||||
private int hitZ;
|
||||
private int hits;
|
||||
private int hardness;
|
||||
private int hitDelay;
|
||||
private MobSpawner spawner;
|
||||
|
||||
@Override
|
||||
public void apply(Level level)
|
||||
{
|
||||
super.apply(level);
|
||||
|
||||
spawner = new MobSpawner(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitBlock(int x, int y, int z, int side)
|
||||
{
|
||||
if(hitDelay > 0)
|
||||
{
|
||||
hitDelay--;
|
||||
} else if(x == hitX && y == hitY && z == hitZ) {
|
||||
int type = minecraft.level.getTile(x, y, z);
|
||||
|
||||
if(type != 0)
|
||||
{
|
||||
Block block = Block.blocks[type];
|
||||
|
||||
hardness = block.getHardness();
|
||||
|
||||
block.spawnBlockParticles(minecraft.level, x, y, z, side, minecraft.particleManager);
|
||||
|
||||
hits++;
|
||||
|
||||
if(hits == hardness + 1)
|
||||
{
|
||||
breakBlock(x, y, z);
|
||||
|
||||
hits = 0;
|
||||
hitDelay = 5;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// TODO: I think if I don't set hits to 0 you can continue breaking from where you left off.
|
||||
|
||||
hits = 0;
|
||||
hitX = x;
|
||||
hitY = y;
|
||||
hitZ = z;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlace(int block)
|
||||
{
|
||||
return minecraft.player.inventory.removeResource(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(int x, int y, int z)
|
||||
{
|
||||
int block = minecraft.level.getTile(x, y, z);
|
||||
Block.blocks[block].onBreak(minecraft.level, x, y, z);
|
||||
|
||||
super.breakBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitBlock(int x, int y, int z)
|
||||
{
|
||||
int block = this.minecraft.level.getTile(x, y, z);
|
||||
|
||||
if(block > 0 && Block.blocks[block].getHardness() == 0)
|
||||
{
|
||||
breakBlock(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetHits()
|
||||
{
|
||||
this.hits = 0;
|
||||
this.hitDelay = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyCracks(float time)
|
||||
{
|
||||
if(hits <= 0)
|
||||
{
|
||||
minecraft.levelRenderer.cracks = 0.0F;
|
||||
} else {
|
||||
minecraft.levelRenderer.cracks = ((float)hits + time - 1.0F) / (float)hardness;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getReachDistance()
|
||||
{
|
||||
return 4.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useItem(Player player, int type)
|
||||
{
|
||||
Block block = Block.blocks[type];
|
||||
if(block == Block.RED_MUSHROOM && minecraft.player.inventory.removeResource(type))
|
||||
{
|
||||
player.hurt(null, 3);
|
||||
|
||||
return true;
|
||||
} else if(block == Block.BROWN_MUSHROOM && minecraft.player.inventory.removeResource(type)) {
|
||||
player.heal(5);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Player player)
|
||||
{
|
||||
player.inventory.slots[8] = Block.TNT.id;
|
||||
player.inventory.count[8] = (int) 1e+5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnMob()
|
||||
{
|
||||
int area = spawner.level.width * spawner.level.height * spawner.level.depth / 64 / 64 / 64;
|
||||
|
||||
if(spawner.level.random.nextInt(100) < area && spawner.level.countInstanceOf(Mob.class) < area * 20)
|
||||
{
|
||||
spawner.spawn(area, spawner.level.player, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareLevel(Level level)
|
||||
{
|
||||
spawner = new MobSpawner(level);
|
||||
|
||||
minecraft.progressBar.setText("Spawning..");
|
||||
|
||||
int area = level.width * level.height * level.depth / 800;
|
||||
|
||||
spawner.spawn(area, null, minecraft.progressBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Player player) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.SessionData;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class BlockSelectScreen extends GuiScreen {
|
||||
|
||||
public BlockSelectScreen() {
|
||||
this.grabsMouse = true;
|
||||
}
|
||||
|
||||
private int getBlockOnScreen(int var1, int var2) {
|
||||
for(int var3 = 0; var3 < SessionData.allowedBlocks.size(); ++var3) {
|
||||
int var4 = this.width / 2 + var3 % 9 * 24 + -108 - 3;
|
||||
int var5 = this.height / 2 + var3 / 9 * 24 + -60 + 3;
|
||||
if(var1 >= var4 && var1 <= var4 + 24 && var2 >= var5 - 12 && var2 <= var5 + 12) {
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
var1 = this.getBlockOnScreen(var1, var2);
|
||||
drawFadingBox(this.width / 2 - 120, 30, this.width / 2 + 120, 180, -1878719232, -1070583712);
|
||||
if(var1 >= 0) {
|
||||
var2 = this.width / 2 + var1 % 9 * 24 + -108;
|
||||
int var3 = this.height / 2 + var1 / 9 * 24 + -60;
|
||||
drawFadingBox(var2 - 3, var3 - 8, var2 + 23, var3 + 24 - 6, -1862270977, -1056964609);
|
||||
}
|
||||
|
||||
drawCenteredString(this.fontRenderer, "Select block", this.width / 2, 40, 16777215);
|
||||
TextureManager var7 = this.minecraft.textureManager;
|
||||
ShapeRenderer var8 = ShapeRenderer.instance;
|
||||
var2 = var7.load("/terrain.png");
|
||||
GL11.glBindTexture(3553, var2);
|
||||
|
||||
for(var2 = 0; var2 < SessionData.allowedBlocks.size(); ++var2) {
|
||||
Block var4 = (Block)SessionData.allowedBlocks.get(var2);
|
||||
GL11.glPushMatrix();
|
||||
int var5 = this.width / 2 + var2 % 9 * 24 + -108;
|
||||
int var6 = this.height / 2 + var2 / 9 * 24 + -60;
|
||||
GL11.glTranslatef((float)var5, (float)var6, 0.0F);
|
||||
GL11.glScalef(10.0F, 10.0F, 10.0F);
|
||||
GL11.glTranslatef(1.0F, 0.5F, 8.0F);
|
||||
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
if(var1 == var2) {
|
||||
GL11.glScalef(1.6F, 1.6F, 1.6F);
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-1.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(-1.0F, -1.0F, -1.0F);
|
||||
var8.begin();
|
||||
var4.renderFullbright(var8);
|
||||
var8.end();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final void onMouseClick(int var1, int var2, int var3) {
|
||||
if(var3 == 0) {
|
||||
this.minecraft.player.inventory.replaceSlot(this.getBlockOnScreen(var1, var2));
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
33
src/main/java/com/mojang/minecraft/gui/Button.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.Screen;
|
||||
|
||||
public class Button extends Screen {
|
||||
|
||||
int width;
|
||||
int height;
|
||||
public int x;
|
||||
public int y;
|
||||
public String text;
|
||||
public int id;
|
||||
public boolean active;
|
||||
public boolean visible;
|
||||
|
||||
|
||||
public Button(int var1, int var2, int var3, String var4) {
|
||||
this(var1, var2, var3, 200, 20, var4);
|
||||
}
|
||||
|
||||
protected Button(int var1, int var2, int var3, int var4, int var5, String var6) {
|
||||
this.width = 200;
|
||||
this.height = 20;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
this.id = var1;
|
||||
this.x = var2;
|
||||
this.y = var3;
|
||||
this.width = var4;
|
||||
this.height = 20;
|
||||
this.text = var6;
|
||||
}
|
||||
}
|
69
src/main/java/com/mojang/minecraft/gui/ChatInputScreen.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.net.NetworkManager;
|
||||
import com.mojang.minecraft.net.PacketType;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public final class ChatInputScreen extends GuiScreen {
|
||||
|
||||
private String message = "";
|
||||
private int counter = 0;
|
||||
|
||||
|
||||
public final void onOpen() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
}
|
||||
|
||||
public final void onClose() {
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
public final void tick() {
|
||||
++this.counter;
|
||||
}
|
||||
|
||||
protected final void onKeyPress(char var1, int var2) {
|
||||
if(var2 == 1) {
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
} else if(var2 == 28) {
|
||||
NetworkManager var10000 = this.minecraft.networkManager;
|
||||
String var4 = this.message.trim();
|
||||
NetworkManager var3 = var10000;
|
||||
if((var4 = var4.trim()).length() > 0) {
|
||||
var3.netHandler.send(PacketType.CHAT_MESSAGE, new Object[]{Integer.valueOf(-1), var4});
|
||||
}
|
||||
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
} else {
|
||||
if(var2 == 14 && this.message.length() > 0) {
|
||||
this.message = this.message.substring(0, this.message.length() - 1);
|
||||
}
|
||||
|
||||
if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!\\\"#%/()=+?[]{}<>@|$;".indexOf(var1) >= 0 && this.message.length() < 64 - (this.minecraft.session.username.length() + 2)) {
|
||||
this.message = this.message + var1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawBox(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
|
||||
drawString(this.fontRenderer, "> " + this.message + (this.counter / 6 % 2 == 0?"_":""), 4, this.height - 12, 14737632);
|
||||
}
|
||||
|
||||
protected final void onMouseClick(int var1, int var2, int var3) {
|
||||
if(var3 == 0 && this.minecraft.hud.hoveredPlayer != null) {
|
||||
if(this.message.length() > 0 && !this.message.endsWith(" ")) {
|
||||
this.message = this.message + " ";
|
||||
}
|
||||
|
||||
this.message = this.message + this.minecraft.hud.hoveredPlayer;
|
||||
var1 = 64 - (this.minecraft.session.username.length() + 2);
|
||||
if(this.message.length() > var1) {
|
||||
this.message = this.message.substring(0, var1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
57
src/main/java/com/mojang/minecraft/gui/ControlsScreen.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.GameSettings;
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.gui.OptionButton;
|
||||
|
||||
public final class ControlsScreen extends GuiScreen {
|
||||
|
||||
private GuiScreen parent;
|
||||
private String title = "Controls";
|
||||
private GameSettings settings;
|
||||
private int selected = -1;
|
||||
|
||||
|
||||
public ControlsScreen(GuiScreen var1, GameSettings var2) {
|
||||
this.parent = var1;
|
||||
this.settings = var2;
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
for(int var1 = 0; var1 < this.settings.bindings.length; ++var1) {
|
||||
this.buttons.add(new OptionButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.settings.getBinding(var1)));
|
||||
}
|
||||
|
||||
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168, "Done"));
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
for(int var2 = 0; var2 < this.settings.bindings.length; ++var2) {
|
||||
((Button)this.buttons.get(var2)).text = this.settings.getBinding(var2);
|
||||
}
|
||||
|
||||
if(var1.id == 200) {
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
} else {
|
||||
this.selected = var1.id;
|
||||
var1.text = "> " + this.settings.getBinding(var1.id) + " <";
|
||||
}
|
||||
}
|
||||
|
||||
protected final void onKeyPress(char var1, int var2) {
|
||||
if(this.selected >= 0) {
|
||||
this.settings.setBinding(this.selected, var2);
|
||||
((Button)this.buttons.get(this.selected)).text = this.settings.getBinding(this.selected);
|
||||
this.selected = -1;
|
||||
} else {
|
||||
super.onKeyPress(var1, var2);
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
26
src/main/java/com/mojang/minecraft/gui/ErrorScreen.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
|
||||
public final class ErrorScreen extends GuiScreen {
|
||||
|
||||
private String title;
|
||||
private String text;
|
||||
|
||||
|
||||
public ErrorScreen(String var1, String var2) {
|
||||
this.title = var1;
|
||||
this.text = var2;
|
||||
}
|
||||
|
||||
public final void onOpen() {}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, -12574688, -11530224);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 90, 16777215);
|
||||
drawCenteredString(this.fontRenderer, this.text, this.width / 2, 110, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
|
||||
protected final void onKeyPress(char var1, int var2) {}
|
||||
}
|
158
src/main/java/com/mojang/minecraft/gui/FontRenderer.java
Normal file
|
@ -0,0 +1,158 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.GameSettings;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class FontRenderer {
|
||||
|
||||
private int[] widthmap = new int[256];
|
||||
private int fontTexture = 0;
|
||||
private GameSettings settings;
|
||||
|
||||
|
||||
public FontRenderer(GameSettings var1, String var2, TextureManager var3) {
|
||||
this.settings = var1;
|
||||
|
||||
BufferedImage var14;
|
||||
try {
|
||||
var14 = ImageIO.read(TextureManager.class.getResourceAsStream(var2));
|
||||
} catch (IOException var13) {
|
||||
throw new RuntimeException(var13);
|
||||
}
|
||||
|
||||
int var4 = var14.getWidth();
|
||||
int var5 = var14.getHeight();
|
||||
int[] var6 = new int[var4 * var5];
|
||||
var14.getRGB(0, 0, var4, var5, var6, 0, var4);
|
||||
|
||||
for(int var15 = 0; var15 < 128; ++var15) {
|
||||
var5 = var15 % 16;
|
||||
int var7 = var15 / 16;
|
||||
int var8 = 0;
|
||||
|
||||
for(boolean var9 = false; var8 < 8 && !var9; ++var8) {
|
||||
int var10 = (var5 << 3) + var8;
|
||||
var9 = true;
|
||||
|
||||
for(int var11 = 0; var11 < 8 && var9; ++var11) {
|
||||
int var12 = ((var7 << 3) + var11) * var4;
|
||||
if((var6[var10 + var12] & 255) > 128) {
|
||||
var9 = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(var15 == 32) {
|
||||
var8 = 4;
|
||||
}
|
||||
|
||||
this.widthmap[var15] = var8;
|
||||
}
|
||||
|
||||
this.fontTexture = var3.load(var2);
|
||||
}
|
||||
|
||||
public final void render(String var1, int var2, int var3, int var4) {
|
||||
this.render(var1, var2 + 1, var3 + 1, var4, true);
|
||||
this.renderNoShadow(var1, var2, var3, var4);
|
||||
}
|
||||
|
||||
public final void renderNoShadow(String var1, int var2, int var3, int var4) {
|
||||
this.render(var1, var2, var3, var4, false);
|
||||
}
|
||||
|
||||
private void render(String var1, int var2, int var3, int var4, boolean var5) {
|
||||
if(var1 != null) {
|
||||
char[] var12 = var1.toCharArray();
|
||||
if(var5) {
|
||||
var4 = (var4 & 16579836) >> 2;
|
||||
}
|
||||
|
||||
GL11.glBindTexture(3553, this.fontTexture);
|
||||
ShapeRenderer var6 = ShapeRenderer.instance;
|
||||
ShapeRenderer.instance.begin();
|
||||
var6.color(var4);
|
||||
int var7 = 0;
|
||||
|
||||
for(int var8 = 0; var8 < var12.length; ++var8) {
|
||||
int var9;
|
||||
if(var12[var8] == 38 && var12.length > var8 + 1) {
|
||||
if((var4 = "0123456789abcdef".indexOf(var12[var8 + 1])) < 0) {
|
||||
var4 = 15;
|
||||
}
|
||||
|
||||
var9 = (var4 & 8) << 3;
|
||||
int var10 = (var4 & 1) * 191 + var9;
|
||||
int var11 = ((var4 & 2) >> 1) * 191 + var9;
|
||||
var4 = ((var4 & 4) >> 2) * 191 + var9;
|
||||
if(this.settings.anaglyph) {
|
||||
var9 = (var4 * 30 + var11 * 59 + var10 * 11) / 100;
|
||||
var11 = (var4 * 30 + var11 * 70) / 100;
|
||||
var10 = (var4 * 30 + var10 * 70) / 100;
|
||||
var4 = var9;
|
||||
var11 = var11;
|
||||
var10 = var10;
|
||||
}
|
||||
|
||||
var4 = var4 << 16 | var11 << 8 | var10;
|
||||
var8 += 2;
|
||||
if(var5) {
|
||||
var4 = (var4 & 16579836) >> 2;
|
||||
}
|
||||
|
||||
var6.color(var4);
|
||||
}
|
||||
|
||||
var4 = var12[var8] % 16 << 3;
|
||||
var9 = var12[var8] / 16 << 3;
|
||||
float var13 = 7.99F;
|
||||
var6.vertexUV((float)(var2 + var7), (float)var3 + var13, 0.0F, (float)var4 / 128.0F, ((float)var9 + var13) / 128.0F);
|
||||
var6.vertexUV((float)(var2 + var7) + var13, (float)var3 + var13, 0.0F, ((float)var4 + var13) / 128.0F, ((float)var9 + var13) / 128.0F);
|
||||
var6.vertexUV((float)(var2 + var7) + var13, (float)var3, 0.0F, ((float)var4 + var13) / 128.0F, (float)var9 / 128.0F);
|
||||
var6.vertexUV((float)(var2 + var7), (float)var3, 0.0F, (float)var4 / 128.0F, (float)var9 / 128.0F);
|
||||
var7 += this.widthmap[var12[var8]];
|
||||
}
|
||||
|
||||
var6.end();
|
||||
}
|
||||
}
|
||||
|
||||
public final int getWidth(String var1) {
|
||||
if(var1 == null) {
|
||||
return 0;
|
||||
} else {
|
||||
char[] var4 = var1.toCharArray();
|
||||
int var2 = 0;
|
||||
|
||||
for(int var3 = 0; var3 < var4.length; ++var3) {
|
||||
if(var4[var3] == 38) {
|
||||
++var3;
|
||||
} else {
|
||||
var2 += this.widthmap[var4[var3]];
|
||||
}
|
||||
}
|
||||
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
public static String stripColor(String var0) {
|
||||
char[] var3 = var0.toCharArray();
|
||||
String var1 = "";
|
||||
|
||||
for(int var2 = 0; var2 < var3.length; ++var2) {
|
||||
if(var3[var2] == 38) {
|
||||
++var2;
|
||||
} else {
|
||||
var1 = var1 + var3[var2];
|
||||
}
|
||||
}
|
||||
|
||||
return var1;
|
||||
}
|
||||
}
|
46
src/main/java/com/mojang/minecraft/gui/GameOverScreen.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GenerateLevelScreen;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.gui.LoadLevelScreen;
|
||||
import com.mojang.minecraft.gui.OptionsScreen;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class GameOverScreen extends GuiScreen {
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.clear();
|
||||
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 72, "Generate new level..."));
|
||||
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 96, "Load level.."));
|
||||
if(this.minecraft.session == null) {
|
||||
((Button)this.buttons.get(1)).active = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
if(var1.id == 0) {
|
||||
this.minecraft.setCurrentScreen(new OptionsScreen(this, this.minecraft.settings));
|
||||
}
|
||||
|
||||
if(var1.id == 1) {
|
||||
this.minecraft.setCurrentScreen(new GenerateLevelScreen(this));
|
||||
}
|
||||
|
||||
if(this.minecraft.session != null && var1.id == 2) {
|
||||
this.minecraft.setCurrentScreen(new LoadLevelScreen(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1615855616, -1602211792);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(2.0F, 2.0F, 2.0F);
|
||||
drawCenteredString(this.fontRenderer, "Game over!", this.width / 2 / 2, 30, 16777215);
|
||||
GL11.glPopMatrix();
|
||||
drawCenteredString(this.fontRenderer, "Score: &e" + this.minecraft.player.getScore(), this.width / 2, 100, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
|
||||
public final class GenerateLevelScreen extends GuiScreen {
|
||||
|
||||
private GuiScreen parent;
|
||||
|
||||
|
||||
public GenerateLevelScreen(GuiScreen var1) {
|
||||
this.parent = var1;
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.clear();
|
||||
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4, "Small"));
|
||||
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 24, "Normal"));
|
||||
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 48, "Huge"));
|
||||
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 4 + 120, "Cancel"));
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
if(var1.id == 3) {
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
} else {
|
||||
this.minecraft.generateLevel(var1.id);
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, "Generate new level", this.width / 2, 40, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
40
src/main/java/com/mojang/minecraft/gui/GuiMods.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
|
||||
public class GuiMods extends GuiScreen {
|
||||
GuiScreen parent = null;
|
||||
String title = "Optifine";
|
||||
|
||||
public GuiMods(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.add(new OptionButton(1, this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 + 24 * (0 >> 1), minecraft.settings.getSetting(11)));
|
||||
this.buttons.add(new OptionButton(2, this.width / 2 - 155 + 1 % 2 * 160, this.height / 6 + 24 * (1 >> 1), minecraft.settings.getSetting(12)));
|
||||
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done"));
|
||||
}
|
||||
|
||||
public final void onButtonClick(Button var1) {
|
||||
if(var1.id == 1) {
|
||||
minecraft.settings.toggleSetting(11, 0);
|
||||
var1.text = minecraft.settings.getSetting(11);
|
||||
}
|
||||
|
||||
if(var1.id == 2) {
|
||||
minecraft.settings.toggleSetting(12, 0);
|
||||
var1.text = minecraft.settings.getSetting(12);
|
||||
}
|
||||
|
||||
if(var1.id == 200) {
|
||||
minecraft.setCurrentScreen(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
40
src/main/java/com/mojang/minecraft/gui/GuiMore.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
|
||||
public class GuiMore extends GuiScreen {
|
||||
GuiScreen parent = null;
|
||||
String title;
|
||||
|
||||
public GuiMore(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
this.title = "More Options...";
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.add(new Button(50, this.width / 2 - 100, this.height / 6 + 0 + 12, "Mods"));
|
||||
this.buttons.add(new Button(100, this.width / 2 - 100, this.height / 6 + 25 + 12, "Optifine"));
|
||||
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done"));
|
||||
}
|
||||
|
||||
public final void onButtonClick(Button var1) {
|
||||
|
||||
if(var1.id == 50) {
|
||||
minecraft.setCurrentScreen(new GuiMods(this));
|
||||
}
|
||||
|
||||
if(var1.id == 100) {
|
||||
minecraft.setCurrentScreen(new GuiOptifine(this));
|
||||
}
|
||||
|
||||
if(var1.id == 200) {
|
||||
minecraft.setCurrentScreen(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
40
src/main/java/com/mojang/minecraft/gui/GuiOptifine.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
|
||||
public class GuiOptifine extends GuiScreen {
|
||||
GuiScreen parent = null;
|
||||
String title = "Optifine";
|
||||
|
||||
public GuiOptifine(GuiScreen parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.add(new OptionButton(1, this.width / 2 - 155 + 0 % 2 * 160, this.height / 6 + 24 * (0 >> 1), minecraft.settings.getSetting(8)));
|
||||
this.buttons.add(new OptionButton(2, this.width / 2 - 155 + 1 % 2 * 160, this.height / 6 + 24 * (1 >> 1), minecraft.settings.getSetting(9)));
|
||||
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168 + 12, "Done"));
|
||||
}
|
||||
|
||||
public final void onButtonClick(Button var1) {
|
||||
if(var1.id == 1) {
|
||||
minecraft.settings.toggleSetting(8, 0);
|
||||
var1.text = minecraft.settings.getSetting(8);
|
||||
}
|
||||
|
||||
if(var1.id == 2) {
|
||||
minecraft.settings.toggleSetting(9, 0);
|
||||
var1.text = minecraft.settings.getSetting(9);
|
||||
}
|
||||
|
||||
if(var1.id == 200) {
|
||||
minecraft.setCurrentScreen(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
117
src/main/java/com/mojang/minecraft/gui/GuiScreen.java
Normal file
|
@ -0,0 +1,117 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.FontRenderer;
|
||||
import com.mojang.minecraft.gui.Screen;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiScreen extends Screen {
|
||||
|
||||
protected Minecraft minecraft;
|
||||
protected int width;
|
||||
protected int height;
|
||||
protected List buttons = new ArrayList();
|
||||
public boolean grabsMouse = false;
|
||||
protected FontRenderer fontRenderer;
|
||||
|
||||
|
||||
public void render(int var1, int var2) {
|
||||
for(int var3 = 0; var3 < this.buttons.size(); ++var3) {
|
||||
Button var10000 = (Button)this.buttons.get(var3);
|
||||
Minecraft var7 = this.minecraft;
|
||||
Button var4 = var10000;
|
||||
if(var10000.visible) {
|
||||
FontRenderer var8 = var7.fontRenderer;
|
||||
GL11.glBindTexture(3553, var7.textureManager.load("/gui/gui.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
byte var9 = 1;
|
||||
boolean var6 = var1 >= var4.x && var2 >= var4.y && var1 < var4.x + var4.width && var2 < var4.y + var4.height;
|
||||
if(!var4.active) {
|
||||
var9 = 0;
|
||||
} else if(var6) {
|
||||
var9 = 2;
|
||||
}
|
||||
|
||||
var4.drawImage(var4.x, var4.y, 0, 46 + var9 * 20, var4.width / 2, var4.height);
|
||||
var4.drawImage(var4.x + var4.width / 2, var4.y, 200 - var4.width / 2, 46 + var9 * 20, var4.width / 2, var4.height);
|
||||
if(!var4.active) {
|
||||
Button.drawCenteredString(var8, var4.text, var4.x + var4.width / 2, var4.y + (var4.height - 8) / 2, -6250336);
|
||||
} else if(var6) {
|
||||
Button.drawCenteredString(var8, var4.text, var4.x + var4.width / 2, var4.y + (var4.height - 8) / 2, 16777120);
|
||||
} else {
|
||||
Button.drawCenteredString(var8, var4.text, var4.x + var4.width / 2, var4.y + (var4.height - 8) / 2, 14737632);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void onKeyPress(char var1, int var2) {
|
||||
if(var2 == 1) {
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void onMouseClick(int var1, int var2, int var3) {
|
||||
if(var3 == 0) {
|
||||
for(var3 = 0; var3 < this.buttons.size(); ++var3) {
|
||||
Button var4;
|
||||
Button var7;
|
||||
if((var7 = var4 = (Button)this.buttons.get(var3)).active && var1 >= var7.x && var2 >= var7.y && var1 < var7.x + var7.width && var2 < var7.y + var7.height) {
|
||||
this.onButtonClick(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void onButtonClick(Button var1) {}
|
||||
|
||||
public final void open(Minecraft var1, int var2, int var3) {
|
||||
this.minecraft = var1;
|
||||
this.fontRenderer = var1.fontRenderer;
|
||||
this.width = var2;
|
||||
this.height = var3;
|
||||
this.onOpen();
|
||||
}
|
||||
|
||||
public void onOpen() {}
|
||||
|
||||
public final void doInput() {
|
||||
while(Mouse.next()) {
|
||||
this.mouseEvent();
|
||||
}
|
||||
|
||||
while(Keyboard.next()) {
|
||||
this.keyboardEvent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void mouseEvent() {
|
||||
if(Mouse.getEventButtonState()) {
|
||||
int var1 = Mouse.getEventX() * this.width / this.minecraft.width;
|
||||
int var2 = this.height - Mouse.getEventY() * this.height / this.minecraft.height - 1;
|
||||
this.onMouseClick(var1, var2, Mouse.getEventButton());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void keyboardEvent() {
|
||||
if(Keyboard.getEventKeyState()) {
|
||||
this.onKeyPress(Keyboard.getEventCharacter(), Keyboard.getEventKey());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void tick() {}
|
||||
|
||||
public void onClose() {}
|
||||
}
|
215
src/main/java/com/mojang/minecraft/gui/HUDScreen.java
Normal file
|
@ -0,0 +1,215 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.ChatLine;
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.gamemode.SurvivalGameMode;
|
||||
import com.mojang.minecraft.gui.ChatInputScreen;
|
||||
import com.mojang.minecraft.gui.FontRenderer;
|
||||
import com.mojang.minecraft.gui.Screen;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.player.Inventory;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import com.mojang.util.MathHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class HUDScreen extends Screen {
|
||||
|
||||
public List chat = new ArrayList();
|
||||
private Random random = new Random();
|
||||
private Minecraft mc;
|
||||
private int width;
|
||||
private int height;
|
||||
public String hoveredPlayer = null;
|
||||
public int ticks = 0;
|
||||
|
||||
|
||||
public HUDScreen(Minecraft var1, int var2, int var3) {
|
||||
this.mc = var1;
|
||||
this.width = var2 * 240 / var3;
|
||||
this.height = var3 * 240 / var3;
|
||||
}
|
||||
|
||||
public final void render(float var1, boolean var2, int var3, int var4) {
|
||||
FontRenderer var5 = this.mc.fontRenderer;
|
||||
this.mc.renderer.enableGuiMode();
|
||||
TextureManager var6 = this.mc.textureManager;
|
||||
GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/gui.png"));
|
||||
ShapeRenderer var7 = ShapeRenderer.instance;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(3042);
|
||||
Inventory var8 = this.mc.player.inventory;
|
||||
this.imgZ = -90.0F;
|
||||
this.drawImage(this.width / 2 - 91, this.height - 22, 0, 0, 182, 22);
|
||||
this.drawImage(this.width / 2 - 91 - 1 + var8.selected * 20, this.height - 22 - 1, 0, 22, 24, 22);
|
||||
GL11.glBindTexture(3553, this.mc.textureManager.load("/gui/icons.png"));
|
||||
this.drawImage(this.width / 2 - 7, this.height / 2 - 7, 0, 0, 16, 16);
|
||||
boolean var9 = this.mc.player.invulnerableTime / 3 % 2 == 1;
|
||||
if(this.mc.player.invulnerableTime < 10) {
|
||||
var9 = false;
|
||||
}
|
||||
|
||||
int var10 = this.mc.player.health;
|
||||
int var11 = this.mc.player.lastHealth;
|
||||
this.random.setSeed((long)(this.ticks * 312871));
|
||||
int var12;
|
||||
int var14;
|
||||
int var15;
|
||||
int var26;
|
||||
if(this.mc.gamemode.isSurvival()) {
|
||||
for(var12 = 0; var12 < 10; ++var12) {
|
||||
byte var13 = 0;
|
||||
if(var9) {
|
||||
var13 = 1;
|
||||
}
|
||||
|
||||
var14 = this.width / 2 - 91 + (var12 << 3);
|
||||
var15 = this.height - 32;
|
||||
if(var10 <= 4) {
|
||||
var15 += this.random.nextInt(2);
|
||||
}
|
||||
|
||||
this.drawImage(var14, var15, 16 + var13 * 9, 0, 9, 9);
|
||||
if(var9) {
|
||||
if((var12 << 1) + 1 < var11) {
|
||||
this.drawImage(var14, var15, 70, 0, 9, 9);
|
||||
}
|
||||
|
||||
if((var12 << 1) + 1 == var11) {
|
||||
this.drawImage(var14, var15, 79, 0, 9, 9);
|
||||
}
|
||||
}
|
||||
|
||||
if((var12 << 1) + 1 < var10) {
|
||||
this.drawImage(var14, var15, 52, 0, 9, 9);
|
||||
}
|
||||
|
||||
if((var12 << 1) + 1 == var10) {
|
||||
this.drawImage(var14, var15, 61, 0, 9, 9);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.mc.player.isUnderWater()) {
|
||||
var12 = (int)Math.ceil((double)(this.mc.player.airSupply - 2) * 10.0D / 300.0D);
|
||||
var26 = (int)Math.ceil((double)this.mc.player.airSupply * 10.0D / 300.0D) - var12;
|
||||
|
||||
for(var14 = 0; var14 < var12 + var26; ++var14) {
|
||||
if(var14 < var12) {
|
||||
this.drawImage(this.width / 2 - 91 + (var14 << 3), this.height - 32 - 9, 16, 18, 9, 9);
|
||||
} else {
|
||||
this.drawImage(this.width / 2 - 91 + (var14 << 3), this.height - 32 - 9, 25, 18, 9, 9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(3042);
|
||||
|
||||
String var23;
|
||||
for(var12 = 0; var12 < var8.slots.length; ++var12) {
|
||||
var26 = this.width / 2 - 90 + var12 * 20;
|
||||
var14 = this.height - 16;
|
||||
if((var15 = var8.slots[var12]) > 0) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)var26, (float)var14, -50.0F);
|
||||
if(var8.popTime[var12] > 0) {
|
||||
float var18;
|
||||
float var21 = -MathHelper.sin((var18 = ((float)var8.popTime[var12] - var1) / 5.0F) * var18 * 3.1415927F) * 8.0F;
|
||||
float var19 = MathHelper.sin(var18 * var18 * 3.1415927F) + 1.0F;
|
||||
float var16 = MathHelper.sin(var18 * 3.1415927F) + 1.0F;
|
||||
GL11.glTranslatef(10.0F, var21 + 10.0F, 0.0F);
|
||||
GL11.glScalef(var19, var16, 1.0F);
|
||||
GL11.glTranslatef(-10.0F, -10.0F, 0.0F);
|
||||
}
|
||||
|
||||
GL11.glScalef(10.0F, 10.0F, 10.0F);
|
||||
GL11.glTranslatef(1.0F, 0.5F, 0.0F);
|
||||
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-1.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(-1.0F, -1.0F, -1.0F);
|
||||
int var20 = var6.load("/terrain.png");
|
||||
GL11.glBindTexture(3553, var20);
|
||||
var7.begin();
|
||||
Block.blocks[var15].renderFullbright(var7);
|
||||
var7.end();
|
||||
GL11.glPopMatrix();
|
||||
if(var8.count[var12] > 1) {
|
||||
var23 = "" + var8.count[var12];
|
||||
var5.render(var23, var26 + 19 - var5.getWidth(var23), var14 + 6, 16777215);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var5.render("0.30", 2, 2, 16777215);
|
||||
if(this.mc.settings.showFrameRate) {
|
||||
var5.render(this.mc.debug, 2, 12, 16777215);
|
||||
}
|
||||
|
||||
if(this.mc.gamemode instanceof SurvivalGameMode) {
|
||||
String var24 = "Score: &e" + this.mc.player.getScore();
|
||||
var5.render(var24, this.width - var5.getWidth(var24) - 2, 2, 16777215);
|
||||
var5.render("Arrows: " + this.mc.player.arrows, this.width / 2 + 8, this.height - 33, 16777215);
|
||||
}
|
||||
|
||||
byte var25 = 10;
|
||||
boolean var27 = false;
|
||||
if(this.mc.currentScreen instanceof ChatInputScreen) {
|
||||
var25 = 20;
|
||||
var27 = true;
|
||||
}
|
||||
|
||||
for(var14 = 0; var14 < this.chat.size() && var14 < var25; ++var14) {
|
||||
if(((ChatLine)this.chat.get(var14)).time < 200 || var27) {
|
||||
var5.render(((ChatLine)this.chat.get(var14)).message, 2, this.height - 8 - var14 * 9 - 20, 16777215);
|
||||
}
|
||||
}
|
||||
|
||||
var14 = this.width / 2;
|
||||
var15 = this.height / 2;
|
||||
this.hoveredPlayer = null;
|
||||
if(Keyboard.isKeyDown(15) && this.mc.networkManager != null && this.mc.networkManager.isConnected()) {
|
||||
List var22 = this.mc.networkManager.getPlayers();
|
||||
GL11.glEnable(3042);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glBegin(7);
|
||||
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.7F);
|
||||
GL11.glVertex2f((float)(var14 + 128), (float)(var15 - 68 - 12));
|
||||
GL11.glVertex2f((float)(var14 - 128), (float)(var15 - 68 - 12));
|
||||
GL11.glColor4f(0.2F, 0.2F, 0.2F, 0.8F);
|
||||
GL11.glVertex2f((float)(var14 - 128), (float)(var15 + 68));
|
||||
GL11.glVertex2f((float)(var14 + 128), (float)(var15 + 68));
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glEnable(3553);
|
||||
var23 = "Connected players:";
|
||||
var5.render(var23, var14 - var5.getWidth(var23) / 2, var15 - 64 - 12, 16777215);
|
||||
|
||||
for(var11 = 0; var11 < var22.size(); ++var11) {
|
||||
int var28 = var14 + var11 % 2 * 120 - 120;
|
||||
int var17 = var15 - 64 + (var11 / 2 << 3);
|
||||
if(var2 && var3 >= var28 && var4 >= var17 && var3 < var28 + 120 && var4 < var17 + 8) {
|
||||
this.hoveredPlayer = (String)var22.get(var11);
|
||||
var5.renderNoShadow((String)var22.get(var11), var28 + 2, var17, 16777215);
|
||||
} else {
|
||||
var5.renderNoShadow((String)var22.get(var11), var28, var17, 15658734);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void addChat(String var1) {
|
||||
this.chat.add(0, new ChatLine(var1));
|
||||
|
||||
while(this.chat.size() > 50) {
|
||||
this.chat.remove(this.chat.size() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
52
src/main/java/com/mojang/minecraft/gui/LevelDialog.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.LoadLevelScreen;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
final class LevelDialog extends Thread {
|
||||
|
||||
// $FF: synthetic field
|
||||
private LoadLevelScreen screen;
|
||||
|
||||
|
||||
LevelDialog(LoadLevelScreen var1) {
|
||||
super();
|
||||
this.screen = var1;
|
||||
}
|
||||
|
||||
public final void run() {
|
||||
JFileChooser var1;
|
||||
LoadLevelScreen var2;
|
||||
try {
|
||||
LoadLevelScreen var10000 = this.screen;
|
||||
var1 = new JFileChooser();
|
||||
var10000.chooser = var1;
|
||||
FileNameExtensionFilter var3 = new FileNameExtensionFilter("Minecraft levels", new String[]{"mine"});
|
||||
var2 = this.screen;
|
||||
this.screen.chooser.setFileFilter(var3);
|
||||
var2 = this.screen;
|
||||
this.screen.chooser.setMultiSelectionEnabled(false);
|
||||
int var7;
|
||||
if(this.screen.saving) {
|
||||
var2 = this.screen;
|
||||
var7 = this.screen.chooser.showSaveDialog(this.screen.minecraft.canvas);
|
||||
} else {
|
||||
var2 = this.screen;
|
||||
var7 = this.screen.chooser.showOpenDialog(this.screen.minecraft.canvas);
|
||||
}
|
||||
|
||||
if(var7 == 0) {
|
||||
(var2 = this.screen).selectedFile = this.screen.chooser.getSelectedFile();
|
||||
}
|
||||
} finally {
|
||||
boolean var6 = false;
|
||||
var2 = this.screen;
|
||||
this.screen.frozen = false;
|
||||
var1 = null;
|
||||
var2 = this.screen;
|
||||
this.screen.chooser = var1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
85
src/main/java/com/mojang/minecraft/gui/LevelNameScreen.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public final class LevelNameScreen extends GuiScreen {
|
||||
|
||||
private GuiScreen parent;
|
||||
private String title = "Enter level name:";
|
||||
private int id;
|
||||
private String name;
|
||||
private int counter = 0;
|
||||
|
||||
|
||||
public LevelNameScreen(GuiScreen var1, String var2, int var3) {
|
||||
this.parent = var1;
|
||||
this.id = var3;
|
||||
this.name = var2;
|
||||
if(this.name.equals("-")) {
|
||||
this.name = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.clear();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4 + 120, "Save"));
|
||||
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 144, "Cancel"));
|
||||
((Button)this.buttons.get(0)).active = this.name.trim().length() > 1;
|
||||
}
|
||||
|
||||
public final void onClose() {
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
public final void tick() {
|
||||
++this.counter;
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
if(var1.active) {
|
||||
if(var1.id == 0 && this.name.trim().length() > 1) {
|
||||
Minecraft var10000 = this.minecraft;
|
||||
int var10001 = this.id;
|
||||
String var2 = this.name.trim();
|
||||
int var3 = var10001;
|
||||
Minecraft var4 = var10000;
|
||||
var10000.levelIo.saveOnline(var4.level, var4.host, var4.session.username, var4.session.sessionId, var2, var3);
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
|
||||
if(var1.id == 1) {
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected final void onKeyPress(char var1, int var2) {
|
||||
if(var2 == 14 && this.name.length() > 0) {
|
||||
this.name = this.name.substring(0, this.name.length() - 1);
|
||||
}
|
||||
|
||||
if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ,.:-_\'*!\"#%/()=+?[]{}<>".indexOf(var1) >= 0 && this.name.length() < 64) {
|
||||
this.name = this.name + var1;
|
||||
}
|
||||
|
||||
((Button)this.buttons.get(0)).active = this.name.trim().length() > 1;
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 40, 16777215);
|
||||
int var3 = this.width / 2 - 100;
|
||||
int var4 = this.height / 2 - 10;
|
||||
drawBox(var3 - 1, var4 - 1, var3 + 200 + 1, var4 + 20 + 1, -6250336);
|
||||
drawBox(var3, var4, var3 + 200, var4 + 20, -16777216);
|
||||
drawString(this.fontRenderer, this.name + (this.counter / 6 % 2 == 0?"_":""), var3 + 4, var4 + 6, 14737632);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
164
src/main/java/com/mojang/minecraft/gui/LoadLevelScreen.java
Normal file
|
@ -0,0 +1,164 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.gui.LevelDialog;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class LoadLevelScreen extends GuiScreen implements Runnable {
|
||||
|
||||
protected GuiScreen parent;
|
||||
private boolean finished = false;
|
||||
private boolean loaded = false;
|
||||
private String[] levels = null;
|
||||
private String status = "";
|
||||
protected String title = "Load level";
|
||||
boolean frozen = false;
|
||||
JFileChooser chooser;
|
||||
protected boolean saving = false;
|
||||
protected File selectedFile;
|
||||
|
||||
|
||||
public LoadLevelScreen(GuiScreen var1) {
|
||||
this.parent = var1;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
if(this.frozen) {
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
} catch (InterruptedException var2) {
|
||||
var2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
this.status = "Getting level list..";
|
||||
URL var1 = new URL("http://" + this.minecraft.host + "/listmaps.jsp?user=" + this.minecraft.session.username);
|
||||
BufferedReader var4 = new BufferedReader(new InputStreamReader(var1.openConnection().getInputStream()));
|
||||
this.levels = var4.readLine().split(";");
|
||||
if(this.levels.length >= 5) {
|
||||
this.setLevels(this.levels);
|
||||
this.loaded = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.status = this.levels[0];
|
||||
this.finished = true;
|
||||
} catch (Exception var3) {
|
||||
var3.printStackTrace();
|
||||
this.status = "Failed to load levels";
|
||||
this.finished = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void setLevels(String[] var1) {
|
||||
for(int var2 = 0; var2 < 5; ++var2) {
|
||||
((Button)this.buttons.get(var2)).active = !var1[var2].equals("-");
|
||||
((Button)this.buttons.get(var2)).text = var1[var2];
|
||||
((Button)this.buttons.get(var2)).visible = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onOpen() {
|
||||
(new Thread(this)).start();
|
||||
|
||||
for(int var1 = 0; var1 < 5; ++var1) {
|
||||
this.buttons.add(new Button(var1, this.width / 2 - 100, this.height / 6 + var1 * 24, "---"));
|
||||
((Button)this.buttons.get(var1)).visible = false;
|
||||
((Button)this.buttons.get(var1)).active = false;
|
||||
}
|
||||
|
||||
this.buttons.add(new Button(5, this.width / 2 - 100, this.height / 6 + 120 + 12, "Load file..."));
|
||||
this.buttons.add(new Button(6, this.width / 2 - 100, this.height / 6 + 168, "Cancel"));
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
if(!this.frozen) {
|
||||
if(var1.active) {
|
||||
if(this.loaded && var1.id < 5) {
|
||||
this.openLevel(var1.id);
|
||||
}
|
||||
|
||||
if(this.finished || this.loaded && var1.id == 5) {
|
||||
this.frozen = true;
|
||||
LevelDialog var2;
|
||||
(var2 = new LevelDialog(this)).setDaemon(true);
|
||||
SwingUtilities.invokeLater(var2);
|
||||
}
|
||||
|
||||
if(this.finished || this.loaded && var1.id == 6) {
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void openLevel(File var1) {
|
||||
File var2 = var1;
|
||||
Minecraft var4 = this.minecraft;
|
||||
Level var5;
|
||||
boolean var10000;
|
||||
if((var5 = this.minecraft.levelIo.load(var2)) == null) {
|
||||
var10000 = false;
|
||||
} else {
|
||||
var4.setLevel(var5);
|
||||
var10000 = true;
|
||||
}
|
||||
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
}
|
||||
|
||||
protected void openLevel(int var1) {
|
||||
this.minecraft.loadOnlineLevel(this.minecraft.session.username, var1);
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
|
||||
public void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
|
||||
if(this.frozen) {
|
||||
drawCenteredString(this.fontRenderer, "Selecting file..", this.width / 2, this.height / 2 - 4, 16777215);
|
||||
|
||||
try {
|
||||
Thread.sleep(20L);
|
||||
} catch (InterruptedException var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if(!this.loaded) {
|
||||
drawCenteredString(this.fontRenderer, this.status, this.width / 2, this.height / 2 - 4, 16777215);
|
||||
}
|
||||
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
||||
|
||||
public final void onClose() {
|
||||
super.onClose();
|
||||
if(this.chooser != null) {
|
||||
this.chooser.cancelSelection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void tick() {
|
||||
super.tick();
|
||||
if(this.selectedFile != null) {
|
||||
this.openLevel(this.selectedFile);
|
||||
this.selectedFile = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
10
src/main/java/com/mojang/minecraft/gui/OptionButton.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
|
||||
public final class OptionButton extends Button {
|
||||
|
||||
public OptionButton(int var1, int var2, int var3, String var4) {
|
||||
super(var1, var2, var3, 150, 20, var4);
|
||||
}
|
||||
}
|
58
src/main/java/com/mojang/minecraft/gui/OptionsScreen.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.GameSettings;
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.ControlsScreen;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.gui.OptionButton;
|
||||
|
||||
public final class OptionsScreen extends GuiScreen {
|
||||
|
||||
private GuiScreen parent;
|
||||
private String title = "Options";
|
||||
private GameSettings settings;
|
||||
|
||||
|
||||
public OptionsScreen(GuiScreen var1, GameSettings var2) {
|
||||
this.parent = var1;
|
||||
this.settings = var2;
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
for(int var1 = 0; var1 < this.settings.settingCount; ++var1) {
|
||||
this.buttons.add(new OptionButton(var1, this.width / 2 - 155 + var1 % 2 * 160, this.height / 6 + 24 * (var1 >> 1), this.settings.getSetting(var1)));
|
||||
}
|
||||
|
||||
this.buttons.add(new Button(50, this.width / 2 - 100, this.height / 6 + 95 + 12, "More..."));
|
||||
this.buttons.add(new Button(100, this.width / 2 - 100, this.height / 6 + 120 + 12, "Controls..."));
|
||||
this.buttons.add(new Button(200, this.width / 2 - 100, this.height / 6 + 168, "Done"));
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
if(var1.active) {
|
||||
if(var1.id < 100) {
|
||||
this.settings.toggleSetting(var1.id, 1);
|
||||
var1.text = this.settings.getSetting(var1.id);
|
||||
}
|
||||
|
||||
if(var1.id == 50) {
|
||||
this.minecraft.setCurrentScreen(new GuiMore(this));
|
||||
}
|
||||
|
||||
if(var1.id == 100) {
|
||||
this.minecraft.setCurrentScreen(new ControlsScreen(this, this.settings));
|
||||
}
|
||||
|
||||
if(var1.id == 200) {
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, this.title, this.width / 2, 20, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
63
src/main/java/com/mojang/minecraft/gui/PauseScreen.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GenerateLevelScreen;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.gui.LoadLevelScreen;
|
||||
import com.mojang.minecraft.gui.OptionsScreen;
|
||||
import com.mojang.minecraft.gui.SaveLevelScreen;
|
||||
|
||||
public final class PauseScreen extends GuiScreen {
|
||||
|
||||
public final void onOpen() {
|
||||
this.buttons.clear();
|
||||
this.buttons.add(new Button(0, this.width / 2 - 100, this.height / 4, "Options..."));
|
||||
this.buttons.add(new Button(1, this.width / 2 - 100, this.height / 4 + 24, "Generate new level..."));
|
||||
this.buttons.add(new Button(2, this.width / 2 - 100, this.height / 4 + 48, "Save level.."));
|
||||
this.buttons.add(new Button(3, this.width / 2 - 100, this.height / 4 + 72, "Load level.."));
|
||||
this.buttons.add(new Button(4, this.width / 2 - 100, this.height / 4 + 120, "Back to game"));
|
||||
if(this.minecraft.session == null) {
|
||||
((Button)this.buttons.get(2)).active = false;
|
||||
((Button)this.buttons.get(3)).active = false;
|
||||
}
|
||||
|
||||
if(this.minecraft.networkManager != null) {
|
||||
((Button)this.buttons.get(1)).active = false;
|
||||
((Button)this.buttons.get(2)).active = false;
|
||||
((Button)this.buttons.get(3)).active = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected final void onButtonClick(Button var1) {
|
||||
if(var1.id == 0) {
|
||||
this.minecraft.setCurrentScreen(new OptionsScreen(this, this.minecraft.settings));
|
||||
}
|
||||
|
||||
if(var1.id == 1) {
|
||||
this.minecraft.setCurrentScreen(new GenerateLevelScreen(this));
|
||||
}
|
||||
|
||||
if(this.minecraft.session != null) {
|
||||
if(var1.id == 2) {
|
||||
this.minecraft.setCurrentScreen(new SaveLevelScreen(this));
|
||||
}
|
||||
|
||||
if(var1.id == 3) {
|
||||
this.minecraft.setCurrentScreen(new LoadLevelScreen(this));
|
||||
}
|
||||
}
|
||||
|
||||
if(var1.id == 4) {
|
||||
this.minecraft.setCurrentScreen((GuiScreen)null);
|
||||
this.minecraft.grabMouse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
drawFadingBox(0, 0, this.width, this.height, 1610941696, -1607454624);
|
||||
drawCenteredString(this.fontRenderer, "Game menu", this.width / 2, 40, 16777215);
|
||||
super.render(var1, var2);
|
||||
}
|
||||
}
|
56
src/main/java/com/mojang/minecraft/gui/SaveLevelScreen.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.gui.Button;
|
||||
import com.mojang.minecraft.gui.GuiScreen;
|
||||
import com.mojang.minecraft.gui.LevelNameScreen;
|
||||
import com.mojang.minecraft.gui.LoadLevelScreen;
|
||||
import java.io.File;
|
||||
|
||||
public final class SaveLevelScreen extends LoadLevelScreen {
|
||||
|
||||
public SaveLevelScreen(GuiScreen var1) {
|
||||
super(var1);
|
||||
this.title = "Save level";
|
||||
this.saving = true;
|
||||
}
|
||||
|
||||
public final void onOpen() {
|
||||
super.onOpen();
|
||||
((Button)this.buttons.get(5)).text = "Save file...";
|
||||
}
|
||||
|
||||
protected final void setLevels(String[] var1) {
|
||||
for(int var2 = 0; var2 < 5; ++var2) {
|
||||
((Button)this.buttons.get(var2)).text = var1[var2];
|
||||
((Button)this.buttons.get(var2)).visible = true;
|
||||
((Button)this.buttons.get(var2)).active = this.minecraft.session.haspaid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final void render(int var1, int var2) {
|
||||
super.render(var1, var2);
|
||||
if(!this.minecraft.session.haspaid) {
|
||||
drawFadingBox(this.width / 2 - 80, 72, this.width / 2 + 80, 120, -536870912, -536870912);
|
||||
drawCenteredString(this.fontRenderer, "Premium only!", this.width / 2, 80, 16748688);
|
||||
drawCenteredString(this.fontRenderer, "Purchase the game to be able", this.width / 2, 96, 14712960);
|
||||
drawCenteredString(this.fontRenderer, "to save your levels online.", this.width / 2, 104, 14712960);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void openLevel(File var1) {
|
||||
if(!var1.getName().endsWith(".mine")) {
|
||||
var1 = new File(var1.getParentFile(), var1.getName() + ".mine");
|
||||
}
|
||||
|
||||
File var2 = var1;
|
||||
Minecraft var3 = this.minecraft;
|
||||
this.minecraft.levelIo.save(var3.level, var2);
|
||||
this.minecraft.setCurrentScreen(this.parent);
|
||||
}
|
||||
|
||||
protected final void openLevel(int var1) {
|
||||
this.minecraft.setCurrentScreen(new LevelNameScreen(this, ((Button)this.buttons.get(var1)).text, var1));
|
||||
}
|
||||
}
|
75
src/main/java/com/mojang/minecraft/gui/Screen.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package com.mojang.minecraft.gui;
|
||||
|
||||
import com.mojang.minecraft.gui.FontRenderer;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Screen {
|
||||
|
||||
protected float imgZ = 0.0F;
|
||||
|
||||
|
||||
protected static void drawBox(int var0, int var1, int var2, int var3, int var4) {
|
||||
float var5 = (float)(var4 >>> 24) / 255.0F;
|
||||
float var6 = (float)(var4 >> 16 & 255) / 255.0F;
|
||||
float var7 = (float)(var4 >> 8 & 255) / 255.0F;
|
||||
float var9 = (float)(var4 & 255) / 255.0F;
|
||||
ShapeRenderer var8 = ShapeRenderer.instance;
|
||||
GL11.glEnable(3042);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(var6, var7, var9, var5);
|
||||
var8.begin();
|
||||
var8.vertex((float)var0, (float)var3, 0.0F);
|
||||
var8.vertex((float)var2, (float)var3, 0.0F);
|
||||
var8.vertex((float)var2, (float)var1, 0.0F);
|
||||
var8.vertex((float)var0, (float)var1, 0.0F);
|
||||
var8.end();
|
||||
GL11.glEnable(3553);
|
||||
GL11.glDisable(3042);
|
||||
}
|
||||
|
||||
protected static void drawFadingBox(int var0, int var1, int var2, int var3, int var4, int var5) {
|
||||
float var6 = (float)(var4 >>> 24) / 255.0F;
|
||||
float var7 = (float)(var4 >> 16 & 255) / 255.0F;
|
||||
float var8 = (float)(var4 >> 8 & 255) / 255.0F;
|
||||
float var12 = (float)(var4 & 255) / 255.0F;
|
||||
float var9 = (float)(var5 >>> 24) / 255.0F;
|
||||
float var10 = (float)(var5 >> 16 & 255) / 255.0F;
|
||||
float var11 = (float)(var5 >> 8 & 255) / 255.0F;
|
||||
float var13 = (float)(var5 & 255) / 255.0F;
|
||||
GL11.glDisable(3553);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glBegin(7);
|
||||
GL11.glColor4f(var7, var8, var12, var6);
|
||||
GL11.glVertex2f((float)var2, (float)var1);
|
||||
GL11.glVertex2f((float)var0, (float)var1);
|
||||
GL11.glColor4f(var10, var11, var13, var9);
|
||||
GL11.glVertex2f((float)var0, (float)var3);
|
||||
GL11.glVertex2f((float)var2, (float)var3);
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(3042);
|
||||
GL11.glEnable(3553);
|
||||
}
|
||||
|
||||
public static void drawCenteredString(FontRenderer var0, String var1, int var2, int var3, int var4) {
|
||||
var0.render(var1, var2 - var0.getWidth(var1) / 2, var3, var4);
|
||||
}
|
||||
|
||||
public static void drawString(FontRenderer var0, String var1, int var2, int var3, int var4) {
|
||||
var0.render(var1, var2, var3, var4);
|
||||
}
|
||||
|
||||
public final void drawImage(int var1, int var2, int var3, int var4, int var5, int var6) {
|
||||
float var7 = 0.00390625F;
|
||||
float var8 = 0.00390625F;
|
||||
ShapeRenderer var9 = ShapeRenderer.instance;
|
||||
ShapeRenderer.instance.begin();
|
||||
var9.vertexUV((float)var1, (float)(var2 + var6), this.imgZ, (float)var3 * var7, (float)(var4 + var6) * var8);
|
||||
var9.vertexUV((float)(var1 + var5), (float)(var2 + var6), this.imgZ, (float)(var3 + var5) * var7, (float)(var4 + var6) * var8);
|
||||
var9.vertexUV((float)(var1 + var5), (float)var2, this.imgZ, (float)(var3 + var5) * var7, (float)var4 * var8);
|
||||
var9.vertexUV((float)var1, (float)var2, this.imgZ, (float)var3 * var7, (float)var4 * var8);
|
||||
var9.end();
|
||||
}
|
||||
}
|
294
src/main/java/com/mojang/minecraft/item/Arrow.java
Normal file
|
@ -0,0 +1,294 @@
|
|||
package com.mojang.minecraft.item;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.player.Player;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import com.mojang.util.MathHelper;
|
||||
import java.util.List;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Arrow extends Entity
|
||||
{
|
||||
public Arrow(Level level1, Entity owner, float x, float y, float z, float unknown0, float unknown1, float unknown2)
|
||||
{
|
||||
super(level1);
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
setSize(0.3F, 0.5F);
|
||||
|
||||
heightOffset = bbHeight / 2.0F;
|
||||
damage = 3;
|
||||
|
||||
if(!(owner instanceof Player))
|
||||
{
|
||||
type = 1;
|
||||
} else {
|
||||
damage = 7;
|
||||
}
|
||||
|
||||
heightOffset = 0.25F;
|
||||
|
||||
float unknown3 = MathHelper.cos(-unknown0 * 0.017453292F - 3.1415927F);
|
||||
float unknown4 = MathHelper.sin(-unknown0 * 0.017453292F - 3.1415927F);
|
||||
|
||||
unknown0 = MathHelper.cos(-unknown1 * 0.017453292F);
|
||||
unknown1 = MathHelper.sin(-unknown1 * 0.017453292F);
|
||||
|
||||
slide = false;
|
||||
|
||||
gravity = 1.0F / unknown2;
|
||||
|
||||
xo -= unknown3 * 0.2F;
|
||||
zo += unknown4 * 0.2F;
|
||||
|
||||
x -= unknown3 * 0.2F;
|
||||
z += unknown4 * 0.2F;
|
||||
|
||||
xd = unknown4 * unknown0 * unknown2;
|
||||
yd = unknown1 * unknown2;
|
||||
zd = unknown3 * unknown0 * unknown2;
|
||||
|
||||
setPos(x, y, z);
|
||||
|
||||
unknown3 = MathHelper.sqrt(xd * xd + zd * zd);
|
||||
|
||||
yRotO = yRot = (float)(Math.atan2((double)xd, (double)zd) * 180.0D / 3.1415927410125732D);
|
||||
xRotO = xRot = (float)(Math.atan2((double)yd, (double)unknown3) * 180.0D / 3.1415927410125732D);
|
||||
|
||||
makeStepSound = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
time++;
|
||||
|
||||
xRotO = xRot;
|
||||
yRotO = yRot;
|
||||
|
||||
xo = x;
|
||||
yo = y;
|
||||
zo = z;
|
||||
|
||||
if(hasHit)
|
||||
{
|
||||
stickTime++;
|
||||
|
||||
if(type == 0)
|
||||
{
|
||||
if(stickTime >= 300 && Math.random() < 0.009999999776482582D)
|
||||
{
|
||||
remove();
|
||||
}
|
||||
} else if(type == 1 && stickTime >= 20) {
|
||||
remove();
|
||||
}
|
||||
} else {
|
||||
xd *= 0.998F;
|
||||
yd *= 0.998F;
|
||||
zd *= 0.998F;
|
||||
|
||||
yd -= 0.02F * gravity;
|
||||
|
||||
int unknown0 = (int)(MathHelper.sqrt(xd * xd + yd * yd + zd * zd) / 0.2F + 1.0F);
|
||||
|
||||
float x0 = xd / (float)unknown0;
|
||||
float y0 = yd / (float)unknown0;
|
||||
float z0 = zd / (float)unknown0;
|
||||
|
||||
for(int unknown4 = 0; unknown4 < unknown0 && !collision; unknown4++)
|
||||
{
|
||||
AABB unknown5 = bb.expand(x0, y0, z0);
|
||||
|
||||
if(level.getCubes(unknown5).size() > 0)
|
||||
{
|
||||
collision = true;
|
||||
}
|
||||
|
||||
List blockMapEntitiesList = level.blockMap.getEntities(this, unknown5);
|
||||
|
||||
for(int currentEntity = 0; currentEntity < blockMapEntitiesList.size(); currentEntity++)
|
||||
{
|
||||
Entity entity = (Entity)blockMapEntitiesList.get(currentEntity);
|
||||
|
||||
if((entity).isShootable() && (entity != owner || time > 5))
|
||||
{
|
||||
entity.hurt(this, damage);
|
||||
|
||||
collision = true;
|
||||
|
||||
remove();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!collision)
|
||||
{
|
||||
bb.move(x0, y0, z0);
|
||||
|
||||
x += x0;
|
||||
y += y0;
|
||||
z += z0;
|
||||
|
||||
blockMap.moved(this);
|
||||
}
|
||||
}
|
||||
|
||||
if(collision)
|
||||
{
|
||||
hasHit = true;
|
||||
|
||||
xd = yd = zd = 0.0F;
|
||||
}
|
||||
|
||||
if(!hasHit)
|
||||
{
|
||||
float unknown6 = MathHelper.sqrt(xd * xd + zd * zd);
|
||||
|
||||
yRot = (float)(Math.atan2((double)xd, (double)zd) * 180.0D / 3.1415927410125732D);
|
||||
|
||||
for(xRot = (float)(Math.atan2((double)yd, (double)unknown6) * 180.0D / 3.1415927410125732D); xRot - xRotO < -180.0F; xRotO -= 360.0F)
|
||||
{
|
||||
// TODO: ?.
|
||||
}
|
||||
|
||||
while(xRot - xRotO >= 180.0F)
|
||||
{
|
||||
xRotO += 360.0F;
|
||||
}
|
||||
|
||||
while(yRot - yRotO < -180.0F)
|
||||
{
|
||||
yRotO -= 360.0F;
|
||||
}
|
||||
|
||||
while(yRot - yRotO >= 180.0F)
|
||||
{
|
||||
yRotO += 360.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TextureManager textureManager, float unknown0)
|
||||
{
|
||||
textureId = textureManager.load("/item/arrows.png");
|
||||
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
|
||||
|
||||
float brightness = level.getBrightness((int)x, (int)y, (int)z);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(brightness, brightness, brightness, 1.0F);
|
||||
GL11.glTranslatef(xo + (x - xo) * unknown0, this.yo + (this.y - this.yo) * unknown0 - this.heightOffset / 2.0F, this.zo + (this.z - this.zo) * unknown0);
|
||||
GL11.glRotatef(yRotO + (yRot - yRotO) * unknown0 - 90.0F, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(xRotO + (xRot - xRotO) * unknown0, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
|
||||
|
||||
ShapeRenderer shapeRenderer = ShapeRenderer.instance;
|
||||
|
||||
unknown0 = 0.5F;
|
||||
|
||||
float unknown1 = (float)(0 + type * 10) / 32.0F;
|
||||
float unknown2 = (float)(5 + type * 10) / 32.0F;
|
||||
float unknown3 = 0.15625F;
|
||||
|
||||
float unknown4 = (float)(5 + type * 10) / 32.0F;
|
||||
float unknown5 = (float)(10 + type * 10) / 32.0F;
|
||||
float unknown6 = 0.05625F;
|
||||
|
||||
GL11.glScalef(0.05625F, unknown6, unknown6);
|
||||
|
||||
GL11.glNormal3f(unknown6, 0.0F, 0.0F);
|
||||
|
||||
shapeRenderer.begin();
|
||||
shapeRenderer.vertexUV(-7.0F, -2.0F, -2.0F, 0.0F, unknown4);
|
||||
shapeRenderer.vertexUV(-7.0F, -2.0F, 2.0F, unknown3, unknown4);
|
||||
shapeRenderer.vertexUV(-7.0F, 2.0F, 2.0F, unknown3, unknown5);
|
||||
shapeRenderer.vertexUV(-7.0F, 2.0F, -2.0F, 0.0F, unknown5);
|
||||
shapeRenderer.end();
|
||||
|
||||
GL11.glNormal3f(-unknown6, 0.0F, 0.0F);
|
||||
|
||||
shapeRenderer.begin();
|
||||
shapeRenderer.vertexUV(-7.0F, 2.0F, -2.0F, 0.0F, unknown4);
|
||||
shapeRenderer.vertexUV(-7.0F, 2.0F, 2.0F, unknown3, unknown4);
|
||||
shapeRenderer.vertexUV(-7.0F, -2.0F, 2.0F, unknown3, unknown5);
|
||||
shapeRenderer.vertexUV(-7.0F, -2.0F, -2.0F, 0.0F, unknown5);
|
||||
shapeRenderer.end();
|
||||
|
||||
for(int unknown7 = 0; unknown7 < 4; unknown7++)
|
||||
{
|
||||
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
|
||||
|
||||
GL11.glNormal3f(0.0F, -unknown6, 0.0F);
|
||||
|
||||
shapeRenderer.vertexUV(-8.0F, -2.0F, 0.0F, 0.0F, unknown1);
|
||||
shapeRenderer.vertexUV(8.0F, -2.0F, 0.0F, unknown0, unknown1);
|
||||
shapeRenderer.vertexUV(8.0F, 2.0F, 0.0F, unknown0, unknown2);
|
||||
shapeRenderer.vertexUV(-8.0F, 2.0F, 0.0F, 0.0F, unknown2);
|
||||
shapeRenderer.end();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerTouch(Entity entity)
|
||||
{
|
||||
Player player = (Player)entity;
|
||||
|
||||
if(hasHit && owner == player && player.arrows < 99)
|
||||
{
|
||||
TakeEntityAnim takeEntityAnim = new TakeEntityAnim(level, this, player);
|
||||
|
||||
level.addEntity(takeEntityAnim);
|
||||
|
||||
player.arrows++;
|
||||
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardKillScore(Entity entity, int score)
|
||||
{
|
||||
owner.awardKillScore(entity, score);
|
||||
}
|
||||
|
||||
public static final long serialVersionUID = 0L;
|
||||
|
||||
private float xd;
|
||||
private float yd;
|
||||
private float zd;
|
||||
|
||||
private float yRot;
|
||||
private float xRot;
|
||||
private float yRotO;
|
||||
private float xRotO;
|
||||
|
||||
private boolean hasHit = false;
|
||||
|
||||
private int stickTime = 0;
|
||||
|
||||
private Entity owner;
|
||||
|
||||
private int time = 0;
|
||||
private int type = 0;
|
||||
|
||||
private float gravity = 0.0F;
|
||||
|
||||
private int damage;
|
||||
|
||||
public Entity getOwner()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
}
|
149
src/main/java/com/mojang/minecraft/item/Item.java
Normal file
|
@ -0,0 +1,149 @@
|
|||
package com.mojang.minecraft.item;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.player.Player;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import com.mojang.util.MathHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class Item extends Entity
|
||||
{
|
||||
public Item(Level level1, float x, float y, float z, int block)
|
||||
{
|
||||
super(level1);
|
||||
|
||||
setSize(0.25F, 0.25F);
|
||||
|
||||
heightOffset = bbHeight / 2.0F;
|
||||
|
||||
setPos(x, y, z);
|
||||
|
||||
resource = block;
|
||||
|
||||
rot = (float)(Math.random() * 360.0D);
|
||||
|
||||
xd = (float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D);
|
||||
yd = 0.2F;
|
||||
zd = (float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D);
|
||||
|
||||
makeStepSound = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
xo = x;
|
||||
yo = y;
|
||||
zo = z;
|
||||
|
||||
yd -= 0.04F;
|
||||
|
||||
move(xd, yd, zd);
|
||||
|
||||
xd *= 0.98F;
|
||||
yd *= 0.98F;
|
||||
zd *= 0.98F;
|
||||
|
||||
if(onGround)
|
||||
{
|
||||
xd *= 0.7F;
|
||||
zd *= 0.7F;
|
||||
yd *= -0.5F;
|
||||
}
|
||||
|
||||
tickCount++;
|
||||
|
||||
age++;
|
||||
|
||||
if(age >= 6000)
|
||||
{
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TextureManager textureManager, float unknown0)
|
||||
{
|
||||
textureId = textureManager.load("/terrain.png");
|
||||
|
||||
GL11.glBindTexture(3553, this.textureId);
|
||||
|
||||
float brightness = level.getBrightness((int)x, (int)y, (int)z);
|
||||
float unknown1 = rot + ((float)tickCount + unknown0) * 3.0F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(brightness, brightness, brightness, 1.0F);
|
||||
|
||||
float unknown2 = (brightness = MathHelper.sin(unknown1 / 10.0F)) * 0.1F + 0.1F;
|
||||
|
||||
GL11.glTranslatef(xo + (x - xo) * unknown0, yo + (y - yo) * unknown0 + unknown2, zo + (z - zo) * unknown0);
|
||||
GL11.glRotatef(unknown1, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
models[resource].generateList();
|
||||
|
||||
brightness = (brightness = (brightness = brightness * 0.5F + 0.5F) * brightness) * brightness;
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, brightness * 0.4F);
|
||||
GL11.glDisable(3553);
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 1);
|
||||
GL11.glDisable(3008);
|
||||
|
||||
models[resource].generateList();
|
||||
|
||||
GL11.glEnable(3008);
|
||||
GL11.glDisable(3042);
|
||||
GL11.glBlendFunc(770, 771);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glEnable(3553);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerTouch(Entity entity)
|
||||
{
|
||||
Player player = (Player)entity;
|
||||
|
||||
if(player.addResource(resource))
|
||||
{
|
||||
TakeEntityAnim takeEntityAnim = new TakeEntityAnim(level, this, player);
|
||||
|
||||
level.addEntity(takeEntityAnim);
|
||||
|
||||
remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final long serialVersionUID = 0L;
|
||||
|
||||
private static ItemModel[] models = new ItemModel[256];
|
||||
|
||||
private float xd;
|
||||
private float yd;
|
||||
private float zd;
|
||||
|
||||
private float rot;
|
||||
|
||||
private int resource;
|
||||
|
||||
private int tickCount;
|
||||
|
||||
private int age = 0;
|
||||
|
||||
public static void initModels()
|
||||
{
|
||||
for(int unknown0 = 0; unknown0 < 256; unknown0++)
|
||||
{
|
||||
Block var1 = Block.blocks[unknown0];
|
||||
|
||||
if(var1 != null)
|
||||
{
|
||||
models[unknown0] = new ItemModel(var1.textureId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
62
src/main/java/com/mojang/minecraft/item/ItemModel.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package com.mojang.minecraft.item;
|
||||
|
||||
import com.mojang.minecraft.model.ModelPart;
|
||||
import com.mojang.minecraft.model.TexturedQuad;
|
||||
import com.mojang.minecraft.model.Vertex;
|
||||
|
||||
public class ItemModel
|
||||
{
|
||||
public ItemModel(int tex)
|
||||
{
|
||||
float var3 = -2.0F;
|
||||
float var4 = -2.0F;
|
||||
float var15 = -2.0F;
|
||||
|
||||
model.vertices = new Vertex[8];
|
||||
model.quads = new TexturedQuad[6];
|
||||
|
||||
Vertex vertex1 = new Vertex(var15, var4, var3, 0.0F, 0.0F);
|
||||
Vertex vertex2 = new Vertex(2.0F, var4, var3, 0.0F, 8.0F);
|
||||
Vertex vertex3 = new Vertex(2.0F, 2.0F, var3, 8.0F, 8.0F);
|
||||
Vertex vertex4 = new Vertex(var15, 2.0F, var3, 8.0F, 0.0F);
|
||||
Vertex vertex5 = new Vertex(var15, var4, 2.0F, 0.0F, 0.0F);
|
||||
Vertex vertex6 = new Vertex(2.0F, var4, 2.0F, 0.0F, 8.0F);
|
||||
Vertex vertex7 = new Vertex(2.0F, 2.0F, 2.0F, 8.0F, 8.0F);
|
||||
Vertex vertex8 = new Vertex(var15, 2.0F, 2.0F, 8.0F, 0.0F);
|
||||
|
||||
model.vertices[0] = vertex1;
|
||||
model.vertices[1] = vertex2;
|
||||
model.vertices[2] = vertex3;
|
||||
model.vertices[3] = vertex4;
|
||||
model.vertices[4] = vertex5;
|
||||
model.vertices[5] = vertex6;
|
||||
model.vertices[6] = vertex7;
|
||||
model.vertices[7] = vertex8;
|
||||
|
||||
float u1 = ((float)(tex % 16) + (1.0F - 0.25F)) / 16.0F;
|
||||
float v1 = ((float)(tex / 16) + (1.0F - 0.25F)) / 16.0F;
|
||||
float u2 = ((float)(tex % 16) + 0.25F) / 16.0F;
|
||||
float v2 = ((float)(tex / 16) + 0.25F) / 16.0F;
|
||||
|
||||
Vertex[] vertexes1 = new Vertex[] {vertex6, vertex2, vertex3, vertex7};
|
||||
Vertex[] vertexes2 = new Vertex[] {vertex1, vertex5, vertex8, vertex4};
|
||||
Vertex[] vertexes3 = new Vertex[] {vertex6, vertex5, vertex1, vertex2};
|
||||
Vertex[] vertexes4 = new Vertex[] {vertex3, vertex4, vertex8, vertex7};
|
||||
Vertex[] vertexes5 = new Vertex[] {vertex2, vertex1, vertex4, vertex3};
|
||||
Vertex[] vertexes6 = new Vertex[] {vertex5, vertex6, vertex7, vertex8};
|
||||
|
||||
model.quads[0] = new TexturedQuad(vertexes1, u1, v1, u2, v2);
|
||||
model.quads[1] = new TexturedQuad(vertexes2, u1, v1, u2, v2);
|
||||
model.quads[2] = new TexturedQuad(vertexes3, u1, v1, u2, v2);
|
||||
model.quads[3] = new TexturedQuad(vertexes4, u1, v1, u2, v2);
|
||||
model.quads[4] = new TexturedQuad(vertexes5, u1, v1, u2, v2);
|
||||
model.quads[5] = new TexturedQuad(vertexes6, u1, v1, u2, v2);
|
||||
}
|
||||
|
||||
private ModelPart model = new ModelPart(0, 0);
|
||||
|
||||
public void generateList()
|
||||
{
|
||||
model.render(0.0625F);
|
||||
}
|
||||
}
|
192
src/main/java/com/mojang/minecraft/item/PrimedTnt.java
Normal file
|
@ -0,0 +1,192 @@
|
|||
package com.mojang.minecraft.item;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.particle.SmokeParticle;
|
||||
import com.mojang.minecraft.particle.TerrainParticle;
|
||||
import com.mojang.minecraft.player.Player;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import com.mojang.util.MathHelper;
|
||||
import java.util.Random;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class PrimedTnt extends Entity
|
||||
{
|
||||
public PrimedTnt(Level level1, float x, float y, float z)
|
||||
{
|
||||
super(level1);
|
||||
|
||||
setSize(0.98F, 0.98F);
|
||||
|
||||
heightOffset = bbHeight / 2.0F;
|
||||
|
||||
setPos(x, y, z);
|
||||
|
||||
float unknown0 = (float)(Math.random() * 3.1415927410125732D * 2.0D);
|
||||
|
||||
xd = -MathHelper.sin(unknown0 * 3.1415927F / 180.0F) * 0.02F;
|
||||
yd = 0.2F;
|
||||
zd = -MathHelper.cos(unknown0 * 3.1415927F / 180.0F) * 0.02F;
|
||||
|
||||
makeStepSound = false;
|
||||
|
||||
life = 40;
|
||||
|
||||
xo = x;
|
||||
yo = y;
|
||||
zo = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
xo = x;
|
||||
yo = y;
|
||||
zo = z;
|
||||
|
||||
yd -= 0.04F;
|
||||
|
||||
move(xd, yd, zd);
|
||||
|
||||
xd *= 0.98F;
|
||||
yd *= 0.98F;
|
||||
zd *= 0.98F;
|
||||
|
||||
if(onGround)
|
||||
{
|
||||
xd *= 0.7F;
|
||||
zd *= 0.7F;
|
||||
yd *= -0.5F;
|
||||
}
|
||||
|
||||
if(!defused)
|
||||
{
|
||||
if(life-- > 0)
|
||||
{
|
||||
SmokeParticle smokeParticle = new SmokeParticle(level, x, y + 0.6F, z);
|
||||
|
||||
level.particleEngine.spawnParticle(smokeParticle);
|
||||
} else {
|
||||
remove();
|
||||
|
||||
Random random = new Random();
|
||||
float radius = 4.0F;
|
||||
|
||||
level.explode(null, x, y, z, radius);
|
||||
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
float unknown0 = (float)random.nextGaussian() * radius / 4.0F;
|
||||
float unknown1 = (float)random.nextGaussian() * radius / 4.0F;
|
||||
float unknown2 = (float)random.nextGaussian() * radius / 4.0F;
|
||||
float unknown3 = MathHelper.sqrt(unknown0 * unknown0 + unknown1 * unknown1 + unknown2 * unknown2);
|
||||
float unknown4 = unknown0 / unknown3 / unknown3;
|
||||
float unknown5 = unknown1 / unknown3 / unknown3;
|
||||
|
||||
unknown3 = unknown2 / unknown3 / unknown3;
|
||||
|
||||
TerrainParticle terrainParticle = new TerrainParticle(level, x + unknown0, y + unknown1, z + unknown2, unknown4, unknown5, unknown3, Block.TNT);
|
||||
|
||||
level.particleEngine.spawnParticle(terrainParticle);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TextureManager textureManager, float unknown0)
|
||||
{
|
||||
int textureID = textureManager.load("/terrain.png");
|
||||
|
||||
GL11.glBindTexture(3553, textureID);
|
||||
|
||||
float brightness = level.getBrightness((int)x, (int)y, (int)z);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(brightness, brightness, brightness, 1.0F);
|
||||
GL11.glTranslatef(xo + (x - xo) * unknown0 - 0.5F, yo + (y - yo) * unknown0 - 0.5F, zo + (z - zo) * unknown0 - 0.5F);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
ShapeRenderer shapeRenderer = ShapeRenderer.instance;
|
||||
|
||||
Block.TNT.renderPreview(shapeRenderer);
|
||||
|
||||
GL11.glDisable(3553);
|
||||
GL11.glDisable(2896);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, (float)((life / 4 + 1) % 2) * 0.4F);
|
||||
|
||||
if(life <= 16)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, (float)((life + 1) % 2) * 0.6F);
|
||||
}
|
||||
|
||||
if(life <= 2)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
|
||||
}
|
||||
|
||||
GL11.glEnable(3042);
|
||||
GL11.glBlendFunc(770, 1);
|
||||
|
||||
Block.TNT.renderPreview(shapeRenderer);
|
||||
|
||||
GL11.glDisable(3042);
|
||||
GL11.glEnable(3553);
|
||||
GL11.glEnable(2896);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerTouch(Entity entity)
|
||||
{
|
||||
if(defused)
|
||||
{
|
||||
Player player = (Player)entity;
|
||||
|
||||
if(player.addResource(Block.TNT.id))
|
||||
{
|
||||
TakeEntityAnim takeEntityAnim = new TakeEntityAnim(this.level, this, player);
|
||||
|
||||
level.addEntity(takeEntityAnim);
|
||||
|
||||
remove();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hurt(Entity entity, int damage)
|
||||
{
|
||||
if(!removed)
|
||||
{
|
||||
super.hurt(entity, damage);
|
||||
|
||||
if(entity instanceof Player)
|
||||
{
|
||||
remove();
|
||||
|
||||
Item item = new Item(level, x, y, z, Block.TNT.id);
|
||||
|
||||
level.addEntity(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
return !this.removed;
|
||||
}
|
||||
|
||||
public static final long serialVersionUID = 0L;
|
||||
private float xd;
|
||||
private float yd;
|
||||
private float zd;
|
||||
public int life = 0;
|
||||
private boolean defused;
|
||||
}
|
63
src/main/java/com/mojang/minecraft/item/TakeEntityAnim.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package com.mojang.minecraft.item;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
|
||||
public class TakeEntityAnim extends Entity
|
||||
{
|
||||
public TakeEntityAnim(Level level1, Entity item, Entity player)
|
||||
{
|
||||
super(level1);
|
||||
|
||||
this.item = item;
|
||||
this.player = player;
|
||||
|
||||
setSize(1.0F, 1.0F);
|
||||
|
||||
xorg = item.x;
|
||||
yorg = item.y;
|
||||
zorg = item.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
time++;
|
||||
|
||||
if(time >= 3)
|
||||
{
|
||||
remove();
|
||||
}
|
||||
|
||||
// TODO: Is this right?
|
||||
float distance = (distance = (float)time / 3.0F) * distance;
|
||||
|
||||
xo = item.xo = item.x;
|
||||
yo = item.yo = item.y;
|
||||
zo = item.zo = item.z;
|
||||
|
||||
x = item.x = xorg + (player.x - xorg) * distance;
|
||||
y = item.y = yorg + (player.y - 1.0F - yorg) * distance;
|
||||
z = item.z = zorg + (player.z - zorg) * distance;
|
||||
|
||||
setPos(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TextureManager textureManager, float unknown0)
|
||||
{
|
||||
item.render(textureManager, unknown0);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int time = 0;
|
||||
|
||||
private Entity item;
|
||||
private Entity player;
|
||||
|
||||
private float xorg;
|
||||
private float yorg;
|
||||
private float zorg;
|
||||
}
|
86
src/main/java/com/mojang/minecraft/level/BlockMap$Slot.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.level.BlockMap;
|
||||
import com.mojang.minecraft.level.SyntheticClass;
|
||||
import java.io.Serializable;
|
||||
|
||||
class BlockMap$Slot implements Serializable {
|
||||
|
||||
public static final long serialVersionUID = 0L;
|
||||
private int xSlot;
|
||||
private int ySlot;
|
||||
private int zSlot;
|
||||
// $FF: synthetic field
|
||||
final BlockMap blockMap;
|
||||
|
||||
|
||||
private BlockMap$Slot(BlockMap var1) {
|
||||
this.blockMap = var1;
|
||||
}
|
||||
|
||||
public BlockMap$Slot init(float var1, float var2, float var3) {
|
||||
this.xSlot = (int)(var1 / 16.0F);
|
||||
this.ySlot = (int)(var2 / 16.0F);
|
||||
this.zSlot = (int)(var3 / 16.0F);
|
||||
if(this.xSlot < 0) {
|
||||
this.xSlot = 0;
|
||||
}
|
||||
|
||||
if(this.ySlot < 0) {
|
||||
this.ySlot = 0;
|
||||
}
|
||||
|
||||
if(this.zSlot < 0) {
|
||||
this.zSlot = 0;
|
||||
}
|
||||
|
||||
if(this.xSlot >= BlockMap.getWidth(this.blockMap)) {
|
||||
this.xSlot = BlockMap.getWidth(this.blockMap) - 1;
|
||||
}
|
||||
|
||||
if(this.ySlot >= BlockMap.getDepth(this.blockMap)) {
|
||||
this.ySlot = BlockMap.getDepth(this.blockMap) - 1;
|
||||
}
|
||||
|
||||
if(this.zSlot >= BlockMap.getHeight(this.blockMap)) {
|
||||
this.zSlot = BlockMap.getHeight(this.blockMap) - 1;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void add(Entity var1) {
|
||||
if(this.xSlot >= 0 && this.ySlot >= 0 && this.zSlot >= 0) {
|
||||
this.blockMap.entityGrid[(this.zSlot * BlockMap.getDepth(this.blockMap) + this.ySlot) * BlockMap.getWidth(this.blockMap) + this.xSlot].add(var1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void remove(Entity var1) {
|
||||
if(this.xSlot >= 0 && this.ySlot >= 0 && this.zSlot >= 0) {
|
||||
this.blockMap.entityGrid[(this.zSlot * BlockMap.getDepth(this.blockMap) + this.ySlot) * BlockMap.getWidth(this.blockMap) + this.xSlot].remove(var1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
BlockMap$Slot(BlockMap var1, SyntheticClass var2) {
|
||||
this(var1);
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
static int getXSlot(BlockMap$Slot var0) {
|
||||
return var0.xSlot;
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
static int getYSlot(BlockMap$Slot var0) {
|
||||
return var0.ySlot;
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
static int getZSlot(BlockMap$Slot var0) {
|
||||
return var0.zSlot;
|
||||
}
|
||||
}
|
280
src/main/java/com/mojang/minecraft/level/BlockMap.java
Normal file
|
@ -0,0 +1,280 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.level.BlockMap$Slot;
|
||||
import com.mojang.minecraft.level.SyntheticClass;
|
||||
import com.mojang.minecraft.model.Vec3D;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.render.Frustrum;
|
||||
import com.mojang.minecraft.render.TextureManager;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockMap implements Serializable {
|
||||
|
||||
public static final long serialVersionUID = 0L;
|
||||
private int width;
|
||||
private int depth;
|
||||
private int height;
|
||||
private BlockMap$Slot slot = new BlockMap$Slot(this, (SyntheticClass)null);
|
||||
private BlockMap$Slot slot2 = new BlockMap$Slot(this, (SyntheticClass)null);
|
||||
public List[] entityGrid;
|
||||
public List all = new ArrayList();
|
||||
private List tmp = new ArrayList();
|
||||
|
||||
|
||||
public BlockMap(int var1, int var2, int var3) {
|
||||
this.width = var1 / 16;
|
||||
this.depth = var2 / 16;
|
||||
this.height = var3 / 16;
|
||||
if(this.width == 0) {
|
||||
this.width = 1;
|
||||
}
|
||||
|
||||
if(this.depth == 0) {
|
||||
this.depth = 1;
|
||||
}
|
||||
|
||||
if(this.height == 0) {
|
||||
this.height = 1;
|
||||
}
|
||||
|
||||
this.entityGrid = new ArrayList[this.width * this.depth * this.height];
|
||||
|
||||
for(var1 = 0; var1 < this.width; ++var1) {
|
||||
for(var2 = 0; var2 < this.depth; ++var2) {
|
||||
for(var3 = 0; var3 < this.height; ++var3) {
|
||||
this.entityGrid[(var3 * this.depth + var2) * this.width + var1] = new ArrayList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void insert(Entity var1) {
|
||||
this.all.add(var1);
|
||||
this.slot.init(var1.x, var1.y, var1.z).add(var1);
|
||||
var1.xOld = var1.x;
|
||||
var1.yOld = var1.y;
|
||||
var1.zOld = var1.z;
|
||||
var1.blockMap = this;
|
||||
}
|
||||
|
||||
public void remove(Entity var1) {
|
||||
this.slot.init(var1.xOld, var1.yOld, var1.zOld).remove(var1);
|
||||
this.all.remove(var1);
|
||||
}
|
||||
|
||||
public void moved(Entity var1) {
|
||||
BlockMap$Slot var2 = this.slot.init(var1.xOld, var1.yOld, var1.zOld);
|
||||
BlockMap$Slot var3 = this.slot2.init(var1.x, var1.y, var1.z);
|
||||
if(!var2.equals(var3)) {
|
||||
var2.remove(var1);
|
||||
var3.add(var1);
|
||||
var1.xOld = var1.x;
|
||||
var1.yOld = var1.y;
|
||||
var1.zOld = var1.z;
|
||||
}
|
||||
}
|
||||
|
||||
public List getEntities(Entity var1, float var2, float var3, float var4, float var5, float var6, float var7) {
|
||||
this.tmp.clear();
|
||||
return this.getEntities(var1, var2, var3, var4, var5, var6, var7, this.tmp);
|
||||
}
|
||||
|
||||
public List getEntities(Entity var1, float var2, float var3, float var4, float var5, float var6, float var7, List var8) {
|
||||
BlockMap$Slot var9 = this.slot.init(var2, var3, var4);
|
||||
BlockMap$Slot var10 = this.slot2.init(var5, var6, var7);
|
||||
|
||||
for(int var11 = BlockMap$Slot.getXSlot(var9) - 1; var11 <= BlockMap$Slot.getXSlot(var10) + 1; ++var11) {
|
||||
for(int var12 = BlockMap$Slot.getYSlot(var9) - 1; var12 <= BlockMap$Slot.getYSlot(var10) + 1; ++var12) {
|
||||
for(int var13 = BlockMap$Slot.getZSlot(var9) - 1; var13 <= BlockMap$Slot.getZSlot(var10) + 1; ++var13) {
|
||||
if(var11 >= 0 && var12 >= 0 && var13 >= 0 && var11 < this.width && var12 < this.depth && var13 < this.height) {
|
||||
List var14 = this.entityGrid[(var13 * this.depth + var12) * this.width + var11];
|
||||
|
||||
for(int var15 = 0; var15 < var14.size(); ++var15) {
|
||||
Entity var16;
|
||||
if((var16 = (Entity)var14.get(var15)) != var1 && var16.intersects(var2, var3, var4, var5, var6, var7)) {
|
||||
var8.add(var16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var8;
|
||||
}
|
||||
|
||||
public void removeAllNonCreativeModeEntities() {
|
||||
for(int var1 = 0; var1 < this.width; ++var1) {
|
||||
for(int var2 = 0; var2 < this.depth; ++var2) {
|
||||
for(int var3 = 0; var3 < this.height; ++var3) {
|
||||
List var4 = this.entityGrid[(var3 * this.depth + var2) * this.width + var1];
|
||||
|
||||
for(int var5 = 0; var5 < var4.size(); ++var5) {
|
||||
if(!((Entity)var4.get(var5)).isCreativeModeAllowed()) {
|
||||
var4.remove(var5--);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for(int var1 = 0; var1 < this.width; ++var1) {
|
||||
for(int var2 = 0; var2 < this.depth; ++var2) {
|
||||
for(int var3 = 0; var3 < this.height; ++var3) {
|
||||
this.entityGrid[(var3 * this.depth + var2) * this.width + var1].clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List getEntities(Entity var1, AABB var2) {
|
||||
this.tmp.clear();
|
||||
return this.getEntities(var1, var2.x0, var2.y0, var2.z0, var2.x1, var2.y1, var2.z1, this.tmp);
|
||||
}
|
||||
|
||||
public List getEntities(Entity var1, AABB var2, List var3) {
|
||||
return this.getEntities(var1, var2.x0, var2.y0, var2.z0, var2.x1, var2.y1, var2.z1, var3);
|
||||
}
|
||||
|
||||
public void tickAll() {
|
||||
for(int var1 = 0; var1 < this.all.size(); ++var1) {
|
||||
Entity var2;
|
||||
(var2 = (Entity)this.all.get(var1)).tick();
|
||||
if(var2.removed) {
|
||||
this.all.remove(var1--);
|
||||
this.slot.init(var2.xOld, var2.yOld, var2.zOld).remove(var2);
|
||||
} else {
|
||||
int var3 = (int)(var2.xOld / 16.0F);
|
||||
int var4 = (int)(var2.yOld / 16.0F);
|
||||
int var5 = (int)(var2.zOld / 16.0F);
|
||||
int var6 = (int)(var2.x / 16.0F);
|
||||
int var7 = (int)(var2.y / 16.0F);
|
||||
int var8 = (int)(var2.z / 16.0F);
|
||||
if(var3 != var6 || var4 != var7 || var5 != var8) {
|
||||
this.moved(var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void render(Vec3D var1, Frustrum var2, TextureManager var3, float var4) {
|
||||
for(int var5 = 0; var5 < this.width; ++var5) {
|
||||
float var6 = (float)((var5 << 4) - 2);
|
||||
float var7 = (float)((var5 + 1 << 4) + 2);
|
||||
|
||||
for(int var8 = 0; var8 < this.depth; ++var8) {
|
||||
float var9 = (float)((var8 << 4) - 2);
|
||||
float var10 = (float)((var8 + 1 << 4) + 2);
|
||||
|
||||
for(int var11 = 0; var11 < this.height; ++var11) {
|
||||
List var12;
|
||||
if((var12 = this.entityGrid[(var11 * this.depth + var8) * this.width + var5]).size() != 0) {
|
||||
float var13 = (float)((var11 << 4) - 2);
|
||||
float var14 = (float)((var11 + 1 << 4) + 2);
|
||||
if(var2.isBoxInFrustrum(var6, var9, var13, var7, var10, var14)) {
|
||||
float var16 = var14;
|
||||
float var17 = var10;
|
||||
float var15 = var7;
|
||||
var14 = var13;
|
||||
var13 = var9;
|
||||
float var18 = var6;
|
||||
Frustrum var19 = var2;
|
||||
int var20 = 0;
|
||||
|
||||
boolean var10000;
|
||||
while(true) {
|
||||
if(var20 >= 6) {
|
||||
var10000 = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var14 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var13 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var18 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(var19.frustrum[var20][0] * var15 + var19.frustrum[var20][1] * var17 + var19.frustrum[var20][2] * var16 + var19.frustrum[var20][3] <= 0.0F) {
|
||||
var10000 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
++var20;
|
||||
}
|
||||
|
||||
boolean var21 = var10000;
|
||||
|
||||
for(int var23 = 0; var23 < var12.size(); ++var23) {
|
||||
Entity var22;
|
||||
if((var22 = (Entity)var12.get(var23)).shouldRender(var1)) {
|
||||
if(!var21) {
|
||||
AABB var24 = var22.bb;
|
||||
if(!var2.isBoxInFrustrum(var24.x0, var24.y0, var24.z0, var24.x1, var24.y1, var24.z1)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var22.render(var3, var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
static int getWidth(BlockMap var0) {
|
||||
return var0.width;
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
static int getDepth(BlockMap var0) {
|
||||
return var0.depth;
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
static int getHeight(BlockMap var0) {
|
||||
return var0.height;
|
||||
}
|
||||
}
|
1013
src/main/java/com/mojang/minecraft/level/Level.java
Normal file
258
src/main/java/com/mojang/minecraft/level/LevelIO.java
Normal file
|
@ -0,0 +1,258 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.ProgressBarDisplay;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.LevelObjectInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public final class LevelIO {
|
||||
|
||||
private ProgressBarDisplay progressBar;
|
||||
|
||||
|
||||
public LevelIO(ProgressBarDisplay var1) {
|
||||
this.progressBar = var1;
|
||||
}
|
||||
|
||||
public final boolean save(Level var1, File var2) {
|
||||
try {
|
||||
FileOutputStream var5 = new FileOutputStream(var2);
|
||||
save(var1, (OutputStream)var5);
|
||||
var5.close();
|
||||
return true;
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Failed!");
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException var3) {
|
||||
;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final Level load(File var1) {
|
||||
try {
|
||||
FileInputStream var5 = new FileInputStream(var1);
|
||||
Level var2 = this.load((InputStream)var5);
|
||||
var5.close();
|
||||
return var2;
|
||||
} catch (Exception var4) {
|
||||
var4.printStackTrace();
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Failed!");
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException var3) {
|
||||
;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean saveOnline(Level var1, String var2, String var3, String var4, String var5, int var6) {
|
||||
if(var4 == null) {
|
||||
var4 = "";
|
||||
}
|
||||
|
||||
if(this.progressBar != null && this.progressBar != null) {
|
||||
this.progressBar.setTitle("Saving level");
|
||||
}
|
||||
|
||||
try {
|
||||
if(this.progressBar != null && this.progressBar != null) {
|
||||
this.progressBar.setText("Compressing..");
|
||||
}
|
||||
|
||||
ByteArrayOutputStream var7 = new ByteArrayOutputStream();
|
||||
save(var1, (OutputStream)var7);
|
||||
var7.close();
|
||||
byte[] var10 = var7.toByteArray();
|
||||
if(this.progressBar != null && this.progressBar != null) {
|
||||
this.progressBar.setText("Connecting..");
|
||||
}
|
||||
|
||||
HttpURLConnection var12;
|
||||
(var12 = (HttpURLConnection)(new URL("http://" + var2 + "/level/save.html")).openConnection()).setDoInput(true);
|
||||
var12.setDoOutput(true);
|
||||
var12.setRequestMethod("POST");
|
||||
DataOutputStream var13;
|
||||
(var13 = new DataOutputStream(var12.getOutputStream())).writeUTF(var3);
|
||||
var13.writeUTF(var4);
|
||||
var13.writeUTF(var5);
|
||||
var13.writeByte(var6);
|
||||
var13.writeInt(var10.length);
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Saving..");
|
||||
}
|
||||
|
||||
var13.write(var10);
|
||||
var13.close();
|
||||
BufferedReader var11;
|
||||
if(!(var11 = new BufferedReader(new InputStreamReader(var12.getInputStream()))).readLine().equalsIgnoreCase("ok")) {
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Failed: " + var11.readLine());
|
||||
}
|
||||
|
||||
var11.close();
|
||||
Thread.sleep(1000L);
|
||||
return false;
|
||||
} else {
|
||||
var11.close();
|
||||
return true;
|
||||
}
|
||||
} catch (Exception var9) {
|
||||
var9.printStackTrace();
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Failed!");
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException var8) {
|
||||
;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public final Level loadOnline(String var1, String var2, int var3) {
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setTitle("Loading level");
|
||||
}
|
||||
|
||||
try {
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Connecting..");
|
||||
}
|
||||
|
||||
HttpURLConnection var6;
|
||||
(var6 = (HttpURLConnection)(new URL("http://" + var1 + "/level/load.html?id=" + var3 + "&user=" + var2)).openConnection()).setDoInput(true);
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Loading..");
|
||||
}
|
||||
|
||||
DataInputStream var7;
|
||||
if((var7 = new DataInputStream(var6.getInputStream())).readUTF().equalsIgnoreCase("ok")) {
|
||||
return this.load((InputStream)var7);
|
||||
} else {
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Failed: " + var7.readUTF());
|
||||
}
|
||||
|
||||
var7.close();
|
||||
Thread.sleep(1000L);
|
||||
return null;
|
||||
}
|
||||
} catch (Exception var5) {
|
||||
var5.printStackTrace();
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Failed!");
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(3000L);
|
||||
} catch (InterruptedException var4) {
|
||||
;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final Level load(InputStream var1) {
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setTitle("Loading level");
|
||||
}
|
||||
|
||||
if(this.progressBar != null) {
|
||||
this.progressBar.setText("Reading..");
|
||||
}
|
||||
|
||||
try {
|
||||
DataInputStream var10;
|
||||
if((var10 = new DataInputStream(new GZIPInputStream(var1))).readInt() != 656127880) {
|
||||
return null;
|
||||
} else {
|
||||
byte var12;
|
||||
if((var12 = var10.readByte()) > 2) {
|
||||
return null;
|
||||
} else if(var12 <= 1) {
|
||||
String var14 = var10.readUTF();
|
||||
String var15 = var10.readUTF();
|
||||
long var3 = var10.readLong();
|
||||
short var5 = var10.readShort();
|
||||
short var6 = var10.readShort();
|
||||
short var7 = var10.readShort();
|
||||
byte[] var8 = new byte[var5 * var6 * var7];
|
||||
var10.readFully(var8);
|
||||
var10.close();
|
||||
Level var11;
|
||||
(var11 = new Level()).setData(var5, var7, var6, var8);
|
||||
var11.name = var14;
|
||||
var11.creator = var15;
|
||||
var11.createTime = var3;
|
||||
return var11;
|
||||
} else {
|
||||
Level var2;
|
||||
LevelObjectInputStream var13;
|
||||
(var2 = (Level)(var13 = new LevelObjectInputStream(var10)).readObject()).initTransient();
|
||||
var13.close();
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
} catch (Exception var9) {
|
||||
var9.printStackTrace();
|
||||
System.out.println("Failed to load level: " + var9.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Level var0, OutputStream var1) {
|
||||
try {
|
||||
DataOutputStream var3;
|
||||
(var3 = new DataOutputStream(new GZIPOutputStream(var1))).writeInt(656127880);
|
||||
var3.writeByte(2);
|
||||
ObjectOutputStream var4;
|
||||
(var4 = new ObjectOutputStream(var3)).writeObject(var0);
|
||||
var4.close();
|
||||
} catch (Exception var2) {
|
||||
var2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] decompress(InputStream var0) {
|
||||
try {
|
||||
DataInputStream var3;
|
||||
byte[] var1 = new byte[(var3 = new DataInputStream(new GZIPInputStream(var0))).readInt()];
|
||||
var3.readFully(var1);
|
||||
var3.close();
|
||||
return var1;
|
||||
} catch (Exception var2) {
|
||||
throw new RuntimeException(var2);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class LevelObjectInputStream extends ObjectInputStream {
|
||||
|
||||
private Set classes = new HashSet();
|
||||
|
||||
|
||||
public LevelObjectInputStream(InputStream var1) throws IOException {
|
||||
super(var1);
|
||||
this.classes.add("com.mojang.minecraft.player.Player$1");
|
||||
this.classes.add("com.mojang.minecraft.mob.Creeper$1");
|
||||
this.classes.add("com.mojang.minecraft.mob.Skeleton$1");
|
||||
}
|
||||
|
||||
protected final ObjectStreamClass readClassDescriptor() {
|
||||
try
|
||||
{
|
||||
ObjectStreamClass var1 = super.readClassDescriptor();
|
||||
return this.classes.contains(var1.getName())?ObjectStreamClass.lookup(Class.forName(var1.getName())):var1;
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
106
src/main/java/com/mojang/minecraft/level/MobSpawner.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
import com.mojang.minecraft.Entity;
|
||||
import com.mojang.minecraft.ProgressBarDisplay;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.liquid.LiquidType;
|
||||
import com.mojang.minecraft.mob.Creeper;
|
||||
import com.mojang.minecraft.mob.Mob;
|
||||
import com.mojang.minecraft.mob.Pig;
|
||||
import com.mojang.minecraft.mob.Sheep;
|
||||
import com.mojang.minecraft.mob.Skeleton;
|
||||
import com.mojang.minecraft.mob.Spider;
|
||||
import com.mojang.minecraft.mob.Zombie;
|
||||
|
||||
public final class MobSpawner {
|
||||
|
||||
public Level level;
|
||||
|
||||
|
||||
public MobSpawner(Level var1) {
|
||||
this.level = var1;
|
||||
}
|
||||
|
||||
public final int spawn(int var1, Entity var2, ProgressBarDisplay var3) {
|
||||
int var4 = 0;
|
||||
|
||||
for(int var5 = 0; var5 < var1; ++var5) {
|
||||
if(var3 != null) {
|
||||
var3.setProgress(var5 * 100 / (var1 - 1));
|
||||
}
|
||||
|
||||
int var6 = this.level.random.nextInt(6);
|
||||
int var7 = this.level.random.nextInt(this.level.width);
|
||||
int var8 = (int)(Math.min(this.level.random.nextFloat(), this.level.random.nextFloat()) * (float)this.level.depth);
|
||||
int var9 = this.level.random.nextInt(this.level.height);
|
||||
if(!this.level.isSolidTile(var7, var8, var9) && this.level.getLiquid(var7, var8, var9) == LiquidType.NOT_LIQUID && (!this.level.isLit(var7, var8, var9) || this.level.random.nextInt(5) == 0)) {
|
||||
for(int var10 = 0; var10 < 3; ++var10) {
|
||||
int var11 = var7;
|
||||
int var12 = var8;
|
||||
int var13 = var9;
|
||||
|
||||
for(int var14 = 0; var14 < 3; ++var14) {
|
||||
var11 += this.level.random.nextInt(6) - this.level.random.nextInt(6);
|
||||
var12 += this.level.random.nextInt(1) - this.level.random.nextInt(1);
|
||||
var13 += this.level.random.nextInt(6) - this.level.random.nextInt(6);
|
||||
if(var11 >= 0 && var13 >= 1 && var12 >= 0 && var12 < this.level.depth - 2 && var11 < this.level.width && var13 < this.level.height && this.level.isSolidTile(var11, var12 - 1, var13) && !this.level.isSolidTile(var11, var12, var13) && !this.level.isSolidTile(var11, var12 + 1, var13)) {
|
||||
float var15 = (float)var11 + 0.5F;
|
||||
float var16 = (float)var12 + 1.0F;
|
||||
float var17 = (float)var13 + 0.5F;
|
||||
float var19;
|
||||
float var18;
|
||||
float var20;
|
||||
if(var2 != null) {
|
||||
var18 = var15 - var2.x;
|
||||
var19 = var16 - var2.y;
|
||||
var20 = var17 - var2.z;
|
||||
if(var18 * var18 + var19 * var19 + var20 * var20 < 256.0F) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
var18 = var15 - (float)this.level.xSpawn;
|
||||
var19 = var16 - (float)this.level.ySpawn;
|
||||
var20 = var17 - (float)this.level.zSpawn;
|
||||
if(var18 * var18 + var19 * var19 + var20 * var20 < 256.0F) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Object var21 = null;
|
||||
if(var6 == 0) {
|
||||
var21 = new Zombie(this.level, var15, var16, var17);
|
||||
}
|
||||
|
||||
if(var6 == 1) {
|
||||
var21 = new Skeleton(this.level, var15, var16, var17);
|
||||
}
|
||||
|
||||
if(var6 == 2) {
|
||||
var21 = new Pig(this.level, var15, var16, var17);
|
||||
}
|
||||
|
||||
if(var6 == 3) {
|
||||
var21 = new Creeper(this.level, var15, var16, var17);
|
||||
}
|
||||
|
||||
if(var6 == 4) {
|
||||
var21 = new Spider(this.level, var15, var16, var17);
|
||||
}
|
||||
|
||||
if(var6 == 5) {
|
||||
var21 = new Sheep(this.level, var15, var16, var17);
|
||||
}
|
||||
|
||||
if(this.level.isFree(((Mob)var21).bb)) {
|
||||
++var4;
|
||||
this.level.addEntity((Entity)var21);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var4;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
|
||||
public final class NextTickListEntry {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public int block;
|
||||
public int ticks;
|
||||
|
||||
|
||||
public NextTickListEntry(int var1, int var2, int var3, int var4) {
|
||||
this.x = var1;
|
||||
this.y = var2;
|
||||
this.z = var3;
|
||||
this.block = var4;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.mojang.minecraft.level;
|
||||
|
||||
|
||||
// $FF: synthetic class
|
||||
final class SyntheticClass {
|
||||
}
|
|
@ -0,0 +1,544 @@
|
|||
package com.mojang.minecraft.level.generator;
|
||||
|
||||
import com.mojang.minecraft.ProgressBarDisplay;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.generator.noise.CombinedNoise;
|
||||
import com.mojang.minecraft.level.generator.noise.OctaveNoise;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.util.MathHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public final class LevelGenerator {
|
||||
|
||||
private ProgressBarDisplay progressBar;
|
||||
private int width;
|
||||
private int depth;
|
||||
private int height;
|
||||
private Random random = new Random();
|
||||
private byte[] blocks;
|
||||
private int waterLevel;
|
||||
private int[] h = new int[1048576];
|
||||
|
||||
|
||||
public LevelGenerator(ProgressBarDisplay var1) {
|
||||
this.progressBar = var1;
|
||||
}
|
||||
|
||||
public final Level generate(String var1, int var2, int var3, int var4) {
|
||||
this.progressBar.setTitle("Generating level");
|
||||
this.width = var2;
|
||||
this.depth = var3;
|
||||
this.height = 64;
|
||||
this.waterLevel = 32;
|
||||
this.blocks = new byte[var2 * var3 << 6];
|
||||
this.progressBar.setText("Raising..");
|
||||
LevelGenerator var5 = this;
|
||||
CombinedNoise var6 = new CombinedNoise(new OctaveNoise(this.random, 8), new OctaveNoise(this.random, 8));
|
||||
CombinedNoise var7 = new CombinedNoise(new OctaveNoise(this.random, 8), new OctaveNoise(this.random, 8));
|
||||
OctaveNoise var8 = new OctaveNoise(this.random, 6);
|
||||
int[] var9 = new int[this.width * this.depth];
|
||||
float var10 = 1.3F;
|
||||
|
||||
int var11;
|
||||
int var12;
|
||||
for(var11 = 0; var11 < var5.width; ++var11) {
|
||||
var5.setProgress(var11 * 100 / (var5.width - 1));
|
||||
|
||||
for(var12 = 0; var12 < var5.depth; ++var12) {
|
||||
double var13 = var6.compute((double)((float)var11 * var10), (double)((float)var12 * var10)) / 6.0D + (double)-4;
|
||||
double var15 = var7.compute((double)((float)var11 * var10), (double)((float)var12 * var10)) / 5.0D + 10.0D + (double)-4;
|
||||
if(var8.compute((double)var11, (double)var12) / 8.0D > 0.0D) {
|
||||
var15 = var13;
|
||||
}
|
||||
|
||||
double var19;
|
||||
if((var19 = Math.max(var13, var15) / 2.0D) < 0.0D) {
|
||||
var19 *= 0.8D;
|
||||
}
|
||||
|
||||
var9[var11 + var12 * var5.width] = (int)var19;
|
||||
}
|
||||
}
|
||||
|
||||
this.progressBar.setText("Eroding..");
|
||||
int[] var42 = var9;
|
||||
var5 = this;
|
||||
var7 = new CombinedNoise(new OctaveNoise(this.random, 8), new OctaveNoise(this.random, 8));
|
||||
CombinedNoise var49 = new CombinedNoise(new OctaveNoise(this.random, 8), new OctaveNoise(this.random, 8));
|
||||
|
||||
int var23;
|
||||
int var51;
|
||||
int var54;
|
||||
for(var51 = 0; var51 < var5.width; ++var51) {
|
||||
var5.setProgress(var51 * 100 / (var5.width - 1));
|
||||
|
||||
for(var54 = 0; var54 < var5.depth; ++var54) {
|
||||
double var21 = var7.compute((double)(var51 << 1), (double)(var54 << 1)) / 8.0D;
|
||||
var12 = var49.compute((double)(var51 << 1), (double)(var54 << 1)) > 0.0D?1:0;
|
||||
if(var21 > 2.0D) {
|
||||
var23 = ((var42[var51 + var54 * var5.width] - var12) / 2 << 1) + var12;
|
||||
var42[var51 + var54 * var5.width] = var23;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.progressBar.setText("Soiling..");
|
||||
var42 = var9;
|
||||
var5 = this;
|
||||
int var46 = this.width;
|
||||
int var48 = this.depth;
|
||||
var51 = this.height;
|
||||
OctaveNoise var53 = new OctaveNoise(this.random, 8);
|
||||
|
||||
int var25;
|
||||
int var24;
|
||||
int var27;
|
||||
int var26;
|
||||
int var28;
|
||||
for(var24 = 0; var24 < var46; ++var24) {
|
||||
var5.setProgress(var24 * 100 / (var5.width - 1));
|
||||
|
||||
for(var11 = 0; var11 < var48; ++var11) {
|
||||
var12 = (int)(var53.compute((double)var24, (double)var11) / 24.0D) - 4;
|
||||
var25 = (var23 = var42[var24 + var11 * var46] + var5.waterLevel) + var12;
|
||||
var42[var24 + var11 * var46] = Math.max(var23, var25);
|
||||
if(var42[var24 + var11 * var46] > var51 - 2) {
|
||||
var42[var24 + var11 * var46] = var51 - 2;
|
||||
}
|
||||
|
||||
if(var42[var24 + var11 * var46] < 1) {
|
||||
var42[var24 + var11 * var46] = 1;
|
||||
}
|
||||
|
||||
for(var26 = 0; var26 < var51; ++var26) {
|
||||
var27 = (var26 * var5.depth + var11) * var5.width + var24;
|
||||
var28 = 0;
|
||||
if(var26 <= var23) {
|
||||
var28 = Block.DIRT.id;
|
||||
}
|
||||
|
||||
if(var26 <= var25) {
|
||||
var28 = Block.STONE.id;
|
||||
}
|
||||
|
||||
if(var26 == 0) {
|
||||
var28 = Block.LAVA.id;
|
||||
}
|
||||
|
||||
var5.blocks[var27] = (byte)var28;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.progressBar.setText("Carving..");
|
||||
boolean var45 = true;
|
||||
boolean var44 = false;
|
||||
var5 = this;
|
||||
var48 = this.width;
|
||||
var51 = this.depth;
|
||||
var54 = this.height;
|
||||
var24 = var48 * var51 * var54 / 256 / 64 << 1;
|
||||
|
||||
for(var11 = 0; var11 < var24; ++var11) {
|
||||
var5.setProgress(var11 * 100 / (var24 - 1) / 4);
|
||||
float var55 = var5.random.nextFloat() * (float)var48;
|
||||
float var59 = var5.random.nextFloat() * (float)var54;
|
||||
float var56 = var5.random.nextFloat() * (float)var51;
|
||||
var26 = (int)((var5.random.nextFloat() + var5.random.nextFloat()) * 200.0F);
|
||||
float var61 = var5.random.nextFloat() * 3.1415927F * 2.0F;
|
||||
float var64 = 0.0F;
|
||||
float var29 = var5.random.nextFloat() * 3.1415927F * 2.0F;
|
||||
float var30 = 0.0F;
|
||||
float var31 = var5.random.nextFloat() * var5.random.nextFloat();
|
||||
|
||||
for(int var32 = 0; var32 < var26; ++var32) {
|
||||
var55 += MathHelper.sin(var61) * MathHelper.cos(var29);
|
||||
var56 += MathHelper.cos(var61) * MathHelper.cos(var29);
|
||||
var59 += MathHelper.sin(var29);
|
||||
var61 += var64 * 0.2F;
|
||||
var64 = (var64 *= 0.9F) + (var5.random.nextFloat() - var5.random.nextFloat());
|
||||
var29 = (var29 + var30 * 0.5F) * 0.5F;
|
||||
var30 = (var30 *= 0.75F) + (var5.random.nextFloat() - var5.random.nextFloat());
|
||||
if(var5.random.nextFloat() >= 0.25F) {
|
||||
float var43 = var55 + (var5.random.nextFloat() * 4.0F - 2.0F) * 0.2F;
|
||||
float var50 = var59 + (var5.random.nextFloat() * 4.0F - 2.0F) * 0.2F;
|
||||
float var33 = var56 + (var5.random.nextFloat() * 4.0F - 2.0F) * 0.2F;
|
||||
float var34 = ((float)var5.height - var50) / (float)var5.height;
|
||||
var34 = 1.2F + (var34 * 3.5F + 1.0F) * var31;
|
||||
var34 = MathHelper.sin((float)var32 * 3.1415927F / (float)var26) * var34;
|
||||
|
||||
for(int var35 = (int)(var43 - var34); var35 <= (int)(var43 + var34); ++var35) {
|
||||
for(int var36 = (int)(var50 - var34); var36 <= (int)(var50 + var34); ++var36) {
|
||||
for(int var37 = (int)(var33 - var34); var37 <= (int)(var33 + var34); ++var37) {
|
||||
float var38 = (float)var35 - var43;
|
||||
float var39 = (float)var36 - var50;
|
||||
float var40 = (float)var37 - var33;
|
||||
if(var38 * var38 + var39 * var39 * 2.0F + var40 * var40 < var34 * var34 && var35 >= 1 && var36 >= 1 && var37 >= 1 && var35 < var5.width - 1 && var36 < var5.height - 1 && var37 < var5.depth - 1) {
|
||||
int var66 = (var36 * var5.depth + var37) * var5.width + var35;
|
||||
if(var5.blocks[var66] == Block.STONE.id) {
|
||||
var5.blocks[var66] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.populateOre(Block.COAL_ORE.id, 90, 1, 4);
|
||||
this.populateOre(Block.IRON_ORE.id, 70, 2, 4);
|
||||
this.populateOre(Block.GOLD_ORE.id, 50, 3, 4);
|
||||
this.progressBar.setText("Watering..");
|
||||
var5 = this;
|
||||
var51 = Block.STATIONARY_WATER.id;
|
||||
this.setProgress(0);
|
||||
|
||||
for(var54 = 0; var54 < var5.width; ++var54) {
|
||||
var5.flood(var54, var5.height / 2 - 1, 0, 0, var51);
|
||||
var5.flood(var54, var5.height / 2 - 1, var5.depth - 1, 0, var51);
|
||||
}
|
||||
|
||||
for(var54 = 0; var54 < var5.depth; ++var54) {
|
||||
var5.flood(0, var5.height / 2 - 1, var54, 0, var51);
|
||||
var5.flood(var5.width - 1, var5.height / 2 - 1, var54, 0, var51);
|
||||
}
|
||||
|
||||
var54 = var5.width * var5.depth / 8000;
|
||||
|
||||
for(var24 = 0; var24 < var54; ++var24) {
|
||||
if(var24 % 100 == 0) {
|
||||
var5.setProgress(var24 * 100 / (var54 - 1));
|
||||
}
|
||||
|
||||
var11 = var5.random.nextInt(var5.width);
|
||||
var12 = var5.waterLevel - 1 - var5.random.nextInt(2);
|
||||
var23 = var5.random.nextInt(var5.depth);
|
||||
if(var5.blocks[(var12 * var5.depth + var23) * var5.width + var11] == 0) {
|
||||
var5.flood(var11, var12, var23, 0, var51);
|
||||
}
|
||||
}
|
||||
|
||||
var5.setProgress(100);
|
||||
this.progressBar.setText("Melting..");
|
||||
var5 = this;
|
||||
var46 = this.width * this.depth * this.height / 20000;
|
||||
|
||||
for(var48 = 0; var48 < var46; ++var48) {
|
||||
if(var48 % 100 == 0) {
|
||||
var5.setProgress(var48 * 100 / (var46 - 1));
|
||||
}
|
||||
|
||||
var51 = var5.random.nextInt(var5.width);
|
||||
var54 = (int)(var5.random.nextFloat() * var5.random.nextFloat() * (float)(var5.waterLevel - 3));
|
||||
var24 = var5.random.nextInt(var5.depth);
|
||||
if(var5.blocks[(var54 * var5.depth + var24) * var5.width + var51] == 0) {
|
||||
var5.flood(var51, var54, var24, 0, Block.STATIONARY_LAVA.id);
|
||||
}
|
||||
}
|
||||
|
||||
var5.setProgress(100);
|
||||
this.progressBar.setText("Growing..");
|
||||
var42 = var9;
|
||||
var5 = this;
|
||||
var46 = this.width;
|
||||
var48 = this.depth;
|
||||
var51 = this.height;
|
||||
var53 = new OctaveNoise(this.random, 8);
|
||||
OctaveNoise var58 = new OctaveNoise(this.random, 8);
|
||||
|
||||
int var63;
|
||||
for(var11 = 0; var11 < var46; ++var11) {
|
||||
var5.setProgress(var11 * 100 / (var5.width - 1));
|
||||
|
||||
for(var12 = 0; var12 < var48; ++var12) {
|
||||
boolean var60 = var53.compute((double)var11, (double)var12) > 8.0D;
|
||||
boolean var57 = var58.compute((double)var11, (double)var12) > 12.0D;
|
||||
var27 = ((var26 = var42[var11 + var12 * var46]) * var5.depth + var12) * var5.width + var11;
|
||||
if(((var28 = var5.blocks[((var26 + 1) * var5.depth + var12) * var5.width + var11] & 255) == Block.WATER.id || var28 == Block.STATIONARY_WATER.id) && var26 <= var51 / 2 - 1 && var57) {
|
||||
var5.blocks[var27] = (byte)Block.GRAVEL.id;
|
||||
}
|
||||
|
||||
if(var28 == 0) {
|
||||
var63 = Block.GRASS.id;
|
||||
if(var26 <= var51 / 2 - 1 && var60) {
|
||||
var63 = Block.SAND.id;
|
||||
}
|
||||
|
||||
var5.blocks[var27] = (byte)var63;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.progressBar.setText("Planting..");
|
||||
var42 = var9;
|
||||
var5 = this;
|
||||
var46 = this.width;
|
||||
var48 = this.width * this.depth / 3000;
|
||||
|
||||
for(var51 = 0; var51 < var48; ++var51) {
|
||||
var54 = var5.random.nextInt(2);
|
||||
var5.setProgress(var51 * 50 / (var48 - 1));
|
||||
var24 = var5.random.nextInt(var5.width);
|
||||
var11 = var5.random.nextInt(var5.depth);
|
||||
|
||||
for(var12 = 0; var12 < 10; ++var12) {
|
||||
var23 = var24;
|
||||
var25 = var11;
|
||||
|
||||
for(var26 = 0; var26 < 5; ++var26) {
|
||||
var23 += var5.random.nextInt(6) - var5.random.nextInt(6);
|
||||
var25 += var5.random.nextInt(6) - var5.random.nextInt(6);
|
||||
if((var54 < 2 || var5.random.nextInt(4) == 0) && var23 >= 0 && var25 >= 0 && var23 < var5.width && var25 < var5.depth) {
|
||||
var27 = var42[var23 + var25 * var46] + 1;
|
||||
if((var5.blocks[(var27 * var5.depth + var25) * var5.width + var23] & 255) == 0) {
|
||||
var63 = (var27 * var5.depth + var25) * var5.width + var23;
|
||||
if((var5.blocks[((var27 - 1) * var5.depth + var25) * var5.width + var23] & 255) == Block.GRASS.id) {
|
||||
if(var54 == 0) {
|
||||
var5.blocks[var63] = (byte)Block.DANDELION.id;
|
||||
} else if(var54 == 1) {
|
||||
var5.blocks[var63] = (byte)Block.ROSE.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var42 = var9;
|
||||
var5 = this;
|
||||
var46 = this.width;
|
||||
var51 = this.width * this.depth * this.height / 2000;
|
||||
|
||||
for(var54 = 0; var54 < var51; ++var54) {
|
||||
var24 = var5.random.nextInt(2);
|
||||
var5.setProgress(var54 * 50 / (var51 - 1) + 50);
|
||||
var11 = var5.random.nextInt(var5.width);
|
||||
var12 = var5.random.nextInt(var5.height);
|
||||
var23 = var5.random.nextInt(var5.depth);
|
||||
|
||||
for(var25 = 0; var25 < 20; ++var25) {
|
||||
var26 = var11;
|
||||
var27 = var12;
|
||||
var28 = var23;
|
||||
|
||||
for(var63 = 0; var63 < 5; ++var63) {
|
||||
var26 += var5.random.nextInt(6) - var5.random.nextInt(6);
|
||||
var27 += var5.random.nextInt(2) - var5.random.nextInt(2);
|
||||
var28 += var5.random.nextInt(6) - var5.random.nextInt(6);
|
||||
if((var24 < 2 || var5.random.nextInt(4) == 0) && var26 >= 0 && var28 >= 0 && var27 >= 1 && var26 < var5.width && var28 < var5.depth && var27 < var42[var26 + var28 * var46] - 1 && (var5.blocks[(var27 * var5.depth + var28) * var5.width + var26] & 255) == 0) {
|
||||
int var62 = (var27 * var5.depth + var28) * var5.width + var26;
|
||||
if((var5.blocks[((var27 - 1) * var5.depth + var28) * var5.width + var26] & 255) == Block.STONE.id) {
|
||||
if(var24 == 0) {
|
||||
var5.blocks[var62] = (byte)Block.BROWN_MUSHROOM.id;
|
||||
} else if(var24 == 1) {
|
||||
var5.blocks[var62] = (byte)Block.RED_MUSHROOM.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Level var65;
|
||||
(var65 = new Level()).waterLevel = this.waterLevel;
|
||||
var65.setData(var2, 64, var3, this.blocks);
|
||||
var65.createTime = System.currentTimeMillis();
|
||||
var65.creator = var1;
|
||||
var65.name = "A Nice World";
|
||||
int[] var52 = var9;
|
||||
Level var47 = var65;
|
||||
var5 = this;
|
||||
var48 = this.width;
|
||||
var51 = this.width * this.depth / 4000;
|
||||
|
||||
for(var54 = 0; var54 < var51; ++var54) {
|
||||
var5.setProgress(var54 * 50 / (var51 - 1) + 50);
|
||||
var24 = var5.random.nextInt(var5.width);
|
||||
var11 = var5.random.nextInt(var5.depth);
|
||||
|
||||
for(var12 = 0; var12 < 20; ++var12) {
|
||||
var23 = var24;
|
||||
var25 = var11;
|
||||
|
||||
for(var26 = 0; var26 < 20; ++var26) {
|
||||
var23 += var5.random.nextInt(6) - var5.random.nextInt(6);
|
||||
var25 += var5.random.nextInt(6) - var5.random.nextInt(6);
|
||||
if(var23 >= 0 && var25 >= 0 && var23 < var5.width && var25 < var5.depth) {
|
||||
var27 = var52[var23 + var25 * var48] + 1;
|
||||
if(var5.random.nextInt(4) == 0) {
|
||||
var47.maybeGrowTree(var23, var27, var25);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return var65;
|
||||
}
|
||||
|
||||
private void populateOre(int var1, int var2, int var3, int var4) {
|
||||
byte var25 = (byte)var1;
|
||||
var4 = this.width;
|
||||
int var5 = this.depth;
|
||||
int var6 = this.height;
|
||||
int var7 = var4 * var5 * var6 / 256 / 64 * var2 / 100;
|
||||
|
||||
for(int var8 = 0; var8 < var7; ++var8) {
|
||||
this.setProgress(var8 * 100 / (var7 - 1) / 4 + var3 * 100 / 4);
|
||||
float var9 = this.random.nextFloat() * (float)var4;
|
||||
float var10 = this.random.nextFloat() * (float)var6;
|
||||
float var11 = this.random.nextFloat() * (float)var5;
|
||||
int var12 = (int)((this.random.nextFloat() + this.random.nextFloat()) * 75.0F * (float)var2 / 100.0F);
|
||||
float var13 = this.random.nextFloat() * 3.1415927F * 2.0F;
|
||||
float var14 = 0.0F;
|
||||
float var15 = this.random.nextFloat() * 3.1415927F * 2.0F;
|
||||
float var16 = 0.0F;
|
||||
|
||||
for(int var17 = 0; var17 < var12; ++var17) {
|
||||
var9 += MathHelper.sin(var13) * MathHelper.cos(var15);
|
||||
var11 += MathHelper.cos(var13) * MathHelper.cos(var15);
|
||||
var10 += MathHelper.sin(var15);
|
||||
var13 += var14 * 0.2F;
|
||||
var14 = (var14 *= 0.9F) + (this.random.nextFloat() - this.random.nextFloat());
|
||||
var15 = (var15 + var16 * 0.5F) * 0.5F;
|
||||
var16 = (var16 *= 0.9F) + (this.random.nextFloat() - this.random.nextFloat());
|
||||
float var18 = MathHelper.sin((float)var17 * 3.1415927F / (float)var12) * (float)var2 / 100.0F + 1.0F;
|
||||
|
||||
for(int var19 = (int)(var9 - var18); var19 <= (int)(var9 + var18); ++var19) {
|
||||
for(int var20 = (int)(var10 - var18); var20 <= (int)(var10 + var18); ++var20) {
|
||||
for(int var21 = (int)(var11 - var18); var21 <= (int)(var11 + var18); ++var21) {
|
||||
float var22 = (float)var19 - var9;
|
||||
float var23 = (float)var20 - var10;
|
||||
float var24 = (float)var21 - var11;
|
||||
if(var22 * var22 + var23 * var23 * 2.0F + var24 * var24 < var18 * var18 && var19 >= 1 && var20 >= 1 && var21 >= 1 && var19 < this.width - 1 && var20 < this.height - 1 && var21 < this.depth - 1) {
|
||||
int var26 = (var20 * this.depth + var21) * this.width + var19;
|
||||
if(this.blocks[var26] == Block.STONE.id) {
|
||||
this.blocks[var26] = var25;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setProgress(int var1) {
|
||||
this.progressBar.setProgress(var1);
|
||||
}
|
||||
|
||||
private long flood(int var1, int var2, int var3, int var4, int var5) {
|
||||
byte var20 = (byte)var5;
|
||||
ArrayList var21 = new ArrayList();
|
||||
byte var6 = 0;
|
||||
int var7 = 1;
|
||||
|
||||
int var8;
|
||||
for(var8 = 1; 1 << var7 < this.width; ++var7) {
|
||||
;
|
||||
}
|
||||
|
||||
while(1 << var8 < this.depth) {
|
||||
++var8;
|
||||
}
|
||||
|
||||
int var9 = this.depth - 1;
|
||||
int var10 = this.width - 1;
|
||||
int var22 = var6 + 1;
|
||||
this.h[0] = ((var2 << var8) + var3 << var7) + var1;
|
||||
long var11 = 0L;
|
||||
var1 = this.width * this.depth;
|
||||
|
||||
while(var22 > 0) {
|
||||
--var22;
|
||||
var2 = this.h[var22];
|
||||
if(var22 == 0 && var21.size() > 0) {
|
||||
this.h = (int[])var21.remove(var21.size() - 1);
|
||||
var22 = this.h.length;
|
||||
}
|
||||
|
||||
var3 = var2 >> var7 & var9;
|
||||
int var13 = var2 >> var7 + var8;
|
||||
|
||||
int var14;
|
||||
int var15;
|
||||
for(var15 = var14 = var2 & var10; var14 > 0 && this.blocks[var2 - 1] == 0; --var2) {
|
||||
--var14;
|
||||
}
|
||||
|
||||
while(var15 < this.width && this.blocks[var2 + var15 - var14] == 0) {
|
||||
++var15;
|
||||
}
|
||||
|
||||
int var16 = var2 >> var7 & var9;
|
||||
int var17 = var2 >> var7 + var8;
|
||||
if(var16 != var3 || var17 != var13) {
|
||||
System.out.println("Diagonal flood!?");
|
||||
}
|
||||
|
||||
boolean var23 = false;
|
||||
boolean var24 = false;
|
||||
boolean var18 = false;
|
||||
var11 += (long)(var15 - var14);
|
||||
|
||||
for(var14 = var14; var14 < var15; ++var14) {
|
||||
this.blocks[var2] = var20;
|
||||
boolean var19;
|
||||
if(var3 > 0) {
|
||||
if((var19 = this.blocks[var2 - this.width] == 0) && !var23) {
|
||||
if(var22 == this.h.length) {
|
||||
var21.add(this.h);
|
||||
this.h = new int[1048576];
|
||||
var22 = 0;
|
||||
}
|
||||
|
||||
this.h[var22++] = var2 - this.width;
|
||||
}
|
||||
|
||||
var23 = var19;
|
||||
}
|
||||
|
||||
if(var3 < this.depth - 1) {
|
||||
if((var19 = this.blocks[var2 + this.width] == 0) && !var24) {
|
||||
if(var22 == this.h.length) {
|
||||
var21.add(this.h);
|
||||
this.h = new int[1048576];
|
||||
var22 = 0;
|
||||
}
|
||||
|
||||
this.h[var22++] = var2 + this.width;
|
||||
}
|
||||
|
||||
var24 = var19;
|
||||
}
|
||||
|
||||
if(var13 > 0) {
|
||||
byte var25 = this.blocks[var2 - var1];
|
||||
if((var20 == Block.LAVA.id || var20 == Block.STATIONARY_LAVA.id) && (var25 == Block.WATER.id || var25 == Block.STATIONARY_WATER.id)) {
|
||||
this.blocks[var2 - var1] = (byte)Block.STONE.id;
|
||||
}
|
||||
|
||||
if((var19 = var25 == 0) && !var18) {
|
||||
if(var22 == this.h.length) {
|
||||
var21.add(this.h);
|
||||
this.h = new int[1048576];
|
||||
var22 = 0;
|
||||
}
|
||||
|
||||
this.h[var22++] = var2 - var1;
|
||||
}
|
||||
|
||||
var18 = var19;
|
||||
}
|
||||
|
||||
++var2;
|
||||
}
|
||||
}
|
||||
|
||||
return var11;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.mojang.minecraft.level.generator.noise;
|
||||
|
||||
public final class CombinedNoise extends Noise
|
||||
{
|
||||
public CombinedNoise(Noise noise1, Noise noise2)
|
||||
{
|
||||
this.noise1 = noise1;
|
||||
this.noise2 = noise2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double compute(double x, double z)
|
||||
{
|
||||
return noise1.compute(x + noise2.compute(x, z), z);
|
||||
}
|
||||
|
||||
private Noise noise1;
|
||||
private Noise noise2;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.mojang.minecraft.level.generator.noise;
|
||||
|
||||
|
||||
public abstract class Noise
|
||||
{
|
||||
public abstract double compute(double x, double z);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.mojang.minecraft.level.generator.noise;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class OctaveNoise extends Noise
|
||||
{
|
||||
public OctaveNoise(Random random, int octaves)
|
||||
{
|
||||
this.octaves = octaves;
|
||||
perlin = new PerlinNoise[octaves];
|
||||
|
||||
for(int count = 0; count < octaves; count++)
|
||||
{
|
||||
perlin[count] = new PerlinNoise(random);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double compute(double x, double z)
|
||||
{
|
||||
double result = 0.0D;
|
||||
double unknown0 = 1.0D;
|
||||
|
||||
for(int count = 0; count < octaves; count++)
|
||||
{
|
||||
result += perlin[count].compute(x / unknown0, z / unknown0) * unknown0;
|
||||
|
||||
unknown0 *= 2.0D;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private PerlinNoise[] perlin;
|
||||
private int octaves;
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.mojang.minecraft.level.generator.noise;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PerlinNoise extends Noise
|
||||
{
|
||||
public PerlinNoise()
|
||||
{
|
||||
this(new Random());
|
||||
}
|
||||
|
||||
public PerlinNoise(Random random)
|
||||
{
|
||||
noise = new int[512];
|
||||
|
||||
for(int count = 0; count < 256; noise[count] = count++)
|
||||
{
|
||||
}
|
||||
|
||||
for(int count = 0; count < 256; count++)
|
||||
{
|
||||
int unknown0 = random.nextInt(256 - count) + count;
|
||||
int unknown1 = noise[count];
|
||||
|
||||
noise[count] = noise[unknown0];
|
||||
noise[unknown0] = unknown1;
|
||||
noise[count + 256] = noise[count];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double compute(double x, double z)
|
||||
{
|
||||
double unknown0 = 0.0D;
|
||||
double unknown1 = z;
|
||||
double unknown2 = x;
|
||||
|
||||
int unknown3 = (int)Math.floor(x) & 255;
|
||||
int unknown4 = (int)Math.floor(z) & 255;
|
||||
int unknown5 = (int)Math.floor(0.0D) & 255;
|
||||
|
||||
unknown2 -= Math.floor(unknown2);
|
||||
unknown1 -= Math.floor(unknown1);
|
||||
unknown0 = 0.0D - Math.floor(0.0D);
|
||||
|
||||
double unknown6 = a(unknown2);
|
||||
double unknown7 = a(unknown1);
|
||||
double unknown8 = a(unknown0);
|
||||
|
||||
int unknown9 = noise[unknown3] + unknown4;
|
||||
int unknown10 = noise[unknown9] + unknown5;
|
||||
|
||||
unknown9 = noise[unknown9 + 1] + unknown5;
|
||||
unknown3 = noise[unknown3 + 1] + unknown4;
|
||||
unknown4 = noise[unknown3] + unknown5;
|
||||
unknown3 = noise[unknown3 + 1] + unknown5;
|
||||
|
||||
// TODO: Maybe organize better.
|
||||
return lerp(
|
||||
unknown8,
|
||||
lerp(
|
||||
unknown7,
|
||||
lerp(
|
||||
unknown6,
|
||||
grad(
|
||||
noise[unknown10],
|
||||
unknown2,
|
||||
unknown1,
|
||||
unknown0),
|
||||
grad(
|
||||
noise[unknown4],
|
||||
unknown2 - 1.0D,
|
||||
unknown1,
|
||||
unknown0)),
|
||||
lerp(
|
||||
unknown6,
|
||||
grad(
|
||||
noise[unknown9],
|
||||
unknown2,
|
||||
unknown1 - 1.0D,
|
||||
unknown0),
|
||||
grad(
|
||||
noise[unknown3],
|
||||
unknown2 - 1.0D,
|
||||
unknown1 - 1.0D,
|
||||
unknown0))),
|
||||
lerp(
|
||||
unknown7,
|
||||
lerp(
|
||||
unknown6,
|
||||
grad(
|
||||
noise[unknown10 + 1],
|
||||
unknown2,
|
||||
unknown1,
|
||||
unknown0 - 1.0D),
|
||||
grad(
|
||||
noise[unknown4 + 1],
|
||||
unknown2 - 1.0D,
|
||||
unknown1,
|
||||
unknown0 - 1.0D)),
|
||||
lerp(
|
||||
unknown6,
|
||||
grad(
|
||||
noise[unknown9 + 1],
|
||||
unknown2,
|
||||
unknown1 - 1.0D,
|
||||
unknown0 - 1.0D),
|
||||
grad(
|
||||
noise[unknown3 + 1],
|
||||
unknown2 - 1.0D,
|
||||
unknown1 - 1.0D,
|
||||
unknown0 - 1.0D))));
|
||||
}
|
||||
|
||||
private int[] noise;
|
||||
|
||||
private static double a(double unknown0)
|
||||
{
|
||||
return unknown0 * unknown0 * unknown0 * (unknown0 * (unknown0 * 6.0D - 15.0D) + 10.0D);
|
||||
}
|
||||
|
||||
private static double lerp(double unknown0, double unknown1, double unknown2)
|
||||
{
|
||||
return unknown1 + unknown0 * (unknown2 - unknown1);
|
||||
}
|
||||
|
||||
private static double grad(int unknown0, double unknown1, double unknown2, double unknown3)
|
||||
{
|
||||
double unknown4 = (unknown0 &= 15) < 8 ? unknown1 : unknown2;
|
||||
double unknown5 = unknown0 < 4 ? unknown2 : (unknown0 != 12 && unknown0 != 14 ? unknown3 : unknown1);
|
||||
|
||||
return ((unknown0 & 1) == 0 ? unknown4 : -unknown4) + ((unknown0 & 2) == 0 ? unknown5 : -unknown5);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.mojang.minecraft.level.liquid;
|
||||
|
||||
public class LiquidType
|
||||
{
|
||||
private LiquidType(int type)
|
||||
{
|
||||
values = new LiquidType[4];
|
||||
|
||||
values[type] = this;
|
||||
}
|
||||
|
||||
private LiquidType[] values;
|
||||
|
||||
public static final LiquidType NOT_LIQUID = new LiquidType(0);
|
||||
public static final LiquidType WATER = new LiquidType(1);
|
||||
public static final LiquidType LAVA = new LiquidType(2);
|
||||
}
|
742
src/main/java/com/mojang/minecraft/level/tile/Block.java
Normal file
|
@ -0,0 +1,742 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.MovingObjectPosition;
|
||||
import com.mojang.minecraft.item.Item;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.liquid.LiquidType;
|
||||
import com.mojang.minecraft.model.Vec3D;
|
||||
import com.mojang.minecraft.particle.ParticleManager;
|
||||
import com.mojang.minecraft.particle.TerrainParticle;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import java.util.Random;
|
||||
|
||||
public class Block
|
||||
{
|
||||
protected Block(int id)
|
||||
{
|
||||
explodes = true;
|
||||
blocks[id] = this;
|
||||
this.id = id;
|
||||
|
||||
setBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
opaque[id] = isSolid();
|
||||
cube[id] = isCube();
|
||||
liquid[id] = false;
|
||||
}
|
||||
|
||||
protected Block(int id, int textureID)
|
||||
{
|
||||
this(id);
|
||||
|
||||
textureId = textureID;
|
||||
}
|
||||
|
||||
protected static Random random = new Random();
|
||||
public static final Block[] blocks = new Block[256];
|
||||
public static final boolean[] physics = new boolean[256];
|
||||
private static boolean[] opaque = new boolean[256];
|
||||
private static boolean[] cube = new boolean[256];
|
||||
public static final boolean[] liquid = new boolean[256];
|
||||
private static int[] tickDelay = new int[256];
|
||||
public static final Block STONE;
|
||||
public static final Block GRASS;
|
||||
public static final Block DIRT;
|
||||
public static final Block COBBLESTONE;
|
||||
public static final Block WOOD;
|
||||
public static final Block SAPLING;
|
||||
public static final Block BEDROCK;
|
||||
public static final Block WATER;
|
||||
public static final Block STATIONARY_WATER;
|
||||
public static final Block LAVA;
|
||||
public static final Block STATIONARY_LAVA;
|
||||
public static final Block SAND;
|
||||
public static final Block GRAVEL;
|
||||
public static final Block GOLD_ORE;
|
||||
public static final Block IRON_ORE;
|
||||
public static final Block COAL_ORE;
|
||||
public static final Block LOG;
|
||||
public static final Block LEAVES;
|
||||
public static final Block SPONGE;
|
||||
public static final Block GLASS;
|
||||
public static final Block RED_WOOL;
|
||||
public static final Block ORANGE_WOOL;
|
||||
public static final Block YELLOW_WOOL;
|
||||
public static final Block LIME_WOOL;
|
||||
public static final Block GREEN_WOOL;
|
||||
public static final Block AQUA_GREEN_WOOL;
|
||||
public static final Block CYAN_WOOL;
|
||||
public static final Block BLUE_WOOL;
|
||||
public static final Block PURPLE_WOOL;
|
||||
public static final Block INDIGO_WOOL;
|
||||
public static final Block VIOLET_WOOL;
|
||||
public static final Block MAGENTA_WOOL;
|
||||
public static final Block PINK_WOOL;
|
||||
public static final Block BLACK_WOOL;
|
||||
public static final Block GRAY_WOOL;
|
||||
public static final Block WHITE_WOOL;
|
||||
public static final Block DANDELION;
|
||||
public static final Block ROSE;
|
||||
public static final Block BROWN_MUSHROOM;
|
||||
public static final Block RED_MUSHROOM;
|
||||
public static final Block GOLD_BLOCK;
|
||||
public static final Block IRON_BLOCK;
|
||||
public static final Block DOUBLE_SLAB;
|
||||
public static final Block SLAB;
|
||||
public static final Block BRICK;
|
||||
public static final Block TNT;
|
||||
public static final Block BOOKSHELF;
|
||||
public static final Block MOSSY_COBBLESTONE;
|
||||
public static final Block OBSIDIAN;
|
||||
public int textureId;
|
||||
public final int id;
|
||||
public Tile$SoundType stepsound;
|
||||
private int hardness;
|
||||
private boolean explodes;
|
||||
public float x1;
|
||||
public float y1;
|
||||
public float z1;
|
||||
public float x2;
|
||||
public float y2;
|
||||
public float z2;
|
||||
public float particleGravity;
|
||||
|
||||
public boolean isCube()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Block setData(Tile$SoundType soundType, float var2, float particleGravity, float hardness)
|
||||
{
|
||||
this.particleGravity = particleGravity;
|
||||
this.stepsound = soundType;
|
||||
this.hardness = (int)(hardness * 20.0F);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void setPhysics(boolean physics)
|
||||
{
|
||||
this.physics[id] = physics;
|
||||
}
|
||||
|
||||
protected void setBounds(float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.z1 = z1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.z2 = z2;
|
||||
}
|
||||
|
||||
public void setTickDelay(int tickDelay)
|
||||
{
|
||||
this.tickDelay[id] = tickDelay;
|
||||
}
|
||||
|
||||
public void renderFullbright(ShapeRenderer shapeRenderer)
|
||||
{
|
||||
float red = 0.5F;
|
||||
float green = 0.8F;
|
||||
float blue = 0.6F;
|
||||
|
||||
shapeRenderer.color(red, red, red);
|
||||
renderInside(shapeRenderer, -2, 0, 0, 0);
|
||||
|
||||
shapeRenderer.color(1.0F, 1.0F, 1.0F);
|
||||
renderInside(shapeRenderer, -2, 0, 0, 1);
|
||||
|
||||
shapeRenderer.color(green, green, green);
|
||||
renderInside(shapeRenderer, -2, 0, 0, 2);
|
||||
|
||||
shapeRenderer.color(green, green, green);
|
||||
renderInside(shapeRenderer, -2, 0, 0, 3);
|
||||
|
||||
shapeRenderer.color(blue, blue, blue);
|
||||
renderInside(shapeRenderer, -2, 0, 0, 4);
|
||||
|
||||
shapeRenderer.color(blue, blue, blue);
|
||||
renderInside(shapeRenderer, -2, 0, 0, 5);
|
||||
}
|
||||
|
||||
protected float getBrightness(Level level, int x, int y, int z)
|
||||
{
|
||||
return level.getBrightness(x, y, z);
|
||||
}
|
||||
|
||||
public boolean canRenderSide(Level level, int x, int y, int z, int side)
|
||||
{
|
||||
return !level.isSolidTile(x, y, z);
|
||||
}
|
||||
|
||||
protected int getTextureId(int texture)
|
||||
{
|
||||
return textureId;
|
||||
}
|
||||
|
||||
public void renderInside(ShapeRenderer shapeRenderer, int x, int y, int z, int side)
|
||||
{
|
||||
int textureID1 = getTextureId(side);
|
||||
|
||||
renderSide(shapeRenderer, x, y, z, side, textureID1);
|
||||
}
|
||||
|
||||
// TODO.
|
||||
public void renderSide(ShapeRenderer shapeRenderer, int x, int y, int z, int side, int textureID)
|
||||
{
|
||||
int var7 = textureID % 16 << 4;
|
||||
int var8 = textureID / 16 << 4;
|
||||
float var9 = (float)var7 / 256.0F;
|
||||
float var17 = ((float)var7 + 15.99F) / 256.0F;
|
||||
float var10 = (float)var8 / 256.0F;
|
||||
float var11 = ((float)var8 + 15.99F) / 256.0F;
|
||||
if(side >= 2 && textureID < 240) {
|
||||
if(this.y1 >= 0.0F && this.y2 <= 1.0F) {
|
||||
var10 = ((float)var8 + this.y1 * 15.99F) / 256.0F;
|
||||
var11 = ((float)var8 + this.y2 * 15.99F) / 256.0F;
|
||||
} else {
|
||||
var10 = (float)var8 / 256.0F;
|
||||
var11 = ((float)var8 + 15.99F) / 256.0F;
|
||||
}
|
||||
}
|
||||
|
||||
float var16 = (float)x + this.x1;
|
||||
float var14 = (float)x + this.x2;
|
||||
float var18 = (float)y + this.y1;
|
||||
float var15 = (float)y + this.y2;
|
||||
float var12 = (float)z + this.z1;
|
||||
float var13 = (float)z + this.z2;
|
||||
if(side == 0) {
|
||||
shapeRenderer.vertexUV(var16, var18, var13, var9, var11);
|
||||
shapeRenderer.vertexUV(var16, var18, var12, var9, var10);
|
||||
shapeRenderer.vertexUV(var14, var18, var12, var17, var10);
|
||||
shapeRenderer.vertexUV(var14, var18, var13, var17, var11);
|
||||
} else if(side == 1) {
|
||||
shapeRenderer.vertexUV(var14, var15, var13, var17, var11);
|
||||
shapeRenderer.vertexUV(var14, var15, var12, var17, var10);
|
||||
shapeRenderer.vertexUV(var16, var15, var12, var9, var10);
|
||||
shapeRenderer.vertexUV(var16, var15, var13, var9, var11);
|
||||
} else if(side == 2) {
|
||||
shapeRenderer.vertexUV(var16, var15, var12, var17, var10);
|
||||
shapeRenderer.vertexUV(var14, var15, var12, var9, var10);
|
||||
shapeRenderer.vertexUV(var14, var18, var12, var9, var11);
|
||||
shapeRenderer.vertexUV(var16, var18, var12, var17, var11);
|
||||
} else if(side == 3) {
|
||||
shapeRenderer.vertexUV(var16, var15, var13, var9, var10);
|
||||
shapeRenderer.vertexUV(var16, var18, var13, var9, var11);
|
||||
shapeRenderer.vertexUV(var14, var18, var13, var17, var11);
|
||||
shapeRenderer.vertexUV(var14, var15, var13, var17, var10);
|
||||
} else if(side == 4) {
|
||||
shapeRenderer.vertexUV(var16, var15, var13, var17, var10);
|
||||
shapeRenderer.vertexUV(var16, var15, var12, var9, var10);
|
||||
shapeRenderer.vertexUV(var16, var18, var12, var9, var11);
|
||||
shapeRenderer.vertexUV(var16, var18, var13, var17, var11);
|
||||
} else if(side == 5) {
|
||||
shapeRenderer.vertexUV(var14, var18, var13, var9, var11);
|
||||
shapeRenderer.vertexUV(var14, var18, var12, var17, var11);
|
||||
shapeRenderer.vertexUV(var14, var15, var12, var17, var10);
|
||||
shapeRenderer.vertexUV(var14, var15, var13, var9, var10);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO.
|
||||
public final void renderSide(ShapeRenderer var1, int var2, int var3, int var4, int var5) {
|
||||
int var6;
|
||||
float var7;
|
||||
float var8 = (var7 = (float)((var6 = this.getTextureId(var5)) % 16) / 16.0F) + 0.0624375F;
|
||||
float var16;
|
||||
float var9 = (var16 = (float)(var6 / 16) / 16.0F) + 0.0624375F;
|
||||
float var10 = (float)var2 + this.x1;
|
||||
float var14 = (float)var2 + this.x2;
|
||||
float var11 = (float)var3 + this.y1;
|
||||
float var15 = (float)var3 + this.y2;
|
||||
float var12 = (float)var4 + this.z1;
|
||||
float var13 = (float)var4 + this.z2;
|
||||
if(var5 == 0) {
|
||||
var1.vertexUV(var14, var11, var13, var8, var9);
|
||||
var1.vertexUV(var14, var11, var12, var8, var16);
|
||||
var1.vertexUV(var10, var11, var12, var7, var16);
|
||||
var1.vertexUV(var10, var11, var13, var7, var9);
|
||||
}
|
||||
|
||||
if(var5 == 1) {
|
||||
var1.vertexUV(var10, var15, var13, var7, var9);
|
||||
var1.vertexUV(var10, var15, var12, var7, var16);
|
||||
var1.vertexUV(var14, var15, var12, var8, var16);
|
||||
var1.vertexUV(var14, var15, var13, var8, var9);
|
||||
}
|
||||
|
||||
if(var5 == 2) {
|
||||
var1.vertexUV(var10, var11, var12, var8, var9);
|
||||
var1.vertexUV(var14, var11, var12, var7, var9);
|
||||
var1.vertexUV(var14, var15, var12, var7, var16);
|
||||
var1.vertexUV(var10, var15, var12, var8, var16);
|
||||
}
|
||||
|
||||
if(var5 == 3) {
|
||||
var1.vertexUV(var14, var15, var13, var8, var16);
|
||||
var1.vertexUV(var14, var11, var13, var8, var9);
|
||||
var1.vertexUV(var10, var11, var13, var7, var9);
|
||||
var1.vertexUV(var10, var15, var13, var7, var16);
|
||||
}
|
||||
|
||||
if(var5 == 4) {
|
||||
var1.vertexUV(var10, var11, var13, var8, var9);
|
||||
var1.vertexUV(var10, var11, var12, var7, var9);
|
||||
var1.vertexUV(var10, var15, var12, var7, var16);
|
||||
var1.vertexUV(var10, var15, var13, var8, var16);
|
||||
}
|
||||
|
||||
if(var5 == 5) {
|
||||
var1.vertexUV(var14, var15, var13, var7, var16);
|
||||
var1.vertexUV(var14, var15, var12, var8, var16);
|
||||
var1.vertexUV(var14, var11, var12, var8, var9);
|
||||
var1.vertexUV(var14, var11, var13, var7, var9);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public AABB getSelectionBox(int x, int y, int z)
|
||||
{
|
||||
AABB aabb = new AABB((float)x + x1, (float)y + y1, (float)z + z1, (float)x + x2, (float)y + y2, (float)z + z2);;
|
||||
|
||||
return aabb;
|
||||
}
|
||||
|
||||
public AABB getCollisionBox(int x, int y, int z)
|
||||
{
|
||||
AABB aabb = new AABB((float)x + x1, (float)y + y1, (float)z + z1, (float)x + x2, (float)y + y2, (float)z + z2);;
|
||||
|
||||
return aabb;
|
||||
}
|
||||
|
||||
public boolean isOpaque()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isSolid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void update(Level level, int x, int y, int z, Random rand)
|
||||
{
|
||||
}
|
||||
|
||||
// TODO.
|
||||
public void spawnBreakParticles(Level level, int x, int y, int z, ParticleManager particleManager)
|
||||
{
|
||||
for(int var6 = 0; var6 < 4; ++var6)
|
||||
{
|
||||
for(int var7 = 0; var7 < 4; ++var7)
|
||||
{
|
||||
for(int var8 = 0; var8 < 4; ++var8)
|
||||
{
|
||||
float var9 = (float)x + ((float)var6 + 0.5F) / (float)4;
|
||||
float var10 = (float)y + ((float)var7 + 0.5F) / (float)4;
|
||||
float var11 = (float)z + ((float)var8 + 0.5F) / (float)4;
|
||||
|
||||
particleManager.spawnParticle(new TerrainParticle(level, var9, var10, var11, var9 - (float) x - 0.5F, var10 - (float) y - 0.5F, var11 - (float) z - 0.5F, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO.
|
||||
public final void spawnBlockParticles(Level var1, int var2, int var3, int var4, int var5, ParticleManager var6) {
|
||||
float var7 = 0.1F;
|
||||
float var8 = (float)var2 + random.nextFloat() * (this.x2 - this.x1 - var7 * 2.0F) + var7 + this.x1;
|
||||
float var9 = (float)var3 + random.nextFloat() * (this.y2 - this.y1 - var7 * 2.0F) + var7 + this.y1;
|
||||
float var10 = (float)var4 + random.nextFloat() * (this.z2 - this.z1 - var7 * 2.0F) + var7 + this.z1;
|
||||
if(var5 == 0) {
|
||||
var9 = (float)var3 + this.y1 - var7;
|
||||
}
|
||||
|
||||
if(var5 == 1) {
|
||||
var9 = (float)var3 + this.y2 + var7;
|
||||
}
|
||||
|
||||
if(var5 == 2) {
|
||||
var10 = (float)var4 + this.z1 - var7;
|
||||
}
|
||||
|
||||
if(var5 == 3) {
|
||||
var10 = (float)var4 + this.z2 + var7;
|
||||
}
|
||||
|
||||
if(var5 == 4) {
|
||||
var8 = (float)var2 + this.x1 - var7;
|
||||
}
|
||||
|
||||
if(var5 == 5) {
|
||||
var8 = (float)var2 + this.x2 + var7;
|
||||
}
|
||||
|
||||
var6.spawnParticle((new TerrainParticle(var1, var8, var9, var10, 0.0F, 0.0F, 0.0F, this)).setPower(0.2F).scale(0.6F));
|
||||
}
|
||||
|
||||
public LiquidType getLiquidType()
|
||||
{
|
||||
return LiquidType.NOT_LIQUID;
|
||||
}
|
||||
|
||||
// TODO.
|
||||
public void onNeighborChange(Level var1, int var2, int var3, int var4, int var5)
|
||||
{
|
||||
}
|
||||
|
||||
public void onPlace(Level level, int x, int y, int z)
|
||||
{
|
||||
}
|
||||
|
||||
public int getTickDelay()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void onAdded(Level level, int x, int y, int z)
|
||||
{
|
||||
}
|
||||
|
||||
// TODO past here.
|
||||
|
||||
public void onRemoved(Level var1, int var2, int var3, int var4) {}
|
||||
|
||||
public int getDropCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getDrop() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public final int getHardness() {
|
||||
return this.hardness;
|
||||
}
|
||||
|
||||
public void onBreak(Level var1, int var2, int var3, int var4) {
|
||||
this.dropItems(var1, var2, var3, var4, 1.0F);
|
||||
}
|
||||
|
||||
public void dropItems(Level var1, int var2, int var3, int var4, float var5) {
|
||||
if(!var1.creativeMode) {
|
||||
int var6 = this.getDropCount();
|
||||
|
||||
for(int var7 = 0; var7 < var6; ++var7) {
|
||||
if(random.nextFloat() <= var5) {
|
||||
float var8 = 0.7F;
|
||||
float var9 = random.nextFloat() * var8 + (1.0F - var8) * 0.5F;
|
||||
float var10 = random.nextFloat() * var8 + (1.0F - var8) * 0.5F;
|
||||
var8 = random.nextFloat() * var8 + (1.0F - var8) * 0.5F;
|
||||
var1.addEntity(new Item(var1, (float)var2 + var9, (float)var3 + var10, (float)var4 + var8, this.getDrop()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void renderPreview(ShapeRenderer var1) {
|
||||
var1.begin();
|
||||
|
||||
for(int var2 = 0; var2 < 6; ++var2) {
|
||||
if(var2 == 0) {
|
||||
var1.normal(0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if(var2 == 1) {
|
||||
var1.normal(0.0F, -1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if(var2 == 2) {
|
||||
var1.normal(0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(var2 == 3) {
|
||||
var1.normal(0.0F, 0.0F, -1.0F);
|
||||
}
|
||||
|
||||
if(var2 == 4) {
|
||||
var1.normal(1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
if(var2 == 5) {
|
||||
var1.normal(-1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
this.renderInside(var1, 0, 0, 0, var2);
|
||||
}
|
||||
|
||||
var1.end();
|
||||
}
|
||||
|
||||
public final boolean canExplode() {
|
||||
return this.explodes;
|
||||
}
|
||||
|
||||
public final MovingObjectPosition clip(int var1, int var2, int var3, Vec3D var4, Vec3D var5) {
|
||||
var4 = var4.add((float)(-var1), (float)(-var2), (float)(-var3));
|
||||
var5 = var5.add((float)(-var1), (float)(-var2), (float)(-var3));
|
||||
Vec3D var6 = var4.getXIntersection(var5, this.x1);
|
||||
Vec3D var7 = var4.getXIntersection(var5, this.x2);
|
||||
Vec3D var8 = var4.getYIntersection(var5, this.y1);
|
||||
Vec3D var9 = var4.getYIntersection(var5, this.y2);
|
||||
Vec3D var10 = var4.getZIntersection(var5, this.z1);
|
||||
var5 = var4.getZIntersection(var5, this.z2);
|
||||
if(!this.xIntersects(var6)) {
|
||||
var6 = null;
|
||||
}
|
||||
|
||||
if(!this.xIntersects(var7)) {
|
||||
var7 = null;
|
||||
}
|
||||
|
||||
if(!this.yIntersects(var8)) {
|
||||
var8 = null;
|
||||
}
|
||||
|
||||
if(!this.yIntersects(var9)) {
|
||||
var9 = null;
|
||||
}
|
||||
|
||||
if(!this.zIntersects(var10)) {
|
||||
var10 = null;
|
||||
}
|
||||
|
||||
if(!this.zIntersects(var5)) {
|
||||
var5 = null;
|
||||
}
|
||||
|
||||
Vec3D var11 = null;
|
||||
if(var6 != null) {
|
||||
var11 = var6;
|
||||
}
|
||||
|
||||
if(var7 != null && (var11 == null || var4.distance(var7) < var4.distance(var11))) {
|
||||
var11 = var7;
|
||||
}
|
||||
|
||||
if(var8 != null && (var11 == null || var4.distance(var8) < var4.distance(var11))) {
|
||||
var11 = var8;
|
||||
}
|
||||
|
||||
if(var9 != null && (var11 == null || var4.distance(var9) < var4.distance(var11))) {
|
||||
var11 = var9;
|
||||
}
|
||||
|
||||
if(var10 != null && (var11 == null || var4.distance(var10) < var4.distance(var11))) {
|
||||
var11 = var10;
|
||||
}
|
||||
|
||||
if(var5 != null && (var11 == null || var4.distance(var5) < var4.distance(var11))) {
|
||||
var11 = var5;
|
||||
}
|
||||
|
||||
if(var11 == null) {
|
||||
return null;
|
||||
} else {
|
||||
byte var12 = -1;
|
||||
if(var11 == var6) {
|
||||
var12 = 4;
|
||||
}
|
||||
|
||||
if(var11 == var7) {
|
||||
var12 = 5;
|
||||
}
|
||||
|
||||
if(var11 == var8) {
|
||||
var12 = 0;
|
||||
}
|
||||
|
||||
if(var11 == var9) {
|
||||
var12 = 1;
|
||||
}
|
||||
|
||||
if(var11 == var10) {
|
||||
var12 = 2;
|
||||
}
|
||||
|
||||
if(var11 == var5) {
|
||||
var12 = 3;
|
||||
}
|
||||
|
||||
return new MovingObjectPosition(var1, var2, var3, var12, var11.add((float)var1, (float)var2, (float)var3));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean xIntersects(Vec3D var1) {
|
||||
return var1 == null?false:var1.y >= this.y1 && var1.y <= this.y2 && var1.z >= this.z1 && var1.z <= this.z2;
|
||||
}
|
||||
|
||||
private boolean yIntersects(Vec3D var1) {
|
||||
return var1 == null?false:var1.x >= this.x1 && var1.x <= this.x2 && var1.z >= this.z1 && var1.z <= this.z2;
|
||||
}
|
||||
|
||||
private boolean zIntersects(Vec3D var1) {
|
||||
return var1 == null?false:var1.x >= this.x1 && var1.x <= this.x2 && var1.y >= this.y1 && var1.y <= this.y2;
|
||||
}
|
||||
|
||||
public void explode(Level var1, int var2, int var3, int var4) {}
|
||||
|
||||
public boolean render(Level var1, int var2, int var3, int var4, ShapeRenderer var5) {
|
||||
boolean var6 = false;
|
||||
float var7 = 0.5F;
|
||||
float var8 = 0.8F;
|
||||
float var9 = 0.6F;
|
||||
float var10;
|
||||
if(this.canRenderSide(var1, var2, var3 - 1, var4, 0)) {
|
||||
var10 = this.getBrightness(var1, var2, var3 - 1, var4);
|
||||
var5.color(var7 * var10, var7 * var10, var7 * var10);
|
||||
this.renderInside(var5, var2, var3, var4, 0);
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if(this.canRenderSide(var1, var2, var3 + 1, var4, 1)) {
|
||||
var10 = this.getBrightness(var1, var2, var3 + 1, var4);
|
||||
var5.color(var10 * 1.0F, var10 * 1.0F, var10 * 1.0F);
|
||||
this.renderInside(var5, var2, var3, var4, 1);
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if(this.canRenderSide(var1, var2, var3, var4 - 1, 2)) {
|
||||
var10 = this.getBrightness(var1, var2, var3, var4 - 1);
|
||||
var5.color(var8 * var10, var8 * var10, var8 * var10);
|
||||
this.renderInside(var5, var2, var3, var4, 2);
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if(this.canRenderSide(var1, var2, var3, var4 + 1, 3)) {
|
||||
var10 = this.getBrightness(var1, var2, var3, var4 + 1);
|
||||
var5.color(var8 * var10, var8 * var10, var8 * var10);
|
||||
this.renderInside(var5, var2, var3, var4, 3);
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if(this.canRenderSide(var1, var2 - 1, var3, var4, 4)) {
|
||||
var10 = this.getBrightness(var1, var2 - 1, var3, var4);
|
||||
var5.color(var9 * var10, var9 * var10, var9 * var10);
|
||||
this.renderInside(var5, var2, var3, var4, 4);
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
if(this.canRenderSide(var1, var2 + 1, var3, var4, 5)) {
|
||||
var10 = this.getBrightness(var1, var2 + 1, var3, var4);
|
||||
var5.color(var9 * var10, var9 * var10, var9 * var10);
|
||||
this.renderInside(var5, var2, var3, var4, 5);
|
||||
var6 = true;
|
||||
}
|
||||
|
||||
return var6;
|
||||
}
|
||||
|
||||
public int getRenderPass() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static {
|
||||
Block var10000 = (new StoneBlock(1, 1)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 1.0F);
|
||||
boolean var0 = false;
|
||||
Block var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
STONE = var1;
|
||||
GRASS = (new GrassBlock(2)).setData(Tile$SoundType.grass, 0.9F, 1.0F, 0.6F);
|
||||
DIRT = (new DirtBlock(3, 2)).setData(Tile$SoundType.grass, 0.8F, 1.0F, 0.5F);
|
||||
var10000 = (new Block(4, 16)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 1.5F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
COBBLESTONE = var1;
|
||||
WOOD = (new Block(5, 4)).setData(Tile$SoundType.wood, 1.0F, 1.0F, 1.5F);
|
||||
SAPLING = (new SaplingBlock(6, 15)).setData(Tile$SoundType.none, 0.7F, 1.0F, 0.0F);
|
||||
var10000 = (new Block(7, 17)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 999.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
BEDROCK = var1;
|
||||
WATER = (new LiquidBlock(8, LiquidType.WATER)).setData(Tile$SoundType.none, 1.0F, 1.0F, 100.0F);
|
||||
STATIONARY_WATER = (new StillLiquidBlock(9, LiquidType.WATER)).setData(Tile$SoundType.none, 1.0F, 1.0F, 100.0F);
|
||||
LAVA = (new LiquidBlock(10, LiquidType.LAVA)).setData(Tile$SoundType.none, 1.0F, 1.0F, 100.0F);
|
||||
STATIONARY_LAVA = (new StillLiquidBlock(11, LiquidType.LAVA)).setData(Tile$SoundType.none, 1.0F, 1.0F, 100.0F);
|
||||
SAND = (new SandBlock(12, 18)).setData(Tile$SoundType.gravel, 0.8F, 1.0F, 0.5F);
|
||||
GRAVEL = (new SandBlock(13, 19)).setData(Tile$SoundType.gravel, 0.8F, 1.0F, 0.6F);
|
||||
var10000 = (new OreBlock(14, 32)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 3.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
GOLD_ORE = var1;
|
||||
var10000 = (new OreBlock(15, 33)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 3.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
IRON_ORE = var1;
|
||||
var10000 = (new OreBlock(16, 34)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 3.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
COAL_ORE = var1;
|
||||
LOG = (new WoodBlock(17)).setData(Tile$SoundType.wood, 1.0F, 1.0F, 2.5F);
|
||||
LEAVES = (new LeavesBlock(18, 22)).setData(Tile$SoundType.grass, 1.0F, 0.4F, 0.2F);
|
||||
SPONGE = (new SpongeBlock(19)).setData(Tile$SoundType.cloth, 1.0F, 0.9F, 0.6F);
|
||||
GLASS = (new GlassBlock(20, 49, false)).setData(Tile$SoundType.metal, 1.0F, 1.0F, 0.3F);
|
||||
RED_WOOL = (new Block(21, 64)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
ORANGE_WOOL = (new Block(22, 65)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
YELLOW_WOOL = (new Block(23, 66)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
LIME_WOOL = (new Block(24, 67)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
GREEN_WOOL = (new Block(25, 68)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
AQUA_GREEN_WOOL = (new Block(26, 69)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
CYAN_WOOL = (new Block(27, 70)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
BLUE_WOOL = (new Block(28, 71)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
PURPLE_WOOL = (new Block(29, 72)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
INDIGO_WOOL = (new Block(30, 73)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
VIOLET_WOOL = (new Block(31, 74)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
MAGENTA_WOOL = (new Block(32, 75)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
PINK_WOOL = (new Block(33, 76)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
BLACK_WOOL = (new Block(34, 77)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
GRAY_WOOL = (new Block(35, 78)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
WHITE_WOOL = (new Block(36, 79)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.8F);
|
||||
DANDELION = (new FlowerBlock(37, 13)).setData(Tile$SoundType.none, 0.7F, 1.0F, 0.0F);
|
||||
ROSE = (new FlowerBlock(38, 12)).setData(Tile$SoundType.none, 0.7F, 1.0F, 0.0F);
|
||||
BROWN_MUSHROOM = (new MushroomBlock(39, 29)).setData(Tile$SoundType.none, 0.7F, 1.0F, 0.0F);
|
||||
RED_MUSHROOM = (new MushroomBlock(40, 28)).setData(Tile$SoundType.none, 0.7F, 1.0F, 0.0F);
|
||||
var10000 = (new MetalBlock(41, 40)).setData(Tile$SoundType.metal, 0.7F, 1.0F, 3.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
GOLD_BLOCK = var1;
|
||||
var10000 = (new MetalBlock(42, 39)).setData(Tile$SoundType.metal, 0.7F, 1.0F, 5.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
IRON_BLOCK = var1;
|
||||
var10000 = (new SlabBlock(43, true)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 2.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
DOUBLE_SLAB = var1;
|
||||
var10000 = (new SlabBlock(44, false)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 2.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
SLAB = var1;
|
||||
var10000 = (new Block(45, 7)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 2.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
BRICK = var1;
|
||||
TNT = (new TNTBlock(46, 8)).setData(Tile$SoundType.cloth, 1.0F, 1.0F, 0.0F);
|
||||
BOOKSHELF = (new BookshelfBlock(47, 35)).setData(Tile$SoundType.wood, 1.0F, 1.0F, 1.5F);
|
||||
var10000 = (new Block(48, 36)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 1.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
MOSSY_COBBLESTONE = var1;
|
||||
var10000 = (new StoneBlock(49, 37)).setData(Tile$SoundType.stone, 1.0F, 1.0F, 10.0F);
|
||||
var0 = false;
|
||||
var1 = var10000;
|
||||
var10000.explodes = false;
|
||||
OBSIDIAN = var1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
|
||||
public final class BookshelfBlock extends Block {
|
||||
|
||||
public BookshelfBlock(int var1, int var2) {
|
||||
super(47, 35);
|
||||
}
|
||||
|
||||
protected final int getTextureId(int texture) {
|
||||
return texture <= 1?4:this.textureId;
|
||||
}
|
||||
|
||||
public final int getDrop() {
|
||||
if(Minecraft.settings.randomDrops) {
|
||||
return new Random().nextInt(49 - 1 + 1) + 1;
|
||||
}
|
||||
return Block.BOOKSHELF.id;
|
||||
}
|
||||
|
||||
public final int getDropCount() {
|
||||
return 0;
|
||||
}
|
||||
}
|
20
src/main/java/com/mojang/minecraft/level/tile/DirtBlock.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
|
||||
public final class DirtBlock extends Block {
|
||||
|
||||
protected DirtBlock(int var1, int var2) {
|
||||
super(3, 2);
|
||||
}
|
||||
|
||||
public final int getDrop() {
|
||||
if(Minecraft.settings.randomDrops) {
|
||||
return new Random().nextInt(49 - 1 + 1) + 1;
|
||||
}
|
||||
return Block.DIRT.id;
|
||||
}
|
||||
}
|
103
src/main/java/com/mojang/minecraft/level/tile/FlowerBlock.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
import com.mojang.util.MathHelper;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class FlowerBlock extends Block {
|
||||
|
||||
protected FlowerBlock(int var1, int var2) {
|
||||
super(var1);
|
||||
this.textureId = var2;
|
||||
this.setPhysics(true);
|
||||
float var3 = 0.2F;
|
||||
this.setBounds(0.5F - var3, 0.0F, 0.5F - var3, var3 + 0.5F, var3 * 3.0F, var3 + 0.5F);
|
||||
}
|
||||
|
||||
public void update(Level level, int x, int y, int z, Random rand) {
|
||||
if(!level.growTrees) {
|
||||
int var6 = level.getTile(x, y - 1, z);
|
||||
if(!level.isLit(x, y, z) || var6 != Block.DIRT.id && var6 != Block.GRASS.id) {
|
||||
level.setTile(x, y, z, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void render(ShapeRenderer var1, float var2, float var3, float var4) {
|
||||
int var15;
|
||||
int var5 = (var15 = this.getTextureId(15)) % 16 << 4;
|
||||
int var6 = var15 / 16 << 4;
|
||||
float var16 = (float)var5 / 256.0F;
|
||||
float var17 = ((float)var5 + 15.99F) / 256.0F;
|
||||
float var7 = (float)var6 / 256.0F;
|
||||
float var18 = ((float)var6 + 15.99F) / 256.0F;
|
||||
|
||||
for(int var8 = 0; var8 < 2; ++var8) {
|
||||
float var9 = (float)((double)MathHelper.sin((float)var8 * 3.1415927F / 2.0F + 0.7853982F) * 0.5D);
|
||||
float var10 = (float)((double)MathHelper.cos((float)var8 * 3.1415927F / 2.0F + 0.7853982F) * 0.5D);
|
||||
float var11 = var2 + 0.5F - var9;
|
||||
var9 += var2 + 0.5F;
|
||||
float var13 = var3 + 1.0F;
|
||||
float var14 = var4 + 0.5F - var10;
|
||||
var10 += var4 + 0.5F;
|
||||
var1.vertexUV(var11, var13, var14, var17, var7);
|
||||
var1.vertexUV(var9, var13, var10, var16, var7);
|
||||
var1.vertexUV(var9, var3, var10, var16, var18);
|
||||
var1.vertexUV(var11, var3, var14, var17, var18);
|
||||
var1.vertexUV(var9, var13, var10, var17, var7);
|
||||
var1.vertexUV(var11, var13, var14, var16, var7);
|
||||
var1.vertexUV(var11, var3, var14, var16, var18);
|
||||
var1.vertexUV(var9, var3, var10, var17, var18);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final boolean isOpaque() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void renderPreview(ShapeRenderer var1) {
|
||||
var1.normal(0.0F, 1.0F, 0.0F);
|
||||
var1.begin();
|
||||
this.render(var1, 0.0F, 0.4F, -0.3F);
|
||||
var1.end();
|
||||
}
|
||||
|
||||
public final boolean isCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean render(Level var1, int var2, int var3, int var4, ShapeRenderer var5) {
|
||||
float var6 = var1.getBrightness(var2, var3, var4);
|
||||
var5.color(var6, var6, var6);
|
||||
this.render(var5, (float)var2, (float)var3, (float)var4);
|
||||
return true;
|
||||
}
|
||||
|
||||
public final void renderFullbright(ShapeRenderer shapeRenderer) {
|
||||
shapeRenderer.color(1.0F, 1.0F, 1.0F);
|
||||
this.render(shapeRenderer, (float)-2, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getCollisionBox(int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getDrop() {
|
||||
if(Minecraft.settings.randomDrops) {
|
||||
return new Random().nextInt(49 - 1 + 1) + 1;
|
||||
}
|
||||
return this == Block.ROSE ? Block.ROSE.id : Block.DANDELION.id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public final class GlassBlock extends Block {
|
||||
|
||||
private boolean showNeighborSides = false;
|
||||
|
||||
|
||||
protected GlassBlock(int var1, int var2, boolean var3) {
|
||||
super(20, 49);
|
||||
}
|
||||
|
||||
public final boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean canRenderSide(Level level, int x, int y, int z, int side) {
|
||||
int var6 = level.getTile(x, y, z);
|
||||
return !this.showNeighborSides && var6 == this.id?false:super.canRenderSide(level, x, y, z, side);
|
||||
}
|
||||
|
||||
public final boolean isOpaque() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import java.util.Random;
|
||||
|
||||
public final class GrassBlock extends Block {
|
||||
|
||||
protected GrassBlock(int var1) {
|
||||
super(2);
|
||||
this.textureId = 3;
|
||||
this.setPhysics(true);
|
||||
}
|
||||
|
||||
protected final int getTextureId(int texture) {
|
||||
return texture == 1 ? 0 : (texture == 0 ? 2 : Minecraft.settings.ofBetterGrass ? 0 : 3);
|
||||
}
|
||||
|
||||
public final void update(Level level, int x, int y, int z, Random rand) {
|
||||
if(rand.nextInt(4) == 0) {
|
||||
if(!level.isLit(x, y, z)) {
|
||||
level.setTile(x, y, z, Block.DIRT.id);
|
||||
} else {
|
||||
for(int var9 = 0; var9 < 4; ++var9) {
|
||||
int var6 = x + rand.nextInt(3) - 1;
|
||||
int var7 = y + rand.nextInt(5) - 3;
|
||||
int var8 = z + rand.nextInt(3) - 1;
|
||||
if(level.getTile(var6, var7, var8) == Block.DIRT.id && level.isLit(var6, var7, var8)) {
|
||||
level.setTile(var6, var7, var8, Block.GRASS.id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final int getDrop() {
|
||||
if(Minecraft.settings.randomDrops) {
|
||||
return new Random().nextInt(49 - 1 + 1) + 1;
|
||||
}
|
||||
return Block.DIRT.getDrop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.level.Level;
|
||||
|
||||
public class LeavesBaseBlock extends Block {
|
||||
|
||||
private boolean showNeighborSides = true;
|
||||
|
||||
|
||||
protected LeavesBaseBlock(int var1, int var2, boolean var3) {
|
||||
super(var1, var2);
|
||||
}
|
||||
|
||||
public final boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean canRenderSide(Level level, int x, int y, int z, int side) {
|
||||
int var6 = level.getTile(x, y, z);
|
||||
return !this.showNeighborSides && var6 == this.id?false:super.canRenderSide(level, x, y, z, side);
|
||||
}
|
||||
|
||||
public final boolean isOpaque() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
import com.mojang.minecraft.level.tile.LeavesBaseBlock;
|
||||
|
||||
public final class LeavesBlock extends LeavesBaseBlock {
|
||||
|
||||
protected LeavesBlock(int var1, int var2) {
|
||||
super(18, 22, true);
|
||||
}
|
||||
|
||||
public final int getDropCount() {
|
||||
return random.nextInt(10) == 0?1:0;
|
||||
}
|
||||
|
||||
public final int getDrop() {
|
||||
return Block.SAPLING.id;
|
||||
}
|
||||
}
|
168
src/main/java/com/mojang/minecraft/level/tile/LiquidBlock.java
Normal file
|
@ -0,0 +1,168 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import com.mojang.minecraft.level.Level;
|
||||
import com.mojang.minecraft.level.liquid.LiquidType;
|
||||
import com.mojang.minecraft.phys.AABB;
|
||||
import com.mojang.minecraft.render.ShapeRenderer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LiquidBlock extends Block {
|
||||
|
||||
protected LiquidType type;
|
||||
protected int stillId;
|
||||
protected int movingId;
|
||||
|
||||
|
||||
protected LiquidBlock(int var1, LiquidType var2) {
|
||||
super(var1);
|
||||
this.type = var2;
|
||||
this.textureId = 14;
|
||||
if(var2 == LiquidType.LAVA) {
|
||||
this.textureId = 30;
|
||||
}
|
||||
|
||||
Block.liquid[var1] = true;
|
||||
this.movingId = var1;
|
||||
this.stillId = var1 + 1;
|
||||
float var4 = 0.01F;
|
||||
float var3 = 0.1F;
|
||||
this.setBounds(var4 + 0.0F, 0.0F - var3 + var4, var4 + 0.0F, var4 + 1.0F, 1.0F - var3 + var4, var4 + 1.0F);
|
||||
this.setPhysics(true);
|
||||
if(var2 == LiquidType.LAVA) {
|
||||
this.setTickDelay(16);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final boolean isCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final void onPlace(Level level, int x, int y, int z) {
|
||||
level.addToTickNextTick(x, y, z, this.movingId);
|
||||
}
|
||||
|
||||
public void update(Level level, int x, int y, int z, Random rand) {
|
||||
boolean var7 = false;
|
||||
z = z;
|
||||
y = y;
|
||||
x = x;
|
||||
level = level;
|
||||
boolean var8 = false;
|
||||
|
||||
boolean var6;
|
||||
do {
|
||||
--y;
|
||||
if(level.getTile(x, y, z) != 0 || !this.canFlow(level, x, y, z)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(var6 = level.setTile(x, y, z, this.movingId)) {
|
||||
var8 = true;
|
||||
}
|
||||
} while(var6 && this.type != LiquidType.LAVA);
|
||||
|
||||
++y;
|
||||
if(this.type == LiquidType.WATER || !var8) {
|
||||
var8 = var8 | this.flow(level, x - 1, y, z) | this.flow(level, x + 1, y, z) | this.flow(level, x, y, z - 1) | this.flow(level, x, y, z + 1);
|
||||
}
|
||||
|
||||
if(!var8) {
|
||||
level.setTileNoUpdate(x, y, z, this.stillId);
|
||||
} else {
|
||||
level.addToTickNextTick(x, y, z, this.movingId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean canFlow(Level var1, int var2, int var3, int var4) {
|
||||
if(this.type == LiquidType.WATER) {
|
||||
for(int var7 = var2 - 2; var7 <= var2 + 2; ++var7) {
|
||||
for(int var5 = var3 - 2; var5 <= var3 + 2; ++var5) {
|
||||
for(int var6 = var4 - 2; var6 <= var4 + 2; ++var6) {
|
||||
if(var1.getTile(var7, var5, var6) == Block.SPONGE.id) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean flow(Level var1, int var2, int var3, int var4) {
|
||||
if(var1.getTile(var2, var3, var4) == 0) {
|
||||
if(!this.canFlow(var1, var2, var3, var4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(var1.setTile(var2, var3, var4, this.movingId)) {
|
||||
var1.addToTickNextTick(var2, var3, var4, this.movingId);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected final float getBrightness(Level level, int x, int y, int z) {
|
||||
return this.type == LiquidType.LAVA?100.0F: level.getBrightness(x, y, z);
|
||||
}
|
||||
|
||||
public final boolean canRenderSide(Level level, int x, int y, int z, int side) {
|
||||
int var6;
|
||||
return x >= 0 && y >= 0 && z >= 0 && x < level.width && z < level.height?((var6 = level.getTile(x, y, z)) != this.movingId && var6 != this.stillId?(side == 1 && (level.getTile(x - 1, y, z) == 0 || level.getTile(x + 1, y, z) == 0 || level.getTile(x, y, z - 1) == 0 || level.getTile(x, y, z + 1) == 0)?true:super.canRenderSide(level, x, y, z, side)):false):false;
|
||||
}
|
||||
|
||||
public final void renderInside(ShapeRenderer shapeRenderer, int x, int y, int z, int side) {
|
||||
super.renderInside(shapeRenderer, x, y, z, side);
|
||||
super.renderSide(shapeRenderer, x, y, z, side);
|
||||
}
|
||||
|
||||
public final boolean isOpaque() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean isSolid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final LiquidType getLiquidType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void onNeighborChange(Level var1, int var2, int var3, int var4, int var5) {
|
||||
if(var5 != 0) {
|
||||
LiquidType var6 = Block.blocks[var5].getLiquidType();
|
||||
if(this.type == LiquidType.WATER && var6 == LiquidType.LAVA || var6 == LiquidType.WATER && this.type == LiquidType.LAVA) {
|
||||
var1.setTile(var2, var3, var4, Block.STONE.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var1.addToTickNextTick(var2, var3, var4, var5);
|
||||
}
|
||||
|
||||
public final int getTickDelay() {
|
||||
return this.type == LiquidType.LAVA?5:0;
|
||||
}
|
||||
|
||||
public final void dropItems(Level var1, int var2, int var3, int var4, float var5) {}
|
||||
|
||||
public final void onBreak(Level var1, int var2, int var3, int var4) {}
|
||||
|
||||
public final int getDropCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final int getRenderPass() {
|
||||
return this.type == LiquidType.WATER?1:0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getCollisionBox(int x, int y, int z)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.mojang.minecraft.level.tile;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.minecraft.Minecraft;
|
||||
import com.mojang.minecraft.level.tile.Block;
|
||||
|
||||
public final class MetalBlock extends Block {
|
||||
|
||||
public MetalBlock(int var1, int var2) {
|
||||
super(var1);
|
||||
this.textureId = var2;
|
||||
}
|
||||
|
||||
protected final int getTextureId(int texture) {
|
||||
return texture == 1?this.textureId - 16:(texture == 0?this.textureId + 16:this.textureId);
|
||||
}
|
||||
|
||||
public final int getDrop() {
|
||||
if(Minecraft.settings.randomDrops) {
|
||||
return new Random().nextInt(49 - 1 + 1) + 1;
|
||||
}
|
||||
return this == Block.GOLD_BLOCK ? Block.GOLD_BLOCK.id : Block.IRON_BLOCK.id;
|
||||
}
|
||||
}
|