Compare commits

..
48 Commits
Author SHA1 Message Date
xiaozhou233 30fde895b6 Docs: README.md 2026-11-10 15:00:21 +08:00
xiaozhou233 ed7fa13e7f Fix: Interpolate world positions with the frame's partial tick
- Pass the 1.8.9 HUD method's partial tick through the render hook into
  EventRender2D instead of reading Timer.renderPartialTicks reflectively
- Let WorldView.snapshot() take that value so ESP projection matches the
  rendered world and no longer advances in 20 Hz steps
- Keep the reflected timer read as a fallback and warn once when it cannot
  be resolved instead of silently interpolating with 0
2026-11-10 13:47:55 +08:00
xiaozhou233 d8a46a1b70 Feat: Show module settings as a page in the ClickGUI content area
- Replace the floating SettingsWindow with an inline settings page
- Return to the module list via the back button or a category click
- Scroll the module list and the settings page with the mouse wheel
- Share module row geometry through ContentList and add a scrollbar
  helper
- Bail out of scroll input when the content fits
2026-11-10 13:26:19 +08:00
xiaozhou233 09de736269 Feat: Add mouse wheel scrolling to client input
- Queue wheel notches in ClientInput for the next frame
- Forward wheel deltas from the 1.8.9 screen and 26.2 input screen
- Hook GuiScreen#handleMouseInput after vanilla, guarded so a
  missing method never disables the other input injections
- Shrink HUD module font size to 10
2026-11-10 13:12:22 +08:00
xiaozhou233 d9075831e3 Feat: Add entity kind and invisibility filters to ESP
- WorldView now captures every entity instead of players only and no longer applies gameplay filtering.

- Add EntityKind (player/monster/animal/villager/other) and local-player/invisible flags to EntityTarget.

- Move target filtering into ESP and add Players, Local Player, Monsters, Animals, Villagers, Others and Invisible options.

- Invisible entities are an independent filter and can be used as a standalone invisible-only ESP.
2026-11-09 15:38:48 +08:00
xiaozhou233 51a232d7ac Feat: Add 2D ESP module and cross-version world wrapper
- Add ESP render module drawing 2D boxes, corner brackets, fill, health
  bar, name and distance for nearby players.
- Add WorldView capability backed by per-version implementations:
  1.8.9 reconstructs the camera from renderViewEntity, Timer partial
  ticks and EntityRenderer#getFOVModifier, including third-person and
  front-view offsets; 26.2 reads GameRenderer#mainCamera directly.
- Add version-independent value objects (WorldSnapshot, EntityTarget,
  ScreenPoint) and Projection math shared by every version.
- Wire the new capability through WrapperProvider, WrapperRegistry and
  MinecraftFactory, and create the world view in OrangeX.start().
- Skip local, dead, invisible and spectator players, and drop targets
  behind the camera.

Verified with :OrangeX:shadowJar, mapping checks for both 1.8.9 mapping
files, member checks against the 1.8.8 obf jar, and fake-world tests for
both version implementations.
2026-11-08 18:11:11 +08:00
xiaozhou233 29eb7609e9 Feat: Add ClickGUI interface and stabilise 26.2 font rendering
- Split the window into style, layout, sidebar, content and settings renderers

- Remove the ACTIVE counter and footer hint; open module settings in a draggable popup on right click

- Use Montserrat for the ClickGUI and snap the window to whole pixels while dragging

- Fix 26.2 glyph snapping: shared baseline, thin-stroke visibility and even horizontal spacing
2026-11-08 15:24:42 +08:00
xiaozhou233 8183eae9d1 Fix: Restore correct rounded-rect corners on 26.2
- V26_2TextureHelper.create now takes raw RGBA again, so V26_2ShapeCache's quarter-circle corner textures are uploaded intact instead of being read as one-byte coverage and appearing grey

- Add an explicit createFromCoverage entry point for font atlases, which still expands directly into the NativeImage buffer

- Point V26_2FontBackend at createFromCoverage so the font texture optimisation is kept
2026-11-08 01:55:41 +08:00
xiaozhou233 6a045fd46f Perf: Reduce font atlas memory and bake cost
- Size atlases from the requested glyph set (Latin 512-2048, CJK 1024-4096) and double on overflow instead of always using a 4096x4096 sheet

- Share one atlas between logical sizes; CJK bake heights are bucketed (12-36px) so neighbouring sizes reuse the same Noto sheet

- Pack Latin at 2x2 and CJK at 1x1 oversampling in two stb passes; the context-wide 2x2 setting was quadrupling CJK atlases

- Budget font textures with -Dorangex.font.atlasBudgetMb (128 MB) using frame-pinned LRU eviction, plus idle release (-Dorangex.font.idleSeconds, 30s) and face cleanup

- Upload 1.8.9 atlases as GL_LUMINANCE_ALPHA with premultiplied glyph blending (2 bytes per texel) and restore the previous blend function after a frame

- Write 26.2 RGBA pixels straight into the NativeImage buffer instead of building a second full-size array

- Move the string width cache into FontFace so it survives across frames, and hoist HUD getFont calls out of the render loops
2026-11-08 01:50:22 +08:00
xiaozhou233 524d540c1a Feat: Add Jello and Montserrat font families
- Register Jello Light/Regular/Medium and Montserrat Light/Regular/Medium/Bold, with weights lacking a bold file reusing a heavier face

- Add Render2D.getFont(FontFamily, size[, bold]) so features can pick a family, implemented by both the 1.8.9 and 26.2 backends

- Allow overriding the default family with -Dorangex.font.family (display name, constant name or font file name); Proxima stays the fallback

- Resolve CJK glyphs missing from the new Latin-only faces through the existing Noto fallback
2026-11-08 01:24:29 +08:00
xiaozhou233 5f3721c294 Feat: Add ClickGUI module bound to RSHIFT
- Add modules/impl/render/ClickGUI with default keybind RSHIFT

- Let the module open/close the input screen via requestOpen/requestClose

- Sync module state when the screen is closed by vanilla handling

- Remove the hard-coded GUI toggle from ClientInput/InputController
2026-11-08 00:50:05 +08:00
xiaozhou233 d241addec7 Fix: Scale injector GUI for HiDPI displays 2026-11-07 20:02:19 +08:00
xiaozhou233 54b476451c Feat: Add dark injector GUI
- Replace the console selection with a FlatDarkLaf Swing window

- List detected Minecraft windows, support a hidden custom PID input and refresh

- Run injection on a background thread and report the result in the status label

- Bundle FlatLaf into injector.jar so the packaged GUI runs standalone
2026-11-07 19:11:06 +08:00
xiaozhou233 f6d8c7da2f Feat: Add module value system
- Add Value, BooleanValue, KeybindValue and ModeValue

- Store values per module with defaults, reset, visibility and JSON encoding

- Wire module keybinds to EventKey so bound keys toggle modules
2026-11-07 18:58:04 +08:00
xiaozhou233 7e27752ffc Feat: HUD Module 2026-11-07 18:45:52 +08:00
xiaozhou233 c8e23c5d1c Build: Keep Java 8 output while compiling 26.2 sources
- Compile main sources with --release 8

- Move record-dependent v26_2 input classes to a separate source set

- Use a JDK 25 toolchain for that source set, still emitting class version 52

- Fix the Injector PrintStream charset constructor for Java 8
2026-11-07 17:01:36 +08:00
xiaozhou233 a84b04877d Refactor: Route key input through EventBus
- Post EventKey from 1.8.9 KeyBinding/GuiScreen hooks

- Hook 26.2 KeyboardHandler#keyPress so keys fire while walking

- Normalize 26.2 GLFW key codes to 1.8.9 LWJGL 2 codes

- Drive the GUI toggle from InputController instead of tick polling
2026-11-07 16:48:26 +08:00
xiaozhou233 70d8a854ea Feat: Auto download client jar and dependence 2026-11-07 15:46:11 +08:00
xiaozhou233 fdeec2a2f5 Fix: Injector warning and Chinese garbled text 2026-11-07 15:15:32 +08:00
xiaozhou233 fea7089ff8 Feat: Upgrade to Java25 gradle-9.8.2, Delete Stubs 2026-11-07 15:11:18 +08:00
xiaozhou233 0599e48ebe Docs: world-gating-and-input.md 2026-11-07 14:52:28 +08:00
xiaozhou233 0232fb0446 Docs: Add support version 2026-11-07 14:03:36 +08:00
xiaozhou233 5c726f54e4 Docs: Add launcher class-loader troubleshooting and hook file index 2026-11-07 13:55:05 +08:00
xiaozhou233 4b55871a8b Fix: Resolve hooks on launchers with remapped class loaders
Inject through the top-level orangexbridge package instead of imported cn.* names, build a fresh Javassist pool with agent-provided runtime class bytes, and fall back to safe class paths. Fixes Lunar GenesisClassLoader hook failures where resource class files still use obfuscated names.
2026-11-07 13:51:57 +08:00
xiaozhou233 cfb0ba4a48 Feat: Add world-only rendering and empty input GUI
Gate EventRender2D on shouldRenderLevel; add cross-version empty input screens toggled with M (1.8.9 generated GuiScreen subclass, 26.2 Screen), ClientInput state and debug overlay; add 26.2 compile stubs; move LWJGL2 jar to libraries.
2026-11-07 13:34:52 +08:00
xiaozhou233 715cb0755f Feat: Add 2D GUI shape rendering
- Extend Render2D with rect, gradient, outline, rounded rect, line and scissor primitives\n- Add shared 1.8.9 fixed-function render state for shapes and glyphs\n- Render 1.8.9 rounded rects with triangle fans and framebuffer scissor\n- Submit 26.2 shapes through GuiGraphicsExtractor fill/fillGradient/scissor\n- Assemble 26.2 rounded corners from cached quarter-circle textures\n- Add GUI rendering documentation and extend the debug overlay
2026-11-05 21:28:21 +08:00
xiaozhou233 b9ac9d5a92 Refactor: Clean up font rendering diagnostics
- Remove one-time hook/texture/glyph debug logs\n- Reuse one legacy glyph drawer instead of allocating it per frame\n- Make the font debug overlay opt-in via -Dorangex.debugFont=true\n- Update font port documentation
2026-11-05 20:56:49 +08:00
xiaozhou233 b909a01fe0 Fix: Enable font debug overlay by default
Forgot -Dorangex.debugFont on Forge/Vanilla launchers left the Render2D event without subscribers. Keep the overlay on by default during the porting phase; disable with -Dorangex.debugFont=false.
2026-11-05 20:45:19 +08:00
xiaozhou233 867949967e Fix: Locate Forge GuiIngameForge HUD method by descriptor
Forge 1.8.9 remaps the HUD override to a name that differs between the universal jar (a), SRG runtime (func_175180_a) and MCP (renderGameOverlay). Find the single instance (F)V method instead of hardcoding renderGameOverlay.
2026-11-05 20:42:44 +08:00
xiaozhou233 c8fa1a4c64 Fix: Shade javassist into OrangeX namespace for Forge
Forge 1.8.9's LaunchClassLoader delegates the javassist package to its parent, so the injected jar's unrelocated javassist classes were never found. Relocate javassist.* to cn.xiaozhou233.orangex.shaded.javassist.* so the hook system is self-contained.
2026-11-05 20:34:53 +08:00
xiaozhou233 c3dab97779 Feat: Add cross-version TTF font rendering
- Port stb_truetype rasterizer and bake TTF glyph atlases\n- Add FontRenderer/Render2D API with section colors, shadows and CJK fallback\n- Add 1.8.9 GL11 backend and 26.2 GuiRenderState backend\n- Hook GuiIngame/GuiIngameForge and Gui#extractRenderState for per-frame 2D\n- Bundle Proxima, Noto and Poppins fonts\n- Add render/font documentation
2026-11-05 20:31:32 +08:00
xiaozhou233 6c19985e52 Feat: Add tick hooks and Fabric 26.2 support
- Add ClassHook/HookManager pipeline that patches classes through
  JuiceAgent retransform
- Fire EventTickPre/EventTickPost around Minecraft.runTick
  (1.8.9: runTick()V, 26.2: runTick(Z)V)
- Prepare the javassist ClassPool with OrangeX.jar and imported
  packages, avoiding the vanilla 1.8.8 default-package "cn" class
  collision on qualified names
- Access the JuiceAgent API through the system ClassLoader so
  Fabric's Knot does not load a second copy without native methods
- Document the hook architecture, event bus and troubleshooting
  under docs/
2026-11-05 14:27:31 +08:00
xiaozhou233 40ca99f853 Feat: Support Fabric 26.2 injection
- Expose OrangeX.jar through KnotClassDelegate.addCodeSource for Fabric
- Resolve 26.2 mappings by runtime class visibility instead of loader type
- Keep identity mappings for the current Mojang-named Fabric 26.2 runtime
2026-11-04 23:06:22 +08:00
xiaozhou233 1699df9c5d Feat: Add Minecraft 26.2 wrapper support
- Implement the 26.2 Minecraft wrapper using the private instance field
- Register the 26.2 provider and use identity mappings for Mojang names
- Fix MappingManager fallthrough for the 26.2 case
- Accept Render thread and resolve the game class loader by class visibility
2026-11-04 22:57:15 +08:00
xiaozhou233 0f2d9614e5 Fix: Convert mapping class names to binary names
Mapping files store internal names such as net/minecraft/client/Minecraft, but Class.forName requires binary names. Vanilla worked because its target class name has no slashes; Forge failed with ClassNotFoundException.
2026-11-04 22:37:57 +08:00
xiaozhou233 13c9bb622c Refactor: Add version provider registry to wrapper
- Add WrapperContext, WrapperProvider and WrapperRegistry for version dispatch
- Move the 1.8.9 implementation to internal.v1_8_9 with constructor injection
- Support identity mappings for MCP development environments
- Document the wrapper structure and how to add a Minecraft version
2026-11-04 22:21:55 +08:00
xiaozhou233 8b9dbce0f7 Refactor: Make runtime detection extensible and Java 8 compatible
Split the runtime package into small, single-purpose pieces so new loaders and Minecraft versions can be added by registration instead of editing control flow.

- Add LoaderProbe registry for mod loader detection

- Add VersionSignatureRegistry/VersionSignature and move structural version signatures out of VersionDetector

- Add VersionIdSource list for Forge/NeoForge metadata readers

- Extract ModernVersionDetector and CandidateClassLoaders

- Replace MinecraftVersion's mutable static id with RuntimeInfo.versionId

- Target Java 8 with source/target 1.8 and --release 8 on JDK 9+

- Add docs/adding-minecraft-versions.md
2026-11-04 01:04:50 +08:00
xiaozhou233 789303c665 Refactor: Move Minecraft runtime detection into OrangeX
Move the full runtime package from Loader to OrangeX (cn.xiaozhou233.orangex.runtime), including loader/version detection, probes and utils.

- OrangeX.start() now detects and stores RuntimeInfo, and prints runtime debug info

- Loader keeps only a self-contained GameClassLoaderResolver for bootstrapping the Minecraft ClassLoader; entry flow is otherwise unchanged

- Move gson dependency to OrangeX with shadow relocation; drop it from Loader
2026-11-04 00:45:58 +08:00
xiaozhou233 34fc410a0c Feat: Add default JuiceAgent config
Configure the built-in jar loader to load Loader.jar and call Loader.entry.
2026-10-27 20:12:42 +08:00
xiaozhou233 faa84b14d0 Feat: Add Injector and injection packaging
- Add Injector module, built to out/injector.jar
- Add packageAll chain producing out/injection.zip from out/tmp
- Copy resources and natives into out/tmp with a flat layout
2026-10-27 20:12:37 +08:00
xiaozhou233 60baa8d1ef Refactor: Detect Minecraft runtime in Loader
- Add runtime detection package for class loader, loader type and version
- Probe vanilla, Forge, NeoForge, Fabric and MCP installations
- Read 26.x versions from version.json and support Forge version lookups
- Unify structural probing in MinecraftProbe and use the game class loader for reflection
- Shade gson into the loader jar under a relocated package
- Restore OrangeX injection using the detected class loader
2026-10-27 20:12:31 +08:00
xiaozhou233 fc7a26f051 Feat: Add Minecraft 1.8.8 client module
- Register Minecraft1.8.8 in settings.gradle and .idea/gradle.xml
- Link Minecraft1.8.8 against the 1.8.8 jar, runtime libraries and Loader
- Ignore decompiled src/ and runtime/ directories
- Add start/stop hooks to OrangeX entry point
- Add shared run configurations for packageAll and Start Client
- Drop unused JUnit test blocks from Loader and OrangeX
2026-10-24 16:44:01 +08:00
xiaozhou233 7c644e4d63 Build: Package shaded jars into out/tmp
- Add root packageAll task aggregating Loader and OrangeX shadow jars
- Add cleanOut task so stale artifacts are removed before packaging
- Output fixed-name Loader.jar and OrangeX.jar into out/tmp
- Switch OrangeX Lombok to compileOnly so it is not shaded
2026-10-24 14:01:21 +08:00
xiaozhou233 a7537e9d98 Feat: Add OrangeX core module
- Register OrangeX subproject in settings.gradle
- Add OrangeX build.gradle with Lombok support
- Add OrangeX singleton entry class
2026-10-24 13:54:36 +08:00
xiaozhou233 d39eb63be4 Feat: Add Loader module
Add Loader bootstrap that locates the Minecraft client thread, reuses its ClassLoader, injects OrangeX.jar via JuiceAgent and invokes OrangeX.start().

Also add JuiceAgent-API jar, register the Loader module in settings.gradle and update IDEA project config.
2026-10-23 19:39:26 +08:00
xiaozhou233 f6fa7c2a23 Feat: Add JuiceAgent Natives 2026-10-22 20:43:03 +08:00
xiaozhou233 64de525eef Add Gradle project skeleton and .gitignore
- build.gradle / settings.gradle with base plugin
- Gradle wrapper (8.x) for reproducible builds
- .gitignore for Gradle, IDE and OS artifacts
- IntelliJ IDEA project metadata
2026-10-22 20:36:01 +08:00
xiaozhou233 976b930ed5 Clean commit and add ReadMe 2026-10-22 19:58:14 +08:00
1891 changed files with 39667 additions and 285473 deletions

No files matched your search

