gun from the starlike 2 thing shuan did, but i improved and fixed the majority of it. i.e it was basically just a bow at first. currently, the gun conflicts with base bows, though it did in the starlike 2 thing. i also added the desktop run thing in build.gradle for intellij (because i use that).
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
eaglercraft-workspace
|
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="17" />
|
||||||
|
</component>
|
||||||
|
</project>
|
16
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
5
.idea/misc.xml
generated
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="corretto-17" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
33
build.gradle
@ -25,8 +25,19 @@ sourceSets {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
desktop {
|
||||||
|
java {
|
||||||
|
srcDirs(
|
||||||
|
"src/main/java",
|
||||||
|
"src/game/java",
|
||||||
|
"src/protocol-game/java",
|
||||||
|
"src/protocol-relay/java",
|
||||||
|
"src/lwjgl/java")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -36,6 +47,8 @@ dependencies {
|
|||||||
teavm(teavm.libs.jso)
|
teavm(teavm.libs.jso)
|
||||||
teavm(teavm.libs.jsoApis)
|
teavm(teavm.libs.jsoApis)
|
||||||
compileOnly "org.teavm:teavm-core:0.9.2" // workaround for a few hacks
|
compileOnly "org.teavm:teavm-core:0.9.2" // workaround for a few hacks
|
||||||
|
|
||||||
|
desktopImplementation fileTree("desktopRuntime/eclipseProject/deps_fix")
|
||||||
}
|
}
|
||||||
|
|
||||||
def folder = "javascript"
|
def folder = "javascript"
|
||||||
@ -45,7 +58,7 @@ teavm.js {
|
|||||||
obfuscated = true
|
obfuscated = true
|
||||||
sourceMap = true
|
sourceMap = true
|
||||||
targetFileName = "../" + name
|
targetFileName = "../" + name
|
||||||
optimization = OptimizationLevel.AGGRESSIVE
|
optimization = OptimizationLevel.BALANCED // Change to "AGGRESSIVE" for release
|
||||||
outOfProcess = false
|
outOfProcess = false
|
||||||
fastGlobalAnalysis = false
|
fastGlobalAnalysis = false
|
||||||
processMemory = 512
|
processMemory = 512
|
||||||
@ -58,7 +71,6 @@ teavm.js {
|
|||||||
|
|
||||||
tasks.named("generateJavaScript") {
|
tasks.named("generateJavaScript") {
|
||||||
doLast {
|
doLast {
|
||||||
delete file(folder + "/js")
|
|
||||||
|
|
||||||
// NOTE: This step may break at any time, and is not required for 99% of browsers
|
// NOTE: This step may break at any time, and is not required for 99% of browsers
|
||||||
|
|
||||||
@ -67,7 +79,22 @@ tasks.named("generateJavaScript") {
|
|||||||
def i = dest.substring(0, dest.indexOf("=\$rt_globals.Symbol('jsoClass');")).lastIndexOf("let ")
|
def i = dest.substring(0, dest.indexOf("=\$rt_globals.Symbol('jsoClass');")).lastIndexOf("let ")
|
||||||
dest = dest.substring(0, i) + "var" + dest.substring(i + 3)
|
dest = dest.substring(0, i) + "var" + dest.substring(i + 3)
|
||||||
def j = dest.indexOf("function(\$rt_globals,\$rt_exports){")
|
def j = dest.indexOf("function(\$rt_globals,\$rt_exports){")
|
||||||
dest = dest.substring(0, j + 34) + "\n" + file("desktopRuntime/resources/ES6ShimScript.txt").getText("UTF-8") + "\n" + dest.substring(j + 34)
|
dest = dest.substring(0, j + 34) + "\n" + file(folder + "/ES6ShimScript.txt").getText("UTF-8") + "\n" + dest.substring(j + 34)
|
||||||
phile.write(dest, "UTF-8")
|
phile.write(dest, "UTF-8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tasks.register("desktopRun", JavaExec) {
|
||||||
|
classpath = sourceSets.desktop.compileClasspath
|
||||||
|
group = "EaglercraftX Desktop"
|
||||||
|
description = "Runs the client"
|
||||||
|
classpath sourceSets.desktop.runtimeClasspath
|
||||||
|
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||||
|
jvmArgs '-XstartOnFirstThread'
|
||||||
|
}
|
||||||
|
|
||||||
|
args = ["hide-renderdoc", "opengl"]
|
||||||
|
workingDir "./desktopRuntime"
|
||||||
|
main 'net.lax1dude.eaglercraft.v1_8.internal.lwjgl.MainClass'
|
||||||
|
}
|
@ -106,6 +106,11 @@ tile.fabricator.name=Fabricator
|
|||||||
item.amber.name=Amber
|
item.amber.name=Amber
|
||||||
item.ambered_bow.name=Ambered Bow
|
item.ambered_bow.name=Ambered Bow
|
||||||
|
|
||||||
|
item.revolver.name=Revolver
|
||||||
|
item.revolverBarrel.name=Revolver Barrel
|
||||||
|
item.revolverHandle.name=Revolver Handle
|
||||||
|
item.bullet.name=Bullet
|
||||||
|
|
||||||
tile.andesite_tiles.name=Andesite Tiles
|
tile.andesite_tiles.name=Andesite Tiles
|
||||||
tile.chiseled_deep_ocean_bricks.name=Chiseled Deep Ocean Bricks
|
tile.chiseled_deep_ocean_bricks.name=Chiseled Deep Ocean Bricks
|
||||||
tile.decorated_acacia_log.name=Decorated Acacia Log
|
tile.decorated_acacia_log.name=Decorated Acacia Log
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/bullet"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ -90, 0, 0 ],
|
||||||
|
"translation": [ 0, 1, -3 ],
|
||||||
|
"scale": [ 0.55, 0.55, 0.55 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/revolver_standby"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 5, 80, -45 ],
|
||||||
|
"translation": [ 0.75, 0, 0.25 ],
|
||||||
|
"scale": [ 1, 1, 1 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/revolver_barrel"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [-90, 0, 0],
|
||||||
|
"translation": [0, 1, -3],
|
||||||
|
"scale": [0.55, 0.55, 0.55]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [0, -135, 25],
|
||||||
|
"translation": [0, 4, 2],
|
||||||
|
"scale": [1.7, 1.7, 1.7]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/revolver_handle"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [-90, 0, 0],
|
||||||
|
"translation": [0, 1, -3],
|
||||||
|
"scale": [0.55, 0.55, 0.55]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [0, -135, 25],
|
||||||
|
"translation": [0, 4, 2],
|
||||||
|
"scale": [1.7, 1.7, 1.7]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/revolver_pulling_0"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 5, 80, -45 ],
|
||||||
|
"translation": [ 0.75, 0, 0.25 ],
|
||||||
|
"scale": [ 1, 1, 1 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/revolver_pulling_1"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 5, 80, -45 ],
|
||||||
|
"translation": [ 0.75, 0, 0.25 ],
|
||||||
|
"scale": [ 1, 1, 1 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent": "builtin/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "starlike:items/revolver_pulling_2"
|
||||||
|
},
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 5, 80, -45 ],
|
||||||
|
"translation": [ 0.75, 0, 0.25 ],
|
||||||
|
"scale": [ 1, 1, 1 ]
|
||||||
|
},
|
||||||
|
"firstperson": {
|
||||||
|
"rotation": [ 0, -135, 25 ],
|
||||||
|
"translation": [ 0, 4, 2 ],
|
||||||
|
"scale": [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,5 +2,13 @@
|
|||||||
"random.chisel": {
|
"random.chisel": {
|
||||||
"category": "player",
|
"category": "player",
|
||||||
"sounds": ["starlike:random/chisel"]
|
"sounds": ["starlike:random/chisel"]
|
||||||
|
},
|
||||||
|
"gun.fire": {
|
||||||
|
"category": "player",
|
||||||
|
"sounds": ["starlike:gun/fire"]
|
||||||
|
},
|
||||||
|
"gun.empty": {
|
||||||
|
"category": "player",
|
||||||
|
"sounds": ["starlike:gun/empty"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
desktopRuntime/resources/assets/starlike/sounds/gun/empty.ogg
Normal file
BIN
desktopRuntime/resources/assets/starlike/sounds/gun/fire.ogg
Normal file
After Width: | Height: | Size: 142 B |
After Width: | Height: | Size: 236 B |
BIN
desktopRuntime/resources/assets/starlike/textures/items/gun.png
Normal file
After Width: | Height: | Size: 184 B |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 251 B |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 256 B |
@ -14,6 +14,7 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
import net.starlikeclient.minecraft.items.ItemBackpack;
|
import net.starlikeclient.minecraft.items.ItemBackpack;
|
||||||
import net.starlikeclient.minecraft.items.ItemChisel;
|
import net.starlikeclient.minecraft.items.ItemChisel;
|
||||||
import net.starlikeclient.minecraft.items.ItemEnderBackpack;
|
import net.starlikeclient.minecraft.items.ItemEnderBackpack;
|
||||||
|
import net.starlikeclient.minecraft.items.ItemRevolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
|
* + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
|
||||||
@ -22,7 +23,7 @@ import net.starlikeclient.minecraft.items.ItemEnderBackpack;
|
|||||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
|
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
|
||||||
* Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
* Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||||
*
|
*
|
||||||
* EaglercraftX 1.8 patch files (c) 2022-2025 lax1dude, ayunami2000. All Rights
|
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
@ -262,6 +263,10 @@ public class Items {
|
|||||||
public static ItemBackpack iron_backpack;
|
public static ItemBackpack iron_backpack;
|
||||||
public static ItemBackpack diamond_backpack;
|
public static ItemBackpack diamond_backpack;
|
||||||
public static ItemEnderBackpack ender_backpack;
|
public static ItemEnderBackpack ender_backpack;
|
||||||
|
public static ItemRevolver revolver;
|
||||||
|
public static Item bullet;
|
||||||
|
public static Item revolver_handle;
|
||||||
|
public static Item revolver_barrel;
|
||||||
|
|
||||||
static void doBootstrap() {
|
static void doBootstrap() {
|
||||||
if (!Bootstrap.isRegistered()) {
|
if (!Bootstrap.isRegistered()) {
|
||||||
@ -491,6 +496,10 @@ public class Items {
|
|||||||
// ambered_bow = (ItemBow) getRegisteredItem("starlike:ambered_bow");
|
// ambered_bow = (ItemBow) getRegisteredItem("starlike:ambered_bow");
|
||||||
diamond_backpack = (ItemBackpack) getRegisteredItem("starlike:diamond_backpack");
|
diamond_backpack = (ItemBackpack) getRegisteredItem("starlike:diamond_backpack");
|
||||||
ender_backpack = (ItemEnderBackpack) getRegisteredItem("starlike:ender_backpack");
|
ender_backpack = (ItemEnderBackpack) getRegisteredItem("starlike:ender_backpack");
|
||||||
|
revolver = (ItemRevolver) getRegisteredItem("starlike:revolver");
|
||||||
|
bullet = getRegisteredItem("starlike:bullet");
|
||||||
|
revolver_barrel = getRegisteredItem("starlike:revolver_barrel");
|
||||||
|
revolver_handle = getRegisteredItem("starlike:revolver_handle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||||||
import net.minecraft.entity.projectile.EntityArrow;
|
import net.minecraft.entity.projectile.EntityArrow;
|
||||||
import net.minecraft.entity.projectile.EntityFireball;
|
import net.minecraft.entity.projectile.EntityFireball;
|
||||||
import net.minecraft.world.Explosion;
|
import net.minecraft.world.Explosion;
|
||||||
|
import net.starlikeclient.minecraft.entities.entity.EntityBullet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
|
* + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
|
||||||
@ -14,7 +15,7 @@ import net.minecraft.world.Explosion;
|
|||||||
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
|
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
|
||||||
* Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
* Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||||
*
|
*
|
||||||
* EaglercraftX 1.8 patch files (c) 2022-2025 lax1dude, ayunami2000. All Rights
|
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights
|
||||||
* Reserved.
|
* Reserved.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
@ -54,6 +55,9 @@ public class DamageSource {
|
|||||||
public static DamageSource causeArrowDamage(EntityArrow arrow, Entity parEntity) {
|
public static DamageSource causeArrowDamage(EntityArrow arrow, Entity parEntity) {
|
||||||
return (new EntityDamageSourceIndirect("arrow", arrow, parEntity)).setProjectile();
|
return (new EntityDamageSourceIndirect("arrow", arrow, parEntity)).setProjectile();
|
||||||
}
|
}
|
||||||
|
public static DamageSource causeArrowDamage(EntityBullet arrow, Entity parEntity) {
|
||||||
|
return (new EntityDamageSourceIndirect("arrow", arrow, parEntity)).setProjectile();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* + returns EntityDamageSourceIndirect of a fireball
|
* + returns EntityDamageSourceIndirect of a fireball
|
||||||
|
@ -0,0 +1,470 @@
|
|||||||
|
package net.starlikeclient.minecraft.entities.entity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.IProjectile;
|
||||||
|
import net.minecraft.entity.monster.EntityEnderman;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.play.server.S2BPacketChangeGameState;
|
||||||
|
import net.minecraft.util.*;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
|
||||||
|
* Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||||
|
*
|
||||||
|
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights
|
||||||
|
* Reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EntityBullet extends Entity implements IProjectile {
|
||||||
|
|
||||||
|
private static final double DEFAULT_DAMAGE = 2.0D;
|
||||||
|
private static final float DEFAULT_SIZE = 0.5F;
|
||||||
|
private static final double RENDER_DISTANCE_WEIGHT = 10.0D;
|
||||||
|
private int xTile = -1;
|
||||||
|
private int yTile = -1;
|
||||||
|
private int zTile = -1;
|
||||||
|
private Block inTile;
|
||||||
|
private int inData;
|
||||||
|
private boolean inGround;
|
||||||
|
public int canBePickedUp;
|
||||||
|
public int arrowShake;
|
||||||
|
public Entity shootingEntity;
|
||||||
|
private int ticksInGround;
|
||||||
|
private int ticksInAir;
|
||||||
|
private double damage = DEFAULT_DAMAGE;
|
||||||
|
private int knockbackStrength;
|
||||||
|
public boolean isChair = false;
|
||||||
|
public EntityBullet(World worldIn) {
|
||||||
|
super(worldIn);
|
||||||
|
initializeBullet();
|
||||||
|
}
|
||||||
|
public EntityBullet(World worldIn, double x, double y, double z) {
|
||||||
|
super(worldIn);
|
||||||
|
initializeBullet();
|
||||||
|
setPosition(x, y, z);
|
||||||
|
}
|
||||||
|
public EntityBullet(World worldIn, EntityLivingBase shooter, EntityLivingBase target, float velocity, float inaccuracy) {
|
||||||
|
super(worldIn);
|
||||||
|
initializeBullet();
|
||||||
|
setupShooter(shooter);
|
||||||
|
calculateInitialPosition(shooter, target, velocity, inaccuracy);
|
||||||
|
}
|
||||||
|
public EntityBullet(World worldIn, EntityLivingBase shooter, float velocity) {
|
||||||
|
super(worldIn);
|
||||||
|
initializeBullet();
|
||||||
|
setupShooter(shooter);
|
||||||
|
setupInitialMotion(velocity);
|
||||||
|
}
|
||||||
|
private void initializeBullet() {
|
||||||
|
this.renderDistanceWeight = RENDER_DISTANCE_WEIGHT;
|
||||||
|
this.setSize(DEFAULT_SIZE, DEFAULT_SIZE);
|
||||||
|
}
|
||||||
|
private void setupShooter(EntityLivingBase shooter) {
|
||||||
|
this.shootingEntity = shooter;
|
||||||
|
if (shooter instanceof EntityPlayer) {
|
||||||
|
this.canBePickedUp = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void calculateInitialPosition(EntityLivingBase shooter, EntityLivingBase target, float velocity, float inaccuracy) {
|
||||||
|
this.posY = shooter.posY + shooter.getEyeHeight() - 0.1D;
|
||||||
|
double dX = target.posX - shooter.posX;
|
||||||
|
double dY = target.getEntityBoundingBox().minY + target.height / 3.0F - this.posY;
|
||||||
|
double dZ = target.posZ - shooter.posZ;
|
||||||
|
double distance = MathHelper.sqrt_double(dX * dX + dZ * dZ);
|
||||||
|
|
||||||
|
if (distance >= 1.0E-7D) {
|
||||||
|
float yaw = (float) (MathHelper.func_181159_b(dZ, dX) * 180.0D / Math.PI) - 90.0F;
|
||||||
|
float pitch = (float) (-(MathHelper.func_181159_b(dY, distance) * 180.0D / Math.PI));
|
||||||
|
double dXNorm = dX / distance;
|
||||||
|
double dZNorm = dZ / distance;
|
||||||
|
this.setLocationAndAngles(shooter.posX + dXNorm, this.posY, shooter.posZ + dZNorm, yaw, pitch);
|
||||||
|
float velocityFactor = (float) (distance * 0.2D);
|
||||||
|
setThrowableHeading(dX, dY + velocityFactor, dZ, velocity, inaccuracy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void setupInitialMotion(float velocity) {
|
||||||
|
this.setSize(DEFAULT_SIZE, DEFAULT_SIZE);
|
||||||
|
this.setLocationAndAngles(this.shootingEntity.posX, this.shootingEntity.posY + this.shootingEntity.getEyeHeight(), this.shootingEntity.posZ, this.shootingEntity.rotationYaw, this.shootingEntity.rotationPitch);
|
||||||
|
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||||
|
this.posY -= 0.1D;
|
||||||
|
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||||
|
this.setPosition(this.posX, this.posY, this.posZ);
|
||||||
|
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||||
|
this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||||
|
this.motionY = -MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI);
|
||||||
|
setThrowableHeading(this.motionX, this.motionY, this.motionZ, velocity * 5.0F, 0.0F); }
|
||||||
|
@Override
|
||||||
|
public boolean canAttackWithItem() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean canTriggerWalking() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void entityInit() {
|
||||||
|
this.dataWatcher.addObject(16, Byte.valueOf((byte) 0));
|
||||||
|
}
|
||||||
|
public double getDamage() {
|
||||||
|
return this.damage;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public float getEyeHeight() {
|
||||||
|
return 0.0F;
|
||||||
|
}
|
||||||
|
public boolean getIsCritical() {
|
||||||
|
return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCollideWithPlayer(EntityPlayer entityplayer) {
|
||||||
|
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) {
|
||||||
|
boolean canPickup = this.canBePickedUp == 1 || (this.canBePickedUp == 2 && entityplayer.capabilities.isCreativeMode); {
|
||||||
|
canPickup = false;
|
||||||
|
}
|
||||||
|
if (canPickup) {
|
||||||
|
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||||
|
entityplayer.onItemPickup(this, 1);
|
||||||
|
this.setDead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onUpdate() {
|
||||||
|
super.onUpdate();
|
||||||
|
if (isChair) {
|
||||||
|
handleChairUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||||
|
initializeRotation();
|
||||||
|
}
|
||||||
|
BlockPos blockPos = new BlockPos(this.xTile, this.yTile, this.zTile);
|
||||||
|
IBlockState blockState = this.worldObj.getBlockState(blockPos);
|
||||||
|
Block block = blockState.getBlock();
|
||||||
|
if (block.getMaterial() != Material.air) {
|
||||||
|
handleBlockCollision(block, blockPos, blockState);
|
||||||
|
}
|
||||||
|
if (this.arrowShake > 0) {
|
||||||
|
--this.arrowShake;
|
||||||
|
}
|
||||||
|
if (this.inGround) {
|
||||||
|
handleInGroundState(block, blockState);
|
||||||
|
} else {
|
||||||
|
handleInAirState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleChairUpdate() {
|
||||||
|
if (!(riddenByEntity instanceof EntityPlayer)) {
|
||||||
|
isChair = false;
|
||||||
|
setDead();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void initializeRotation() {
|
||||||
|
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||||
|
this.prevRotationYaw = this.rotationYaw = (float) (MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||||
|
this.prevRotationPitch = this.rotationPitch = (float) (MathHelper.func_181159_b(this.motionY, (double) f) * 180.0D / Math.PI);
|
||||||
|
}
|
||||||
|
private void handleBlockCollision(Block block, BlockPos blockPos, IBlockState blockState) {
|
||||||
|
block.setBlockBoundsBasedOnState(this.worldObj, blockPos);
|
||||||
|
AxisAlignedBB axisAlignedBB = block.getCollisionBoundingBox(this.worldObj, blockPos, blockState);
|
||||||
|
|
||||||
|
if (axisAlignedBB != null && axisAlignedBB.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) {
|
||||||
|
this.inGround = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleInGroundState(Block block, IBlockState blockState) {
|
||||||
|
int meta = block.getMetaFromState(blockState);
|
||||||
|
|
||||||
|
if (block == this.inTile && meta == this.inData) {
|
||||||
|
++this.ticksInGround;
|
||||||
|
if (this.ticksInGround >= 1200) {
|
||||||
|
this.setDead();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.inGround = false;
|
||||||
|
this.motionX *= this.rand.nextFloat() * 0.2F;
|
||||||
|
this.motionY *= this.rand.nextFloat() * 0.2F;
|
||||||
|
this.motionZ *= this.rand.nextFloat() * 0.2F;
|
||||||
|
this.ticksInGround = 0;
|
||||||
|
this.ticksInAir = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleInAirState() {
|
||||||
|
++this.ticksInAir;
|
||||||
|
Vec3 currentPos = new Vec3(this.posX, this.posY, this.posZ);
|
||||||
|
Vec3 nextPos = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
|
||||||
|
MovingObjectPosition movingObjectPosition = this.worldObj.rayTraceBlocks(currentPos, nextPos, false, true, false);
|
||||||
|
if (movingObjectPosition != null) {
|
||||||
|
nextPos = new Vec3(movingObjectPosition.hitVec.xCoord, movingObjectPosition.hitVec.yCoord, movingObjectPosition.hitVec.zCoord);
|
||||||
|
}
|
||||||
|
Entity entity = findCollidedEntity(currentPos, nextPos);
|
||||||
|
if (entity != null) {
|
||||||
|
movingObjectPosition = new MovingObjectPosition(entity);
|
||||||
|
}
|
||||||
|
if (movingObjectPosition != null) {
|
||||||
|
handleCollision(movingObjectPosition);
|
||||||
|
}
|
||||||
|
if (this.getIsCritical()) {
|
||||||
|
spawnCriticalParticles();
|
||||||
|
}
|
||||||
|
updatePositionAndRotation();
|
||||||
|
applyMotionDamping();
|
||||||
|
}
|
||||||
|
private Entity findCollidedEntity(Vec3 currentPos, Vec3 nextPos) {
|
||||||
|
Entity entity = null;
|
||||||
|
List<Entity> entities = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||||
|
double closestDistance = 0.0D;
|
||||||
|
|
||||||
|
for (Entity entityCandidate : entities) {
|
||||||
|
if (entityCandidate.canBeCollidedWith() && (entityCandidate != this.shootingEntity || this.ticksInAir >= 5)) {
|
||||||
|
float f1 = 0.3F;
|
||||||
|
AxisAlignedBB axisAlignedBB = entityCandidate.getEntityBoundingBox().expand(f1, f1, f1);
|
||||||
|
MovingObjectPosition movingObjectPosition = axisAlignedBB.calculateIntercept(currentPos, nextPos);
|
||||||
|
|
||||||
|
if (movingObjectPosition != null) {
|
||||||
|
double distance = currentPos.squareDistanceTo(movingObjectPosition.hitVec);
|
||||||
|
|
||||||
|
if (distance < closestDistance || closestDistance == 0.0D) {
|
||||||
|
entity = entityCandidate;
|
||||||
|
closestDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
private void handleCollision(MovingObjectPosition movingObjectPosition) {
|
||||||
|
if (movingObjectPosition.entityHit != null) {
|
||||||
|
handleEntityCollision(movingObjectPosition);
|
||||||
|
} else {
|
||||||
|
handleBlockHit(movingObjectPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleEntityCollision(MovingObjectPosition movingObjectPosition) {
|
||||||
|
float velocityMagnitude = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||||
|
int damageAmount = MathHelper.ceiling_double_int(velocityMagnitude * this.damage);
|
||||||
|
if (this.getIsCritical()) {
|
||||||
|
damageAmount += this.rand.nextInt(damageAmount / 2 + 2);
|
||||||
|
}
|
||||||
|
DamageSource damageSource = (this.shootingEntity == null) ? DamageSource.causeArrowDamage(this, this) : DamageSource.causeArrowDamage(this, this.shootingEntity);
|
||||||
|
if (this.isBurning() && !(movingObjectPosition.entityHit instanceof EntityEnderman)) {
|
||||||
|
movingObjectPosition.entityHit.setFire(5);
|
||||||
|
}
|
||||||
|
if (movingObjectPosition.entityHit.attackEntityFrom(damageSource, (float) damageAmount)) {
|
||||||
|
if (movingObjectPosition.entityHit instanceof EntityLivingBase) {
|
||||||
|
handleLivingEntityHit(movingObjectPosition);
|
||||||
|
}
|
||||||
|
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||||
|
|
||||||
|
if (!(movingObjectPosition.entityHit instanceof EntityEnderman)) {
|
||||||
|
this.setDead();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handleMissedHit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleLivingEntityHit(MovingObjectPosition movingObjectPosition) {
|
||||||
|
EntityLivingBase entityLivingBase = (EntityLivingBase) movingObjectPosition.entityHit;
|
||||||
|
if (!this.worldObj.isRemote) {
|
||||||
|
entityLivingBase.setArrowCountInEntity(entityLivingBase.getArrowCountInEntity() + 1);
|
||||||
|
}
|
||||||
|
if (this.knockbackStrength > 0) {
|
||||||
|
applyKnockback(movingObjectPosition, entityLivingBase);
|
||||||
|
}
|
||||||
|
if (this.shootingEntity instanceof EntityLivingBase) {
|
||||||
|
EnchantmentHelper.applyThornEnchantments(entityLivingBase, this.shootingEntity);
|
||||||
|
EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase) this.shootingEntity, entityLivingBase);
|
||||||
|
}
|
||||||
|
if (this.shootingEntity != null && movingObjectPosition.entityHit != this.shootingEntity && movingObjectPosition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) {
|
||||||
|
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void applyKnockback(MovingObjectPosition movingObjectPosition, EntityLivingBase entityLivingBase) {
|
||||||
|
float f7 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||||
|
|
||||||
|
if (f7 > 0.0F) {
|
||||||
|
movingObjectPosition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6D / f7, 0.1D, this.motionZ * this.knockbackStrength * 0.6D / f7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleBlockHit(MovingObjectPosition movingObjectPosition) {
|
||||||
|
BlockPos blockPos = movingObjectPosition.getBlockPos();
|
||||||
|
this.xTile = blockPos.getX();
|
||||||
|
this.yTile = blockPos.getY();
|
||||||
|
this.zTile = blockPos.getZ();
|
||||||
|
IBlockState blockState = this.worldObj.getBlockState(blockPos);
|
||||||
|
this.inTile = blockState.getBlock();
|
||||||
|
this.inData = this.inTile.getMetaFromState(blockState);
|
||||||
|
this.motionX = (float) (movingObjectPosition.hitVec.xCoord - this.posX);
|
||||||
|
this.motionY = (float) (movingObjectPosition.hitVec.yCoord - this.posY);
|
||||||
|
this.motionZ = (float) (movingObjectPosition.hitVec.zCoord - this.posZ);
|
||||||
|
float motionMagnitude = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
|
||||||
|
this.posX -= this.motionX / motionMagnitude * 0.05D;
|
||||||
|
this.posY -= this.motionY / motionMagnitude * 0.05D;
|
||||||
|
this.posZ -= this.motionZ / motionMagnitude * 0.05D;
|
||||||
|
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||||
|
this.inGround = true;
|
||||||
|
this.arrowShake = 7;
|
||||||
|
this.setIsCritical(false);
|
||||||
|
if (this.inTile.getMaterial() != Material.air) {
|
||||||
|
this.inTile.onEntityCollidedWithBlock(this.worldObj, blockPos, blockState, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void handleMissedHit() {
|
||||||
|
this.motionX *= -0.1D;
|
||||||
|
this.motionY *= -0.1D;
|
||||||
|
this.motionZ *= -0.1D;
|
||||||
|
this.rotationYaw += 180.0F;
|
||||||
|
this.prevRotationYaw += 180.0F;
|
||||||
|
this.ticksInAir = 0;
|
||||||
|
}
|
||||||
|
private void spawnCriticalParticles() {
|
||||||
|
for (int k = 0; k < 4; ++k) {
|
||||||
|
this.worldObj.spawnParticle(EnumParticleTypes.CRIT, this.posX + this.motionX * k / 4.0D, this.posY + this.motionY * k / 4.0D, this.posZ + this.motionZ * k / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void updatePositionAndRotation() {
|
||||||
|
this.posX += this.motionX;
|
||||||
|
this.posY += this.motionY;
|
||||||
|
this.posZ += this.motionZ;
|
||||||
|
float f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||||
|
this.rotationYaw = (float) (MathHelper.func_181159_b(this.motionX, this.motionZ) * 180.0D / Math.PI);
|
||||||
|
for (this.rotationPitch = (float) (MathHelper.func_181159_b(this.motionY, f3) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
|
||||||
|
this.prevRotationPitch += 360.0F;
|
||||||
|
}
|
||||||
|
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
|
||||||
|
this.prevRotationYaw -= 360.0F;
|
||||||
|
}
|
||||||
|
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
|
||||||
|
this.prevRotationYaw += 360.0F;
|
||||||
|
}
|
||||||
|
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
|
||||||
|
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
|
||||||
|
}
|
||||||
|
private void applyMotionDamping() {
|
||||||
|
float f4 = 0.99F;
|
||||||
|
float f6 = 0.05F;
|
||||||
|
|
||||||
|
if (this.isInWater()) {
|
||||||
|
spawnWaterParticles();
|
||||||
|
f4 = 0.6F;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isWet()) {
|
||||||
|
this.extinguish();
|
||||||
|
}
|
||||||
|
this.motionX *= f4;
|
||||||
|
this.motionZ *= f4;
|
||||||
|
this.setPosition(this.posX, this.posY, this.posZ);
|
||||||
|
this.doBlockCollisions();
|
||||||
|
}
|
||||||
|
private void spawnWaterParticles() {
|
||||||
|
for (int i1 = 0; i1 < 4; ++i1) {
|
||||||
|
float f8 = 0.25F;
|
||||||
|
this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * f8, this.posY - this.motionY * f8, this.posZ - this.motionZ * f8, this.motionX, this.motionY, this.motionZ, new int[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
this.xTile = nbttagcompound.getShort("xTile");
|
||||||
|
this.yTile = nbttagcompound.getShort("yTile");
|
||||||
|
this.zTile = nbttagcompound.getShort("zTile");
|
||||||
|
this.ticksInGround = nbttagcompound.getShort("life");
|
||||||
|
this.inTile = nbttagcompound.hasKey("inTile", 8) ? Block.getBlockFromName(nbttagcompound.getString("inTile")) : Block.getBlockById(nbttagcompound.getByte("inTile") & 255);
|
||||||
|
this.inData = nbttagcompound.getByte("inData") & 255;
|
||||||
|
this.arrowShake = nbttagcompound.getByte("shake") & 255;
|
||||||
|
this.inGround = nbttagcompound.getByte("inGround") == 1;
|
||||||
|
this.damage = nbttagcompound.hasKey("damage", 99) ? nbttagcompound.getDouble("damage") : DEFAULT_DAMAGE;
|
||||||
|
this.canBePickedUp = nbttagcompound.hasKey("pickup", 99) ? nbttagcompound.getByte("pickup") : (nbttagcompound.hasKey("player", 99) ? (nbttagcompound.getBoolean("player") ? 1 : 0) : 0);
|
||||||
|
}
|
||||||
|
public void setDamage(double damageIn) {
|
||||||
|
this.damage = damageIn;
|
||||||
|
}
|
||||||
|
public void setIsCritical(boolean critical) {
|
||||||
|
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
|
||||||
|
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (critical ? (b0 | 1) : (b0 & -2))));
|
||||||
|
}
|
||||||
|
public void setKnockbackStrength(int knockbackStrengthIn) {
|
||||||
|
this.knockbackStrength = knockbackStrengthIn;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setPositionAndRotation2(double d0, double d1, double d2, float f, float f1, int var9, boolean var10) {
|
||||||
|
this.setPosition(d0, d1, d2);
|
||||||
|
this.setRotation(f, f1);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) {
|
||||||
|
float f = MathHelper.sqrt_double(x * x + y * y + z * z);
|
||||||
|
x = x / (double) f;
|
||||||
|
y = y / (double) f;
|
||||||
|
z = z / (double) f;
|
||||||
|
x = x + this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0075D * inaccuracy;
|
||||||
|
y = y + this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0075D * inaccuracy;
|
||||||
|
z = z + this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.0075D * inaccuracy;
|
||||||
|
x = x * velocity;
|
||||||
|
y = y * velocity;
|
||||||
|
z = z * velocity;
|
||||||
|
this.motionX = x;
|
||||||
|
this.motionY = y;
|
||||||
|
this.motionZ = z;
|
||||||
|
float f1 = MathHelper.sqrt_double(x * x + z * z);
|
||||||
|
this.prevRotationYaw = this.rotationYaw = (float) (MathHelper.func_181159_b(x, z) * 180.0D / Math.PI);
|
||||||
|
this.prevRotationPitch = this.rotationPitch = (float) (MathHelper.func_181159_b(y, (double) f1) * 180.0D / Math.PI);
|
||||||
|
this.ticksInGround = 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setVelocity(double d0, double d1, double d2) {
|
||||||
|
this.motionX = d0;
|
||||||
|
this.motionY = d1;
|
||||||
|
this.motionZ = d2;
|
||||||
|
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
|
||||||
|
float f = MathHelper.sqrt_double(d0 * d0 + d2 * d2);
|
||||||
|
this.prevRotationYaw = this.rotationYaw = (float) (MathHelper.func_181159_b(d0, d2) * 180.0D / Math.PI);
|
||||||
|
this.prevRotationPitch = this.rotationPitch = (float) (MathHelper.func_181159_b(d1, (double) f) * 180.0D / Math.PI);
|
||||||
|
this.prevRotationPitch = this.rotationPitch;
|
||||||
|
this.prevRotationYaw = this.rotationYaw;
|
||||||
|
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
||||||
|
this.ticksInGround = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
nbttagcompound.setShort("xTile", (short) this.xTile);
|
||||||
|
nbttagcompound.setShort("yTile", (short) this.yTile);
|
||||||
|
nbttagcompound.setShort("zTile", (short) this.zTile);
|
||||||
|
nbttagcompound.setShort("life", (short) this.ticksInGround);
|
||||||
|
ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(this.inTile);
|
||||||
|
nbttagcompound.setString("inTile", resourceLocation == null ? "" : resourceLocation.toString());
|
||||||
|
nbttagcompound.setByte("inData", (byte) this.inData);
|
||||||
|
nbttagcompound.setByte("shake", (byte) this.arrowShake);
|
||||||
|
nbttagcompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
|
||||||
|
nbttagcompound.setByte("pickup", (byte) this.canBePickedUp);
|
||||||
|
nbttagcompound.setDouble("damage", this.damage);
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ import net.starlikeclient.minecraft.blocks.BlockSteelGrate;
|
|||||||
import net.starlikeclient.minecraft.items.ItemBackpack;
|
import net.starlikeclient.minecraft.items.ItemBackpack;
|
||||||
import net.starlikeclient.minecraft.items.ItemChisel;
|
import net.starlikeclient.minecraft.items.ItemChisel;
|
||||||
import net.starlikeclient.minecraft.items.ItemEnderBackpack;
|
import net.starlikeclient.minecraft.items.ItemEnderBackpack;
|
||||||
|
import net.starlikeclient.minecraft.items.ItemRevolver;
|
||||||
|
|
||||||
public class ItemsStarlike {
|
public class ItemsStarlike {
|
||||||
private static void blockBootstrapStates() {
|
private static void blockBootstrapStates() {
|
||||||
@ -841,6 +842,13 @@ public class ItemsStarlike {
|
|||||||
(new ItemBackpack(3)).setUnlocalizedName("diamond_backpack"));
|
(new ItemBackpack(3)).setUnlocalizedName("diamond_backpack"));
|
||||||
Item.registerItem(1069, "starlike:ender_backpack",
|
Item.registerItem(1069, "starlike:ender_backpack",
|
||||||
(new ItemEnderBackpack()).setUnlocalizedName("ender_backpack"));
|
(new ItemEnderBackpack()).setUnlocalizedName("ender_backpack"));
|
||||||
|
Item.registerItem(1070, (String) "starlike:revolver", (new ItemRevolver()).setUnlocalizedName("revolver"));
|
||||||
|
Item.registerItem(1071, "starlike:bullet",
|
||||||
|
(new Item()).setUnlocalizedName("bullet").setCreativeTab(CreativeTabs.tabStarlike));
|
||||||
|
Item.registerItem(1072, "starlike:revolver_handle",
|
||||||
|
(new Item()).setUnlocalizedName("revolverHandle").setCreativeTab(CreativeTabs.tabStarlike));
|
||||||
|
Item.registerItem(1073, "starlike:revolver_barrel",
|
||||||
|
(new Item()).setUnlocalizedName("revolverBarrel").setCreativeTab(CreativeTabs.tabStarlike));
|
||||||
|
|
||||||
//autogenerateregisterblock
|
//autogenerateregisterblock
|
||||||
Item.registerItemBlock(Blocks.stripped_spruce_log);
|
Item.registerItemBlock(Blocks.stripped_spruce_log);
|
||||||
@ -1070,6 +1078,10 @@ public class ItemsStarlike {
|
|||||||
e.registerItem(Items.iron_backpack, "starlike:iron_backpack");
|
e.registerItem(Items.iron_backpack, "starlike:iron_backpack");
|
||||||
e.registerItem(Items.diamond_backpack, "starlike:diamond_backpack");
|
e.registerItem(Items.diamond_backpack, "starlike:diamond_backpack");
|
||||||
e.registerItem(Items.ender_backpack, "starlike:ender_backpack");
|
e.registerItem(Items.ender_backpack, "starlike:ender_backpack");
|
||||||
|
e.registerItem(Items.revolver, "starlike:revolver");
|
||||||
|
e.registerItem(Items.bullet, "starlike:bullet");
|
||||||
|
e.registerItem(Items.revolver_barrel, "starlike:revolver_barrel");
|
||||||
|
e.registerItem(Items.revolver_handle, "starlike:revolver_handle");
|
||||||
|
|
||||||
//autogeneraterenderitem
|
//autogeneraterenderitem
|
||||||
e.registerBlock(Blocks.stripped_spruce_log, "starlike:stripped_spruce_log");
|
e.registerBlock(Blocks.stripped_spruce_log, "starlike:stripped_spruce_log");
|
||||||
|
@ -0,0 +1,158 @@
|
|||||||
|
package net.starlikeclient.minecraft.items;
|
||||||
|
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.EnumAction;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.stats.StatList;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.starlikeclient.minecraft.entities.entity.EntityBullet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!" Mod
|
||||||
|
* Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||||||
|
*
|
||||||
|
* EaglercraftX 1.8 patch files (c) 2022-2024 lax1dude, ayunami2000. All Rights
|
||||||
|
* Reserved.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ItemRevolver extends Item {
|
||||||
|
public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" };
|
||||||
|
public double basePower = 1;
|
||||||
|
public int maxDamage = 384;
|
||||||
|
private int revolverMaxBullet = 6;
|
||||||
|
private int revolverBulletCount = 0;
|
||||||
|
|
||||||
|
public ItemRevolver() {
|
||||||
|
this.maxStackSize = 1;
|
||||||
|
this.setMaxDamage(maxDamage);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabCombat);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemRevolver(double power, int maxDam) {
|
||||||
|
this.maxStackSize = 1;
|
||||||
|
maxDamage = maxDam;
|
||||||
|
this.setMaxDamage(maxDamage);
|
||||||
|
this.setCreativeTab(CreativeTabs.tabStarlike);
|
||||||
|
|
||||||
|
basePower = power;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + Return the enchantabpuility factor of the item, most of the time is based
|
||||||
|
* on material.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getItemEnchantability() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + returns the action that specifies what animation to play when the items is
|
||||||
|
* being used
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EnumAction getItemUseAction(ItemStack var1) {
|
||||||
|
return EnumAction.BOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + How long it takes to use or consume an item
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getMaxItemUseDuration(ItemStack var1) {
|
||||||
|
return 72000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + Called whenever this item is equipped and the right mouse button is
|
||||||
|
* pressed. Args: itemStack, world, entityPlayer
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack itemstack, World var2, EntityPlayer entityplayer) {
|
||||||
|
if (entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Items.bullet)) {
|
||||||
|
entityplayer.setItemInUse(itemstack, this.getMaxItemUseDuration(itemstack));
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + Called when the player finishes using this Item (E.g. finishes eating.).
|
||||||
|
* Not called when the player stops using the Item before the action is
|
||||||
|
* complete.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemUseFinish(ItemStack itemstack, World var2, EntityPlayer var3) {
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* + Called when the player stops using an Item (stops holding the right mouse
|
||||||
|
* button).
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft) {
|
||||||
|
boolean flag = playerIn.capabilities.isCreativeMode;
|
||||||
|
if (flag || playerIn.inventory.hasItem(Items.bullet)) {
|
||||||
|
int i = this.getMaxItemUseDuration(stack) - timeLeft;
|
||||||
|
float f = (float) i / 20.0F;
|
||||||
|
f = (f * f + f * 2.0F) / 3.0F;
|
||||||
|
if ((double) f < 0.1D) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f > 1.0F) {
|
||||||
|
f = 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityBullet entityarrow = new EntityBullet(worldIn, playerIn, f * 2.0F);
|
||||||
|
if (f == 1.0F) {
|
||||||
|
entityarrow.setIsCritical(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId,
|
||||||
|
* stack); if (j > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)
|
||||||
|
* j * 0.5D + 0.5D); }
|
||||||
|
*/
|
||||||
|
entityarrow.setDamage(entityarrow.getDamage() + (double) 7.3D * 0.5D + 0.5D);
|
||||||
|
|
||||||
|
stack.damageItem(1, playerIn);
|
||||||
|
worldIn.playSoundAtEntity(playerIn, "starlike:gun.fire", 1.0F,
|
||||||
|
1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
||||||
|
if (flag) {
|
||||||
|
entityarrow.canBePickedUp = 2;
|
||||||
|
} else {
|
||||||
|
playerIn.inventory.consumeInventoryItem(Items.bullet);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
|
||||||
|
if (!worldIn.isRemote) {
|
||||||
|
worldIn.spawnEntityInWorld(entityarrow);
|
||||||
|
}
|
||||||
|
entityarrow.setDamage((entityarrow.getDamage() * basePower));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|