+1 -3
View File
@@ -39,6 +39,4 @@ bin/
.vscode/
### Mac OS ###
.DS_Store
Minecraft-1.8.8-runtime/*
.DS_Store
+1 -2
View File
@@ -5,13 +5,12 @@
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="zulu-1.8 (2)" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/Injector" />
<option value="$PROJECT_DIR$/Loader" />
<option value="$PROJECT_DIR$/Minecraft-1.8.8" />
<option value="$PROJECT_DIR$/Minecraft1.8.8" />
<option value="$PROJECT_DIR$/OrangeX" />
</set>
</option>
+7 -5
View File
@@ -4,13 +4,15 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="EntryPointsManager">
<writeAnnotations>
<writeAnnotation name="lombok.Getter" />
</writeAnnotations>
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="zulu-1.8" project-jdk-type="JavaSDK">
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="zulu-25" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
@@ -1,7 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Injector" type="Application" factoryName="Application">
<configuration default="false" name="Injector" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="cn.xiaozhou233.orangex.injector.Main" />
<module name="OrangeX-Client.Injector.main" />
<option name="VM_PARAMETERS" value="--enable-native-access=ALL-UNNAMED -Dfile.encoding=UTF-8" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/out" />
<extension name="coverage">
<pattern>
@@ -11,7 +12,7 @@
</extension>
<method v="2">
<option name="Make" enabled="true" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="OrangeX-Client [buildAll]" run_configuration_type="GradleRunConfiguration" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="OrangeX-Client [packageAll]" run_configuration_type="GradleRunConfiguration" />
</method>
</configuration>
</component>
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OrangeX-Client [buildAll]" type="GradleRunConfiguration" factoryName="Gradle">
<configuration default="false" name="OrangeX-Client [packageAll]" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
@@ -10,15 +10,18 @@
</option>
<option name="taskNames">
<list>
<option value="buildAll" />
<option value="packageAll" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<GradleProfilingDisabled>false</GradleProfilingDisabled>
<GradleCoverageDisabled>false</GradleCoverageDisabled>
<method v="2" />
</configuration>
</component>
@@ -1,14 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Client" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="zulu-1.8 (2)" />
<configuration default="false" name="[1.8.8] Start Client" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="1.8" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="Start" />
<module name="OrangeX-Client.Minecraft-1.8.8.main" />
<option name="VM_PARAMETERS" value="-Djava.library.path=versions\1.8.8\1.8.8-natives" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Minecraft-1.8.8-runtime" />
<module name="OrangeX-Client.Minecraft1_8_8.main" />
<option name="VM_PARAMETERS" value="-Djava.library.path=versions\1.8.8\1.8.8-natives -Dorangex.dev=true -Dorangex.debugInput=true" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Minecraft1.8.8/runtime" />
<method v="2">
<option name="Make" enabled="true" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="OrangeX-Client [buildAll]" run_configuration_type="GradleRunConfiguration" />
<option name="RunConfigurationTask" enabled="true" run_configuration_name="OrangeX-Client [packageAll]" run_configuration_type="GradleRunConfiguration" />
</method>
</configuration>
</component>
Generated
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>
+21 -7
View File
@@ -1,6 +1,5 @@
plugins {
id 'java'
id "com.gradleup.shadow" version "8.3.9"
}
group = 'cn.xiaozhou233.orangex.injector'
@@ -11,16 +10,31 @@ repositories {
}
dependencies {
implementation files("libraries/JuiceAgent-JavaInjector-1.0-SNAPSHOT.jar")
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
// Source: https://mvnrepository.com/artifact/com.formdev/flatlaf
implementation 'com.formdev:flatlaf:3.8'
}
jar {
test {
useJUnitPlatform()
}
tasks.named('jar') {
destinationDirectory = rootProject.layout.projectDirectory.dir('out')
archiveFileName = 'injector.jar'
manifest {
attributes 'Main-Class': 'cn.xiaozhou233.orangex.injector.Main'
}
// Bundle runtime dependencies (FlatLaf) so injector.jar is self-contained.
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA'
}
shadowJar {
archiveFileName = 'Injector.jar'
destinationDirectory = rootProject.layout.projectDirectory.dir('out')
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
@@ -0,0 +1,22 @@
package cn.xiaozhou233.juiceagent.injector;
public class Injector {
/*
* @param pid process id
* @param path libinject path
*/
public native static boolean inject(int pid, String path);
/*
* @param pid process id
* @param path libinject path
* @param configDir config directory
*/
public native static boolean inject(int pid, String path, String configDir);
/*
* @param keyword window title keyword
* @return windows with title containing keyword
*/
public static native WindowInfo[] findWindowsByTitle(String keyword);
}
@@ -0,0 +1,16 @@
package cn.xiaozhou233.juiceagent.injector;
public class WindowInfo {
public String title;
public int pid;
public WindowInfo(String title, int pid) {
this.title = title;
this.pid = pid;
}
@Override
public String toString() {
return String.format("Title: %-30s | PID: %d", title, pid);
}
}
@@ -1,6 +1,7 @@
package cn.xiaozhou233.orangex.injector;
import java.io.*;
import java.nio.file.Files;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -23,7 +24,7 @@ public class FileUtils {
parent.mkdirs(); // 创建父目录
}
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile))) {
try (BufferedOutputStream bos = new BufferedOutputStream(Files.newOutputStream(outFile.toPath()))) {
byte[] buffer = new byte[4096];
int read;
while ((read = zipIn.read(buffer)) != -1) {
@@ -35,4 +36,4 @@ public class FileUtils {
}
}
}
}
}
@@ -0,0 +1,310 @@
package cn.xiaozhou233.orangex.injector;
import cn.xiaozhou233.juiceagent.injector.Injector;
import cn.xiaozhou233.juiceagent.injector.WindowInfo;
import com.formdev.flatlaf.util.UIScale;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
/**
* Injector front-end: lists the running Minecraft windows, optionally accepts a
* PID typed by hand, and runs {@link Injector#inject(int, String, String)} on a
* background thread.
*/
public class InjectorWindow extends JFrame {
private static final String[] WINDOW_TITLES = {
"Minecraft", "minecraft", "1.8.9", "Badlion", "Lunar"
};
private static final String[] IGNORED_TITLES = {
"Badlion Client", "Badlion Chat", "Home - Lunar Client"
};
private static final Color ACCENT = new Color(0xFF8A00);
private static final Color SUCCESS = new Color(0x66BB6A);
private static final Color ERROR = new Color(0xEF5350);
private static final Color MUTED = new Color(0xAAAAAA);
private final String agentPath;
private final String configDir;
private final DefaultComboBoxModel<ProcessEntry> processModel = new DefaultComboBoxModel<>();
private final JComboBox<ProcessEntry> processBox = new JComboBox<>(processModel);
private final JButton refreshButton = new JButton("Refresh");
private final JCheckBox customPidCheck = new JCheckBox("Use custom PID");
private final JTextField pidField = new JTextField();
private final JButton injectButton = new JButton("Inject");
private final JLabel statusLabel = new JLabel("Ready", SwingConstants.CENTER);
private boolean busy;
public InjectorWindow(String agentPath, String configDir) {
super("OrangeX Injector");
this.agentPath = agentPath;
this.configDir = configDir;
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
setContentPane(buildContent());
setSize(UIScale.scale(470), UIScale.scale(340));
setLocationRelativeTo(null);
getRootPane().setDefaultButton(injectButton);
refreshButton.addActionListener(event -> refreshProcesses());
customPidCheck.addActionListener(event -> {
boolean custom = customPidCheck.isSelected();
pidField.setVisible(custom);
revalidate();
repaint();
if (custom) {
pidField.requestFocusInWindow();
}
updateControls();
});
injectButton.addActionListener(event -> inject());
refreshProcesses();
}
private JPanel buildContent() {
JPanel root = new JPanel(new GridBagLayout());
root.setBorder(new EmptyBorder(
UIScale.scale(20), UIScale.scale(26),
UIScale.scale(16), UIScale.scale(26)));
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
int row = 0;
JLabel title = new JLabel(
"<html><font color='#FF8A00'><b>OrangeX</b></font> Injector</html>",
SwingConstants.CENTER);
title.setFont(title.getFont().deriveFont(Font.BOLD, UIScale.scale(26f)));
gbc.gridy = row++;
gbc.insets = UIScale.scale(new Insets(0, 0, 20, 0));
root.add(title, gbc);
processBox.setPreferredSize(new Dimension(UIScale.scale(200), UIScale.scale(34)));
JPanel processRow = new JPanel(new BorderLayout(UIScale.scale(8), 0));
processRow.add(processBox, BorderLayout.CENTER);
processRow.add(refreshButton, BorderLayout.EAST);
gbc.gridy = row++;
gbc.insets = UIScale.scale(new Insets(0, 0, 10, 0));
root.add(processRow, gbc);
gbc.gridy = row++;
gbc.insets = UIScale.scale(new Insets(0, 0, 8, 0));
root.add(customPidCheck, gbc);
pidField.setPreferredSize(new Dimension(0, UIScale.scale(34)));
pidField.putClientProperty("JTextField.placeholderText", "Enter a process ID");
pidField.setVisible(false);
gbc.gridy = row++;
gbc.insets = UIScale.scale(new Insets(0, 0, 10, 0));
root.add(pidField, gbc);
injectButton.setPreferredSize(new Dimension(0, UIScale.scale(40)));
injectButton.setFont(injectButton.getFont().deriveFont(
Font.BOLD, UIScale.scale(15f)));
injectButton.setBackground(ACCENT);
injectButton.setForeground(Color.WHITE);
injectButton.putClientProperty("JButton.buttonType", "roundRect");
gbc.gridy = row++;
gbc.insets = UIScale.scale(new Insets(10, 0, 12, 0));
root.add(injectButton, gbc);
statusLabel.setFont(statusLabel.getFont().deriveFont(UIScale.scale(12f)));
statusLabel.setForeground(MUTED);
gbc.gridy = row++;
gbc.insets = new Insets(0, 0, 0, 0);
root.add(statusLabel, gbc);
// Keeps the content aligned to the top when the PID field is hidden.
gbc.gridy = row;
gbc.weighty = 1.0;
root.add(Box.createVerticalGlue(), gbc);
return root;
}
/**
* Rescans the open windows and fills the selection box. Errors are shown
* in the status label instead of terminating the window.
*/
public void refreshProcesses() {
processModel.removeAllElements();
List<ProcessEntry> processes;
try {
processes = scanProcesses();
} catch (Throwable throwable) {
throwable.printStackTrace();
setStatus("Failed to scan windows: " + throwable.getClass().getSimpleName(), ERROR);
updateControls();
return;
}
for (ProcessEntry process : processes) {
processModel.addElement(process);
}
if (processes.isEmpty()) {
setStatus("No Minecraft process found", ERROR);
} else {
setStatus(processes.size() + " Minecraft process(es) found", MUTED);
}
updateControls();
}
private List<ProcessEntry> scanProcesses() {
Map<Integer, ProcessEntry> found = new LinkedHashMap<>();
for (String title : WINDOW_TITLES) {
WindowInfo[] windows = Injector.findWindowsByTitle(title);
if (windows == null) {
continue;
}
for (WindowInfo window : windows) {
if (window == null || window.title == null || found.containsKey(window.pid)) {
continue;
}
if (isIgnored(window.title)) {
continue;
}
found.put(window.pid, new ProcessEntry(window.pid, window.title));
}
}
return new ArrayList<>(found.values());
}
private static boolean isIgnored(String title) {
for (String ignored : IGNORED_TITLES) {
if (title.contains(ignored)) {
return true;
}
}
return false;
}
private void inject() {
Integer pid = selectedPid();
if (pid == null) {
return;
}
busy = true;
updateControls();
setStatus("Injecting into PID " + pid + "...", MUTED);
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() {
return Injector.inject(pid, agentPath, configDir);
}
@Override
protected void done() {
busy = false;
updateControls();
try {
if (Boolean.TRUE.equals(get())) {
setStatus("Injection succeeded (PID " + pid + ")", SUCCESS);
} else {
setStatus("Injection failed (PID " + pid + ")", ERROR);
JOptionPane.showMessageDialog(
InjectorWindow.this,
"Injector.inject returned false for PID " + pid + ".",
"Injection failed",
JOptionPane.ERROR_MESSAGE);
}
} catch (InterruptedException exception) {
Thread.currentThread().interrupt();
setStatus("Injection interrupted", ERROR);
} catch (ExecutionException exception) {
Throwable cause = exception.getCause() == null
? exception : exception.getCause();
cause.printStackTrace();
setStatus("Injection failed (PID " + pid + ")", ERROR);
JOptionPane.showMessageDialog(
InjectorWindow.this,
cause.toString(),
"Injection failed",
JOptionPane.ERROR_MESSAGE);
}
}
}.execute();
}
private Integer selectedPid() {
if (customPidCheck.isSelected()) {
String text = pidField.getText().trim();
if (text.isEmpty()) {
showError("Enter a PID first, or untick \"Use custom PID\".");
return null;
}
try {
int pid = Integer.parseInt(text);
if (pid <= 0) {
throw new NumberFormatException("PID must be positive");
}
return pid;
} catch (NumberFormatException exception) {
showError("PID must be a positive integer.");
return null;
}
}
ProcessEntry selected = (ProcessEntry) processBox.getSelectedItem();
if (selected == null) {
showError("No Minecraft process selected. Start the game or use a custom PID.");
return null;
}
return selected.pid;
}
private void updateControls() {
boolean custom = customPidCheck.isSelected();
boolean hasProcess = processModel.getSize() > 0;
processBox.setEnabled(!busy && !custom && hasProcess);
refreshButton.setEnabled(!busy && !custom);
customPidCheck.setEnabled(!busy);
pidField.setEnabled(!busy);
injectButton.setEnabled(!busy && (custom || hasProcess));
}
private void setStatus(String text, Color color) {
statusLabel.setText(text);
statusLabel.setForeground(color);
}
private void showError(String message) {
setStatus(message, ERROR);
JOptionPane.showMessageDialog(
this, message, "OrangeX Injector", JOptionPane.WARNING_MESSAGE);
}
private static final class ProcessEntry {
private final int pid;
private final String title;
private ProcessEntry(int pid, String title) {
this.pid = pid;
this.title = title;
}
@Override
public String toString() {
return title + " (PID: " + pid + ")";
}
}
}
@@ -1,105 +1,142 @@
/*
* OrangeX Injector
* Thanks to StaR4y (https://github.com/StaR4y) for contributing part of the Injector implementation.
*/
package cn.xiaozhou233.orangex.injector;
import cn.xiaozhou233.juiceagent.injector.Injector;
import cn.xiaozhou233.juiceagent.injector.WindowInfo;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.util.UIScale;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
public class Main {
public static String orangexPath = System.getProperty("user.home") + "/.orangex";
public static final String orangexPath =
new File(System.getProperty("user.home"), ".orangex").getAbsolutePath();
public static final String agentPath =
new File(orangexPath, "libloader.dll").getAbsolutePath();
public static final String configDir = orangexPath;
public static void main(String[] args) {
System.out.println("OrangeX Injector");
setupConsole();
int pid = -1;
System.out.println("================");
System.out.println("OrangeX Injector v1.0.0");
System.out.println("OrangeX Path: " + orangexPath);
System.out.println("================");
System.out.println("Unzip injection.zip to " + orangexPath);
extractInjection();
if (!loadNativeLibrary()) {
return;
}
File zipFile = new File("injection.zip");
SwingUtilities.invokeLater(() -> {
installLookAndFeel();
InjectorWindow window = new InjectorWindow(agentPath, configDir);
window.setVisible(true);
});
}
private static void setupConsole() {
try {
System.setOut(new PrintStream(
new FileOutputStream(FileDescriptor.out),
true,
StandardCharsets.UTF_8.name()
));
System.setErr(new PrintStream(
new FileOutputStream(FileDescriptor.err),
true,
StandardCharsets.UTF_8.name()
));
} catch (Exception exception) {
exception.printStackTrace();
}
}
private static void extractInjection() {
File zipFile = new File("./injection.zip");
if (!zipFile.exists()) {
System.err.println("injection.zip not found in runtime directory!");
System.err.println("injection.zip not found!");
return;
}
try (InputStream zipStream = new FileInputStream(zipFile)) {
FileUtils.unzip(zipStream, new File(orangexPath));
System.out.println("Done!");
} catch (IOException e) {
e.printStackTrace();
System.out.println("Extracted injection.zip to " + orangexPath);
} catch (IOException exception) {
System.err.println("[ERROR] Failed to extract injection.zip: " + exception.getMessage());
exception.printStackTrace();
}
}
// Load Native Library
System.load(orangexPath + "/libinject.dll");
// Find Minecraft
ArrayList<Integer> pids = new ArrayList<>();
ArrayList<String> windowTitles = new ArrayList<>();
private static boolean loadNativeLibrary() {
try {
String[] titles = {"Minecraft", "minecraft", "1.8.9", "Badlion", "Lunar"};
String[] ignoreTitles = {"Badlion Client", "Badlion Chat", "Home - Lunar Client"};
for (String title : titles) {
WindowInfo[] list = Injector.findWindowsByTitle(title);
if (list == null || list.length == 0) {
} else {
for (WindowInfo w : list) {
if (pids.contains(w.pid))
continue;
if (Arrays.stream(ignoreTitles).anyMatch(w.title::contains))
continue;
pids.add(w.pid);
windowTitles.add(w.title);
}
}
}
} catch (UnsatisfiedLinkError ule) {
throw new RuntimeException("Native method findWindowsByTitle not available", ule);
} catch (Exception ex) {
System.out.println("[ERROR] Error while calling native findWindowsByTitle: " + ex.getMessage());
ex.printStackTrace();
System.load(new File(orangexPath, "libinject.dll").getAbsolutePath());
System.out.println("Loaded libinject.dll");
return true;
} catch (Throwable throwable) {
throwable.printStackTrace();
JOptionPane.showMessageDialog(
null,
"Failed to load libinject.dll:\n" + throwable,
"OrangeX Injector",
JOptionPane.ERROR_MESSAGE);
return false;
}
}
// Print the result
System.out.println("=======================");
for (int i = 0; i < pids.size(); i++) {
System.out.printf("[ %d ] %s (PID: %d)%n", i + 1, windowTitles.get(i), pids.get(i));
private static void installLookAndFeel() {
try {
FlatDarkLaf.setup();
UIManager.put("Component.accentColor", new Color(0xFF8A00));
UIManager.put("Component.arc", 10);
UIManager.put("Button.arc", 12);
} catch (Throwable throwable) {
System.out.println("[WARN] FlatLaf is not available; using the default look and feel");
return;
}
System.out.println("=======================");
applyWindowScale();
}
if (pids.isEmpty()) {
System.out.println("[ERROR] No Minecraft process found!");
/**
* Large monitors are often driven at 100% OS scaling, which makes Swing
* UIs look tiny. Compute the scale the JRE already applies and add a zoom
* factor on top until the UI reaches a comfortable physical size.
*/
private static void applyWindowScale() {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
if (screen.height < 1120) {
return;
}
// Input the sequence number
try (Scanner scanner = new Scanner(System.in)) {
System.out.printf("[INPUT] Select (1-%d): ", pids.size());
int index = scanner.nextInt();
if (index < 1 || index > pids.size()) {
throw new RuntimeException("Invalid selection: " + index);
}
pid = pids.get(index - 1);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Invalid input", e);
float target = screen.height >= 1800 ? 2.0f : 1.5f;
GraphicsConfiguration configuration = GraphicsEnvironment
.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.getDefaultConfiguration();
double effective = UIScale.getSystemScaleFactor(configuration)
* UIScale.getUserScaleFactor();
if (effective >= target) {
return;
}
// Inject
String agentPath = orangexPath + "/libloader.dll";
String configDir = orangexPath;
Injector.inject(pid, agentPath, configDir);
float zoom = (float) (target / effective);
if (UIScale.setZoomFactor(zoom)) {
FlatLaf.updateUI();
System.out.println("[OrangeX] UI scale " + target + "x (zoom " + zoom + ")");
}
}
}
}
-22
View File
@@ -1,22 +0,0 @@
MIT License
Copyright (c) 2025 xiaozhou233
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+10 -7
View File
@@ -1,9 +1,9 @@
plugins {
id 'java'
id "com.gradleup.shadow" version "8.3.9"
id("com.gradleup.shadow") version "9.6.1"
}
group = 'cn.xiaozhou233.orangex.loader'
group = 'cn.xiaozhou233.orangex.injector'
version = 'unspecified'
repositories {
@@ -11,11 +11,14 @@ repositories {
}
dependencies {
compileOnly files("../libraries/JuiceAgent-API-1.4.1+build.1.jar")
implementation files("../libraries/JuiceRemapper-1.0-SNAPSHOT-all.jar")
implementation files("../libraries/JuiceAgent-API-1.4.1+build.1.jar")
// Source: https://mvnrepository.com/artifact/org.projectlombok/lombok
compileOnly 'org.projectlombok:lombok:1.18.48'
annotationProcessor 'org.projectlombok:lombok:1.18.48'
}
shadowJar {
archiveFileName = 'Loader.jar'
relocate 'org.objectweb.asm', 'cn.xiaozhou233.asm9'
tasks.named('shadowJar') {
destinationDirectory = rootProject.layout.projectDirectory.dir('out/tmp')
archiveFileName = "${project.name}.jar"
}
@@ -1,56 +0,0 @@
package cn.xiaozhou233.orangex.loader;
public class Detector {
private static boolean classExists(String className) {
String resourceName = className.replace('.', '/') + ".class";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = Detector.class.getClassLoader();
}
return classLoader.getResource(resourceName) != null;
}
public static DetectorType detect() {
// Lunar Client Detection
if (classExists("com.moonsworth.lunar.genesis.Genesis")) {
System.out.println("Lunar class found!");
return DetectorType.LUNAR;
}
System.out.println("Lunar class not found");
// Badlion Detection
if (classExists("net.badlion.client.Wrapper")) {
System.out.println("Badlion class found!");
return DetectorType.BADLION;
}
System.out.println("Badlion class not found");
// MCP Detection
if (classExists("net.minecraft.client.Minecraft")) {
System.out.println("MCP class found!");
return DetectorType.MCP;
}
System.out.println("MCP class not found");
// Vanilla Detection
if (classExists("ave")) {
System.out.println("Vanilla class found!");
return DetectorType.VANILLA;
}
System.out.println("Vanilla class not found");
return DetectorType.UNKNOWN;
}
public static boolean isLaunchWrapper() {
return classExists("net.minecraft.launchwrapper.Launch");
}
}
@@ -1,9 +0,0 @@
package cn.xiaozhou233.orangex.loader;
public enum DetectorType {
BADLION,
LUNAR,
VANILLA,
MCP,
UNKNOWN
}
@@ -1,93 +1,135 @@
package cn.xiaozhou233.orangex.loader;
import cn.xiaozhou233.juiceagent.api.JuiceAgent;
import cn.xiaozhou233.orangex.loader.classloader.GameClassLoaderResolver;
import javax.swing.*;
import java.io.File;
import java.lang.reflect.Method;
import java.nio.file.Path;
public class Loader {
public static String userDir = System.getProperty("user.home");
public static final String VERSION = "1.0.0-SNAPSHOT";
public static final String ORANGEX_CLASS = "cn.xiaozhou233.orangex.OrangeX";
public static String OrangeXPath = new File(System.getProperty("user.home")+"/.orangex").getAbsolutePath();
public static Thread clientThread;
public static ClassLoader minecraftClassLoader;
public static void start() {
System.out.println("======== Loader START ========");
public static void entry() {
System.out.println("OrangeX-Loader " + VERSION + " loaded!");
// Find client thread
for (Thread t : Thread.getAllStackTraces().keySet()) {
if ("Client thread".equals(t.getName())) {
clientThread = t;
break;
}
}
if (clientThread == null) {
throw new IllegalStateException("Cannot find Minecraft client thread");
}
// Resolve the Minecraft ClassLoader (runtime detection itself lives in OrangeX)
ClassLoader gameClassLoader = GameClassLoaderResolver.resolve();
// Check if LaunchWrapper exists
if (Detector.isLaunchWrapper()){
System.out.println("LaunchWrapper detected");
}
// Find the game thread. Modern clients use "Render thread"; legacy
// clients use "Client thread". It is only needed as a class loader
// fallback, so a miss here must not abort injection.
clientThread = findGameThread();
// Get Minecraft ClassLoader
minecraftClassLoader = clientThread.getContextClassLoader();
// Get Minecraft ClassLoader (prefer the resolved game class loader)
minecraftClassLoader = gameClassLoader != null
? gameClassLoader
: clientThread != null ? clientThread.getContextClassLoader() : null;
if (minecraftClassLoader == null) {
throw new IllegalStateException("Cannot find Minecraft ClassLoader");
}
System.out.println("Minecraft ClassLoader: " + minecraftClassLoader);
switch (Detector.detect()) {
case MCP:
break;
case VANILLA:
// No more support
JOptionPane.showMessageDialog(
null,
"Not support Vanilla Client! \n 不支持原版客户端!",
"Vanilla Obfuscation",
JOptionPane.ERROR_MESSAGE
);
throw new IllegalStateException("Not support Vanilla Client!");
case LUNAR:
break;
case BADLION:
// No more support
JOptionPane.showMessageDialog(
null,
"Not support Badlion Client! \n 不支持Badlion客户端!",
"Badlion Obfuscation",
JOptionPane.ERROR_MESSAGE
);
throw new IllegalStateException("Not support Badlion Client!");
case UNKNOWN:
JOptionPane.showMessageDialog(
null,
"Inject Failed! Cause: Unknown Obfuscation \n 注入失败! 原因: 未知的混淆",
"Unknown Obfuscation",
JOptionPane.ERROR_MESSAGE
);
throw new IllegalStateException("Unknown Obfuscation");
default:
JOptionPane.showMessageDialog(
null,
"Inject Failed! Cause: Unknown Obfuscation",
"Unknown Obfuscation",
JOptionPane.ERROR_MESSAGE
);
throw new IllegalStateException("Unexpected value: " + Detector.detect());
// Dev Only: Load JuiceAgent
if (isDevEnvironment()) {
System.load(new File("../../natives/libagent.dll").getAbsolutePath());
JuiceAgent.init("");
}
// Load OrangeX
File injectionFile = new File(userDir + "/.orangex/OrangeX.jar");
System.out.println("OrangeX Injection: " + injectionFile.getAbsolutePath());
JuiceAgent.addToClassLoader(injectionFile.getAbsolutePath(), minecraftClassLoader);
File orangexFile;
if (isDevEnvironment()) {
orangexFile = new File("../../out/tmp/OrangeX.jar");
} else {
orangexFile = new File(OrangeXPath + "/OrangeX.jar");
}
System.out.println("OrangeX Injection: " + orangexFile.getAbsolutePath());
// javassist's ClassPool cannot always discover this jar through the
// game ClassLoader, so expose the path to OrangeX explicitly.
System.setProperty("orangex.jar", orangexFile.getAbsolutePath());
addToGameClassLoader(orangexFile, minecraftClassLoader);
// Start OrangeX
try {
Class<?> orangeXClass = Class.forName("cn.xiaozhou233.orangex.OrangeX", true, minecraftClassLoader);
Object orangeXInstance = orangeXClass.getMethod("getInstance").invoke(null);
orangeXClass.getMethod("start").invoke(orangeXInstance);
Class<?> orangeX = Class.forName(ORANGEX_CLASS, true, minecraftClassLoader);
Object orangeXInstance = orangeX.getMethod("getInstance").invoke(null);
orangeX.getMethod("start").invoke(orangeXInstance);
} catch (Exception e) {
System.err.println("Failed to invoke OrangeX start!");
throw new RuntimeException(e);
}
System.out.println("======== Loader END ========");
}
}
public static boolean isDevEnvironment() {
return Boolean.getBoolean("orangex.dev");
}
/**
* Legacy clients call the game thread "Client thread"; 1.13+ calls it
* "Render thread". Return whichever is available.
*/
private static Thread findGameThread() {
Thread renderThread = null;
try {
for (Thread thread : Thread.getAllStackTraces().keySet()) {
String name = thread.getName();
if ("Client thread".equals(name)) {
return thread;
}
if ("Render thread".equals(name) && renderThread == null) {
renderThread = thread;
}
}
} catch (Throwable ignored) {
}
return renderThread;
}
/**
* Fabric's KnotClassLoader keeps its own code-source list and rejects jars
* that were added with a plain URLClassLoader-style addURL. Expose the jar
* through KnotClassDelegate#addCodeSource, which updates both the code
* source list and the internal URL loader.
*/
private static void addToGameClassLoader(File jar, ClassLoader loader) {
if (isKnotClassLoader(loader)) {
try {
addToKnotClassLoader(loader, jar.toPath());
return;
} catch (ReflectiveOperationException | RuntimeException e) {
System.err.println(
"Failed to expose " + jar.getName()
+ " to Fabric KnotClassLoader: " + e);
e.printStackTrace();
}
}
JuiceAgent.addToClassLoader(jar.getAbsolutePath(), loader);
}
private static boolean isKnotClassLoader(ClassLoader loader) {
return loader != null
&& "net.fabricmc.loader.impl.launch.knot.KnotClassLoader"
.equals(loader.getClass().getName());
}
private static void addToKnotClassLoader(ClassLoader loader, Path jar)
throws ReflectiveOperationException {
Method getDelegate = loader.getClass().getDeclaredMethod("getDelegate");
getDelegate.setAccessible(true);
Object delegate = getDelegate.invoke(loader);
Method addCodeSource = delegate.getClass()
.getMethod("addCodeSource", Path.class);
addCodeSource.setAccessible(true);
addCodeSource.invoke(delegate, jar);
}
}
@@ -0,0 +1,123 @@
package cn.xiaozhou233.orangex.loader.classloader;
/**
* Loader-side bootstrap resolver: only resolves the Minecraft game class loader,
* which is required before OrangeX can be injected. Full runtime detection
* (loader type / Minecraft version) lives in OrangeX.
*/
public final class GameClassLoaderResolver {
/**
* Class names that identify the game class loader across supported
* runtimes: Mojang/Forge/MCP, Fabric intermediary, and 1.8 vanilla
* obfuscated clients.
*/
private static final String[] MINECRAFT_CLASSES = {
"net.minecraft.client.Minecraft",
"net.minecraft.class_310",
"ave"
};
public static ClassLoader resolve() {
ClassLoader threadLoader = findGameThreadLoader();
ClassLoader resolved = definingLoaderOf(threadLoader);
if (resolved != null) {
return resolved;
}
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
resolved = definingLoaderOf(contextLoader);
if (resolved != null) {
return resolved;
}
ClassLoader ownLoader = GameClassLoaderResolver.class.getClassLoader();
resolved = definingLoaderOf(ownLoader);
if (resolved != null) {
return resolved;
}
try {
resolved = definingLoaderOf(ClassLoader.getSystemClassLoader());
if (resolved != null) {
return resolved;
}
} catch (SecurityException ignored) {
// Security manager may forbid system loader lookup.
}
// No Minecraft class is visible yet; keep the previous best effort.
if (threadLoader != null) {
return threadLoader;
}
if (contextLoader != null) {
return contextLoader;
}
return ownLoader;
}
/**
* Returns the loader that actually defines the Minecraft class, falling
* back to the candidate itself when the class is defined by the bootstrap
* loader.
*/
private static ClassLoader definingLoaderOf(ClassLoader candidate) {
Class<?> minecraftClass = findClass(candidate, MINECRAFT_CLASSES);
if (minecraftClass == null) {
return null;
}
ClassLoader definingLoader = minecraftClass.getClassLoader();
return definingLoader != null ? definingLoader : candidate;
}
private static ClassLoader findGameThreadLoader() {
// Client thread wins over render thread, regardless of thread iteration order
ClassLoader clientLoader = null;
ClassLoader renderLoader = null;
try {
for (Thread thread : Thread.getAllStackTraces().keySet()) {
String name = thread.getName();
if ("Client thread".equals(name)) {
if (clientLoader == null) {
clientLoader = thread.getContextClassLoader();
}
} else if ("Render thread".equals(name)) {
if (renderLoader == null) {
renderLoader = thread.getContextClassLoader();
}
}
}
} catch (Throwable ignored) {
}
return clientLoader != null ? clientLoader : renderLoader;
}
private static Class<?> findClass(ClassLoader loader, String... names) {
if (loader == null || names == null) {
return null;
}
for (String name : names) {
if (name == null || name.isEmpty()) {
continue;
}
String binaryName = name.indexOf('/') >= 0 ? name.replace('/', '.') : name;
try {
return Class.forName(binaryName, false, loader);
} catch (Throwable ignored) {
}
}
return null;
}
private GameClassLoaderResolver() {
}
}
-26
View File
@@ -1,26 +0,0 @@
plugins {
id 'java'
}
group = 'cn.xiaozhou233.orangex.injector'
version = 'unspecified'
repositories {
mavenCentral()
}
dependencies {
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
implementation fileTree(dir: "../Minecraft-1.8.8-runtime/libraries", include: ["**/*.jar"])
implementation files("../Minecraft-1.8.8-runtime/versions/1.8.8/1.8.8.jar")
implementation files("../libraries/JuiceAgent-API-1.4.1+build.1.jar")
implementation project(":OrangeX")
}
test {
useJUnitPlatform()
}
-20
View File
@@ -1,20 +0,0 @@
import java.io.File;
import java.lang.reflect.Field;
import java.util.Arrays;
import net.minecraft.client.main.Main;
public class Start
{
public static void main(String[] args)
{
Main.main(concat(new String[] {"--version", "mcp", "--accessToken", "0", "--assetsDir", "assets", "--assetIndex", "1.8", "--userProperties", "{}"}, args));
}
public static <T> T[] concat(T[] first, T[] second)
{
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
}
}
@@ -1,51 +0,0 @@
package cn.xiaozhou233.orangex.loader;
import cn.xiaozhou233.juiceagent.api.JuiceAgent;
import java.io.File;
public enum MCPLoader {
INSTANCE;
public static String userDir = System.getProperty("user.home");
public static Thread clientThread;
public static ClassLoader minecraftClassLoader;
public void start() {
System.out.println("======== OrangeX MCP Loader ========");
System.load(new File("../natives/libagent.dll").getAbsolutePath());
JuiceAgent.init("");
// Find client thread
for (Thread t : Thread.getAllStackTraces().keySet()) {
if ("Client thread".equals(t.getName())) {
clientThread = t;
break;
}
}
if (clientThread == null) {
throw new IllegalStateException("Cannot find Minecraft client thread");
}
// Get Minecraft ClassLoader
minecraftClassLoader = clientThread.getContextClassLoader();
System.out.println("Minecraft ClassLoader: " + minecraftClassLoader);
// Load OrangeX
File injectionFile = new File("../../out/tmp/OrangeX.jar");
System.out.println("OrangeX Injection: " + injectionFile.getAbsolutePath());
JuiceAgent.addToClassLoader(injectionFile.getAbsolutePath(), minecraftClassLoader);
try {
Class<?> orangeXClass = Class.forName("cn.xiaozhou233.orangex.OrangeX", true, minecraftClassLoader);
Object instance = orangeXClass.getMethod("getInstance").invoke(null);
orangeXClass.getMethod("start").invoke(instance);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void stop() {
System.out.println("OrangeX MCP Loader Stopping...");
}
}
File diff suppressed because it is too large. Load diff
@@ -1,56 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class BlockAir extends Block
{
protected BlockAir()
{
super(Material.air);
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return -1;
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
{
return false;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
}
/**
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
*/
public boolean isReplaceable(World worldIn, BlockPos pos)
{
return true;
}
}
@@ -1,190 +0,0 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.IInteractionObject;
import net.minecraft.world.World;
public class BlockAnvil extends BlockFalling
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyInteger DAMAGE = PropertyInteger.create("damage", 0, 2);
protected BlockAnvil()
{
super(Material.anvil);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(DAMAGE, Integer.valueOf(0)));
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
EnumFacing enumfacing = placer.getHorizontalFacing().rotateY();
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(FACING, enumfacing).withProperty(DAMAGE, Integer.valueOf(meta >> 2));
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!worldIn.isRemote)
{
playerIn.displayGui(new BlockAnvil.Anvil(worldIn, pos));
}
return true;
}
/**
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
* returns the metadata of the dropped item based on the old metadata of the block.
*/
public int damageDropped(IBlockState state)
{
return ((Integer)state.getValue(DAMAGE)).intValue();
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
if (enumfacing.getAxis() == EnumFacing.Axis.X)
{
this.setBlockBounds(0.0F, 0.0F, 0.125F, 1.0F, 1.0F, 0.875F);
}
else
{
this.setBlockBounds(0.125F, 0.0F, 0.0F, 0.875F, 1.0F, 1.0F);
}
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
list.add(new ItemStack(itemIn, 1, 0));
list.add(new ItemStack(itemIn, 1, 1));
list.add(new ItemStack(itemIn, 1, 2));
}
protected void onStartFalling(EntityFallingBlock fallingEntity)
{
fallingEntity.setHurtEntities(true);
}
public void onEndFalling(World worldIn, BlockPos pos)
{
worldIn.playAuxSFX(1022, pos, 0);
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
/**
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
*/
public IBlockState getStateForEntityRender(IBlockState state)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta & 3)).withProperty(DAMAGE, Integer.valueOf((meta & 15) >> 2));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
i = i | ((Integer)state.getValue(DAMAGE)).intValue() << 2;
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, DAMAGE});
}
public static class Anvil implements IInteractionObject
{
private final World world;
private final BlockPos position;
public Anvil(World worldIn, BlockPos pos)
{
this.world = worldIn;
this.position = pos;
}
public String getName()
{
return "anvil";
}
public boolean hasCustomName()
{
return false;
}
public IChatComponent getDisplayName()
{
return new ChatComponentTranslation(Blocks.anvil.getUnlocalizedName() + ".name", new Object[0]);
}
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
{
return new ContainerRepair(playerInventory, this.world, this.position, playerIn);
}
public String getGuiID()
{
return "minecraft:anvil";
}
}
}
@@ -1,253 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBanner;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockBanner extends BlockContainer
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyInteger ROTATION = PropertyInteger.create("rotation", 0, 15);
protected BlockBanner()
{
super(Material.wood);
float f = 0.25F;
float f1 = 1.0F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
}
/**
* Gets the localized name of this block. Used for the statistics page.
*/
public String getLocalizedName()
{
return StatCollector.translateToLocal("item.banner.white.name");
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
public boolean isFullCube()
{
return false;
}
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return true;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean func_181623_g()
{
return true;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityBanner();
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.banner;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.banner;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBanner)
{
ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)tileentity).getBaseColor());
NBTTagCompound nbttagcompound = new NBTTagCompound();
tileentity.writeToNBT(nbttagcompound);
nbttagcompound.removeTag("x");
nbttagcompound.removeTag("y");
nbttagcompound.removeTag("z");
nbttagcompound.removeTag("id");
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
spawnAsEntity(worldIn, pos, itemstack);
}
else
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return !this.func_181087_e(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos);
}
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
if (te instanceof TileEntityBanner)
{
TileEntityBanner tileentitybanner = (TileEntityBanner)te;
ItemStack itemstack = new ItemStack(Items.banner, 1, ((TileEntityBanner)te).getBaseColor());
NBTTagCompound nbttagcompound = new NBTTagCompound();
TileEntityBanner.func_181020_a(nbttagcompound, tileentitybanner.getBaseColor(), tileentitybanner.func_181021_d());
itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
spawnAsEntity(worldIn, pos, itemstack);
}
else
{
super.harvestBlock(worldIn, player, pos, state, (TileEntity)null);
}
}
public static class BlockBannerHanging extends BlockBanner
{
public BlockBannerHanging()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
float f = 0.0F;
float f1 = 0.78125F;
float f2 = 0.0F;
float f3 = 1.0F;
float f4 = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
switch (enumfacing)
{
case NORTH:
default:
this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
break;
case SOUTH:
this.setBlockBounds(f2, f, 0.0F, f3, f1, f4);
break;
case WEST:
this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
break;
case EAST:
this.setBlockBounds(0.0F, f, f2, f4, f1, f3);
}
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid())
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing = EnumFacing.getFront(meta);
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
{
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState().withProperty(FACING, enumfacing);
}
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing)state.getValue(FACING)).getIndex();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING});
}
}
public static class BlockBannerStanding extends BlockBanner
{
public BlockBannerStanding()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(ROTATION, Integer.valueOf(0)));
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid())
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(ROTATION, Integer.valueOf(meta));
}
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(ROTATION)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {ROTATION});
}
}
}
@@ -1,49 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class BlockBarrier extends Block
{
protected BlockBarrier()
{
super(Material.barrier);
this.setBlockUnbreakable();
this.setResistance(6000001.0F);
this.disableStats();
this.translucent = true;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return -1;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Returns the default ambient occlusion value based on block opacity
*/
public float getAmbientOcclusionLightValue()
{
return 1.0F;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
}
}
@@ -1,242 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class BlockBasePressurePlate extends Block
{
protected BlockBasePressurePlate(Material materialIn)
{
this(materialIn, materialIn.getMaterialMapColor());
}
protected BlockBasePressurePlate(Material p_i46401_1_, MapColor p_i46401_2_)
{
super(p_i46401_1_, p_i46401_2_);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setTickRandomly(true);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState0(worldIn.getBlockState(pos));
}
protected void setBlockBoundsBasedOnState0(IBlockState state)
{
boolean flag = this.getRedstoneStrength(state) > 0;
float f = 0.0625F;
if (flag)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.03125F, 0.9375F);
}
else
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.0625F, 0.9375F);
}
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return 20;
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return true;
}
public boolean func_181623_g()
{
return true;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return this.canBePlacedOn(worldIn, pos.down());
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!this.canBePlacedOn(worldIn, pos.down()))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
}
private boolean canBePlacedOn(World worldIn, BlockPos pos)
{
return World.doesBlockHaveSolidTopSurface(worldIn, pos) || worldIn.getBlockState(pos).getBlock() instanceof BlockFence;
}
/**
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
*/
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
int i = this.getRedstoneStrength(state);
if (i > 0)
{
this.updateState(worldIn, pos, state, i);
}
}
}
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
if (!worldIn.isRemote)
{
int i = this.getRedstoneStrength(state);
if (i == 0)
{
this.updateState(worldIn, pos, state, i);
}
}
}
/**
* Updates the pressure plate when stepped on
*/
protected void updateState(World worldIn, BlockPos pos, IBlockState state, int oldRedstoneStrength)
{
int i = this.computeRedstoneStrength(worldIn, pos);
boolean flag = oldRedstoneStrength > 0;
boolean flag1 = i > 0;
if (oldRedstoneStrength != i)
{
state = this.setRedstoneStrength(state, i);
worldIn.setBlockState(pos, state, 2);
this.updateNeighbors(worldIn, pos);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
}
if (!flag1 && flag)
{
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
}
else if (flag1 && !flag)
{
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
}
if (flag1)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
}
/**
* Returns the cubic AABB inset by 1/8 on all sides
*/
protected AxisAlignedBB getSensitiveAABB(BlockPos pos)
{
float f = 0.125F;
return new AxisAlignedBB((double)((float)pos.getX() + 0.125F), (double)pos.getY(), (double)((float)pos.getZ() + 0.125F), (double)((float)(pos.getX() + 1) - 0.125F), (double)pos.getY() + 0.25D, (double)((float)(pos.getZ() + 1) - 0.125F));
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (this.getRedstoneStrength(state) > 0)
{
this.updateNeighbors(worldIn, pos);
}
super.breakBlock(worldIn, pos, state);
}
/**
* Notify block and block below of changes
*/
protected void updateNeighbors(World worldIn, BlockPos pos)
{
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.down(), this);
}
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return this.getRedstoneStrength(state);
}
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return side == EnumFacing.UP ? this.getRedstoneStrength(state) : 0;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
float f = 0.5F;
float f1 = 0.125F;
float f2 = 0.5F;
this.setBlockBounds(0.0F, 0.375F, 0.0F, 1.0F, 0.625F, 1.0F);
}
public int getMobilityFlag()
{
return 1;
}
protected abstract int computeRedstoneStrength(World worldIn, BlockPos pos);
protected abstract int getRedstoneStrength(IBlockState state);
protected abstract IBlockState setRedstoneStrength(IBlockState state, int strength);
}
@@ -1,156 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.HttpUtil;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
public class BlockBeacon extends BlockContainer
{
public BlockBeacon()
{
super(Material.glass, MapColor.diamondColor);
this.setHardness(3.0F);
this.setCreativeTab(CreativeTabs.tabMisc);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityBeacon();
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBeacon)
{
playerIn.displayGUIChest((TileEntityBeacon)tileentity);
playerIn.triggerAchievement(StatList.field_181730_N);
}
return true;
}
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBeacon)
{
((TileEntityBeacon)tileentity).setName(stack.getDisplayName());
}
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBeacon)
{
((TileEntityBeacon)tileentity).updateBeacon();
worldIn.addBlockEvent(pos, this, 1, 0);
}
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
{
HttpUtil.field_180193_a.submit(new Runnable()
{
public void run()
{
Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);
for (int i = glassPos.getY() - 1; i >= 0; --i)
{
final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());
if (!chunk.canSeeSky(blockpos))
{
break;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() == Blocks.beacon)
{
((WorldServer)worldIn).addScheduledTask(new Runnable()
{
public void run()
{
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if (tileentity instanceof TileEntityBeacon)
{
((TileEntityBeacon)tileentity).updateBeacon();
worldIn.addBlockEvent(blockpos, Blocks.beacon, 1, 0);
}
}
});
}
}
}
});
}
}
@@ -1,336 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
public class BlockBed extends BlockDirectional
{
public static final PropertyEnum<BlockBed.EnumPartType> PART = PropertyEnum.<BlockBed.EnumPartType>create("part", BlockBed.EnumPartType.class);
public static final PropertyBool OCCUPIED = PropertyBool.create("occupied");
public BlockBed()
{
super(Material.cloth);
this.setDefaultState(this.blockState.getBaseState().withProperty(PART, BlockBed.EnumPartType.FOOT).withProperty(OCCUPIED, Boolean.valueOf(false)));
this.setBedBounds();
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
if (state.getValue(PART) != BlockBed.EnumPartType.HEAD)
{
pos = pos.offset((EnumFacing)state.getValue(FACING));
state = worldIn.getBlockState(pos);
if (state.getBlock() != this)
{
return true;
}
}
if (worldIn.provider.canRespawnHere() && worldIn.getBiomeGenForCoords(pos) != BiomeGenBase.hell)
{
if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
{
EntityPlayer entityplayer = this.getPlayerInBed(worldIn, pos);
if (entityplayer != null)
{
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied", new Object[0]));
return true;
}
state = state.withProperty(OCCUPIED, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 4);
}
EntityPlayer.EnumStatus entityplayer$enumstatus = playerIn.trySleep(pos);
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.OK)
{
state = state.withProperty(OCCUPIED, Boolean.valueOf(true));
worldIn.setBlockState(pos, state, 4);
return true;
}
else
{
if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW)
{
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]));
}
else if (entityplayer$enumstatus == EntityPlayer.EnumStatus.NOT_SAFE)
{
playerIn.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]));
}
return true;
}
}
else
{
worldIn.setBlockToAir(pos);
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
worldIn.setBlockToAir(blockpos);
}
worldIn.newExplosion((Entity)null, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, 5.0F, true, true);
return true;
}
}
}
private EntityPlayer getPlayerInBed(World worldIn, BlockPos pos)
{
for (EntityPlayer entityplayer : worldIn.playerEntities)
{
if (entityplayer.isPlayerSleeping() && entityplayer.playerLocation.equals(pos))
{
return entityplayer;
}
}
return null;
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBedBounds();
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
if (state.getValue(PART) == BlockBed.EnumPartType.HEAD)
{
if (worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock() != this)
{
worldIn.setBlockToAir(pos);
}
}
else if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() != this)
{
worldIn.setBlockToAir(pos);
if (!worldIn.isRemote)
{
this.dropBlockAsItem(worldIn, pos, state, 0);
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return state.getValue(PART) == BlockBed.EnumPartType.HEAD ? null : Items.bed;
}
private void setBedBounds()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F);
}
/**
* Returns a safe BlockPos to disembark the bed
*/
public static BlockPos getSafeExitLocation(World worldIn, BlockPos pos, int tries)
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
for (int l = 0; l <= 1; ++l)
{
int i1 = i - enumfacing.getFrontOffsetX() * l - 1;
int j1 = k - enumfacing.getFrontOffsetZ() * l - 1;
int k1 = i1 + 2;
int l1 = j1 + 2;
for (int i2 = i1; i2 <= k1; ++i2)
{
for (int j2 = j1; j2 <= l1; ++j2)
{
BlockPos blockpos = new BlockPos(i2, j, j2);
if (hasRoomForPlayer(worldIn, blockpos))
{
if (tries <= 0)
{
return blockpos;
}
--tries;
}
}
}
}
return null;
}
protected static boolean hasRoomForPlayer(World worldIn, BlockPos pos)
{
return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !worldIn.getBlockState(pos).getBlock().getMaterial().isSolid() && !worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid();
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
if (state.getValue(PART) == BlockBed.EnumPartType.FOOT)
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
}
}
public int getMobilityFlag()
{
return 1;
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.bed;
}
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.capabilities.isCreativeMode && state.getValue(PART) == BlockBed.EnumPartType.HEAD)
{
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
worldIn.setBlockToAir(blockpos);
}
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing = EnumFacing.getHorizontal(meta);
return (meta & 8) > 0 ? this.getDefaultState().withProperty(PART, BlockBed.EnumPartType.HEAD).withProperty(FACING, enumfacing).withProperty(OCCUPIED, Boolean.valueOf((meta & 4) > 0)) : this.getDefaultState().withProperty(PART, BlockBed.EnumPartType.FOOT).withProperty(FACING, enumfacing);
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
if (state.getValue(PART) == BlockBed.EnumPartType.FOOT)
{
IBlockState iblockstate = worldIn.getBlockState(pos.offset((EnumFacing)state.getValue(FACING)));
if (iblockstate.getBlock() == this)
{
state = state.withProperty(OCCUPIED, iblockstate.getValue(OCCUPIED));
}
}
return state;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
if (state.getValue(PART) == BlockBed.EnumPartType.HEAD)
{
i |= 8;
if (((Boolean)state.getValue(OCCUPIED)).booleanValue())
{
i |= 4;
}
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, PART, OCCUPIED});
}
public static enum EnumPartType implements IStringSerializable
{
HEAD("head"),
FOOT("foot");
private final String name;
private EnumPartType(String name)
{
this.name = name;
}
public String toString()
{
return this.name;
}
public String getName()
{
return this.name;
}
}
}
@@ -1,33 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class BlockBookshelf extends Block
{
public BlockBookshelf()
{
super(Material.wood);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 3;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.book;
}
}
@@ -1,54 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
public class BlockBreakable extends Block
{
private boolean ignoreSimilarity;
protected BlockBreakable(Material materialIn, boolean ignoreSimilarityIn)
{
this(materialIn, ignoreSimilarityIn, materialIn.getMaterialMapColor());
}
protected BlockBreakable(Material p_i46393_1_, boolean p_i46393_2_, MapColor p_i46393_3_)
{
super(p_i46393_1_, p_i46393_3_);
this.ignoreSimilarity = p_i46393_2_;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (this == Blocks.glass || this == Blocks.stained_glass)
{
if (worldIn.getBlockState(pos.offset(side.getOpposite())) != iblockstate)
{
return true;
}
if (block == this)
{
return false;
}
}
return !this.ignoreSimilarity && block == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
}
}
@@ -1,216 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityBrewingStand;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class BlockBrewingStand extends BlockContainer
{
public static final PropertyBool[] HAS_BOTTLE = new PropertyBool[] {PropertyBool.create("has_bottle_0"), PropertyBool.create("has_bottle_1"), PropertyBool.create("has_bottle_2")};
public BlockBrewingStand()
{
super(Material.iron);
this.setDefaultState(this.blockState.getBaseState().withProperty(HAS_BOTTLE[0], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[1], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[2], Boolean.valueOf(false)));
}
/**
* Gets the localized name of this block. Used for the statistics page.
*/
public String getLocalizedName()
{
return StatCollector.translateToLocal("item.brewingStand.name");
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityBrewingStand();
}
public boolean isFullCube()
{
return false;
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBoundsForItemRender();
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBrewingStand)
{
playerIn.displayGUIChest((TileEntityBrewingStand)tileentity);
playerIn.triggerAchievement(StatList.field_181729_M);
}
return true;
}
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBrewingStand)
{
((TileEntityBrewingStand)tileentity).setName(stack.getDisplayName());
}
}
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
double d0 = (double)((float)pos.getX() + 0.4F + rand.nextFloat() * 0.2F);
double d1 = (double)((float)pos.getY() + 0.7F + rand.nextFloat() * 0.3F);
double d2 = (double)((float)pos.getZ() + 0.4F + rand.nextFloat() * 0.2F);
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBrewingStand)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityBrewingStand)tileentity);
}
super.breakBlock(worldIn, pos, state);
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.brewing_stand;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.brewing_stand;
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
IBlockState iblockstate = this.getDefaultState();
for (int i = 0; i < 3; ++i)
{
iblockstate = iblockstate.withProperty(HAS_BOTTLE[i], Boolean.valueOf((meta & 1 << i) > 0));
}
return iblockstate;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
for (int j = 0; j < 3; ++j)
{
if (((Boolean)state.getValue(HAS_BOTTLE[j])).booleanValue())
{
i |= 1 << j;
}
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]});
}
}
@@ -1,98 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
public class BlockBush extends Block
{
protected BlockBush()
{
this(Material.plants);
}
protected BlockBush(Material materialIn)
{
this(materialIn, materialIn.getMaterialMapColor());
}
protected BlockBush(Material p_i46452_1_, MapColor p_i46452_2_)
{
super(p_i46452_1_, p_i46452_2_);
this.setTickRandomly(true);
float f = 0.2F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
/**
* is the block grass, dirt or farmland
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
this.checkAndDropBlock(worldIn, pos, state);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
this.checkAndDropBlock(worldIn, pos, state);
}
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (!this.canBlockStay(worldIn, pos, state))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
}
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
return this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
}
@@ -1,386 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class BlockButton extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing");
public static final PropertyBool POWERED = PropertyBool.create("powered");
private final boolean wooden;
protected BlockButton(boolean wooden)
{
super(Material.circuits);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(POWERED, Boolean.valueOf(false)));
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.wooden = wooden;
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return this.wooden ? 30 : 20;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* Check whether this Block can be placed on the given side
*/
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
{
return func_181088_a(worldIn, pos, side.getOpposite());
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
for (EnumFacing enumfacing : EnumFacing.values())
{
if (func_181088_a(worldIn, pos, enumfacing))
{
return true;
}
}
return false;
}
protected static boolean func_181088_a(World p_181088_0_, BlockPos p_181088_1_, EnumFacing p_181088_2_)
{
BlockPos blockpos = p_181088_1_.offset(p_181088_2_);
return p_181088_2_ == EnumFacing.DOWN ? World.doesBlockHaveSolidTopSurface(p_181088_0_, blockpos) : p_181088_0_.getBlockState(blockpos).getBlock().isNormalCube();
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return func_181088_a(worldIn, pos, facing.getOpposite()) ? this.getDefaultState().withProperty(FACING, facing).withProperty(POWERED, Boolean.valueOf(false)) : this.getDefaultState().withProperty(FACING, EnumFacing.DOWN).withProperty(POWERED, Boolean.valueOf(false));
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (this.checkForDrop(worldIn, pos, state) && !func_181088_a(worldIn, pos, ((EnumFacing)state.getValue(FACING)).getOpposite()))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
}
private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
{
if (this.canPlaceBlockAt(worldIn, pos))
{
return true;
}
else
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
return false;
}
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.updateBlockBounds(worldIn.getBlockState(pos));
}
private void updateBlockBounds(IBlockState state)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
boolean flag = ((Boolean)state.getValue(POWERED)).booleanValue();
float f = 0.25F;
float f1 = 0.375F;
float f2 = (float)(flag ? 1 : 2) / 16.0F;
float f3 = 0.125F;
float f4 = 0.1875F;
switch (enumfacing)
{
case EAST:
this.setBlockBounds(0.0F, 0.375F, 0.3125F, f2, 0.625F, 0.6875F);
break;
case WEST:
this.setBlockBounds(1.0F - f2, 0.375F, 0.3125F, 1.0F, 0.625F, 0.6875F);
break;
case SOUTH:
this.setBlockBounds(0.3125F, 0.375F, 0.0F, 0.6875F, 0.625F, f2);
break;
case NORTH:
this.setBlockBounds(0.3125F, 0.375F, 1.0F - f2, 0.6875F, 0.625F, 1.0F);
break;
case UP:
this.setBlockBounds(0.3125F, 0.0F, 0.375F, 0.6875F, 0.0F + f2, 0.625F);
break;
case DOWN:
this.setBlockBounds(0.3125F, 1.0F - f2, 0.375F, 0.6875F, 1.0F, 0.625F);
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
return true;
}
else
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
return true;
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
}
super.breakBlock(worldIn, pos, state);
}
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
}
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return !((Boolean)state.getValue(POWERED)).booleanValue() ? 0 : (state.getValue(FACING) == side ? 15 : 0);
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
*/
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
if (this.wooden)
{
this.checkForArrows(worldIn, pos, state);
}
else
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
}
}
}
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
float f = 0.1875F;
float f1 = 0.125F;
float f2 = 0.125F;
this.setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2);
}
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
if (!worldIn.isRemote)
{
if (this.wooden)
{
if (!((Boolean)state.getValue(POWERED)).booleanValue())
{
this.checkForArrows(worldIn, pos, state);
}
}
}
}
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
this.updateBlockBounds(state);
List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
boolean flag = !list.isEmpty();
boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();
if (flag && !flag1)
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
}
if (!flag && flag1)
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
}
if (flag)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
}
private void notifyNeighbors(World worldIn, BlockPos pos, EnumFacing facing)
{
worldIn.notifyNeighborsOfStateChange(pos, this);
worldIn.notifyNeighborsOfStateChange(pos.offset(facing.getOpposite()), this);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing;
switch (meta & 7)
{
case 0:
enumfacing = EnumFacing.DOWN;
break;
case 1:
enumfacing = EnumFacing.EAST;
break;
case 2:
enumfacing = EnumFacing.WEST;
break;
case 3:
enumfacing = EnumFacing.SOUTH;
break;
case 4:
enumfacing = EnumFacing.NORTH;
break;
case 5:
default:
enumfacing = EnumFacing.UP;
}
return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i;
switch ((EnumFacing)state.getValue(FACING))
{
case EAST:
i = 1;
break;
case WEST:
i = 2;
break;
case SOUTH:
i = 3;
break;
case NORTH:
i = 4;
break;
case UP:
default:
i = 5;
break;
case DOWN:
i = 0;
}
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, POWERED});
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockButtonStone extends BlockButton
{
protected BlockButtonStone()
{
super(false);
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockButtonWood extends BlockButton
{
protected BlockButtonWood()
{
super(true);
}
}
@@ -1,151 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
public class BlockCactus extends Block
{
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
protected BlockCactus()
{
super(Material.cactus);
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
BlockPos blockpos = pos.up();
if (worldIn.isAirBlock(blockpos))
{
int i;
for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i)
{
;
}
if (i < 3)
{
int j = ((Integer)state.getValue(AGE)).intValue();
if (j == 15)
{
worldIn.setBlockState(blockpos, this.getDefaultState());
IBlockState iblockstate = state.withProperty(AGE, Integer.valueOf(0));
worldIn.setBlockState(pos, iblockstate, 4);
this.onNeighborBlockChange(worldIn, blockpos, iblockstate, this);
}
else
{
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4);
}
}
}
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
float f = 0.0625F;
return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)((float)(pos.getY() + 1) - f), (double)((float)(pos.getZ() + 1) - f));
}
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
float f = 0.0625F;
return new AxisAlignedBB((double)((float)pos.getX() + f), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)(pos.getY() + 1), (double)((float)(pos.getZ() + 1) - f));
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) ? this.canBlockStay(worldIn, pos) : false;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!this.canBlockStay(worldIn, pos))
{
worldIn.destroyBlock(pos, true);
}
}
public boolean canBlockStay(World worldIn, BlockPos pos)
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial().isSolid())
{
return false;
}
}
Block block = worldIn.getBlockState(pos.down()).getBlock();
return block == Blocks.cactus || block == Blocks.sand;
}
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
entityIn.attackEntityFrom(DamageSource.cactus, 1.0F);
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {AGE});
}
}
@@ -1,182 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.stats.StatList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockCake extends Block
{
public static final PropertyInteger BITES = PropertyInteger.create("bites", 0, 6);
protected BlockCake()
{
super(Material.cake);
this.setDefaultState(this.blockState.getBaseState().withProperty(BITES, Integer.valueOf(0)));
this.setTickRandomly(true);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
float f = 0.0625F;
float f1 = (float)(1 + ((Integer)worldIn.getBlockState(pos).getValue(BITES)).intValue() * 2) / 16.0F;
float f2 = 0.5F;
this.setBlockBounds(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f);
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
float f = 0.0625F;
float f1 = 0.5F;
this.setBlockBounds(f, 0.0F, f, 1.0F - f, f1, 1.0F - f);
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
float f = 0.0625F;
float f1 = (float)(1 + ((Integer)state.getValue(BITES)).intValue() * 2) / 16.0F;
float f2 = 0.5F;
return new AxisAlignedBB((double)((float)pos.getX() + f1), (double)pos.getY(), (double)((float)pos.getZ() + f), (double)((float)(pos.getX() + 1) - f), (double)((float)pos.getY() + f2), (double)((float)(pos.getZ() + 1) - f));
}
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
return this.getCollisionBoundingBox(worldIn, pos, worldIn.getBlockState(pos));
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
this.eatCake(worldIn, pos, state, playerIn);
return true;
}
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
{
this.eatCake(worldIn, pos, worldIn.getBlockState(pos), playerIn);
}
private void eatCake(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.canEat(false))
{
player.triggerAchievement(StatList.field_181724_H);
player.getFoodStats().addStats(2, 0.1F);
int i = ((Integer)state.getValue(BITES)).intValue();
if (i < 6)
{
worldIn.setBlockState(pos, state.withProperty(BITES, Integer.valueOf(i + 1)), 3);
}
else
{
worldIn.setBlockToAir(pos);
}
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) ? this.canBlockStay(worldIn, pos) : false;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!this.canBlockStay(worldIn, pos))
{
worldIn.setBlockToAir(pos);
}
}
private boolean canBlockStay(World worldIn, BlockPos pos)
{
return worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid();
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return null;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.cake;
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(BITES, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(BITES)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {BITES});
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return (7 - ((Integer)worldIn.getBlockState(pos).getValue(BITES)).intValue()) * 2;
}
public boolean hasComparatorInputOverride()
{
return true;
}
}
@@ -1,151 +0,0 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockCarpet extends Block
{
public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.<EnumDyeColor>create("color", EnumDyeColor.class);
protected BlockCarpet()
{
super(Material.carpet);
this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F);
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setBlockBoundsFromMeta(0);
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
this.setBlockBoundsFromMeta(0);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBlockBoundsFromMeta(0);
}
protected void setBlockBoundsFromMeta(int meta)
{
int i = 0;
float f = (float)(1 * (1 + i)) / 16.0F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos);
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
this.checkForDrop(worldIn, pos, state);
}
private boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state)
{
if (!this.canBlockStay(worldIn, pos))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
return false;
}
else
{
return true;
}
}
private boolean canBlockStay(World worldIn, BlockPos pos)
{
return !worldIn.isAirBlock(pos.down());
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return side == EnumFacing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side);
}
/**
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
* returns the metadata of the dropped item based on the old metadata of the block.
*/
public int damageDropped(IBlockState state)
{
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
for (int i = 0; i < 16; ++i)
{
list.add(new ItemStack(itemIn, 1, i));
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {COLOR});
}
}
@@ -1,17 +0,0 @@
package net.minecraft.block;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class BlockCarrot extends BlockCrops
{
protected Item getSeed()
{
return Items.carrot;
}
protected Item getCrop()
{
return Items.carrot;
}
}
@@ -1,283 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemBanner;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntityBanner;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockCauldron extends Block
{
public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 3);
public BlockCauldron()
{
super(Material.iron, MapColor.stoneColor);
this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, Integer.valueOf(0)));
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
float f = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBoundsForItemRender();
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
int i = ((Integer)state.getValue(LEVEL)).intValue();
float f = (float)pos.getY() + (6.0F + (float)(3 * i)) / 16.0F;
if (!worldIn.isRemote && entityIn.isBurning() && i > 0 && entityIn.getEntityBoundingBox().minY <= (double)f)
{
entityIn.extinguish();
this.setWaterLevel(worldIn, pos, state, i - 1);
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ItemStack itemstack = playerIn.inventory.getCurrentItem();
if (itemstack == null)
{
return true;
}
else
{
int i = ((Integer)state.getValue(LEVEL)).intValue();
Item item = itemstack.getItem();
if (item == Items.water_bucket)
{
if (i < 3)
{
if (!playerIn.capabilities.isCreativeMode)
{
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, new ItemStack(Items.bucket));
}
playerIn.triggerAchievement(StatList.field_181725_I);
this.setWaterLevel(worldIn, pos, state, 3);
}
return true;
}
else if (item == Items.glass_bottle)
{
if (i > 0)
{
if (!playerIn.capabilities.isCreativeMode)
{
ItemStack itemstack2 = new ItemStack(Items.potionitem, 1, 0);
if (!playerIn.inventory.addItemStackToInventory(itemstack2))
{
worldIn.spawnEntityInWorld(new EntityItem(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.5D, (double)pos.getZ() + 0.5D, itemstack2));
}
else if (playerIn instanceof EntityPlayerMP)
{
((EntityPlayerMP)playerIn).sendContainerToPlayer(playerIn.inventoryContainer);
}
playerIn.triggerAchievement(StatList.field_181726_J);
--itemstack.stackSize;
if (itemstack.stackSize <= 0)
{
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
}
}
this.setWaterLevel(worldIn, pos, state, i - 1);
}
return true;
}
else
{
if (i > 0 && item instanceof ItemArmor)
{
ItemArmor itemarmor = (ItemArmor)item;
if (itemarmor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER && itemarmor.hasColor(itemstack))
{
itemarmor.removeColor(itemstack);
this.setWaterLevel(worldIn, pos, state, i - 1);
playerIn.triggerAchievement(StatList.field_181727_K);
return true;
}
}
if (i > 0 && item instanceof ItemBanner && TileEntityBanner.getPatterns(itemstack) > 0)
{
ItemStack itemstack1 = itemstack.copy();
itemstack1.stackSize = 1;
TileEntityBanner.removeBannerData(itemstack1);
if (itemstack.stackSize <= 1 && !playerIn.capabilities.isCreativeMode)
{
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, itemstack1);
}
else
{
if (!playerIn.inventory.addItemStackToInventory(itemstack1))
{
worldIn.spawnEntityInWorld(new EntityItem(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.5D, (double)pos.getZ() + 0.5D, itemstack1));
}
else if (playerIn instanceof EntityPlayerMP)
{
((EntityPlayerMP)playerIn).sendContainerToPlayer(playerIn.inventoryContainer);
}
playerIn.triggerAchievement(StatList.field_181728_L);
if (!playerIn.capabilities.isCreativeMode)
{
--itemstack.stackSize;
}
}
if (!playerIn.capabilities.isCreativeMode)
{
this.setWaterLevel(worldIn, pos, state, i - 1);
}
return true;
}
else
{
return false;
}
}
}
}
}
public void setWaterLevel(World worldIn, BlockPos pos, IBlockState state, int level)
{
worldIn.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(MathHelper.clamp_int(level, 0, 3))), 2);
worldIn.updateComparatorOutputLevel(pos, this);
}
/**
* Called similar to random ticks, but only when it is raining.
*/
public void fillWithRain(World worldIn, BlockPos pos)
{
if (worldIn.rand.nextInt(20) == 1)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (((Integer)iblockstate.getValue(LEVEL)).intValue() < 3)
{
worldIn.setBlockState(pos, iblockstate.cycleProperty(LEVEL), 2);
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.cauldron;
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.cauldron;
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return ((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue();
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(LEVEL, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(LEVEL)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {LEVEL});
}
}
@@ -1,609 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.World;
public class BlockChest extends BlockContainer
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
/** 0 : Normal chest, 1 : Trapped chest */
public final int chestType;
protected BlockChest(int type)
{
super(Material.wood);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
this.chestType = type;
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 2;
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
if (worldIn.getBlockState(pos.north()).getBlock() == this)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
}
else if (worldIn.getBlockState(pos.south()).getBlock() == this)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
}
else if (worldIn.getBlockState(pos.west()).getBlock() == this)
{
this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
else if (worldIn.getBlockState(pos.east()).getBlock() == this)
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
}
else
{
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
this.checkForSurroundingChests(worldIn, pos, state);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() == this)
{
this.checkForSurroundingChests(worldIn, blockpos, iblockstate);
}
}
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
state = state.withProperty(FACING, enumfacing);
BlockPos blockpos = pos.north();
BlockPos blockpos1 = pos.south();
BlockPos blockpos2 = pos.west();
BlockPos blockpos3 = pos.east();
boolean flag = this == worldIn.getBlockState(blockpos).getBlock();
boolean flag1 = this == worldIn.getBlockState(blockpos1).getBlock();
boolean flag2 = this == worldIn.getBlockState(blockpos2).getBlock();
boolean flag3 = this == worldIn.getBlockState(blockpos3).getBlock();
if (!flag && !flag1 && !flag2 && !flag3)
{
worldIn.setBlockState(pos, state, 3);
}
else if (enumfacing.getAxis() != EnumFacing.Axis.X || !flag && !flag1)
{
if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3))
{
if (flag2)
{
worldIn.setBlockState(blockpos2, state, 3);
}
else
{
worldIn.setBlockState(blockpos3, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
}
else
{
if (flag)
{
worldIn.setBlockState(blockpos, state, 3);
}
else
{
worldIn.setBlockState(blockpos1, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setCustomName(stack.getDisplayName());
}
}
}
public IBlockState checkForSurroundingChests(World worldIn, BlockPos pos, IBlockState state)
{
if (worldIn.isRemote)
{
return state;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(pos.north());
IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
Block block = iblockstate.getBlock();
Block block1 = iblockstate1.getBlock();
Block block2 = iblockstate2.getBlock();
Block block3 = iblockstate3.getBlock();
if (block != this && block1 != this)
{
boolean flag = block.isFullBlock();
boolean flag1 = block1.isFullBlock();
if (block2 == this || block3 == this)
{
BlockPos blockpos1 = block2 == this ? pos.west() : pos.east();
IBlockState iblockstate6 = worldIn.getBlockState(blockpos1.north());
IBlockState iblockstate7 = worldIn.getBlockState(blockpos1.south());
enumfacing = EnumFacing.SOUTH;
EnumFacing enumfacing2;
if (block2 == this)
{
enumfacing2 = (EnumFacing)iblockstate2.getValue(FACING);
}
else
{
enumfacing2 = (EnumFacing)iblockstate3.getValue(FACING);
}
if (enumfacing2 == EnumFacing.NORTH)
{
enumfacing = EnumFacing.NORTH;
}
Block block6 = iblockstate6.getBlock();
Block block7 = iblockstate7.getBlock();
if ((flag || block6.isFullBlock()) && !flag1 && !block7.isFullBlock())
{
enumfacing = EnumFacing.SOUTH;
}
if ((flag1 || block7.isFullBlock()) && !flag && !block6.isFullBlock())
{
enumfacing = EnumFacing.NORTH;
}
}
}
else
{
BlockPos blockpos = block == this ? pos.north() : pos.south();
IBlockState iblockstate4 = worldIn.getBlockState(blockpos.west());
IBlockState iblockstate5 = worldIn.getBlockState(blockpos.east());
enumfacing = EnumFacing.EAST;
EnumFacing enumfacing1;
if (block == this)
{
enumfacing1 = (EnumFacing)iblockstate.getValue(FACING);
}
else
{
enumfacing1 = (EnumFacing)iblockstate1.getValue(FACING);
}
if (enumfacing1 == EnumFacing.WEST)
{
enumfacing = EnumFacing.WEST;
}
Block block4 = iblockstate4.getBlock();
Block block5 = iblockstate5.getBlock();
if ((block2.isFullBlock() || block4.isFullBlock()) && !block3.isFullBlock() && !block5.isFullBlock())
{
enumfacing = EnumFacing.EAST;
}
if ((block3.isFullBlock() || block5.isFullBlock()) && !block2.isFullBlock() && !block4.isFullBlock())
{
enumfacing = EnumFacing.WEST;
}
}
state = state.withProperty(FACING, enumfacing);
worldIn.setBlockState(pos, state, 3);
return state;
}
}
public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state)
{
EnumFacing enumfacing = null;
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL)
{
IBlockState iblockstate = worldIn.getBlockState(pos.offset(enumfacing1));
if (iblockstate.getBlock() == this)
{
return state;
}
if (iblockstate.getBlock().isFullBlock())
{
if (enumfacing != null)
{
enumfacing = null;
break;
}
enumfacing = enumfacing1;
}
}
if (enumfacing != null)
{
return state.withProperty(FACING, enumfacing.getOpposite());
}
else
{
EnumFacing enumfacing2 = (EnumFacing)state.getValue(FACING);
if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
{
enumfacing2 = enumfacing2.getOpposite();
}
if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
{
enumfacing2 = enumfacing2.rotateY();
}
if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
{
enumfacing2 = enumfacing2.getOpposite();
}
return state.withProperty(FACING, enumfacing2);
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
int i = 0;
BlockPos blockpos = pos.west();
BlockPos blockpos1 = pos.east();
BlockPos blockpos2 = pos.north();
BlockPos blockpos3 = pos.south();
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos))
{
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos1).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos1))
{
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos2).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos2))
{
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos3).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos3))
{
return false;
}
++i;
}
return i <= 1;
}
private boolean isDoubleChest(World worldIn, BlockPos pos)
{
if (worldIn.getBlockState(pos).getBlock() != this)
{
return false;
}
else
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
if (worldIn.getBlockState(pos.offset(enumfacing)).getBlock() == this)
{
return true;
}
}
return false;
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
tileentity.updateContainingBlockInfo();
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof IInventory)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.breakBlock(worldIn, pos, state);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
ILockableContainer ilockablecontainer = this.getLockableContainer(worldIn, pos);
if (ilockablecontainer != null)
{
playerIn.displayGUIChest(ilockablecontainer);
if (this.chestType == 0)
{
playerIn.triggerAchievement(StatList.field_181723_aa);
}
else if (this.chestType == 1)
{
playerIn.triggerAchievement(StatList.field_181737_U);
}
}
return true;
}
}
public ILockableContainer getLockableContainer(World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (!(tileentity instanceof TileEntityChest))
{
return null;
}
else
{
ILockableContainer ilockablecontainer = (TileEntityChest)tileentity;
if (this.isBlocked(worldIn, pos))
{
return null;
}
else
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block == this)
{
if (this.isBlocked(worldIn, blockpos))
{
return null;
}
TileEntity tileentity1 = worldIn.getTileEntity(blockpos);
if (tileentity1 instanceof TileEntityChest)
{
if (enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH)
{
ilockablecontainer = new InventoryLargeChest("container.chestDouble", ilockablecontainer, (TileEntityChest)tileentity1);
}
else
{
ilockablecontainer = new InventoryLargeChest("container.chestDouble", (TileEntityChest)tileentity1, ilockablecontainer);
}
}
}
}
return ilockablecontainer;
}
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityChest();
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return this.chestType == 1;
}
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
if (!this.canProvidePower())
{
return 0;
}
else
{
int i = 0;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
i = ((TileEntityChest)tileentity).numPlayersUsing;
}
return MathHelper.clamp_int(i, 0, 15);
}
}
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return side == EnumFacing.UP ? this.getWeakPower(worldIn, pos, state, side) : 0;
}
private boolean isBlocked(World worldIn, BlockPos pos)
{
return this.isBelowSolidBlock(worldIn, pos) || this.isOcelotSittingOnChest(worldIn, pos);
}
private boolean isBelowSolidBlock(World worldIn, BlockPos pos)
{
return worldIn.getBlockState(pos.up()).getBlock().isNormalCube();
}
private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos)
{
for (Entity entity : worldIn.getEntitiesWithinAABB(EntityOcelot.class, new AxisAlignedBB((double)pos.getX(), (double)(pos.getY() + 1), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 2), (double)(pos.getZ() + 1))))
{
EntityOcelot entityocelot = (EntityOcelot)entity;
if (entityocelot.isSitting())
{
return true;
}
}
return false;
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return Container.calcRedstoneFromInventory(this.getLockableContainer(worldIn, pos));
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing = EnumFacing.getFront(meta);
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
{
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing)state.getValue(FACING)).getIndex();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING});
}
}
@@ -1,33 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class BlockClay extends Block
{
public BlockClay()
{
super(Material.clay);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.clay_ball;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 4;
}
}
@@ -1,226 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockCocoa extends BlockDirectional implements IGrowable
{
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 2);
public BlockCocoa()
{
super(Material.plants);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(AGE, Integer.valueOf(0)));
this.setTickRandomly(true);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!this.canBlockStay(worldIn, pos, state))
{
this.dropBlock(worldIn, pos, state);
}
else if (worldIn.rand.nextInt(5) == 0)
{
int i = ((Integer)state.getValue(AGE)).intValue();
if (i < 2)
{
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i + 1)), 2);
}
}
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
pos = pos.offset((EnumFacing)state.getValue(FACING));
IBlockState iblockstate = worldIn.getBlockState(pos);
return iblockstate.getBlock() == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE;
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state);
}
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
@SuppressWarnings("incomplete-switch")
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
EnumFacing enumfacing = (EnumFacing)iblockstate.getValue(FACING);
int i = ((Integer)iblockstate.getValue(AGE)).intValue();
int j = 4 + i * 2;
int k = 5 + i * 2;
float f = (float)j / 2.0F;
switch (enumfacing)
{
case SOUTH:
this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)k) / 16.0F, (15.0F - (float)j) / 16.0F, (8.0F + f) / 16.0F, 0.75F, 0.9375F);
break;
case NORTH:
this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)k) / 16.0F, 0.0625F, (8.0F + f) / 16.0F, 0.75F, (1.0F + (float)j) / 16.0F);
break;
case WEST:
this.setBlockBounds(0.0625F, (12.0F - (float)k) / 16.0F, (8.0F - f) / 16.0F, (1.0F + (float)j) / 16.0F, 0.75F, (8.0F + f) / 16.0F);
break;
case EAST:
this.setBlockBounds((15.0F - (float)j) / 16.0F, (12.0F - (float)k) / 16.0F, (8.0F - f) / 16.0F, 0.9375F, 0.75F, (8.0F + f) / 16.0F);
}
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
EnumFacing enumfacing = EnumFacing.fromAngle((double)placer.rotationYaw);
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
if (!facing.getAxis().isHorizontal())
{
facing = EnumFacing.NORTH;
}
return this.getDefaultState().withProperty(FACING, facing.getOpposite()).withProperty(AGE, Integer.valueOf(0));
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!this.canBlockStay(worldIn, pos, state))
{
this.dropBlock(worldIn, pos, state);
}
}
private void dropBlock(World worldIn, BlockPos pos, IBlockState state)
{
worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
this.dropBlockAsItem(worldIn, pos, state, 0);
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
int i = ((Integer)state.getValue(AGE)).intValue();
int j = 1;
if (i >= 2)
{
j = 3;
}
for (int k = 0; k < j; ++k)
{
spawnAsEntity(worldIn, pos, new ItemStack(Items.dye, 1, EnumDyeColor.BROWN.getDyeDamage()));
}
}
public Item getItem(World worldIn, BlockPos pos)
{
return Items.dye;
}
public int getDamageValue(World worldIn, BlockPos pos)
{
return EnumDyeColor.BROWN.getDyeDamage();
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
return ((Integer)state.getValue(AGE)).intValue() < 2;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return true;
}
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(((Integer)state.getValue(AGE)).intValue() + 1)), 2);
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(AGE, Integer.valueOf((meta & 15) >> 2));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
i = i | ((Integer)state.getValue(AGE)).intValue() << 2;
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, AGE});
}
}
@@ -1,74 +0,0 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class BlockColored extends Block
{
public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.<EnumDyeColor>create("color", EnumDyeColor.class);
public BlockColored(Material materialIn)
{
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE));
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
* returns the metadata of the dropped item based on the old metadata of the block.
*/
public int damageDropped(IBlockState state)
{
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
for (EnumDyeColor enumdyecolor : EnumDyeColor.values())
{
list.add(new ItemStack(itemIn, 1, enumdyecolor.getMetadata()));
}
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return ((EnumDyeColor)state.getValue(COLOR)).getMapColor();
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((EnumDyeColor)state.getValue(COLOR)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {COLOR});
}
}
@@ -1,171 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockCommandBlock extends BlockContainer
{
public static final PropertyBool TRIGGERED = PropertyBool.create("triggered");
public BlockCommandBlock()
{
super(Material.iron, MapColor.adobeColor);
this.setDefaultState(this.blockState.getBaseState().withProperty(TRIGGERED, Boolean.valueOf(false)));
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityCommandBlock();
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!worldIn.isRemote)
{
boolean flag = worldIn.isBlockPowered(pos);
boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();
if (flag && !flag1)
{
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
else if (!flag && flag1)
{
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
}
}
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityCommandBlock)
{
((TileEntityCommandBlock)tileentity).getCommandBlockLogic().trigger(worldIn);
worldIn.updateComparatorOutputLevel(pos, this);
}
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return 1;
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity instanceof TileEntityCommandBlock ? ((TileEntityCommandBlock)tileentity).getCommandBlockLogic().tryOpenEditCommandBlock(playerIn) : false;
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity instanceof TileEntityCommandBlock ? ((TileEntityCommandBlock)tileentity).getCommandBlockLogic().getSuccessCount() : 0;
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityCommandBlock)
{
CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).getCommandBlockLogic();
if (stack.hasDisplayName())
{
commandblocklogic.setName(stack.getDisplayName());
}
if (!worldIn.isRemote)
{
commandblocklogic.setTrackOutput(worldIn.getGameRules().getBoolean("sendCommandFeedback"));
}
}
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf((meta & 1) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
if (((Boolean)state.getValue(TRIGGERED)).booleanValue())
{
i |= 1;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {TRIGGERED});
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(TRIGGERED, Boolean.valueOf(false));
}
}
@@ -1,29 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
public class BlockCompressedPowered extends Block
{
public BlockCompressedPowered(Material p_i46386_1_, MapColor p_i46386_2_)
{
super(p_i46386_1_, p_i46386_2_);
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return 15;
}
}
@@ -1,57 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public abstract class BlockContainer extends Block implements ITileEntityProvider
{
protected BlockContainer(Material materialIn)
{
this(materialIn, materialIn.getMaterialMapColor());
}
protected BlockContainer(Material p_i46402_1_, MapColor p_i46402_2_)
{
super(p_i46402_1_, p_i46402_2_);
this.isBlockContainer = true;
}
protected boolean func_181086_a(World p_181086_1_, BlockPos p_181086_2_, EnumFacing p_181086_3_)
{
return p_181086_1_.getBlockState(p_181086_2_.offset(p_181086_3_)).getBlock().getMaterial() == Material.cactus;
}
protected boolean func_181087_e(World p_181087_1_, BlockPos p_181087_2_)
{
return this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.NORTH) || this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.SOUTH) || this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.WEST) || this.func_181086_a(p_181087_1_, p_181087_2_, EnumFacing.EAST);
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return -1;
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
super.breakBlock(worldIn, pos, state);
worldIn.removeTileEntity(pos);
}
/**
* Called on both Client and Server when World#addBlockEvent is called
*/
public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam)
{
super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam);
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam);
}
}
@@ -1,220 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class BlockCrops extends BlockBush implements IGrowable
{
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 7);
protected BlockCrops()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
this.setTickRandomly(true);
float f = 0.5F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
this.setCreativeTab((CreativeTabs)null);
this.setHardness(0.0F);
this.setStepSound(soundTypeGrass);
this.disableStats();
}
/**
* is the block grass, dirt or farmland
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground == Blocks.farmland;
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
super.updateTick(worldIn, pos, state, rand);
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
int i = ((Integer)state.getValue(AGE)).intValue();
if (i < 7)
{
float f = getGrowthChance(this, worldIn, pos);
if (rand.nextInt((int)(25.0F / f) + 1) == 0)
{
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i + 1)), 2);
}
}
}
}
public void grow(World worldIn, BlockPos pos, IBlockState state)
{
int i = ((Integer)state.getValue(AGE)).intValue() + MathHelper.getRandomIntegerInRange(worldIn.rand, 2, 5);
if (i > 7)
{
i = 7;
}
worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(i)), 2);
}
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
{
float f = 1.0F;
BlockPos blockpos = pos.down();
for (int i = -1; i <= 1; ++i)
{
for (int j = -1; j <= 1; ++j)
{
float f1 = 0.0F;
IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));
if (iblockstate.getBlock() == Blocks.farmland)
{
f1 = 1.0F;
if (((Integer)iblockstate.getValue(BlockFarmland.MOISTURE)).intValue() > 0)
{
f1 = 3.0F;
}
}
if (i != 0 || j != 0)
{
f1 /= 4.0F;
}
f += f1;
}
}
BlockPos blockpos1 = pos.north();
BlockPos blockpos2 = pos.south();
BlockPos blockpos3 = pos.west();
BlockPos blockpos4 = pos.east();
boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();
if (flag && flag1)
{
f /= 2.0F;
}
else
{
boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();
if (flag2)
{
f /= 2.0F;
}
}
return f;
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
}
protected Item getSeed()
{
return Items.wheat_seeds;
}
protected Item getCrop()
{
return Items.wheat;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
if (!worldIn.isRemote)
{
int i = ((Integer)state.getValue(AGE)).intValue();
if (i >= 7)
{
int j = 3 + fortune;
for (int k = 0; k < j; ++k)
{
if (worldIn.rand.nextInt(15) <= i)
{
spawnAsEntity(worldIn, pos, new ItemStack(this.getSeed(), 1, 0));
}
}
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return ((Integer)state.getValue(AGE)).intValue() == 7 ? this.getCrop() : this.getSeed();
}
public Item getItem(World worldIn, BlockPos pos)
{
return this.getSeed();
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
return ((Integer)state.getValue(AGE)).intValue() < 7;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return true;
}
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
this.grow(worldIn, pos, state);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {AGE});
}
}
@@ -1,186 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityDaylightDetector;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDaylightDetector extends BlockContainer
{
public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
private final boolean inverted;
public BlockDaylightDetector(boolean inverted)
{
super(Material.wood);
this.inverted = inverted;
this.setDefaultState(this.blockState.getBaseState().withProperty(POWER, Integer.valueOf(0)));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setHardness(0.2F);
this.setStepSound(soundTypeWood);
this.setUnlocalizedName("daylightDetector");
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F);
}
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return ((Integer)state.getValue(POWER)).intValue();
}
public void updatePower(World worldIn, BlockPos pos)
{
if (!worldIn.provider.getHasNoSky())
{
IBlockState iblockstate = worldIn.getBlockState(pos);
int i = worldIn.getLightFor(EnumSkyBlock.SKY, pos) - worldIn.getSkylightSubtracted();
float f = worldIn.getCelestialAngleRadians(1.0F);
float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
f = f + (f1 - f) * 0.2F;
i = Math.round((float)i * MathHelper.cos(f));
i = MathHelper.clamp_int(i, 0, 15);
if (this.inverted)
{
i = 15 - i;
}
if (((Integer)iblockstate.getValue(POWER)).intValue() != i)
{
worldIn.setBlockState(pos, iblockstate.withProperty(POWER, Integer.valueOf(i)), 3);
}
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (playerIn.isAllowEdit())
{
if (worldIn.isRemote)
{
return true;
}
else
{
if (this.inverted)
{
worldIn.setBlockState(pos, Blocks.daylight_detector.getDefaultState().withProperty(POWER, state.getValue(POWER)), 4);
Blocks.daylight_detector.updatePower(worldIn, pos);
}
else
{
worldIn.setBlockState(pos, Blocks.daylight_detector_inverted.getDefaultState().withProperty(POWER, state.getValue(POWER)), 4);
Blocks.daylight_detector_inverted.updatePower(worldIn, pos);
}
return true;
}
}
else
{
return super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(Blocks.daylight_detector);
}
public Item getItem(World worldIn, BlockPos pos)
{
return Item.getItemFromBlock(Blocks.daylight_detector);
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityDaylightDetector();
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(POWER, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(POWER)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {POWER});
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
if (!this.inverted)
{
super.getSubBlocks(itemIn, tab, list);
}
}
}
@@ -1,70 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class BlockDeadBush extends BlockBush
{
protected BlockDeadBush()
{
super(Material.vine);
float f = 0.4F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return MapColor.woodColor;
}
/**
* is the block grass, dirt or farmland
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground == Blocks.sand || ground == Blocks.hardened_clay || ground == Blocks.stained_hardened_clay || ground == Blocks.dirt;
}
/**
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
*/
public boolean isReplaceable(World worldIn, BlockPos pos)
{
return true;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return null;
}
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
{
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.deadbush, 1, 0));
}
else
{
super.harvestBlock(worldIn, player, pos, state, te);
}
}
}
@@ -1,21 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.util.EnumFacing;
public abstract class BlockDirectional extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
protected BlockDirectional(Material materialIn)
{
super(materialIn);
}
protected BlockDirectional(Material p_i46398_1_, MapColor p_i46398_2_)
{
super(p_i46398_1_, p_i46398_2_);
}
}
@@ -1,175 +0,0 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDirt extends Block
{
public static final PropertyEnum<BlockDirt.DirtType> VARIANT = PropertyEnum.<BlockDirt.DirtType>create("variant", BlockDirt.DirtType.class);
public static final PropertyBool SNOWY = PropertyBool.create("snowy");
protected BlockDirt()
{
super(Material.ground);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockDirt.DirtType.DIRT).withProperty(SNOWY, Boolean.valueOf(false)));
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return ((BlockDirt.DirtType)state.getValue(VARIANT)).func_181066_d();
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
if (state.getValue(VARIANT) == BlockDirt.DirtType.PODZOL)
{
Block block = worldIn.getBlockState(pos.up()).getBlock();
state = state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
}
return state;
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
list.add(new ItemStack(this, 1, BlockDirt.DirtType.DIRT.getMetadata()));
list.add(new ItemStack(this, 1, BlockDirt.DirtType.COARSE_DIRT.getMetadata()));
list.add(new ItemStack(this, 1, BlockDirt.DirtType.PODZOL.getMetadata()));
}
public int getDamageValue(World worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
return iblockstate.getBlock() != this ? 0 : ((BlockDirt.DirtType)iblockstate.getValue(VARIANT)).getMetadata();
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, BlockDirt.DirtType.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((BlockDirt.DirtType)state.getValue(VARIANT)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {VARIANT, SNOWY});
}
/**
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
* returns the metadata of the dropped item based on the old metadata of the block.
*/
public int damageDropped(IBlockState state)
{
BlockDirt.DirtType blockdirt$dirttype = (BlockDirt.DirtType)state.getValue(VARIANT);
if (blockdirt$dirttype == BlockDirt.DirtType.PODZOL)
{
blockdirt$dirttype = BlockDirt.DirtType.DIRT;
}
return blockdirt$dirttype.getMetadata();
}
public static enum DirtType implements IStringSerializable
{
DIRT(0, "dirt", "default", MapColor.dirtColor),
COARSE_DIRT(1, "coarse_dirt", "coarse", MapColor.dirtColor),
PODZOL(2, "podzol", MapColor.obsidianColor);
private static final BlockDirt.DirtType[] METADATA_LOOKUP = new BlockDirt.DirtType[values().length];
private final int metadata;
private final String name;
private final String unlocalizedName;
private final MapColor field_181067_h;
private DirtType(int p_i46396_3_, String p_i46396_4_, MapColor p_i46396_5_)
{
this(p_i46396_3_, p_i46396_4_, p_i46396_4_, p_i46396_5_);
}
private DirtType(int p_i46397_3_, String p_i46397_4_, String p_i46397_5_, MapColor p_i46397_6_)
{
this.metadata = p_i46397_3_;
this.name = p_i46397_4_;
this.unlocalizedName = p_i46397_5_;
this.field_181067_h = p_i46397_6_;
}
public int getMetadata()
{
return this.metadata;
}
public String getUnlocalizedName()
{
return this.unlocalizedName;
}
public MapColor func_181066_d()
{
return this.field_181067_h;
}
public String toString()
{
return this.name;
}
public static BlockDirt.DirtType byMetadata(int metadata)
{
if (metadata < 0 || metadata >= METADATA_LOOKUP.length)
{
metadata = 0;
}
return METADATA_LOOKUP[metadata];
}
public String getName()
{
return this.name;
}
static {
for (BlockDirt.DirtType blockdirt$dirttype : values())
{
METADATA_LOOKUP[blockdirt$dirttype.getMetadata()] = blockdirt$dirttype;
}
}
}
}
@@ -1,303 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IPosition;
import net.minecraft.dispenser.PositionImpl;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityDispenser;
import net.minecraft.tileentity.TileEntityDropper;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.RegistryDefaulted;
import net.minecraft.world.World;
public class BlockDispenser extends BlockContainer
{
public static final PropertyDirection FACING = PropertyDirection.create("facing");
public static final PropertyBool TRIGGERED = PropertyBool.create("triggered");
public static final RegistryDefaulted<Item, IBehaviorDispenseItem> dispenseBehaviorRegistry = new RegistryDefaulted(new BehaviorDefaultDispenseItem());
protected Random rand = new Random();
protected BlockDispenser()
{
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(TRIGGERED, Boolean.valueOf(false)));
this.setCreativeTab(CreativeTabs.tabRedstone);
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return 4;
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
super.onBlockAdded(worldIn, pos, state);
this.setDefaultDirection(worldIn, pos, state);
}
private void setDefaultDirection(World worldIn, BlockPos pos, IBlockState state)
{
if (!worldIn.isRemote)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
boolean flag = worldIn.getBlockState(pos.north()).getBlock().isFullBlock();
boolean flag1 = worldIn.getBlockState(pos.south()).getBlock().isFullBlock();
if (enumfacing == EnumFacing.NORTH && flag && !flag1)
{
enumfacing = EnumFacing.SOUTH;
}
else if (enumfacing == EnumFacing.SOUTH && flag1 && !flag)
{
enumfacing = EnumFacing.NORTH;
}
else
{
boolean flag2 = worldIn.getBlockState(pos.west()).getBlock().isFullBlock();
boolean flag3 = worldIn.getBlockState(pos.east()).getBlock().isFullBlock();
if (enumfacing == EnumFacing.WEST && flag2 && !flag3)
{
enumfacing = EnumFacing.EAST;
}
else if (enumfacing == EnumFacing.EAST && flag3 && !flag2)
{
enumfacing = EnumFacing.WEST;
}
}
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing).withProperty(TRIGGERED, Boolean.valueOf(false)), 2);
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityDispenser)
{
playerIn.displayGUIChest((TileEntityDispenser)tileentity);
if (tileentity instanceof TileEntityDropper)
{
playerIn.triggerAchievement(StatList.field_181731_O);
}
else
{
playerIn.triggerAchievement(StatList.field_181733_Q);
}
}
return true;
}
}
protected void dispense(World worldIn, BlockPos pos)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
worldIn.playAuxSFX(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
}
}
}
}
protected IBehaviorDispenseItem getBehavior(ItemStack stack)
{
return (IBehaviorDispenseItem)dispenseBehaviorRegistry.getObject(stack == null ? null : stack.getItem());
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
boolean flag1 = ((Boolean)state.getValue(TRIGGERED)).booleanValue();
if (flag && !flag1)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(true)), 4);
}
else if (!flag && flag1)
{
worldIn.setBlockState(pos, state.withProperty(TRIGGERED, Boolean.valueOf(false)), 4);
}
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
this.dispense(worldIn, pos);
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityDispenser();
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)).withProperty(TRIGGERED, Boolean.valueOf(false));
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
worldIn.setBlockState(pos, state.withProperty(FACING, BlockPistonBase.getFacingFromEntity(worldIn, pos, placer)), 2);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityDispenser)
{
((TileEntityDispenser)tileentity).setCustomName(stack.getDisplayName());
}
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityDispenser)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityDispenser)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.breakBlock(worldIn, pos, state);
}
/**
* Get the position where the dispenser at the given Coordinates should dispense to.
*/
public static IPosition getDispensePosition(IBlockSource coords)
{
EnumFacing enumfacing = getFacing(coords.getBlockMetadata());
double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
return new PositionImpl(d0, d1, d2);
}
/**
* Get the facing of a dispenser with the given metadata
*/
public static EnumFacing getFacing(int meta)
{
return EnumFacing.getFront(meta & 7);
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
*/
public IBlockState getStateForEntityRender(IBlockState state)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(TRIGGERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
if (((Boolean)state.getValue(TRIGGERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, TRIGGERED});
}
}
@@ -1,477 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDoor extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyEnum<BlockDoor.EnumHingePosition> HINGE = PropertyEnum.<BlockDoor.EnumHingePosition>create("hinge", BlockDoor.EnumHingePosition.class);
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyEnum<BlockDoor.EnumDoorHalf> HALF = PropertyEnum.<BlockDoor.EnumDoorHalf>create("half", BlockDoor.EnumDoorHalf.class);
protected BlockDoor(Material materialIn)
{
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(OPEN, Boolean.valueOf(false)).withProperty(HINGE, BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf(false)).withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER));
}
/**
* Gets the localized name of this block. Used for the statistics page.
*/
public String getLocalizedName()
{
return StatCollector.translateToLocal((this.getUnlocalizedName() + ".name").replaceAll("tile", "item"));
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return isOpen(combineMetadata(worldIn, pos));
}
public boolean isFullCube()
{
return false;
}
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBoundBasedOnMeta(combineMetadata(worldIn, pos));
}
private void setBoundBasedOnMeta(int combinedMeta)
{
float f = 0.1875F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F);
EnumFacing enumfacing = getFacing(combinedMeta);
boolean flag = isOpen(combinedMeta);
boolean flag1 = isHingeLeft(combinedMeta);
if (flag)
{
if (enumfacing == EnumFacing.EAST)
{
if (!flag1)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}
else
{
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}
}
else if (enumfacing == EnumFacing.SOUTH)
{
if (!flag1)
{
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
}
else if (enumfacing == EnumFacing.WEST)
{
if (!flag1)
{
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}
}
else if (enumfacing == EnumFacing.NORTH)
{
if (!flag1)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
else
{
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
}
else if (enumfacing == EnumFacing.EAST)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
else if (enumfacing == EnumFacing.SOUTH)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
}
else if (enumfacing == EnumFacing.WEST)
{
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else if (enumfacing == EnumFacing.NORTH)
{
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (this.blockMaterial == Material.iron)
{
return true;
}
else
{
BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() != this)
{
return false;
}
else
{
state = iblockstate.cycleProperty(OPEN);
worldIn.setBlockState(blockpos, state, 2);
worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
return true;
}
}
}
public void toggleDoor(World worldIn, BlockPos pos, boolean open)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this)
{
BlockPos blockpos = iblockstate.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
IBlockState iblockstate1 = pos == blockpos ? iblockstate : worldIn.getBlockState(blockpos);
if (iblockstate1.getBlock() == this && ((Boolean)iblockstate1.getValue(OPEN)).booleanValue() != open)
{
worldIn.setBlockState(blockpos, iblockstate1.withProperty(OPEN, Boolean.valueOf(open)), 2);
worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, open ? 1003 : 1006, pos, 0);
}
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
{
BlockPos blockpos = pos.down();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() != this)
{
worldIn.setBlockToAir(pos);
}
else if (neighborBlock != this)
{
this.onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
}
}
else
{
boolean flag1 = false;
BlockPos blockpos1 = pos.up();
IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);
if (iblockstate1.getBlock() != this)
{
worldIn.setBlockToAir(pos);
flag1 = true;
}
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
{
worldIn.setBlockToAir(pos);
flag1 = true;
if (iblockstate1.getBlock() == this)
{
worldIn.setBlockToAir(blockpos1);
}
}
if (flag1)
{
if (!worldIn.isRemote)
{
this.dropBlockAsItem(worldIn, pos, state, 0);
}
}
else
{
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);
if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != ((Boolean)iblockstate1.getValue(POWERED)).booleanValue())
{
worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);
if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
{
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
}
}
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER ? null : this.getItem();
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit.
*/
public MovingObjectPosition collisionRayTrace(World worldIn, BlockPos pos, Vec3 start, Vec3 end)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.collisionRayTrace(worldIn, pos, start, end);
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return pos.getY() >= 255 ? false : World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up());
}
public int getMobilityFlag()
{
return 1;
}
public static int combineMetadata(IBlockAccess worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
int i = iblockstate.getBlock().getMetaFromState(iblockstate);
boolean flag = isTop(i);
IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
int j = iblockstate1.getBlock().getMetaFromState(iblockstate1);
int k = flag ? j : i;
IBlockState iblockstate2 = worldIn.getBlockState(pos.up());
int l = iblockstate2.getBlock().getMetaFromState(iblockstate2);
int i1 = flag ? i : l;
boolean flag1 = (i1 & 1) != 0;
boolean flag2 = (i1 & 2) != 0;
return removeHalfBit(k) | (flag ? 8 : 0) | (flag1 ? 16 : 0) | (flag2 ? 32 : 0);
}
public Item getItem(World worldIn, BlockPos pos)
{
return this.getItem();
}
private Item getItem()
{
return this == Blocks.iron_door ? Items.iron_door : (this == Blocks.spruce_door ? Items.spruce_door : (this == Blocks.birch_door ? Items.birch_door : (this == Blocks.jungle_door ? Items.jungle_door : (this == Blocks.acacia_door ? Items.acacia_door : (this == Blocks.dark_oak_door ? Items.dark_oak_door : Items.oak_door)))));
}
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
BlockPos blockpos = pos.down();
if (player.capabilities.isCreativeMode && state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER && worldIn.getBlockState(blockpos).getBlock() == this)
{
worldIn.setBlockToAir(blockpos);
}
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER)
{
IBlockState iblockstate = worldIn.getBlockState(pos.up());
if (iblockstate.getBlock() == this)
{
state = state.withProperty(HINGE, iblockstate.getValue(HINGE)).withProperty(POWERED, iblockstate.getValue(POWERED));
}
}
else
{
IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
if (iblockstate1.getBlock() == this)
{
state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN));
}
}
return state;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return (meta & 8) > 0 ? this.getDefaultState().withProperty(HALF, BlockDoor.EnumDoorHalf.UPPER).withProperty(HINGE, (meta & 1) > 0 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT).withProperty(POWERED, Boolean.valueOf((meta & 2) > 0)) : this.getDefaultState().withProperty(HALF, BlockDoor.EnumDoorHalf.LOWER).withProperty(FACING, EnumFacing.getHorizontal(meta & 3).rotateYCCW()).withProperty(OPEN, Boolean.valueOf((meta & 4) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
{
i = i | 8;
if (state.getValue(HINGE) == BlockDoor.EnumHingePosition.RIGHT)
{
i |= 1;
}
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 2;
}
}
else
{
i = i | ((EnumFacing)state.getValue(FACING)).rotateY().getHorizontalIndex();
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
i |= 4;
}
}
return i;
}
protected static int removeHalfBit(int meta)
{
return meta & 7;
}
public static boolean isOpen(IBlockAccess worldIn, BlockPos pos)
{
return isOpen(combineMetadata(worldIn, pos));
}
public static EnumFacing getFacing(IBlockAccess worldIn, BlockPos pos)
{
return getFacing(combineMetadata(worldIn, pos));
}
public static EnumFacing getFacing(int combinedMeta)
{
return EnumFacing.getHorizontal(combinedMeta & 3).rotateYCCW();
}
protected static boolean isOpen(int combinedMeta)
{
return (combinedMeta & 4) != 0;
}
protected static boolean isTop(int meta)
{
return (meta & 8) != 0;
}
protected static boolean isHingeLeft(int combinedMeta)
{
return (combinedMeta & 16) != 0;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {HALF, FACING, OPEN, HINGE, POWERED});
}
public static enum EnumDoorHalf implements IStringSerializable
{
UPPER,
LOWER;
public String toString()
{
return this.getName();
}
public String getName()
{
return this == UPPER ? "upper" : "lower";
}
}
public static enum EnumHingePosition implements IStringSerializable
{
LEFT,
RIGHT;
public String toString()
{
return this.getName();
}
public String getName()
{
return this == LEFT ? "left" : "right";
}
}
}
@@ -1,402 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColorHelper;
public class BlockDoublePlant extends BlockBush implements IGrowable
{
public static final PropertyEnum<BlockDoublePlant.EnumPlantType> VARIANT = PropertyEnum.<BlockDoublePlant.EnumPlantType>create("variant", BlockDoublePlant.EnumPlantType.class);
public static final PropertyEnum<BlockDoublePlant.EnumBlockHalf> HALF = PropertyEnum.<BlockDoublePlant.EnumBlockHalf>create("half", BlockDoublePlant.EnumBlockHalf.class);
public static final PropertyEnum<EnumFacing> field_181084_N = BlockDirectional.FACING;
public BlockDoublePlant()
{
super(Material.vine);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockDoublePlant.EnumPlantType.SUNFLOWER).withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(field_181084_N, EnumFacing.NORTH));
this.setHardness(0.0F);
this.setStepSound(soundTypeGrass);
this.setUnlocalizedName("doublePlant");
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public BlockDoublePlant.EnumPlantType getVariant(IBlockAccess worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this)
{
iblockstate = this.getActualState(iblockstate, worldIn, pos);
return (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
}
else
{
return BlockDoublePlant.EnumPlantType.FERN;
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && worldIn.isAirBlock(pos.up());
}
/**
* Whether this Block can be replaced directly by other blocks (true for e.g. tall grass)
*/
public boolean isReplaceable(World worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() != this)
{
return true;
}
else
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)this.getActualState(iblockstate, worldIn, pos).getValue(VARIANT);
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN || blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS;
}
}
protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (!this.canBlockStay(worldIn, pos, state))
{
boolean flag = state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER;
BlockPos blockpos = flag ? pos : pos.up();
BlockPos blockpos1 = flag ? pos.down() : pos;
Block block = (Block)(flag ? this : worldIn.getBlockState(blockpos).getBlock());
Block block1 = (Block)(flag ? worldIn.getBlockState(blockpos1).getBlock() : this);
if (block == this)
{
worldIn.setBlockState(blockpos, Blocks.air.getDefaultState(), 2);
}
if (block1 == this)
{
worldIn.setBlockState(blockpos1, Blocks.air.getDefaultState(), 3);
if (!flag)
{
this.dropBlockAsItem(worldIn, blockpos1, state, 0);
}
}
}
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
{
return worldIn.getBlockState(pos.down()).getBlock() == this;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(pos.up());
return iblockstate.getBlock() == this && super.canBlockStay(worldIn, pos, iblockstate);
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
{
return null;
}
else
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN ? null : (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? (rand.nextInt(8) == 0 ? Items.wheat_seeds : null) : Item.getItemFromBlock(this));
}
}
/**
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
* returns the metadata of the dropped item based on the old metadata of the block.
*/
public int damageDropped(IBlockState state)
{
return state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.UPPER && state.getValue(VARIANT) != BlockDoublePlant.EnumPlantType.GRASS ? ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta() : 0;
}
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
public void placeAt(World worldIn, BlockPos lowerPos, BlockDoublePlant.EnumPlantType variant, int flags)
{
worldIn.setBlockState(lowerPos, this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, variant), flags);
worldIn.setBlockState(lowerPos.up(), this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), flags);
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
worldIn.setBlockState(pos.up(), this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER), 2);
}
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
if (worldIn.isRemote || player.getCurrentEquippedItem() == null || player.getCurrentEquippedItem().getItem() != Items.shears || state.getValue(HALF) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.onHarvest(worldIn, pos, state, player))
{
super.harvestBlock(worldIn, player, pos, state, te);
}
}
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
{
if (worldIn.getBlockState(pos.down()).getBlock() == this)
{
if (!player.capabilities.isCreativeMode)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
{
worldIn.destroyBlock(pos.down(), true);
}
else if (!worldIn.isRemote)
{
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
{
this.onHarvest(worldIn, pos, iblockstate, player);
worldIn.setBlockToAir(pos.down());
}
else
{
worldIn.destroyBlock(pos.down(), true);
}
}
else
{
worldIn.setBlockToAir(pos.down());
}
}
else
{
worldIn.setBlockToAir(pos.down());
}
}
}
else if (player.capabilities.isCreativeMode && worldIn.getBlockState(pos.up()).getBlock() == this)
{
worldIn.setBlockState(pos.up(), Blocks.air.getDefaultState(), 2);
}
super.onBlockHarvested(worldIn, pos, state, player);
}
private boolean onHarvest(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
{
return false;
}
else
{
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
int i = (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? BlockTallGrass.EnumType.GRASS : BlockTallGrass.EnumType.FERN).getMeta();
spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 2, i));
return true;
}
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
for (BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype : BlockDoublePlant.EnumPlantType.values())
{
list.add(new ItemStack(itemIn, 1, blockdoubleplant$enumplanttype.getMeta()));
}
}
public int getDamageValue(World worldIn, BlockPos pos)
{
return this.getVariant(worldIn, pos).getMeta();
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return true;
}
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
spawnAsEntity(worldIn, pos, new ItemStack(this, 1, this.getVariant(worldIn, pos).getMeta()));
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return (meta & 8) > 0 ? this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.UPPER) : this.getDefaultState().withProperty(HALF, BlockDoublePlant.EnumBlockHalf.LOWER).withProperty(VARIANT, BlockDoublePlant.EnumPlantType.byMetadata(meta & 7));
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
if (iblockstate.getBlock() == this)
{
state = state.withProperty(VARIANT, iblockstate.getValue(VARIANT));
}
}
return state;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER ? 8 | ((EnumFacing)state.getValue(field_181084_N)).getHorizontalIndex() : ((BlockDoublePlant.EnumPlantType)state.getValue(VARIANT)).getMeta();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {HALF, VARIANT, field_181084_N});
}
/**
* Get the OffsetType for this Block. Determines if the model is rendered slightly offset.
*/
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
public static enum EnumBlockHalf implements IStringSerializable
{
UPPER,
LOWER;
public String toString()
{
return this.getName();
}
public String getName()
{
return this == UPPER ? "upper" : "lower";
}
}
public static enum EnumPlantType implements IStringSerializable
{
SUNFLOWER(0, "sunflower"),
SYRINGA(1, "syringa"),
GRASS(2, "double_grass", "grass"),
FERN(3, "double_fern", "fern"),
ROSE(4, "double_rose", "rose"),
PAEONIA(5, "paeonia");
private static final BlockDoublePlant.EnumPlantType[] META_LOOKUP = new BlockDoublePlant.EnumPlantType[values().length];
private final int meta;
private final String name;
private final String unlocalizedName;
private EnumPlantType(int meta, String name)
{
this(meta, name, name);
}
private EnumPlantType(int meta, String name, String unlocalizedName)
{
this.meta = meta;
this.name = name;
this.unlocalizedName = unlocalizedName;
}
public int getMeta()
{
return this.meta;
}
public String toString()
{
return this.name;
}
public static BlockDoublePlant.EnumPlantType byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public String getName()
{
return this.name;
}
public String getUnlocalizedName()
{
return this.unlocalizedName;
}
static {
for (BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype : values())
{
META_LOOKUP[blockdoubleplant$enumplanttype.getMeta()] = blockdoubleplant$enumplanttype;
}
}
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockDoubleStoneSlab extends BlockStoneSlab
{
public boolean isDouble()
{
return true;
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockDoubleStoneSlabNew extends BlockStoneSlabNew
{
public boolean isDouble()
{
return true;
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockDoubleWoodSlab extends BlockWoodSlab
{
public boolean isDouble()
{
return true;
}
}
@@ -1,149 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDragonEgg extends Block
{
public BlockDragonEgg()
{
super(Material.dragonEgg, MapColor.blackColor);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
this.checkFall(worldIn, pos);
}
private void checkFall(World worldIn, BlockPos pos)
{
if (BlockFalling.canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
{
int i = 32;
if (!BlockFalling.fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
{
worldIn.spawnEntityInWorld(new EntityFallingBlock(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), this.getDefaultState()));
}
else
{
worldIn.setBlockToAir(pos);
BlockPos blockpos;
for (blockpos = pos; BlockFalling.canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
{
;
}
if (blockpos.getY() > 0)
{
worldIn.setBlockState(blockpos, this.getDefaultState(), 2);
}
}
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
this.teleport(worldIn, pos);
return true;
}
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn)
{
this.teleport(worldIn, pos);
}
private void teleport(World worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this)
{
for (int i = 0; i < 1000; ++i)
{
BlockPos blockpos = pos.add(worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16), worldIn.rand.nextInt(8) - worldIn.rand.nextInt(8), worldIn.rand.nextInt(16) - worldIn.rand.nextInt(16));
if (worldIn.getBlockState(blockpos).getBlock().blockMaterial == Material.air)
{
if (worldIn.isRemote)
{
for (int j = 0; j < 128; ++j)
{
double d0 = worldIn.rand.nextDouble();
float f = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
float f1 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
float f2 = (worldIn.rand.nextFloat() - 0.5F) * 0.2F;
double d1 = (double)blockpos.getX() + (double)(pos.getX() - blockpos.getX()) * d0 + (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
double d2 = (double)blockpos.getY() + (double)(pos.getY() - blockpos.getY()) * d0 + worldIn.rand.nextDouble() * 1.0D - 0.5D;
double d3 = (double)blockpos.getZ() + (double)(pos.getZ() - blockpos.getZ()) * d0 + (worldIn.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d1, d2, d3, (double)f, (double)f1, (double)f2, new int[0]);
}
}
else
{
worldIn.setBlockState(blockpos, iblockstate, 2);
worldIn.setBlockToAir(pos);
}
return;
}
}
}
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return 5;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
}
@@ -1,89 +0,0 @@
package net.minecraft.block;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityDispenser;
import net.minecraft.tileentity.TileEntityDropper;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockDropper extends BlockDispenser
{
private final IBehaviorDispenseItem dropBehavior = new BehaviorDefaultDispenseItem();
protected IBehaviorDispenseItem getBehavior(ItemStack stack)
{
return this.dropBehavior;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityDropper();
}
protected void dispense(World worldIn, BlockPos pos)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
worldIn.playAuxSFX(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
if (itemstack != null)
{
EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
ItemStack itemstack1;
if (iinventory == null)
{
itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);
if (itemstack1 != null && itemstack1.stackSize <= 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (--itemstack1.stackSize <= 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
tileentitydispenser.setInventorySlotContents(i, itemstack1);
}
}
}
}
}
@@ -1,293 +0,0 @@
package net.minecraft.block;
import java.util.EnumSet;
import java.util.Random;
import java.util.Set;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockDynamicLiquid extends BlockLiquid
{
int adjacentSourceBlocks;
protected BlockDynamicLiquid(Material materialIn)
{
super(materialIn);
}
private void placeStaticBlock(World worldIn, BlockPos pos, IBlockState currentState)
{
worldIn.setBlockState(pos, getStaticBlock(this.blockMaterial).getDefaultState().withProperty(LEVEL, currentState.getValue(LEVEL)), 2);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
int i = ((Integer)state.getValue(LEVEL)).intValue();
int j = 1;
if (this.blockMaterial == Material.lava && !worldIn.provider.doesWaterVaporize())
{
j = 2;
}
int k = this.tickRate(worldIn);
if (i > 0)
{
int l = -100;
this.adjacentSourceBlocks = 0;
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
l = this.checkAdjacentBlock(worldIn, pos.offset(enumfacing), l);
}
int i1 = l + j;
if (i1 >= 8 || l < 0)
{
i1 = -1;
}
if (this.getLevel(worldIn, pos.up()) >= 0)
{
int j1 = this.getLevel(worldIn, pos.up());
if (j1 >= 8)
{
i1 = j1;
}
else
{
i1 = j1 + 8;
}
}
if (this.adjacentSourceBlocks >= 2 && this.blockMaterial == Material.water)
{
IBlockState iblockstate1 = worldIn.getBlockState(pos.down());
if (iblockstate1.getBlock().getMaterial().isSolid())
{
i1 = 0;
}
else if (iblockstate1.getBlock().getMaterial() == this.blockMaterial && ((Integer)iblockstate1.getValue(LEVEL)).intValue() == 0)
{
i1 = 0;
}
}
if (this.blockMaterial == Material.lava && i < 8 && i1 < 8 && i1 > i && rand.nextInt(4) != 0)
{
k *= 4;
}
if (i1 == i)
{
this.placeStaticBlock(worldIn, pos, state);
}
else
{
i = i1;
if (i1 < 0)
{
worldIn.setBlockToAir(pos);
}
else
{
state = state.withProperty(LEVEL, Integer.valueOf(i1));
worldIn.setBlockState(pos, state, 2);
worldIn.scheduleUpdate(pos, this, k);
worldIn.notifyNeighborsOfStateChange(pos, this);
}
}
}
else
{
this.placeStaticBlock(worldIn, pos, state);
}
IBlockState iblockstate = worldIn.getBlockState(pos.down());
if (this.canFlowInto(worldIn, pos.down(), iblockstate))
{
if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.down()).getBlock().getMaterial() == Material.water)
{
worldIn.setBlockState(pos.down(), Blocks.stone.getDefaultState());
this.triggerMixEffects(worldIn, pos.down());
return;
}
if (i >= 8)
{
this.tryFlowInto(worldIn, pos.down(), iblockstate, i);
}
else
{
this.tryFlowInto(worldIn, pos.down(), iblockstate, i + 8);
}
}
else if (i >= 0 && (i == 0 || this.isBlocked(worldIn, pos.down(), iblockstate)))
{
Set<EnumFacing> set = this.getPossibleFlowDirections(worldIn, pos);
int k1 = i + j;
if (i >= 8)
{
k1 = 1;
}
if (k1 >= 8)
{
return;
}
for (EnumFacing enumfacing1 : set)
{
this.tryFlowInto(worldIn, pos.offset(enumfacing1), worldIn.getBlockState(pos.offset(enumfacing1)), k1);
}
}
}
private void tryFlowInto(World worldIn, BlockPos pos, IBlockState state, int level)
{
if (this.canFlowInto(worldIn, pos, state))
{
if (state.getBlock() != Blocks.air)
{
if (this.blockMaterial == Material.lava)
{
this.triggerMixEffects(worldIn, pos);
}
else
{
state.getBlock().dropBlockAsItem(worldIn, pos, state, 0);
}
}
worldIn.setBlockState(pos, this.getDefaultState().withProperty(LEVEL, Integer.valueOf(level)), 3);
}
}
private int func_176374_a(World worldIn, BlockPos pos, int distance, EnumFacing calculateFlowCost)
{
int i = 1000;
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
if (enumfacing != calculateFlowCost)
{
BlockPos blockpos = pos.offset(enumfacing);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (!this.isBlocked(worldIn, blockpos, iblockstate) && (iblockstate.getBlock().getMaterial() != this.blockMaterial || ((Integer)iblockstate.getValue(LEVEL)).intValue() > 0))
{
if (!this.isBlocked(worldIn, blockpos.down(), iblockstate))
{
return distance;
}
if (distance < 4)
{
int j = this.func_176374_a(worldIn, blockpos, distance + 1, enumfacing.getOpposite());
if (j < i)
{
i = j;
}
}
}
}
}
return i;
}
private Set<EnumFacing> getPossibleFlowDirections(World worldIn, BlockPos pos)
{
int i = 1000;
Set<EnumFacing> set = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (!this.isBlocked(worldIn, blockpos, iblockstate) && (iblockstate.getBlock().getMaterial() != this.blockMaterial || ((Integer)iblockstate.getValue(LEVEL)).intValue() > 0))
{
int j;
if (this.isBlocked(worldIn, blockpos.down(), worldIn.getBlockState(blockpos.down())))
{
j = this.func_176374_a(worldIn, blockpos, 1, enumfacing.getOpposite());
}
else
{
j = 0;
}
if (j < i)
{
set.clear();
}
if (j <= i)
{
set.add(enumfacing);
i = j;
}
}
}
return set;
}
private boolean isBlocked(World worldIn, BlockPos pos, IBlockState state)
{
Block block = worldIn.getBlockState(pos).getBlock();
return !(block instanceof BlockDoor) && block != Blocks.standing_sign && block != Blocks.ladder && block != Blocks.reeds ? (block.blockMaterial == Material.portal ? true : block.blockMaterial.blocksMovement()) : true;
}
protected int checkAdjacentBlock(World worldIn, BlockPos pos, int currentMinLevel)
{
int i = this.getLevel(worldIn, pos);
if (i < 0)
{
return currentMinLevel;
}
else
{
if (i == 0)
{
++this.adjacentSourceBlocks;
}
if (i >= 8)
{
i = 0;
}
return currentMinLevel >= 0 && i >= currentMinLevel ? currentMinLevel : i;
}
}
private boolean canFlowInto(World worldIn, BlockPos pos, IBlockState state)
{
Material material = state.getBlock().getMaterial();
return material != this.blockMaterial && material != Material.lava && !this.isBlocked(worldIn, pos, state);
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
if (!this.checkForMixing(worldIn, pos, state))
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
}
}
@@ -1,128 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEnchantmentTable;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
public class BlockEnchantmentTable extends BlockContainer
{
protected BlockEnchantmentTable()
{
super(Material.rock, MapColor.redColor);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public boolean isFullCube()
{
return false;
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
super.randomDisplayTick(worldIn, pos, state, rand);
for (int i = -2; i <= 2; ++i)
{
for (int j = -2; j <= 2; ++j)
{
if (i > -2 && i < 2 && j == -1)
{
j = 2;
}
if (rand.nextInt(16) == 0)
{
for (int k = 0; k <= 1; ++k)
{
BlockPos blockpos = pos.add(i, k, j);
if (worldIn.getBlockState(blockpos).getBlock() == Blocks.bookshelf)
{
if (!worldIn.isAirBlock(pos.add(i / 2, 0, j / 2)))
{
break;
}
worldIn.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, (double)pos.getX() + 0.5D, (double)pos.getY() + 2.0D, (double)pos.getZ() + 0.5D, (double)((float)i + rand.nextFloat()) - 0.5D, (double)((float)k - rand.nextFloat() - 1.0F), (double)((float)j + rand.nextFloat()) - 0.5D, new int[0]);
}
}
}
}
}
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityEnchantmentTable();
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityEnchantmentTable)
{
playerIn.displayGui((TileEntityEnchantmentTable)tileentity);
}
return true;
}
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityEnchantmentTable)
{
((TileEntityEnchantmentTable)tileentity).setCustomName(stack.getDisplayName());
}
}
}
}
@@ -1,108 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEndPortal;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockEndPortal extends BlockContainer
{
protected BlockEndPortal(Material materialIn)
{
super(materialIn);
this.setLightLevel(1.0F);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityEndPortal();
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
float f = 0.0625F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return side == EnumFacing.DOWN ? super.shouldSideBeRendered(worldIn, pos, side) : false;
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
if (entityIn.ridingEntity == null && entityIn.riddenByEntity == null && !worldIn.isRemote)
{
entityIn.travelToDimension(1);
}
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
double d0 = (double)((float)pos.getX() + rand.nextFloat());
double d1 = (double)((float)pos.getY() + 0.8F);
double d2 = (double)((float)pos.getZ() + rand.nextFloat());
double d3 = 0.0D;
double d4 = 0.0D;
double d5 = 0.0D;
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return MapColor.blackColor;
}
}
@@ -1,119 +0,0 @@
package net.minecraft.block;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockEndPortalFrame extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
public static final PropertyBool EYE = PropertyBool.create("eye");
public BlockEndPortalFrame()
{
super(Material.rock, MapColor.greenColor);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(EYE, Boolean.valueOf(false)));
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
if (((Boolean)worldIn.getBlockState(pos).getValue(EYE)).booleanValue())
{
this.setBlockBounds(0.3125F, 0.8125F, 0.3125F, 0.6875F, 1.0F, 0.6875F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
this.setBlockBoundsForItemRender();
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return null;
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()).withProperty(EYE, Boolean.valueOf(false));
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return ((Boolean)worldIn.getBlockState(pos).getValue(EYE)).booleanValue() ? 15 : 0;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(EYE, Boolean.valueOf((meta & 4) != 0)).withProperty(FACING, EnumFacing.getHorizontal(meta & 3));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
if (((Boolean)state.getValue(EYE)).booleanValue())
{
i |= 4;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, EYE});
}
}
@@ -1,175 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.InventoryEnderChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEnderChest;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
public class BlockEnderChest extends BlockContainer
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
protected BlockEnderChest()
{
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 2;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(Blocks.obsidian);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 8;
}
protected boolean canSilkHarvest()
{
return true;
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
InventoryEnderChest inventoryenderchest = playerIn.getInventoryEnderChest();
TileEntity tileentity = worldIn.getTileEntity(pos);
if (inventoryenderchest != null && tileentity instanceof TileEntityEnderChest)
{
if (worldIn.getBlockState(pos.up()).getBlock().isNormalCube())
{
return true;
}
else if (worldIn.isRemote)
{
return true;
}
else
{
inventoryenderchest.setChestTileEntity((TileEntityEnderChest)tileentity);
playerIn.displayGUIChest(inventoryenderchest);
playerIn.triggerAchievement(StatList.field_181738_V);
return true;
}
}
else
{
return true;
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityEnderChest();
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
for (int i = 0; i < 3; ++i)
{
int j = rand.nextInt(2) * 2 - 1;
int k = rand.nextInt(2) * 2 - 1;
double d0 = (double)pos.getX() + 0.5D + 0.25D * (double)j;
double d1 = (double)((float)pos.getY() + rand.nextFloat());
double d2 = (double)pos.getZ() + 0.5D + 0.25D * (double)k;
double d3 = (double)(rand.nextFloat() * (float)j);
double d4 = ((double)rand.nextFloat() - 0.5D) * 0.125D;
double d5 = (double)(rand.nextFloat() * (float)k);
worldIn.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5, new int[0]);
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing = EnumFacing.getFront(meta);
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
{
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing)state.getValue(FACING)).getIndex();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING});
}
}
@@ -1,62 +0,0 @@
package net.minecraft.block;
import net.minecraft.util.BlockPos;
public class BlockEventData
{
private BlockPos position;
private Block blockType;
/** Different for each blockID */
private int eventID;
private int eventParameter;
public BlockEventData(BlockPos pos, Block blockType, int eventId, int p_i45756_4_)
{
this.position = pos;
this.eventID = eventId;
this.eventParameter = p_i45756_4_;
this.blockType = blockType;
}
public BlockPos getPosition()
{
return this.position;
}
/**
* Get the Event ID (different for each BlockID)
*/
public int getEventID()
{
return this.eventID;
}
public int getEventParameter()
{
return this.eventParameter;
}
public Block getBlock()
{
return this.blockType;
}
public boolean equals(Object p_equals_1_)
{
if (!(p_equals_1_ instanceof BlockEventData))
{
return false;
}
else
{
BlockEventData blockeventdata = (BlockEventData)p_equals_1_;
return this.position.equals(blockeventdata.position) && this.eventID == blockeventdata.eventID && this.eventParameter == blockeventdata.eventParameter && this.blockType == blockeventdata.blockType;
}
}
public String toString()
{
return "TE(" + this.position + ")," + this.eventID + "," + this.eventParameter + "," + this.blockType;
}
}
@@ -1,103 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
public class BlockFalling extends Block
{
public static boolean fallInstantly;
public BlockFalling()
{
super(Material.sand);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public BlockFalling(Material materialIn)
{
super(materialIn);
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
this.checkFallable(worldIn, pos);
}
}
private void checkFallable(World worldIn, BlockPos pos)
{
if (canFallInto(worldIn, pos.down()) && pos.getY() >= 0)
{
int i = 32;
if (!fallInstantly && worldIn.isAreaLoaded(pos.add(-i, -i, -i), pos.add(i, i, i)))
{
if (!worldIn.isRemote)
{
EntityFallingBlock entityfallingblock = new EntityFallingBlock(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, worldIn.getBlockState(pos));
this.onStartFalling(entityfallingblock);
worldIn.spawnEntityInWorld(entityfallingblock);
}
}
else
{
worldIn.setBlockToAir(pos);
BlockPos blockpos;
for (blockpos = pos.down(); canFallInto(worldIn, blockpos) && blockpos.getY() > 0; blockpos = blockpos.down())
{
;
}
if (blockpos.getY() > 0)
{
worldIn.setBlockState(blockpos.up(), this.getDefaultState());
}
}
}
}
protected void onStartFalling(EntityFallingBlock fallingEntity)
{
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return 2;
}
public static boolean canFallInto(World worldIn, BlockPos pos)
{
Block block = worldIn.getBlockState(pos).getBlock();
Material material = block.blockMaterial;
return block == Blocks.fire || material == Material.air || material == Material.water || material == Material.lava;
}
public void onEndFalling(World worldIn, BlockPos pos)
{
}
}
@@ -1,177 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFarmland extends Block
{
public static final PropertyInteger MOISTURE = PropertyInteger.create("moisture", 0, 7);
protected BlockFarmland()
{
super(Material.ground);
this.setDefaultState(this.blockState.getBaseState().withProperty(MOISTURE, Integer.valueOf(0)));
this.setTickRandomly(true);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
this.setLightOpacity(255);
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1));
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
int i = ((Integer)state.getValue(MOISTURE)).intValue();
if (!this.hasWater(worldIn, pos) && !worldIn.canLightningStrike(pos.up()))
{
if (i > 0)
{
worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(i - 1)), 2);
}
else if (!this.hasCrops(worldIn, pos))
{
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
}
}
else if (i < 7)
{
worldIn.setBlockState(pos, state.withProperty(MOISTURE, Integer.valueOf(7)), 2);
}
}
/**
* Block's chance to react to a living entity falling on it.
*/
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
{
if (entityIn instanceof EntityLivingBase)
{
if (!worldIn.isRemote && worldIn.rand.nextFloat() < fallDistance - 0.5F)
{
if (!(entityIn instanceof EntityPlayer) && !worldIn.getGameRules().getBoolean("mobGriefing"))
{
return;
}
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
}
super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
}
}
private boolean hasCrops(World worldIn, BlockPos pos)
{
Block block = worldIn.getBlockState(pos.up()).getBlock();
return block instanceof BlockCrops || block instanceof BlockStem;
}
private boolean hasWater(World worldIn, BlockPos pos)
{
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(pos.add(-4, 0, -4), pos.add(4, 1, 4)))
{
if (worldIn.getBlockState(blockpos$mutableblockpos).getBlock().getMaterial() == Material.water)
{
return true;
}
}
return false;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
if (worldIn.getBlockState(pos.up()).getBlock().getMaterial().isSolid())
{
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
}
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
switch (side)
{
case UP:
return true;
case NORTH:
case SOUTH:
case WEST:
case EAST:
Block block = worldIn.getBlockState(pos).getBlock();
return !block.isOpaqueCube() && block != Blocks.farmland;
default:
return super.shouldSideBeRendered(worldIn, pos, side);
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Blocks.dirt.getItemDropped(Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
}
public Item getItem(World worldIn, BlockPos pos)
{
return Item.getItemFromBlock(Blocks.dirt);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(MOISTURE, Integer.valueOf(meta & 7));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(MOISTURE)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {MOISTURE});
}
}
@@ -1,198 +0,0 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemLead;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFence extends Block
{
/** Whether this fence connects in the northern direction */
public static final PropertyBool NORTH = PropertyBool.create("north");
/** Whether this fence connects in the eastern direction */
public static final PropertyBool EAST = PropertyBool.create("east");
/** Whether this fence connects in the southern direction */
public static final PropertyBool SOUTH = PropertyBool.create("south");
/** Whether this fence connects in the western direction */
public static final PropertyBool WEST = PropertyBool.create("west");
public BlockFence(Material materialIn)
{
this(materialIn, materialIn.getMaterialMapColor());
}
public BlockFence(Material p_i46395_1_, MapColor p_i46395_2_)
{
super(p_i46395_1_, p_i46395_2_);
this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
this.setCreativeTab(CreativeTabs.tabDecorations);
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
boolean flag = this.canConnectTo(worldIn, pos.north());
boolean flag1 = this.canConnectTo(worldIn, pos.south());
boolean flag2 = this.canConnectTo(worldIn, pos.west());
boolean flag3 = this.canConnectTo(worldIn, pos.east());
float f = 0.375F;
float f1 = 0.625F;
float f2 = 0.375F;
float f3 = 0.625F;
if (flag)
{
f2 = 0.0F;
}
if (flag1)
{
f3 = 1.0F;
}
if (flag || flag1)
{
this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
f2 = 0.375F;
f3 = 0.625F;
if (flag2)
{
f = 0.0F;
}
if (flag3)
{
f1 = 1.0F;
}
if (flag2 || flag3 || !flag && !flag1)
{
this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
if (flag)
{
f2 = 0.0F;
}
if (flag1)
{
f3 = 1.0F;
}
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
boolean flag = this.canConnectTo(worldIn, pos.north());
boolean flag1 = this.canConnectTo(worldIn, pos.south());
boolean flag2 = this.canConnectTo(worldIn, pos.west());
boolean flag3 = this.canConnectTo(worldIn, pos.east());
float f = 0.375F;
float f1 = 0.625F;
float f2 = 0.375F;
float f3 = 0.625F;
if (flag)
{
f2 = 0.0F;
}
if (flag1)
{
f3 = 1.0F;
}
if (flag2)
{
f = 0.0F;
}
if (flag3)
{
f1 = 1.0F;
}
this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return false;
}
public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
{
Block block = worldIn.getBlockState(pos).getBlock();
return block == Blocks.barrier ? false : ((!(block instanceof BlockFence) || block.blockMaterial != this.blockMaterial) && !(block instanceof BlockFenceGate) ? (block.blockMaterial.isOpaque() && block.isFullCube() ? block.blockMaterial != Material.gourd : false) : true);
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
return worldIn.isRemote ? true : ItemLead.attachToFence(playerIn, worldIn, pos);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return 0;
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
return state.withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west())));
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {NORTH, EAST, WEST, SOUTH});
}
}
@@ -1,197 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFenceGate extends BlockDirectional
{
public static final PropertyBool OPEN = PropertyBool.create("open");
public static final PropertyBool POWERED = PropertyBool.create("powered");
public static final PropertyBool IN_WALL = PropertyBool.create("in_wall");
public BlockFenceGate(BlockPlanks.EnumType p_i46394_1_)
{
super(Material.wood, p_i46394_1_.func_181070_c());
this.setDefaultState(this.blockState.getBaseState().withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false)));
this.setCreativeTab(CreativeTabs.tabRedstone);
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
EnumFacing.Axis enumfacing$axis = ((EnumFacing)state.getValue(FACING)).getAxis();
if (enumfacing$axis == EnumFacing.Axis.Z && (worldIn.getBlockState(pos.west()).getBlock() == Blocks.cobblestone_wall || worldIn.getBlockState(pos.east()).getBlock() == Blocks.cobblestone_wall) || enumfacing$axis == EnumFacing.Axis.X && (worldIn.getBlockState(pos.north()).getBlock() == Blocks.cobblestone_wall || worldIn.getBlockState(pos.south()).getBlock() == Blocks.cobblestone_wall))
{
state = state.withProperty(IN_WALL, Boolean.valueOf(true));
}
return state;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.getBlockState(pos.down()).getBlock().getMaterial().isSolid() ? super.canPlaceBlockAt(worldIn, pos) : false;
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
return null;
}
else
{
EnumFacing.Axis enumfacing$axis = ((EnumFacing)state.getValue(FACING)).getAxis();
return enumfacing$axis == EnumFacing.Axis.Z ? new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)((float)pos.getZ() + 0.375F), (double)(pos.getX() + 1), (double)((float)pos.getY() + 1.5F), (double)((float)pos.getZ() + 0.625F)) : new AxisAlignedBB((double)((float)pos.getX() + 0.375F), (double)pos.getY(), (double)pos.getZ(), (double)((float)pos.getX() + 0.625F), (double)((float)pos.getY() + 1.5F), (double)(pos.getZ() + 1));
}
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
EnumFacing.Axis enumfacing$axis = ((EnumFacing)worldIn.getBlockState(pos).getValue(FACING)).getAxis();
if (enumfacing$axis == EnumFacing.Axis.Z)
{
this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F);
}
else
{
this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F);
}
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return ((Boolean)worldIn.getBlockState(pos).getValue(OPEN)).booleanValue();
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing()).withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)).withProperty(IN_WALL, Boolean.valueOf(false));
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
state = state.withProperty(OPEN, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 2);
}
else
{
EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);
if (state.getValue(FACING) == enumfacing.getOpposite())
{
state = state.withProperty(FACING, enumfacing);
}
state = state.withProperty(OPEN, Boolean.valueOf(true));
worldIn.setBlockState(pos, state, 2);
}
worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
return true;
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!worldIn.isRemote)
{
boolean flag = worldIn.isBlockPowered(pos);
if (flag || neighborBlock.canProvidePower())
{
if (flag && !((Boolean)state.getValue(OPEN)).booleanValue() && !((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(true)).withProperty(POWERED, Boolean.valueOf(true)), 2);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1003, pos, 0);
}
else if (!flag && ((Boolean)state.getValue(OPEN)).booleanValue() && ((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(false)).withProperty(POWERED, Boolean.valueOf(false)), 2);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1006, pos, 0);
}
else if (flag != ((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)), 2);
}
}
}
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)).withProperty(OPEN, Boolean.valueOf((meta & 4) != 0)).withProperty(POWERED, Boolean.valueOf((meta & 8) != 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
if (((Boolean)state.getValue(OPEN)).booleanValue())
{
i |= 4;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, OPEN, POWERED, IN_WALL});
}
}
@@ -1,506 +0,0 @@
package net.minecraft.block;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderEnd;
public class BlockFire extends Block
{
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15);
public static final PropertyBool FLIP = PropertyBool.create("flip");
public static final PropertyBool ALT = PropertyBool.create("alt");
public static final PropertyBool NORTH = PropertyBool.create("north");
public static final PropertyBool EAST = PropertyBool.create("east");
public static final PropertyBool SOUTH = PropertyBool.create("south");
public static final PropertyBool WEST = PropertyBool.create("west");
public static final PropertyInteger UPPER = PropertyInteger.create("upper", 0, 2);
private final Map<Block, Integer> encouragements = Maps.<Block, Integer>newIdentityHashMap();
private final Map<Block, Integer> flammabilities = Maps.<Block, Integer>newIdentityHashMap();
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
{
boolean flag = (i + j + k & 1) == 1;
boolean flag1 = (i / 2 + j / 2 + k / 2 & 1) == 1;
int l = 0;
if (this.canCatchFire(worldIn, pos.up()))
{
l = flag ? 1 : 2;
}
return state.withProperty(NORTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canCatchFire(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canCatchFire(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canCatchFire(worldIn, pos.west()))).withProperty(UPPER, Integer.valueOf(l)).withProperty(FLIP, Boolean.valueOf(flag1)).withProperty(ALT, Boolean.valueOf(flag));
}
else
{
return this.getDefaultState();
}
}
protected BlockFire()
{
super(Material.fire);
this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)).withProperty(FLIP, Boolean.valueOf(false)).withProperty(ALT, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(UPPER, Integer.valueOf(0)));
this.setTickRandomly(true);
}
public static void init()
{
Blocks.fire.setFireInfo(Blocks.planks, 5, 20);
Blocks.fire.setFireInfo(Blocks.double_wooden_slab, 5, 20);
Blocks.fire.setFireInfo(Blocks.wooden_slab, 5, 20);
Blocks.fire.setFireInfo(Blocks.oak_fence_gate, 5, 20);
Blocks.fire.setFireInfo(Blocks.spruce_fence_gate, 5, 20);
Blocks.fire.setFireInfo(Blocks.birch_fence_gate, 5, 20);
Blocks.fire.setFireInfo(Blocks.jungle_fence_gate, 5, 20);
Blocks.fire.setFireInfo(Blocks.dark_oak_fence_gate, 5, 20);
Blocks.fire.setFireInfo(Blocks.acacia_fence_gate, 5, 20);
Blocks.fire.setFireInfo(Blocks.oak_fence, 5, 20);
Blocks.fire.setFireInfo(Blocks.spruce_fence, 5, 20);
Blocks.fire.setFireInfo(Blocks.birch_fence, 5, 20);
Blocks.fire.setFireInfo(Blocks.jungle_fence, 5, 20);
Blocks.fire.setFireInfo(Blocks.dark_oak_fence, 5, 20);
Blocks.fire.setFireInfo(Blocks.acacia_fence, 5, 20);
Blocks.fire.setFireInfo(Blocks.oak_stairs, 5, 20);
Blocks.fire.setFireInfo(Blocks.birch_stairs, 5, 20);
Blocks.fire.setFireInfo(Blocks.spruce_stairs, 5, 20);
Blocks.fire.setFireInfo(Blocks.jungle_stairs, 5, 20);
Blocks.fire.setFireInfo(Blocks.log, 5, 5);
Blocks.fire.setFireInfo(Blocks.log2, 5, 5);
Blocks.fire.setFireInfo(Blocks.leaves, 30, 60);
Blocks.fire.setFireInfo(Blocks.leaves2, 30, 60);
Blocks.fire.setFireInfo(Blocks.bookshelf, 30, 20);
Blocks.fire.setFireInfo(Blocks.tnt, 15, 100);
Blocks.fire.setFireInfo(Blocks.tallgrass, 60, 100);
Blocks.fire.setFireInfo(Blocks.double_plant, 60, 100);
Blocks.fire.setFireInfo(Blocks.yellow_flower, 60, 100);
Blocks.fire.setFireInfo(Blocks.red_flower, 60, 100);
Blocks.fire.setFireInfo(Blocks.deadbush, 60, 100);
Blocks.fire.setFireInfo(Blocks.wool, 30, 60);
Blocks.fire.setFireInfo(Blocks.vine, 15, 100);
Blocks.fire.setFireInfo(Blocks.coal_block, 5, 5);
Blocks.fire.setFireInfo(Blocks.hay_block, 60, 20);
Blocks.fire.setFireInfo(Blocks.carpet, 60, 20);
}
public void setFireInfo(Block blockIn, int encouragement, int flammability)
{
this.encouragements.put(blockIn, Integer.valueOf(encouragement));
this.flammabilities.put(blockIn, Integer.valueOf(flammability));
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return 30;
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (worldIn.getGameRules().getBoolean("doFireTick"))
{
if (!this.canPlaceBlockAt(worldIn, pos))
{
worldIn.setBlockToAir(pos);
}
Block block = worldIn.getBlockState(pos.down()).getBlock();
boolean flag = block == Blocks.netherrack;
if (worldIn.provider instanceof WorldProviderEnd && block == Blocks.bedrock)
{
flag = true;
}
if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos))
{
worldIn.setBlockToAir(pos);
}
else
{
int i = ((Integer)state.getValue(AGE)).intValue();
if (i < 15)
{
state = state.withProperty(AGE, Integer.valueOf(i + rand.nextInt(3) / 2));
worldIn.setBlockState(pos, state, 4);
}
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + rand.nextInt(10));
if (!flag)
{
if (!this.canNeighborCatchFire(worldIn, pos))
{
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) || i > 3)
{
worldIn.setBlockToAir(pos);
}
return;
}
if (!this.canCatchFire(worldIn, pos.down()) && i == 15 && rand.nextInt(4) == 0)
{
worldIn.setBlockToAir(pos);
return;
}
}
boolean flag1 = worldIn.isBlockinHighHumidity(pos);
int j = 0;
if (flag1)
{
j = -50;
}
this.catchOnFire(worldIn, pos.east(), 300 + j, rand, i);
this.catchOnFire(worldIn, pos.west(), 300 + j, rand, i);
this.catchOnFire(worldIn, pos.down(), 250 + j, rand, i);
this.catchOnFire(worldIn, pos.up(), 250 + j, rand, i);
this.catchOnFire(worldIn, pos.north(), 300 + j, rand, i);
this.catchOnFire(worldIn, pos.south(), 300 + j, rand, i);
for (int k = -1; k <= 1; ++k)
{
for (int l = -1; l <= 1; ++l)
{
for (int i1 = -1; i1 <= 4; ++i1)
{
if (k != 0 || i1 != 0 || l != 0)
{
int j1 = 100;
if (i1 > 1)
{
j1 += (i1 - 1) * 100;
}
BlockPos blockpos = pos.add(k, i1, l);
int k1 = this.getNeighborEncouragement(worldIn, blockpos);
if (k1 > 0)
{
int l1 = (k1 + 40 + worldIn.getDifficulty().getDifficultyId() * 7) / (i + 30);
if (flag1)
{
l1 /= 2;
}
if (l1 > 0 && rand.nextInt(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos)))
{
int i2 = i + rand.nextInt(5) / 4;
if (i2 > 15)
{
i2 = 15;
}
worldIn.setBlockState(blockpos, state.withProperty(AGE, Integer.valueOf(i2)), 3);
}
}
}
}
}
}
}
}
}
protected boolean canDie(World worldIn, BlockPos pos)
{
return worldIn.canLightningStrike(pos) || worldIn.canLightningStrike(pos.west()) || worldIn.canLightningStrike(pos.east()) || worldIn.canLightningStrike(pos.north()) || worldIn.canLightningStrike(pos.south());
}
public boolean requiresUpdates()
{
return false;
}
private int getFlammability(Block blockIn)
{
Integer integer = (Integer)this.flammabilities.get(blockIn);
return integer == null ? 0 : integer.intValue();
}
private int getEncouragement(Block blockIn)
{
Integer integer = (Integer)this.encouragements.get(blockIn);
return integer == null ? 0 : integer.intValue();
}
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
{
int i = this.getFlammability(worldIn.getBlockState(pos).getBlock());
if (random.nextInt(chance) < i)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (random.nextInt(age + 10) < 5 && !worldIn.canLightningStrike(pos))
{
int j = age + random.nextInt(5) / 4;
if (j > 15)
{
j = 15;
}
worldIn.setBlockState(pos, this.getDefaultState().withProperty(AGE, Integer.valueOf(j)), 3);
}
else
{
worldIn.setBlockToAir(pos);
}
if (iblockstate.getBlock() == Blocks.tnt)
{
Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));
}
}
}
private boolean canNeighborCatchFire(World worldIn, BlockPos pos)
{
for (EnumFacing enumfacing : EnumFacing.values())
{
if (this.canCatchFire(worldIn, pos.offset(enumfacing)))
{
return true;
}
}
return false;
}
private int getNeighborEncouragement(World worldIn, BlockPos pos)
{
if (!worldIn.isAirBlock(pos))
{
return 0;
}
else
{
int i = 0;
for (EnumFacing enumfacing : EnumFacing.values())
{
i = Math.max(this.getEncouragement(worldIn.getBlockState(pos.offset(enumfacing)).getBlock()), i);
}
return i;
}
}
/**
* Returns if this block is collidable (only used by Fire). Args: x, y, z
*/
public boolean isCollidable()
{
return false;
}
/**
* Checks if the block can be caught on fire
*/
public boolean canCatchFire(IBlockAccess worldIn, BlockPos pos)
{
return this.getEncouragement(worldIn.getBlockState(pos).getBlock()) > 0;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) || this.canNeighborCatchFire(worldIn, pos);
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
{
worldIn.setBlockToAir(pos);
}
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
if (worldIn.provider.getDimensionId() > 0 || !Blocks.portal.func_176548_d(worldIn, pos))
{
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !this.canNeighborCatchFire(worldIn, pos))
{
worldIn.setBlockToAir(pos);
}
else
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn) + worldIn.rand.nextInt(10));
}
}
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (rand.nextInt(24) == 0)
{
worldIn.playSound((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), "fire.fire", 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
}
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && !Blocks.fire.canCatchFire(worldIn, pos.down()))
{
if (Blocks.fire.canCatchFire(worldIn, pos.west()))
{
for (int j = 0; j < 2; ++j)
{
double d3 = (double)pos.getX() + rand.nextDouble() * 0.10000000149011612D;
double d8 = (double)pos.getY() + rand.nextDouble();
double d13 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.fire.canCatchFire(worldIn, pos.east()))
{
for (int k = 0; k < 2; ++k)
{
double d4 = (double)(pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D;
double d9 = (double)pos.getY() + rand.nextDouble();
double d14 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.fire.canCatchFire(worldIn, pos.north()))
{
for (int l = 0; l < 2; ++l)
{
double d5 = (double)pos.getX() + rand.nextDouble();
double d10 = (double)pos.getY() + rand.nextDouble();
double d15 = (double)pos.getZ() + rand.nextDouble() * 0.10000000149011612D;
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.fire.canCatchFire(worldIn, pos.south()))
{
for (int i1 = 0; i1 < 2; ++i1)
{
double d6 = (double)pos.getX() + rand.nextDouble();
double d11 = (double)pos.getY() + rand.nextDouble();
double d16 = (double)(pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D;
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.fire.canCatchFire(worldIn, pos.up()))
{
for (int j1 = 0; j1 < 2; ++j1)
{
double d7 = (double)pos.getX() + rand.nextDouble();
double d12 = (double)(pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D;
double d17 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
else
{
for (int i = 0; i < 3; ++i)
{
double d0 = (double)pos.getX() + rand.nextDouble();
double d1 = (double)pos.getY() + rand.nextDouble() * 0.5D + 0.5D;
double d2 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return MapColor.tntColor;
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(AGE)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {AGE, NORTH, EAST, SOUTH, WEST, UPPER, FLIP, ALT});
}
}
@@ -1,196 +0,0 @@
package net.minecraft.block;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.List;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
public abstract class BlockFlower extends BlockBush
{
protected PropertyEnum<BlockFlower.EnumFlowerType> type;
protected BlockFlower()
{
this.setDefaultState(this.blockState.getBaseState().withProperty(this.getTypeProperty(), this.getBlockType() == BlockFlower.EnumFlowerColor.RED ? BlockFlower.EnumFlowerType.POPPY : BlockFlower.EnumFlowerType.DANDELION));
}
/**
* Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
* returns the metadata of the dropped item based on the old metadata of the block.
*/
public int damageDropped(IBlockState state)
{
return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
}
/**
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
*/
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
{
for (BlockFlower.EnumFlowerType blockflower$enumflowertype : BlockFlower.EnumFlowerType.getTypes(this.getBlockType()))
{
list.add(new ItemStack(itemIn, 1, blockflower$enumflowertype.getMeta()));
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(this.getTypeProperty(), BlockFlower.EnumFlowerType.getType(this.getBlockType(), meta));
}
/**
* Get the Type of this flower (Yellow/Red)
*/
public abstract BlockFlower.EnumFlowerColor getBlockType();
public IProperty<BlockFlower.EnumFlowerType> getTypeProperty()
{
if (this.type == null)
{
this.type = PropertyEnum.<BlockFlower.EnumFlowerType>create("type", BlockFlower.EnumFlowerType.class, new Predicate<BlockFlower.EnumFlowerType>()
{
public boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
{
return p_apply_1_.getBlockType() == BlockFlower.this.getBlockType();
}
});
}
return this.type;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((BlockFlower.EnumFlowerType)state.getValue(this.getTypeProperty())).getMeta();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {this.getTypeProperty()});
}
/**
* Get the OffsetType for this Block. Determines if the model is rendered slightly offset.
*/
public Block.EnumOffsetType getOffsetType()
{
return Block.EnumOffsetType.XZ;
}
public static enum EnumFlowerColor
{
YELLOW,
RED;
public BlockFlower getBlock()
{
return this == YELLOW ? Blocks.yellow_flower : Blocks.red_flower;
}
}
public static enum EnumFlowerType implements IStringSerializable
{
DANDELION(BlockFlower.EnumFlowerColor.YELLOW, 0, "dandelion"),
POPPY(BlockFlower.EnumFlowerColor.RED, 0, "poppy"),
BLUE_ORCHID(BlockFlower.EnumFlowerColor.RED, 1, "blue_orchid", "blueOrchid"),
ALLIUM(BlockFlower.EnumFlowerColor.RED, 2, "allium"),
HOUSTONIA(BlockFlower.EnumFlowerColor.RED, 3, "houstonia"),
RED_TULIP(BlockFlower.EnumFlowerColor.RED, 4, "red_tulip", "tulipRed"),
ORANGE_TULIP(BlockFlower.EnumFlowerColor.RED, 5, "orange_tulip", "tulipOrange"),
WHITE_TULIP(BlockFlower.EnumFlowerColor.RED, 6, "white_tulip", "tulipWhite"),
PINK_TULIP(BlockFlower.EnumFlowerColor.RED, 7, "pink_tulip", "tulipPink"),
OXEYE_DAISY(BlockFlower.EnumFlowerColor.RED, 8, "oxeye_daisy", "oxeyeDaisy");
private static final BlockFlower.EnumFlowerType[][] TYPES_FOR_BLOCK = new BlockFlower.EnumFlowerType[BlockFlower.EnumFlowerColor.values().length][];
private final BlockFlower.EnumFlowerColor blockType;
private final int meta;
private final String name;
private final String unlocalizedName;
private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name)
{
this(blockType, meta, name, name);
}
private EnumFlowerType(BlockFlower.EnumFlowerColor blockType, int meta, String name, String unlocalizedName)
{
this.blockType = blockType;
this.meta = meta;
this.name = name;
this.unlocalizedName = unlocalizedName;
}
public BlockFlower.EnumFlowerColor getBlockType()
{
return this.blockType;
}
public int getMeta()
{
return this.meta;
}
public static BlockFlower.EnumFlowerType getType(BlockFlower.EnumFlowerColor blockType, int meta)
{
BlockFlower.EnumFlowerType[] ablockflower$enumflowertype = TYPES_FOR_BLOCK[blockType.ordinal()];
if (meta < 0 || meta >= ablockflower$enumflowertype.length)
{
meta = 0;
}
return ablockflower$enumflowertype[meta];
}
public static BlockFlower.EnumFlowerType[] getTypes(BlockFlower.EnumFlowerColor flowerColor)
{
return TYPES_FOR_BLOCK[flowerColor.ordinal()];
}
public String toString()
{
return this.name;
}
public String getName()
{
return this.name;
}
public String getUnlocalizedName()
{
return this.unlocalizedName;
}
static {
for (final BlockFlower.EnumFlowerColor blockflower$enumflowercolor : BlockFlower.EnumFlowerColor.values())
{
Collection<BlockFlower.EnumFlowerType> collection = Collections2.<BlockFlower.EnumFlowerType>filter(Lists.newArrayList(values()), new Predicate<BlockFlower.EnumFlowerType>()
{
public boolean apply(BlockFlower.EnumFlowerType p_apply_1_)
{
return p_apply_1_.getBlockType() == blockflower$enumflowercolor;
}
});
TYPES_FOR_BLOCK[blockflower$enumflowercolor.ordinal()] = (BlockFlower.EnumFlowerType[])collection.toArray(new BlockFlower.EnumFlowerType[collection.size()]);
}
}
}
}
@@ -1,494 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFlowerPot;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockFlowerPot extends BlockContainer
{
public static final PropertyInteger LEGACY_DATA = PropertyInteger.create("legacy_data", 0, 15);
public static final PropertyEnum<BlockFlowerPot.EnumFlowerType> CONTENTS = PropertyEnum.<BlockFlowerPot.EnumFlowerType>create("contents", BlockFlowerPot.EnumFlowerType.class);
public BlockFlowerPot()
{
super(Material.circuits);
this.setDefaultState(this.blockState.getBaseState().withProperty(CONTENTS, BlockFlowerPot.EnumFlowerType.EMPTY).withProperty(LEGACY_DATA, Integer.valueOf(0)));
this.setBlockBoundsForItemRender();
}
/**
* Gets the localized name of this block. Used for the statistics page.
*/
public String getLocalizedName()
{
return StatCollector.translateToLocal("item.flowerPot.name");
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
float f = 0.375F;
float f1 = f / 2.0F;
this.setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, f, 0.5F + f1);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
public boolean isFullCube()
{
return false;
}
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFlowerPot)
{
Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem();
if (item instanceof ItemBlock)
{
return Block.getBlockFromItem(item).colorMultiplier(worldIn, pos, renderPass);
}
}
return 16777215;
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
ItemStack itemstack = playerIn.inventory.getCurrentItem();
if (itemstack != null && itemstack.getItem() instanceof ItemBlock)
{
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
if (tileentityflowerpot == null)
{
return false;
}
else if (tileentityflowerpot.getFlowerPotItem() != null)
{
return false;
}
else
{
Block block = Block.getBlockFromItem(itemstack.getItem());
if (!this.canNotContain(block, itemstack.getMetadata()))
{
return false;
}
else
{
tileentityflowerpot.setFlowerPotData(itemstack.getItem(), itemstack.getMetadata());
tileentityflowerpot.markDirty();
worldIn.markBlockForUpdate(pos);
playerIn.triggerAchievement(StatList.field_181736_T);
if (!playerIn.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
{
playerIn.inventory.setInventorySlotContents(playerIn.inventory.currentItem, (ItemStack)null);
}
return true;
}
}
}
else
{
return false;
}
}
private boolean canNotContain(Block blockIn, int meta)
{
return blockIn != Blocks.yellow_flower && blockIn != Blocks.red_flower && blockIn != Blocks.cactus && blockIn != Blocks.brown_mushroom && blockIn != Blocks.red_mushroom && blockIn != Blocks.sapling && blockIn != Blocks.deadbush ? blockIn == Blocks.tallgrass && meta == BlockTallGrass.EnumType.FERN.getMeta() : true;
}
public Item getItem(World worldIn, BlockPos pos)
{
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
return tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null ? tileentityflowerpot.getFlowerPotItem() : Items.flower_pot;
}
public int getDamageValue(World worldIn, BlockPos pos)
{
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
return tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null ? tileentityflowerpot.getFlowerPotData() : 0;
}
/**
* Returns true only if block is flowerPot
*/
public boolean isFlowerPot()
{
return true;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
if (tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null)
{
spawnAsEntity(worldIn, pos, new ItemStack(tileentityflowerpot.getFlowerPotItem(), 1, tileentityflowerpot.getFlowerPotData()));
}
super.breakBlock(worldIn, pos, state);
}
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
super.onBlockHarvested(worldIn, pos, state, player);
if (player.capabilities.isCreativeMode)
{
TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);
if (tileentityflowerpot != null)
{
tileentityflowerpot.setFlowerPotData((Item)null, 0);
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.flower_pot;
}
private TileEntityFlowerPot getTileEntity(World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
return tileentity instanceof TileEntityFlowerPot ? (TileEntityFlowerPot)tileentity : null;
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
Block block = null;
int i = 0;
switch (meta)
{
case 1:
block = Blocks.red_flower;
i = BlockFlower.EnumFlowerType.POPPY.getMeta();
break;
case 2:
block = Blocks.yellow_flower;
break;
case 3:
block = Blocks.sapling;
i = BlockPlanks.EnumType.OAK.getMetadata();
break;
case 4:
block = Blocks.sapling;
i = BlockPlanks.EnumType.SPRUCE.getMetadata();
break;
case 5:
block = Blocks.sapling;
i = BlockPlanks.EnumType.BIRCH.getMetadata();
break;
case 6:
block = Blocks.sapling;
i = BlockPlanks.EnumType.JUNGLE.getMetadata();
break;
case 7:
block = Blocks.red_mushroom;
break;
case 8:
block = Blocks.brown_mushroom;
break;
case 9:
block = Blocks.cactus;
break;
case 10:
block = Blocks.deadbush;
break;
case 11:
block = Blocks.tallgrass;
i = BlockTallGrass.EnumType.FERN.getMeta();
break;
case 12:
block = Blocks.sapling;
i = BlockPlanks.EnumType.ACACIA.getMetadata();
break;
case 13:
block = Blocks.sapling;
i = BlockPlanks.EnumType.DARK_OAK.getMetadata();
}
return new TileEntityFlowerPot(Item.getItemFromBlock(block), i);
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {CONTENTS, LEGACY_DATA});
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(LEGACY_DATA)).intValue();
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
BlockFlowerPot.EnumFlowerType blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFlowerPot)
{
TileEntityFlowerPot tileentityflowerpot = (TileEntityFlowerPot)tileentity;
Item item = tileentityflowerpot.getFlowerPotItem();
if (item instanceof ItemBlock)
{
int i = tileentityflowerpot.getFlowerPotData();
Block block = Block.getBlockFromItem(item);
if (block == Blocks.sapling)
{
switch (BlockPlanks.EnumType.byMetadata(i))
{
case OAK:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.OAK_SAPLING;
break;
case SPRUCE:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.SPRUCE_SAPLING;
break;
case BIRCH:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.BIRCH_SAPLING;
break;
case JUNGLE:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.JUNGLE_SAPLING;
break;
case ACACIA:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.ACACIA_SAPLING;
break;
case DARK_OAK:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DARK_OAK_SAPLING;
break;
default:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
}
}
else if (block == Blocks.tallgrass)
{
switch (i)
{
case 0:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DEAD_BUSH;
break;
case 2:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.FERN;
break;
default:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
}
}
else if (block == Blocks.yellow_flower)
{
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DANDELION;
}
else if (block == Blocks.red_flower)
{
switch (BlockFlower.EnumFlowerType.getType(BlockFlower.EnumFlowerColor.RED, i))
{
case POPPY:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.POPPY;
break;
case BLUE_ORCHID:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.BLUE_ORCHID;
break;
case ALLIUM:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.ALLIUM;
break;
case HOUSTONIA:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.HOUSTONIA;
break;
case RED_TULIP:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.RED_TULIP;
break;
case ORANGE_TULIP:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.ORANGE_TULIP;
break;
case WHITE_TULIP:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.WHITE_TULIP;
break;
case PINK_TULIP:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.PINK_TULIP;
break;
case OXEYE_DAISY:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.OXEYE_DAISY;
break;
default:
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.EMPTY;
}
}
else if (block == Blocks.red_mushroom)
{
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.MUSHROOM_RED;
}
else if (block == Blocks.brown_mushroom)
{
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.MUSHROOM_BROWN;
}
else if (block == Blocks.deadbush)
{
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.DEAD_BUSH;
}
else if (block == Blocks.cactus)
{
blockflowerpot$enumflowertype = BlockFlowerPot.EnumFlowerType.CACTUS;
}
}
}
return state.withProperty(CONTENTS, blockflowerpot$enumflowertype);
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
public static enum EnumFlowerType implements IStringSerializable
{
EMPTY("empty"),
POPPY("rose"),
BLUE_ORCHID("blue_orchid"),
ALLIUM("allium"),
HOUSTONIA("houstonia"),
RED_TULIP("red_tulip"),
ORANGE_TULIP("orange_tulip"),
WHITE_TULIP("white_tulip"),
PINK_TULIP("pink_tulip"),
OXEYE_DAISY("oxeye_daisy"),
DANDELION("dandelion"),
OAK_SAPLING("oak_sapling"),
SPRUCE_SAPLING("spruce_sapling"),
BIRCH_SAPLING("birch_sapling"),
JUNGLE_SAPLING("jungle_sapling"),
ACACIA_SAPLING("acacia_sapling"),
DARK_OAK_SAPLING("dark_oak_sapling"),
MUSHROOM_RED("mushroom_red"),
MUSHROOM_BROWN("mushroom_brown"),
DEAD_BUSH("dead_bush"),
FERN("fern"),
CACTUS("cactus");
private final String name;
private EnumFlowerType(String name)
{
this.name = name;
}
public String toString()
{
return this.name;
}
public String getName()
{
return this.name;
}
}
}
@@ -1,272 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
public class BlockFurnace extends BlockContainer
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
private final boolean isBurning;
private static boolean keepInventory;
protected BlockFurnace(boolean isBurning)
{
super(Material.rock);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
this.isBurning = isBurning;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(Blocks.furnace);
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
this.setDefaultFacing(worldIn, pos, state);
}
private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
{
if (!worldIn.isRemote)
{
Block block = worldIn.getBlockState(pos.north()).getBlock();
Block block1 = worldIn.getBlockState(pos.south()).getBlock();
Block block2 = worldIn.getBlockState(pos.west()).getBlock();
Block block3 = worldIn.getBlockState(pos.east()).getBlock();
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
{
enumfacing = EnumFacing.SOUTH;
}
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
{
enumfacing = EnumFacing.NORTH;
}
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
{
enumfacing = EnumFacing.EAST;
}
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
{
enumfacing = EnumFacing.WEST;
}
worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
}
@SuppressWarnings("incomplete-switch")
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (this.isBurning)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
double d0 = (double)pos.getX() + 0.5D;
double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
double d2 = (double)pos.getZ() + 0.5D;
double d3 = 0.52D;
double d4 = rand.nextDouble() * 0.6D - 0.3D;
switch (enumfacing)
{
case WEST:
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
break;
case EAST:
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D, new int[0]);
break;
case NORTH:
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D, new int[0]);
break;
case SOUTH:
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFurnace)
{
playerIn.displayGUIChest((TileEntityFurnace)tileentity);
playerIn.triggerAchievement(StatList.field_181741_Y);
}
return true;
}
}
public static void setState(boolean active, World worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
TileEntity tileentity = worldIn.getTileEntity(pos);
keepInventory = true;
if (active)
{
worldIn.setBlockState(pos, Blocks.lit_furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
worldIn.setBlockState(pos, Blocks.lit_furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
}
else
{
worldIn.setBlockState(pos, Blocks.furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
worldIn.setBlockState(pos, Blocks.furnace.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);
}
keepInventory = false;
if (tileentity != null)
{
tileentity.validate();
worldIn.setTileEntity(pos, tileentity);
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityFurnace();
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFurnace)
{
((TileEntityFurnace)tileentity).setCustomInventoryName(stack.getDisplayName());
}
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (!keepInventory)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityFurnace)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
}
super.breakBlock(worldIn, pos, state);
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}
public Item getItem(World worldIn, BlockPos pos)
{
return Item.getItemFromBlock(Blocks.furnace);
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Possibly modify the given BlockState before rendering it on an Entity (Minecarts, Endermen, ...)
*/
public IBlockState getStateForEntityRender(IBlockState state)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.SOUTH);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing = EnumFacing.getFront(meta);
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
{
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing)state.getValue(FACING)).getIndex();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING});
}
}
@@ -1,38 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.EnumWorldBlockLayer;
public class BlockGlass extends BlockBreakable
{
public BlockGlass(Material materialIn, boolean ignoreSimilarity)
{
super(materialIn, ignoreSimilarity);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
public boolean isFullCube()
{
return false;
}
protected boolean canSilkHarvest()
{
return true;
}
}
@@ -1,51 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.MathHelper;
public class BlockGlowstone extends Block
{
public BlockGlowstone(Material materialIn)
{
super(materialIn);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Get the quantity dropped based on the given fortune level
*/
public int quantityDroppedWithBonus(int fortune, Random random)
{
return MathHelper.clamp_int(this.quantityDropped(random) + random.nextInt(fortune + 1), 1, 4);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 2 + random.nextInt(3);
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.glowstone_dust;
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return MapColor.sandColor;
}
}
@@ -1,174 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.ColorizerGrass;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColorHelper;
public class BlockGrass extends Block implements IGrowable
{
public static final PropertyBool SNOWY = PropertyBool.create("snowy");
protected BlockGrass()
{
super(Material.grass);
this.setDefaultState(this.blockState.getBaseState().withProperty(SNOWY, Boolean.valueOf(false)));
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Get the actual Block state of this Block at the given position. This applies properties not visible in the
* metadata, such as fence connections.
*/
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
Block block = worldIn.getBlockState(pos.up()).getBlock();
return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.snow || block == Blocks.snow_layer));
}
public int getBlockColor()
{
return ColorizerGrass.getGrassColor(0.5D, 1.0D);
}
public int getRenderColor(IBlockState state)
{
return this.getBlockColor();
}
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 4 && worldIn.getBlockState(pos.up()).getBlock().getLightOpacity() > 2)
{
worldIn.setBlockState(pos, Blocks.dirt.getDefaultState());
}
else
{
if (worldIn.getLightFromNeighbors(pos.up()) >= 9)
{
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = pos.add(rand.nextInt(3) - 1, rand.nextInt(5) - 3, rand.nextInt(3) - 1);
Block block = worldIn.getBlockState(blockpos.up()).getBlock();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.DIRT && worldIn.getLightFromNeighbors(blockpos.up()) >= 4 && block.getLightOpacity() <= 2)
{
worldIn.setBlockState(blockpos, Blocks.grass.getDefaultState());
}
}
}
}
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Blocks.dirt.getItemDropped(Blocks.dirt.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), rand, fortune);
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
return true;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return true;
}
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
BlockPos blockpos = pos.up();
for (int i = 0; i < 128; ++i)
{
BlockPos blockpos1 = blockpos;
int j = 0;
while (true)
{
if (j >= i / 16)
{
if (worldIn.getBlockState(blockpos1).getBlock().blockMaterial == Material.air)
{
if (rand.nextInt(8) == 0)
{
BlockFlower.EnumFlowerType blockflower$enumflowertype = worldIn.getBiomeGenForCoords(blockpos1).pickRandomFlower(rand, blockpos1);
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
IBlockState iblockstate = blockflower.getDefaultState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);
if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
{
worldIn.setBlockState(blockpos1, iblockstate, 3);
}
}
else
{
IBlockState iblockstate1 = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);
if (Blocks.tallgrass.canBlockStay(worldIn, blockpos1, iblockstate1))
{
worldIn.setBlockState(blockpos1, iblockstate1, 3);
}
}
}
break;
}
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
if (worldIn.getBlockState(blockpos1.down()).getBlock() != Blocks.grass || worldIn.getBlockState(blockpos1).getBlock().isNormalCube())
{
break;
}
++j;
}
}
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT_MIPPED;
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return 0;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {SNOWY});
}
}
@@ -1,31 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class BlockGravel extends BlockFalling
{
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
if (fortune > 3)
{
fortune = 3;
}
return rand.nextInt(10 - fortune * 3) == 0 ? Items.flint : Item.getItemFromBlock(this);
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return MapColor.stoneColor;
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockHalfStoneSlab extends BlockStoneSlab
{
public boolean isDouble()
{
return false;
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockHalfStoneSlabNew extends BlockStoneSlabNew
{
public boolean isDouble()
{
return false;
}
}
@@ -1,9 +0,0 @@
package net.minecraft.block;
public class BlockHalfWoodSlab extends BlockWoodSlab
{
public boolean isDouble()
{
return false;
}
}
@@ -1,23 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
public class BlockHardenedClay extends Block
{
public BlockHardenedClay()
{
super(Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
return MapColor.adobeColor;
}
}
@@ -1,83 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockHay extends BlockRotatedPillar
{
public BlockHay()
{
super(Material.grass, MapColor.yellowColor);
this.setDefaultState(this.blockState.getBaseState().withProperty(AXIS, EnumFacing.Axis.Y));
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing.Axis enumfacing$axis = EnumFacing.Axis.Y;
int i = meta & 12;
if (i == 4)
{
enumfacing$axis = EnumFacing.Axis.X;
}
else if (i == 8)
{
enumfacing$axis = EnumFacing.Axis.Z;
}
return this.getDefaultState().withProperty(AXIS, enumfacing$axis);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);
if (enumfacing$axis == EnumFacing.Axis.X)
{
i |= 4;
}
else if (enumfacing$axis == EnumFacing.Axis.Z)
{
i |= 8;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {AXIS});
}
protected ItemStack createStackedBlock(IBlockState state)
{
return new ItemStack(Item.getItemFromBlock(this), 1, 0);
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(AXIS, facing.getAxis());
}
}
@@ -1,253 +0,0 @@
package net.minecraft.block;
import com.google.common.base.Predicate;
import java.util.List;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockHopper extends BlockContainer
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", new Predicate<EnumFacing>()
{
public boolean apply(EnumFacing p_apply_1_)
{
return p_apply_1_ != EnumFacing.UP;
}
});
public static final PropertyBool ENABLED = PropertyBool.create("enabled");
public BlockHopper()
{
super(Material.iron, MapColor.stoneColor);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.DOWN).withProperty(ENABLED, Boolean.valueOf(true)));
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
float f = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
EnumFacing enumfacing = facing.getOpposite();
if (enumfacing == EnumFacing.UP)
{
enumfacing = EnumFacing.DOWN;
}
return this.getDefaultState().withProperty(FACING, enumfacing).withProperty(ENABLED, Boolean.valueOf(true));
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityHopper();
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityHopper)
{
((TileEntityHopper)tileentity).setCustomName(stack.getDisplayName());
}
}
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
this.updateState(worldIn, pos, state);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityHopper)
{
playerIn.displayGUIChest((TileEntityHopper)tileentity);
playerIn.triggerAchievement(StatList.field_181732_P);
}
return true;
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
this.updateState(worldIn, pos, state);
}
private void updateState(World worldIn, BlockPos pos, IBlockState state)
{
boolean flag = !worldIn.isBlockPowered(pos);
if (flag != ((Boolean)state.getValue(ENABLED)).booleanValue())
{
worldIn.setBlockState(pos, state.withProperty(ENABLED, Boolean.valueOf(flag)), 4);
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityHopper)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityHopper)tileentity);
worldIn.updateComparatorOutputLevel(pos, this);
}
super.breakBlock(worldIn, pos, state);
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return true;
}
public static EnumFacing getFacing(int meta)
{
return EnumFacing.getFront(meta & 7);
}
/**
* Get's the hopper's active status from the 8-bit of the metadata. Note that the metadata stores whether the block
* is powered, so this returns true when that bit is 0.
*/
public static boolean isEnabled(int meta)
{
return (meta & 8) != 8;
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
return Container.calcRedstone(worldIn.getTileEntity(pos));
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT_MIPPED;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, getFacing(meta)).withProperty(ENABLED, Boolean.valueOf(isEnabled(meta)));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((EnumFacing)state.getValue(FACING)).getIndex();
if (!((Boolean)state.getValue(ENABLED)).booleanValue())
{
i |= 8;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, ENABLED});
}
}
@@ -1,160 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
public class BlockHugeMushroom extends Block
{
public static final PropertyEnum<BlockHugeMushroom.EnumType> VARIANT = PropertyEnum.<BlockHugeMushroom.EnumType>create("variant", BlockHugeMushroom.EnumType.class);
private final Block smallBlock;
public BlockHugeMushroom(Material p_i46392_1_, MapColor p_i46392_2_, Block p_i46392_3_)
{
super(p_i46392_1_, p_i46392_2_);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockHugeMushroom.EnumType.ALL_OUTSIDE));
this.smallBlock = p_i46392_3_;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return Math.max(0, random.nextInt(10) - 7);
}
/**
* Get the MapColor for this Block and the given BlockState
*/
public MapColor getMapColor(IBlockState state)
{
switch ((BlockHugeMushroom.EnumType)state.getValue(VARIANT))
{
case ALL_STEM:
return MapColor.clothColor;
case ALL_INSIDE:
return MapColor.sandColor;
case STEM:
return MapColor.sandColor;
default:
return super.getMapColor(state);
}
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(this.smallBlock);
}
public Item getItem(World worldIn, BlockPos pos)
{
return Item.getItemFromBlock(this.smallBlock);
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState();
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, BlockHugeMushroom.EnumType.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((BlockHugeMushroom.EnumType)state.getValue(VARIANT)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {VARIANT});
}
public static enum EnumType implements IStringSerializable
{
NORTH_WEST(1, "north_west"),
NORTH(2, "north"),
NORTH_EAST(3, "north_east"),
WEST(4, "west"),
CENTER(5, "center"),
EAST(6, "east"),
SOUTH_WEST(7, "south_west"),
SOUTH(8, "south"),
SOUTH_EAST(9, "south_east"),
STEM(10, "stem"),
ALL_INSIDE(0, "all_inside"),
ALL_OUTSIDE(14, "all_outside"),
ALL_STEM(15, "all_stem");
private static final BlockHugeMushroom.EnumType[] META_LOOKUP = new BlockHugeMushroom.EnumType[16];
private final int meta;
private final String name;
private EnumType(int meta, String name)
{
this.meta = meta;
this.name = name;
}
public int getMetadata()
{
return this.meta;
}
public String toString()
{
return this.name;
}
public static BlockHugeMushroom.EnumType byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
BlockHugeMushroom.EnumType blockhugemushroom$enumtype = META_LOOKUP[meta];
return blockhugemushroom$enumtype == null ? META_LOOKUP[0] : blockhugemushroom$enumtype;
}
public String getName()
{
return this.name;
}
static {
for (BlockHugeMushroom.EnumType blockhugemushroom$enumtype : values())
{
META_LOOKUP[blockhugemushroom$enumtype.getMetadata()] = blockhugemushroom$enumtype;
}
}
}
}
@@ -1,94 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.World;
public class BlockIce extends BlockBreakable
{
public BlockIce()
{
super(Material.ice, false);
this.slipperiness = 0.98F;
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.TRANSLUCENT;
}
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
player.addExhaustion(0.025F);
if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
{
ItemStack itemstack = this.createStackedBlock(state);
if (itemstack != null)
{
spawnAsEntity(worldIn, pos, itemstack);
}
}
else
{
if (worldIn.provider.doesWaterVaporize())
{
worldIn.setBlockToAir(pos);
return;
}
int i = EnchantmentHelper.getFortuneModifier(player);
this.dropBlockAsItem(worldIn, pos, state, i);
Material material = worldIn.getBlockState(pos.down()).getBlock().getMaterial();
if (material.blocksMovement() || material.isLiquid())
{
worldIn.setBlockState(pos, Blocks.flowing_water.getDefaultState());
}
}
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (worldIn.getLightFor(EnumSkyBlock.BLOCK, pos) > 11 - this.getLightOpacity())
{
if (worldIn.provider.doesWaterVaporize())
{
worldIn.setBlockToAir(pos);
}
else
{
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
worldIn.setBlockState(pos, Blocks.water.getDefaultState());
}
}
}
public int getMobilityFlag()
{
return 0;
}
}
@@ -1,205 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockJukebox extends BlockContainer
{
public static final PropertyBool HAS_RECORD = PropertyBool.create("has_record");
protected BlockJukebox()
{
super(Material.wood, MapColor.dirtColor);
this.setDefaultState(this.blockState.getBaseState().withProperty(HAS_RECORD, Boolean.valueOf(false)));
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (((Boolean)state.getValue(HAS_RECORD)).booleanValue())
{
this.dropRecord(worldIn, pos, state);
state = state.withProperty(HAS_RECORD, Boolean.valueOf(false));
worldIn.setBlockState(pos, state, 2);
return true;
}
else
{
return false;
}
}
public void insertRecord(World worldIn, BlockPos pos, IBlockState state, ItemStack recordStack)
{
if (!worldIn.isRemote)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof BlockJukebox.TileEntityJukebox)
{
((BlockJukebox.TileEntityJukebox)tileentity).setRecord(new ItemStack(recordStack.getItem(), 1, recordStack.getMetadata()));
worldIn.setBlockState(pos, state.withProperty(HAS_RECORD, Boolean.valueOf(true)), 2);
}
}
}
private void dropRecord(World worldIn, BlockPos pos, IBlockState state)
{
if (!worldIn.isRemote)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof BlockJukebox.TileEntityJukebox)
{
BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox)tileentity;
ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord();
if (itemstack != null)
{
worldIn.playAuxSFX(1005, pos, 0);
worldIn.playRecord(pos, (String)null);
blockjukebox$tileentityjukebox.setRecord((ItemStack)null);
float f = 0.7F;
double d0 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
double d1 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.2D + 0.6D;
double d2 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
ItemStack itemstack1 = itemstack.copy();
EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, itemstack1);
entityitem.setDefaultPickupDelay();
worldIn.spawnEntityInWorld(entityitem);
}
}
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
this.dropRecord(worldIn, pos, state);
super.breakBlock(worldIn, pos, state);
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
if (!worldIn.isRemote)
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, 0);
}
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new BlockJukebox.TileEntityJukebox();
}
public boolean hasComparatorInputOverride()
{
return true;
}
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof BlockJukebox.TileEntityJukebox)
{
ItemStack itemstack = ((BlockJukebox.TileEntityJukebox)tileentity).getRecord();
if (itemstack != null)
{
return Item.getIdFromItem(itemstack.getItem()) + 1 - Item.getIdFromItem(Items.record_13);
}
}
return 0;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(HAS_RECORD, Boolean.valueOf(meta > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Boolean)state.getValue(HAS_RECORD)).booleanValue() ? 1 : 0;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {HAS_RECORD});
}
public static class TileEntityJukebox extends TileEntity
{
private ItemStack record;
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
if (compound.hasKey("RecordItem", 10))
{
this.setRecord(ItemStack.loadItemStackFromNBT(compound.getCompoundTag("RecordItem")));
}
else if (compound.getInteger("Record") > 0)
{
this.setRecord(new ItemStack(Item.getItemById(compound.getInteger("Record")), 1, 0));
}
}
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
if (this.getRecord() != null)
{
compound.setTag("RecordItem", this.getRecord().writeToNBT(new NBTTagCompound()));
}
}
public ItemStack getRecord()
{
return this.record;
}
public void setRecord(ItemStack recordStack)
{
this.record = recordStack;
this.markDirty();
}
}
}
@@ -1,164 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockLadder extends Block
{
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
protected BlockLadder()
{
super(Material.circuits);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getCollisionBoundingBox(worldIn, pos, state);
}
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos)
{
this.setBlockBoundsBasedOnState(worldIn, pos);
return super.getSelectedBoundingBox(worldIn, pos);
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == this)
{
float f = 0.125F;
switch ((EnumFacing)iblockstate.getValue(FACING))
{
case NORTH:
this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
break;
case SOUTH:
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
break;
case WEST:
this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
break;
case EAST:
default:
this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
}
}
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return worldIn.getBlockState(pos.west()).getBlock().isNormalCube() ? true : (worldIn.getBlockState(pos.east()).getBlock().isNormalCube() ? true : (worldIn.getBlockState(pos.north()).getBlock().isNormalCube() ? true : worldIn.getBlockState(pos.south()).getBlock().isNormalCube()));
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
if (facing.getAxis().isHorizontal() && this.canBlockStay(worldIn, pos, facing))
{
return this.getDefaultState().withProperty(FACING, facing);
}
else
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
if (this.canBlockStay(worldIn, pos, enumfacing))
{
return this.getDefaultState().withProperty(FACING, enumfacing);
}
}
return this.getDefaultState();
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
if (!this.canBlockStay(worldIn, pos, enumfacing))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
protected boolean canBlockStay(World worldIn, BlockPos pos, EnumFacing facing)
{
return worldIn.getBlockState(pos.offset(facing.getOpposite())).getBlock().isNormalCube();
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
EnumFacing enumfacing = EnumFacing.getFront(meta);
if (enumfacing.getAxis() == EnumFacing.Axis.Y)
{
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState().withProperty(FACING, enumfacing);
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((EnumFacing)state.getValue(FACING)).getIndex();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING});
}
}
@@ -1,304 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.ColorizerFoliage;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColorHelper;
public abstract class BlockLeaves extends BlockLeavesBase
{
public static final PropertyBool DECAYABLE = PropertyBool.create("decayable");
public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay");
int[] surroundings;
protected int iconIndex;
protected boolean isTransparent;
public BlockLeaves()
{
super(Material.leaves, false);
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.tabDecorations);
this.setHardness(0.2F);
this.setLightOpacity(1);
this.setStepSound(soundTypeGrass);
}
public int getBlockColor()
{
return ColorizerFoliage.getFoliageColor(0.5D, 1.0D);
}
public int getRenderColor(IBlockState state)
{
return ColorizerFoliage.getFoliageColorBasic();
}
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
int i = 1;
int j = i + 1;
int k = pos.getX();
int l = pos.getY();
int i1 = pos.getZ();
if (worldIn.isAreaLoaded(new BlockPos(k - j, l - j, i1 - j), new BlockPos(k + j, l + j, i1 + j)))
{
for (int j1 = -i; j1 <= i; ++j1)
{
for (int k1 = -i; k1 <= i; ++k1)
{
for (int l1 = -i; l1 <= i; ++l1)
{
BlockPos blockpos = pos.add(j1, k1, l1);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(CHECK_DECAY)).booleanValue())
{
worldIn.setBlockState(blockpos, iblockstate.withProperty(CHECK_DECAY, Boolean.valueOf(true)), 4);
}
}
}
}
}
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!worldIn.isRemote)
{
if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue() && ((Boolean)state.getValue(DECAYABLE)).booleanValue())
{
int i = 4;
int j = i + 1;
int k = pos.getX();
int l = pos.getY();
int i1 = pos.getZ();
int j1 = 32;
int k1 = j1 * j1;
int l1 = j1 / 2;
if (this.surroundings == null)
{
this.surroundings = new int[j1 * j1 * j1];
}
if (worldIn.isAreaLoaded(new BlockPos(k - j, l - j, i1 - j), new BlockPos(k + j, l + j, i1 + j)))
{
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for (int i2 = -i; i2 <= i; ++i2)
{
for (int j2 = -i; j2 <= i; ++j2)
{
for (int k2 = -i; k2 <= i; ++k2)
{
Block block = worldIn.getBlockState(blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2)).getBlock();
if (block != Blocks.log && block != Blocks.log2)
{
if (block.getMaterial() == Material.leaves)
{
this.surroundings[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = -2;
}
else
{
this.surroundings[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = -1;
}
}
else
{
this.surroundings[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = 0;
}
}
}
}
for (int i3 = 1; i3 <= 4; ++i3)
{
for (int j3 = -i; j3 <= i; ++j3)
{
for (int k3 = -i; k3 <= i; ++k3)
{
for (int l3 = -i; l3 <= i; ++l3)
{
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + l3 + l1] == i3 - 1)
{
if (this.surroundings[(j3 + l1 - 1) * k1 + (k3 + l1) * j1 + l3 + l1] == -2)
{
this.surroundings[(j3 + l1 - 1) * k1 + (k3 + l1) * j1 + l3 + l1] = i3;
}
if (this.surroundings[(j3 + l1 + 1) * k1 + (k3 + l1) * j1 + l3 + l1] == -2)
{
this.surroundings[(j3 + l1 + 1) * k1 + (k3 + l1) * j1 + l3 + l1] = i3;
}
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1 - 1) * j1 + l3 + l1] == -2)
{
this.surroundings[(j3 + l1) * k1 + (k3 + l1 - 1) * j1 + l3 + l1] = i3;
}
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1 + 1) * j1 + l3 + l1] == -2)
{
this.surroundings[(j3 + l1) * k1 + (k3 + l1 + 1) * j1 + l3 + l1] = i3;
}
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + (l3 + l1 - 1)] == -2)
{
this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + (l3 + l1 - 1)] = i3;
}
if (this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + l3 + l1 + 1] == -2)
{
this.surroundings[(j3 + l1) * k1 + (k3 + l1) * j1 + l3 + l1 + 1] = i3;
}
}
}
}
}
}
}
int l2 = this.surroundings[l1 * k1 + l1 * j1 + l1];
if (l2 >= 0)
{
worldIn.setBlockState(pos, state.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4);
}
else
{
this.destroy(worldIn, pos);
}
}
}
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (worldIn.canLightningStrike(pos.up()) && !World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) && rand.nextInt(15) == 1)
{
double d0 = (double)((float)pos.getX() + rand.nextFloat());
double d1 = (double)pos.getY() - 0.05D;
double d2 = (double)((float)pos.getZ() + rand.nextFloat());
worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
private void destroy(World worldIn, BlockPos pos)
{
this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0);
worldIn.setBlockToAir(pos);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return random.nextInt(20) == 0 ? 1 : 0;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Item.getItemFromBlock(Blocks.sapling);
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
if (!worldIn.isRemote)
{
int i = this.getSaplingDropChance(state);
if (fortune > 0)
{
i -= 2 << fortune;
if (i < 10)
{
i = 10;
}
}
if (worldIn.rand.nextInt(i) == 0)
{
Item item = this.getItemDropped(state, worldIn.rand, fortune);
spawnAsEntity(worldIn, pos, new ItemStack(item, 1, this.damageDropped(state)));
}
i = 200;
if (fortune > 0)
{
i -= 10 << fortune;
if (i < 40)
{
i = 40;
}
}
this.dropApple(worldIn, pos, state, i);
}
}
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance)
{
}
protected int getSaplingDropChance(IBlockState state)
{
return 20;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return !this.fancyGraphics;
}
/**
* Pass true to draw this block using fancy graphics, or false for fast graphics.
*/
public void setGraphicsLevel(boolean fancy)
{
this.isTransparent = fancy;
this.fancyGraphics = fancy;
this.iconIndex = fancy ? 0 : 1;
}
public EnumWorldBlockLayer getBlockLayer()
{
return this.isTransparent ? EnumWorldBlockLayer.CUTOUT_MIPPED : EnumWorldBlockLayer.SOLID;
}
public boolean isVisuallyOpaque()
{
return false;
}
public abstract BlockPlanks.EnumType getWoodType(int meta);
}
@@ -1,30 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
public class BlockLeavesBase extends Block
{
protected boolean fancyGraphics;
protected BlockLeavesBase(Material materialIn, boolean fancyGraphics)
{
super(materialIn);
this.fancyGraphics = fancyGraphics;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return !this.fancyGraphics && worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
}
}
@@ -1,380 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockLever extends Block
{
public static final PropertyEnum<BlockLever.EnumOrientation> FACING = PropertyEnum.<BlockLever.EnumOrientation>create("facing", BlockLever.EnumOrientation.class);
public static final PropertyBool POWERED = PropertyBool.create("powered");
protected BlockLever()
{
super(Material.circuits);
this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, BlockLever.EnumOrientation.NORTH).withProperty(POWERED, Boolean.valueOf(false)));
this.setCreativeTab(CreativeTabs.tabRedstone);
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return false;
}
/**
* Check whether this Block can be placed on the given side
*/
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side)
{
return func_181090_a(worldIn, pos, side.getOpposite());
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
for (EnumFacing enumfacing : EnumFacing.values())
{
if (func_181090_a(worldIn, pos, enumfacing))
{
return true;
}
}
return false;
}
protected static boolean func_181090_a(World p_181090_0_, BlockPos p_181090_1_, EnumFacing p_181090_2_)
{
return BlockButton.func_181088_a(p_181090_0_, p_181090_1_, p_181090_2_);
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
IBlockState iblockstate = this.getDefaultState().withProperty(POWERED, Boolean.valueOf(false));
if (func_181090_a(worldIn, pos, facing.getOpposite()))
{
return iblockstate.withProperty(FACING, BlockLever.EnumOrientation.forFacings(facing, placer.getHorizontalFacing()));
}
else
{
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
if (enumfacing != facing && func_181090_a(worldIn, pos, enumfacing.getOpposite()))
{
return iblockstate.withProperty(FACING, BlockLever.EnumOrientation.forFacings(enumfacing, placer.getHorizontalFacing()));
}
}
if (World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
{
return iblockstate.withProperty(FACING, BlockLever.EnumOrientation.forFacings(EnumFacing.UP, placer.getHorizontalFacing()));
}
else
{
return iblockstate;
}
}
}
public static int getMetadataForFacing(EnumFacing facing)
{
switch (facing)
{
case DOWN:
return 0;
case UP:
return 5;
case NORTH:
return 4;
case SOUTH:
return 3;
case WEST:
return 2;
case EAST:
return 1;
default:
return -1;
}
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (this.func_181091_e(worldIn, pos, state) && !func_181090_a(worldIn, pos, ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing().getOpposite()))
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
}
private boolean func_181091_e(World p_181091_1_, BlockPos p_181091_2_, IBlockState p_181091_3_)
{
if (this.canPlaceBlockAt(p_181091_1_, p_181091_2_))
{
return true;
}
else
{
this.dropBlockAsItem(p_181091_1_, p_181091_2_, p_181091_3_, 0);
p_181091_1_.setBlockToAir(p_181091_2_);
return false;
}
}
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
float f = 0.1875F;
switch ((BlockLever.EnumOrientation)worldIn.getBlockState(pos).getValue(FACING))
{
case EAST:
this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
break;
case WEST:
this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
break;
case SOUTH:
this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
break;
case NORTH:
this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
break;
case UP_Z:
case UP_X:
f = 0.25F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f);
break;
case DOWN_X:
case DOWN_Z:
f = 0.25F;
this.setBlockBounds(0.5F - f, 0.4F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f);
}
}
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else
{
state = state.cycleProperty(POWERED);
worldIn.setBlockState(pos, state, 3);
worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F);
worldIn.notifyNeighborsOfStateChange(pos, this);
EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
return true;
}
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
worldIn.notifyNeighborsOfStateChange(pos, this);
EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing();
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this);
}
super.breakBlock(worldIn, pos, state);
}
public int getWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
}
public int getStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return !((Boolean)state.getValue(POWERED)).booleanValue() ? 0 : (((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing() == side ? 15 : 0);
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(FACING, BlockLever.EnumOrientation.byMetadata(meta & 7)).withProperty(POWERED, Boolean.valueOf((meta & 8) > 0));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
int i = 0;
i = i | ((BlockLever.EnumOrientation)state.getValue(FACING)).getMetadata();
if (((Boolean)state.getValue(POWERED)).booleanValue())
{
i |= 8;
}
return i;
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {FACING, POWERED});
}
public static enum EnumOrientation implements IStringSerializable
{
DOWN_X(0, "down_x", EnumFacing.DOWN),
EAST(1, "east", EnumFacing.EAST),
WEST(2, "west", EnumFacing.WEST),
SOUTH(3, "south", EnumFacing.SOUTH),
NORTH(4, "north", EnumFacing.NORTH),
UP_Z(5, "up_z", EnumFacing.UP),
UP_X(6, "up_x", EnumFacing.UP),
DOWN_Z(7, "down_z", EnumFacing.DOWN);
private static final BlockLever.EnumOrientation[] META_LOOKUP = new BlockLever.EnumOrientation[values().length];
private final int meta;
private final String name;
private final EnumFacing facing;
private EnumOrientation(int meta, String name, EnumFacing facing)
{
this.meta = meta;
this.name = name;
this.facing = facing;
}
public int getMetadata()
{
return this.meta;
}
public EnumFacing getFacing()
{
return this.facing;
}
public String toString()
{
return this.name;
}
public static BlockLever.EnumOrientation byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public static BlockLever.EnumOrientation forFacings(EnumFacing clickedSide, EnumFacing entityFacing)
{
switch (clickedSide)
{
case DOWN:
switch (entityFacing.getAxis())
{
case X:
return DOWN_X;
case Z:
return DOWN_Z;
default:
throw new IllegalArgumentException("Invalid entityFacing " + entityFacing + " for facing " + clickedSide);
}
case UP:
switch (entityFacing.getAxis())
{
case X:
return UP_X;
case Z:
return UP_Z;
default:
throw new IllegalArgumentException("Invalid entityFacing " + entityFacing + " for facing " + clickedSide);
}
case NORTH:
return NORTH;
case SOUTH:
return SOUTH;
case WEST:
return WEST;
case EAST:
return EAST;
default:
throw new IllegalArgumentException("Invalid facing: " + clickedSide);
}
}
public String getName()
{
return this.name;
}
static {
for (BlockLever.EnumOrientation blocklever$enumorientation : values())
{
META_LOOKUP[blocklever$enumorientation.getMetadata()] = blocklever$enumorientation;
}
}
}
}
@@ -1,84 +0,0 @@
package net.minecraft.block;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockLilyPad extends BlockBush
{
protected BlockLilyPad()
{
float f = 0.5F;
float f1 = 0.015625F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
/**
* Add all collision boxes of this Block to the list that intersect with the given mask.
*/
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
{
if (collidingEntity == null || !(collidingEntity instanceof EntityBoat))
{
super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
}
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ);
}
public int getBlockColor()
{
return 7455580;
}
public int getRenderColor(IBlockState state)
{
return 7455580;
}
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return 2129968;
}
/**
* is the block grass, dirt or farmland
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground == Blocks.water;
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
if (pos.getY() >= 0 && pos.getY() < 256)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
return iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0;
}
else
{
return false;
}
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return 0;
}
}
@@ -1,410 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeColorHelper;
public abstract class BlockLiquid extends Block
{
public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 15);
protected BlockLiquid(Material materialIn)
{
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, Integer.valueOf(0)));
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
this.setTickRandomly(true);
}
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
{
return this.blockMaterial != Material.lava;
}
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
return this.blockMaterial == Material.water ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : 16777215;
}
/**
* Returns the percentage of the liquid block that is air, based on the given flow decay of the liquid
*/
public static float getLiquidHeightPercent(int meta)
{
if (meta >= 8)
{
meta = 0;
}
return (float)(meta + 1) / 9.0F;
}
protected int getLevel(IBlockAccess worldIn, BlockPos pos)
{
return worldIn.getBlockState(pos).getBlock().getMaterial() == this.blockMaterial ? ((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() : -1;
}
protected int getEffectiveFlowDecay(IBlockAccess worldIn, BlockPos pos)
{
int i = this.getLevel(worldIn, pos);
return i >= 8 ? 0 : i;
}
public boolean isFullCube()
{
return false;
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
{
return hitIfLiquid && ((Integer)state.getValue(LEVEL)).intValue() == 0;
}
/**
* Whether this Block is solid on the given Side
*/
public boolean isBlockSolid(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
return material == this.blockMaterial ? false : (side == EnumFacing.UP ? true : (material == Material.ice ? false : super.isBlockSolid(worldIn, pos, side)));
}
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return worldIn.getBlockState(pos).getBlock().getMaterial() == this.blockMaterial ? false : (side == EnumFacing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side));
}
public boolean func_176364_g(IBlockAccess blockAccess, BlockPos pos)
{
for (int i = -1; i <= 1; ++i)
{
for (int j = -1; j <= 1; ++j)
{
IBlockState iblockstate = blockAccess.getBlockState(pos.add(i, 0, j));
Block block = iblockstate.getBlock();
Material material = block.getMaterial();
if (material != this.blockMaterial && !block.isFullBlock())
{
return true;
}
}
}
return false;
}
public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
{
return null;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 1;
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return null;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
protected Vec3 getFlowVector(IBlockAccess worldIn, BlockPos pos)
{
Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
int i = this.getEffectiveFlowDecay(worldIn, pos);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
BlockPos blockpos = pos.offset(enumfacing);
int j = this.getEffectiveFlowDecay(worldIn, blockpos);
if (j < 0)
{
if (!worldIn.getBlockState(blockpos).getBlock().getMaterial().blocksMovement())
{
j = this.getEffectiveFlowDecay(worldIn, blockpos.down());
if (j >= 0)
{
int k = j - (i - 8);
vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * k), (double)((blockpos.getY() - pos.getY()) * k), (double)((blockpos.getZ() - pos.getZ()) * k));
}
}
}
else if (j >= 0)
{
int l = j - i;
vec3 = vec3.addVector((double)((blockpos.getX() - pos.getX()) * l), (double)((blockpos.getY() - pos.getY()) * l), (double)((blockpos.getZ() - pos.getZ()) * l));
}
}
if (((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() >= 8)
{
for (EnumFacing enumfacing1 : EnumFacing.Plane.HORIZONTAL)
{
BlockPos blockpos1 = pos.offset(enumfacing1);
if (this.isBlockSolid(worldIn, blockpos1, enumfacing1) || this.isBlockSolid(worldIn, blockpos1.up(), enumfacing1))
{
vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D);
break;
}
}
}
return vec3.normalize();
}
public Vec3 modifyAcceleration(World worldIn, BlockPos pos, Entity entityIn, Vec3 motion)
{
return motion.add(this.getFlowVector(worldIn, pos));
}
/**
* How many world ticks before ticking
*/
public int tickRate(World worldIn)
{
return this.blockMaterial == Material.water ? 5 : (this.blockMaterial == Material.lava ? (worldIn.provider.getHasNoSky() ? 10 : 30) : 0);
}
public int getMixedBrightnessForBlock(IBlockAccess worldIn, BlockPos pos)
{
int i = worldIn.getCombinedLight(pos, 0);
int j = worldIn.getCombinedLight(pos.up(), 0);
int k = i & 255;
int l = j & 255;
int i1 = i >> 16 & 255;
int j1 = j >> 16 & 255;
return (k > l ? k : l) | (i1 > j1 ? i1 : j1) << 16;
}
public EnumWorldBlockLayer getBlockLayer()
{
return this.blockMaterial == Material.water ? EnumWorldBlockLayer.TRANSLUCENT : EnumWorldBlockLayer.SOLID;
}
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
double d0 = (double)pos.getX();
double d1 = (double)pos.getY();
double d2 = (double)pos.getZ();
if (this.blockMaterial == Material.water)
{
int i = ((Integer)state.getValue(LEVEL)).intValue();
if (i > 0 && i < 8)
{
if (rand.nextInt(64) == 0)
{
worldIn.playSound(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "liquid.water", rand.nextFloat() * 0.25F + 0.75F, rand.nextFloat() * 1.0F + 0.5F, false);
}
}
else if (rand.nextInt(10) == 0)
{
worldIn.spawnParticle(EnumParticleTypes.SUSPENDED, d0 + (double)rand.nextFloat(), d1 + (double)rand.nextFloat(), d2 + (double)rand.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (this.blockMaterial == Material.lava && worldIn.getBlockState(pos.up()).getBlock().getMaterial() == Material.air && !worldIn.getBlockState(pos.up()).getBlock().isOpaqueCube())
{
if (rand.nextInt(100) == 0)
{
double d8 = d0 + (double)rand.nextFloat();
double d4 = d1 + this.maxY;
double d6 = d2 + (double)rand.nextFloat();
worldIn.spawnParticle(EnumParticleTypes.LAVA, d8, d4, d6, 0.0D, 0.0D, 0.0D, new int[0]);
worldIn.playSound(d8, d4, d6, "liquid.lavapop", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
}
if (rand.nextInt(200) == 0)
{
worldIn.playSound(d0, d1, d2, "liquid.lava", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false);
}
}
if (rand.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
{
Material material = worldIn.getBlockState(pos.down(2)).getBlock().getMaterial();
if (!material.blocksMovement() && !material.isLiquid())
{
double d3 = d0 + (double)rand.nextFloat();
double d5 = d1 - 1.05D;
double d7 = d2 + (double)rand.nextFloat();
if (this.blockMaterial == Material.water)
{
worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
}
else
{
worldIn.spawnParticle(EnumParticleTypes.DRIP_LAVA, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
}
public static double getFlowDirection(IBlockAccess worldIn, BlockPos pos, Material materialIn)
{
Vec3 vec3 = getFlowingBlock(materialIn).getFlowVector(worldIn, pos);
return vec3.xCoord == 0.0D && vec3.zCoord == 0.0D ? -1000.0D : MathHelper.func_181159_b(vec3.zCoord, vec3.xCoord) - (Math.PI / 2D);
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
this.checkForMixing(worldIn, pos, state);
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
this.checkForMixing(worldIn, pos, state);
}
public boolean checkForMixing(World worldIn, BlockPos pos, IBlockState state)
{
if (this.blockMaterial == Material.lava)
{
boolean flag = false;
for (EnumFacing enumfacing : EnumFacing.values())
{
if (enumfacing != EnumFacing.DOWN && worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial() == Material.water)
{
flag = true;
break;
}
}
if (flag)
{
Integer integer = (Integer)state.getValue(LEVEL);
if (integer.intValue() == 0)
{
worldIn.setBlockState(pos, Blocks.obsidian.getDefaultState());
this.triggerMixEffects(worldIn, pos);
return true;
}
if (integer.intValue() <= 4)
{
worldIn.setBlockState(pos, Blocks.cobblestone.getDefaultState());
this.triggerMixEffects(worldIn, pos);
return true;
}
}
}
return false;
}
protected void triggerMixEffects(World worldIn, BlockPos pos)
{
double d0 = (double)pos.getX();
double d1 = (double)pos.getY();
double d2 = (double)pos.getZ();
worldIn.playSoundEffect(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
for (int i = 0; i < 8; ++i)
{
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(LEVEL, Integer.valueOf(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((Integer)state.getValue(LEVEL)).intValue();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {LEVEL});
}
public static BlockDynamicLiquid getFlowingBlock(Material materialIn)
{
if (materialIn == Material.water)
{
return Blocks.flowing_water;
}
else if (materialIn == Material.lava)
{
return Blocks.flowing_lava;
}
else
{
throw new IllegalArgumentException("Invalid material");
}
}
public static BlockStaticLiquid getStaticBlock(Material materialIn)
{
if (materialIn == Material.water)
{
return Blocks.water;
}
else if (materialIn == Material.lava)
{
return Blocks.lava;
}
else
{
throw new IllegalArgumentException("Invalid material");
}
}
}
@@ -1,95 +0,0 @@
package net.minecraft.block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
public abstract class BlockLog extends BlockRotatedPillar
{
public static final PropertyEnum<BlockLog.EnumAxis> LOG_AXIS = PropertyEnum.<BlockLog.EnumAxis>create("axis", BlockLog.EnumAxis.class);
public BlockLog()
{
super(Material.wood);
this.setCreativeTab(CreativeTabs.tabBlock);
this.setHardness(2.0F);
this.setStepSound(soundTypeWood);
}
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
int i = 4;
int j = i + 1;
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j)))
{
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i)))
{
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock().getMaterial() == Material.leaves && !((Boolean)iblockstate.getValue(BlockLeaves.CHECK_DECAY)).booleanValue())
{
worldIn.setBlockState(blockpos, iblockstate.withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(true)), 4);
}
}
}
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(LOG_AXIS, BlockLog.EnumAxis.fromFacingAxis(facing.getAxis()));
}
public static enum EnumAxis implements IStringSerializable
{
X("x"),
Y("y"),
Z("z"),
NONE("none");
private final String name;
private EnumAxis(String name)
{
this.name = name;
}
public String toString()
{
return this.name;
}
public static BlockLog.EnumAxis fromFacingAxis(EnumFacing.Axis axis)
{
switch (axis)
{
case X:
return X;
case Y:
return Y;
case Z:
return Z;
default:
return NONE;
}
}
public String getName()
{
return this.name;
}
}
}
@@ -1,42 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class BlockMelon extends Block
{
protected BlockMelon()
{
super(Material.gourd, MapColor.limeColor);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.melon;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 3 + random.nextInt(5);
}
/**
* Get the quantity dropped based on the given fortune level
*/
public int quantityDroppedWithBonus(int fortune, Random random)
{
return Math.min(9, this.quantityDropped(random) + random.nextInt(1 + fortune));
}
}
@@ -1,79 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
public class BlockMobSpawner extends BlockContainer
{
protected BlockMobSpawner()
{
super(Material.rock);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileEntityMobSpawner();
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return null;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
int i = 15 + worldIn.rand.nextInt(15) + worldIn.rand.nextInt(15);
this.dropXpOnBlockBreak(worldIn, pos, i);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
}
@@ -1,127 +0,0 @@
package net.minecraft.block;
import java.util.Random;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import net.minecraft.world.gen.feature.WorldGenerator;
public class BlockMushroom extends BlockBush implements IGrowable
{
protected BlockMushroom()
{
float f = 0.2F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
this.setTickRandomly(true);
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (rand.nextInt(25) == 0)
{
int i = 5;
int j = 4;
for (BlockPos blockpos : BlockPos.getAllInBoxMutable(pos.add(-4, -1, -4), pos.add(4, 1, 4)))
{
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
--i;
if (i <= 0)
{
return;
}
}
}
BlockPos blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
for (int k = 0; k < 4; ++k)
{
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
{
pos = blockpos1;
}
blockpos1 = pos.add(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
}
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
{
worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
}
}
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return super.canPlaceBlockAt(worldIn, pos) && this.canBlockStay(worldIn, pos, this.getDefaultState());
}
/**
* is the block grass, dirt or farmland
*/
protected boolean canPlaceBlockOn(Block ground)
{
return ground.isFullBlock();
}
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
if (pos.getY() >= 0 && pos.getY() < 256)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));
}
else
{
return false;
}
}
public boolean generateBigMushroom(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
worldIn.setBlockToAir(pos);
WorldGenerator worldgenerator = null;
if (this == Blocks.brown_mushroom)
{
worldgenerator = new WorldGenBigMushroom(Blocks.brown_mushroom_block);
}
else if (this == Blocks.red_mushroom)
{
worldgenerator = new WorldGenBigMushroom(Blocks.red_mushroom_block);
}
if (worldgenerator != null && worldgenerator.generate(worldIn, rand, pos))
{
return true;
}
else
{
worldIn.setBlockState(pos, state, 3);
return false;
}
}
/**
* Whether this IGrowable can grow
*/
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient)
{
return true;
}
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
return (double)rand.nextFloat() < 0.4D;
}
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
this.generateBigMushroom(worldIn, pos, state, rand);
}
}
Loaded 100 of 1891 files, more files were not shown because too many files have changed in this diff. Show more