Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8ea69085b | ||
|
|
b6826e7cba | ||
|
|
4535874ed6 | ||
|
|
95453b430e | ||
|
|
3635266bd5 | ||
|
|
fedee1ba43 | ||
|
|
6f183b615e | ||
|
|
15b257d120 | ||
|
|
4ead9f53fb | ||
|
|
305e09ae4f | ||
|
|
9009b1372a | ||
|
|
8dc27474ec | ||
|
|
4c016707a4 | ||
|
|
abbe4c1017 | ||
|
|
c067e59981 | ||
|
|
7f87295901 | ||
|
|
e564437ed7 | ||
|
|
f483529855 | ||
|
|
da451de69f | ||
|
|
8b8082cd7b |
No files matched your search
@@ -0,0 +1,17 @@
|
||||
name: Optimize images
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
push:
|
||||
branches: [ master, main, release/** ]
|
||||
paths:
|
||||
- "**/*.png"
|
||||
|
||||
jobs:
|
||||
optimize-images:
|
||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/optimize-images.yml@master
|
||||
secrets: inherit
|
||||
@@ -2,17 +2,21 @@
|
||||
|
||||
dependencies {
|
||||
api("curse.maven:cofh-lib-220333:2388748")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.6:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.53:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ForestryMC:4.11.4:api") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:OpenComputers:1.12.12-GTNH:api") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.8.55-GTNH:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:CodeChickenCore:1.4.10:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:ForestryMC:4.11.14:api") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:OpenComputers:1.12.38-GTNH:api") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:CodeChickenCore:1.4.12:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:inventory-tweaks:1.7.1:dev") {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.6-GTNH:dev') {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.225:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:Backhand:1.8.2:dev") {transitive = false}
|
||||
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.11-GTNH:dev') {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.52.461:dev") {transitive = false}
|
||||
compileOnly("com.github.GTNewHorizons:Backhand:1.8.8:dev") {transitive = false}
|
||||
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") {transitive = false}
|
||||
compileOnly("curse.maven:computercraft-67504:2269339") {transitive = false}
|
||||
|
||||
compileOnly('curse.maven:automagy-222153:2285272')
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.10.25:dev')
|
||||
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.8.118-GTNH:dev")
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
#This file is generated by updateDaemonJvm
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/4945f00643ec68e7c7a6b66f90124f89/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/93aeea858331bd6bb00ba94759830234/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/4945f00643ec68e7c7a6b66f90124f89/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/93aeea858331bd6bb00ba94759830234/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3426ffcaa54c3f62406beb1f1ab8b179/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/93aeea858331bd6bb00ba94759830234/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3087f28f30be41ab6818c16a488f5f8a/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/0ef34dd9312b12d61ba1b8e66126d140/redirect
|
||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/c2dd35c9d0aaf0ba6ad0791320f99dfc/redirect
|
||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/e5810bd7fd1f8a586644409d395a7e55/redirect
|
||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/fa1e318c287360478e3c83a9a3ef1007/redirect
|
||||
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/7b3c4877c0749019e6805bb61e421497/redirect
|
||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/8e1d9ee5d0f13e442218f6884a306da1/redirect
|
||||
toolchainVersion=25
|
||||
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
||||
@@ -17,7 +17,7 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.19'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,21 @@ package com.brandon3055.draconicevolution;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.ClientProxy;
|
||||
import com.brandon3055.draconicevolution.client.creativetab.DETab;
|
||||
import com.brandon3055.draconicevolution.common.CommonProxy;
|
||||
import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
|
||||
@Mod(
|
||||
@@ -23,7 +26,9 @@ import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
version = References.VERSION,
|
||||
canBeDeactivated = false,
|
||||
guiFactory = References.GUIFACTORY,
|
||||
dependencies = "after:NotEnoughItems;" + "after:ThermalExpansion;" + "after:ThermalFoundation;")
|
||||
dependencies = "after:NotEnoughItems;" + "after:ThermalExpansion;"
|
||||
+ "after:ThermalFoundation;"
|
||||
+ "required-after:gtnhlib@[0.9.47,);")
|
||||
public class DraconicEvolution {
|
||||
|
||||
@Mod.Instance(References.MODID)
|
||||
@@ -51,10 +56,20 @@ public class DraconicEvolution {
|
||||
|
||||
public static Enchantment reaperEnchant;
|
||||
|
||||
public static final boolean isAutomagyLoaded = Loader.isModLoaded("Automagy");
|
||||
public static final boolean isEioLoaded = Loader.isModLoaded("EnderIO");
|
||||
|
||||
public DraconicEvolution() {
|
||||
LogHelper.info("Hello Minecraft!!!");
|
||||
}
|
||||
|
||||
public static ClientProxy clientProxy() {
|
||||
if (proxy.isClient()) {
|
||||
return ((ClientProxy) proxy);
|
||||
}
|
||||
throw new IllegalStateException("Accessed ClientProxy from dedicated server");
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public static void preInit(final FMLPreInitializationEvent event) {
|
||||
if (debug) LogHelper.info("Initialization");
|
||||
@@ -73,6 +88,12 @@ public class DraconicEvolution {
|
||||
proxy.postInit(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onServerStopped(final FMLServerStoppedEvent event) {
|
||||
if (debug) System.out.println("onServerStopped()");
|
||||
proxy.onServerStopped(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void processMessage(FMLInterModComms.IMCEvent event) {
|
||||
for (FMLInterModComms.IMCMessage m : event.getMessages()) {
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.brandon3055.draconicevolution.api;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.utils.DataUtils;
|
||||
import com.brandon3055.draconicevolution.common.world.ChaosWorldGenHandler;
|
||||
import com.brandon3055.draconicevolution.common.world.DraconicWorldGenerator;
|
||||
@@ -67,4 +71,25 @@ public class GeneratorOverride {
|
||||
public static void setOreEnabledInEnd(boolean cometsEnabled) {
|
||||
DraconicWorldGenerator.oreEnabledInEnd = cometsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns coordinates of the nearest chaos island for the given chunk, or {@code null}
|
||||
* <p>
|
||||
* This is for mods who need to know where chaos islands generate, for example to avoid overlapping their own world
|
||||
* features.
|
||||
*
|
||||
* @param chunkX chunk X position
|
||||
* @param chunkZ chunk Z position
|
||||
* @return Chaos Island Center coordinates, or {@code null} if none generates for that cell
|
||||
*/
|
||||
public static @Nullable ChunkCoordinates getNearestChaosIslandCenter(int chunkX, int chunkZ) {
|
||||
if (!DraconicWorldGenerator.chaosIslandsEnabled || !ConfigHandler.generateChaosIslands) return null;
|
||||
|
||||
DataUtils.XZPair<Integer, Integer> center = ChaosWorldGenHandler.getClosestChaosSpawn(chunkX, chunkZ);
|
||||
|
||||
// tHe island in (0, 0) is never generated
|
||||
if (center.x == 0 && center.z == 0) return null;
|
||||
|
||||
return new ChunkCoordinates(center.x, 80, center.z);
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,30 @@ package com.brandon3055.draconicevolution.client;
|
||||
|
||||
import static com.brandon3055.draconicevolution.integration.nei.IMCForNEI.IMCSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.client.handler.HudHandler;
|
||||
import com.brandon3055.draconicevolution.client.handler.ItemDisplayManager;
|
||||
import com.brandon3055.draconicevolution.client.handler.ParticleHandler;
|
||||
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
|
||||
import com.brandon3055.draconicevolution.client.keybinding.KeyBindings;
|
||||
import com.brandon3055.draconicevolution.client.handler.ShieldRenderHandler;
|
||||
import com.brandon3055.draconicevolution.client.keybinding.KeyInputHandler;
|
||||
import com.brandon3055.draconicevolution.client.render.IRenderTweak;
|
||||
import com.brandon3055.draconicevolution.client.render.block.RenderCrystal;
|
||||
@@ -80,6 +87,7 @@ import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileChaosShard;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDislocatorInhibitor;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDissEnchanter;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser;
|
||||
@@ -104,11 +112,22 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public final class ClientProxy extends CommonProxy {
|
||||
|
||||
private static final boolean debug = DraconicEvolution.debug;
|
||||
public static String downloadLocation;
|
||||
|
||||
private final Map<World, List<TileDislocatorInhibitor>> clientInhibitorsMap = new HashMap<>();
|
||||
private ClientEventHandler clientHandler;
|
||||
private KeyInputHandler keybindHandler;
|
||||
private ItemDisplayManager itemDisplay;
|
||||
private ShieldRenderHandler shieldRenderer;
|
||||
|
||||
public ClientProxy() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
@@ -121,15 +140,24 @@ public class ClientProxy extends CommonProxy {
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
super.init(event);
|
||||
FMLCommonHandler.instance().bus().register(new KeyInputHandler());
|
||||
FMLCommonHandler.instance().bus().register(new ClientEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new HudHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
|
||||
KeyBindings.init();
|
||||
this.keybindHandler = new KeyInputHandler();
|
||||
FMLCommonHandler.instance().bus().register(this.keybindHandler);
|
||||
this.clientHandler = new ClientEventHandler();
|
||||
FMLCommonHandler.instance().bus().register(this.clientHandler);
|
||||
MinecraftForge.EVENT_BUS.register(this.clientHandler);
|
||||
final HudHandler hudHandler = new HudHandler();
|
||||
FMLCommonHandler.instance().bus().register(hudHandler);
|
||||
MinecraftForge.EVENT_BUS.register(hudHandler);
|
||||
registerRenderIDs();
|
||||
registerRendering();
|
||||
ResourceHandler.instance.tick(null);
|
||||
IMCSender();
|
||||
this.itemDisplay = new ItemDisplayManager(60);
|
||||
FMLCommonHandler.instance().bus().register(this.itemDisplay);
|
||||
MinecraftForge.EVENT_BUS.register(this.itemDisplay);
|
||||
this.shieldRenderer = new ShieldRenderHandler();
|
||||
FMLCommonHandler.instance().bus().register(this.shieldRenderer);
|
||||
MinecraftForge.EVENT_BUS.register(this.shieldRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,7 +166,24 @@ public class ClientProxy extends CommonProxy {
|
||||
ResourceHandler.instance.tick(null);
|
||||
}
|
||||
|
||||
public void registerRendering() {
|
||||
@SubscribeEvent
|
||||
public void onClientDisconnect(final FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
|
||||
this.clientInhibitorsMap.clear();
|
||||
this.itemDisplay.startDrawing(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
if (event.world.isRemote) {
|
||||
this.clientInhibitorsMap.remove(event.world);
|
||||
} else {
|
||||
super.onWorldUnload(event);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerRendering() {
|
||||
// spotless:off
|
||||
// Item Renderers
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new RenderBow());
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new RenderBow());
|
||||
@@ -159,84 +204,29 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
|
||||
if (!ConfigHandler.useOldD2DToolTextures) {
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.draconicSword,
|
||||
new RenderTool(
|
||||
"models/tools/DraconicSword.obj",
|
||||
"textures/models/tools/DraconicSword.png",
|
||||
(IRenderTweak) ModItems.draconicSword));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.wyvernPickaxe,
|
||||
new RenderTool(
|
||||
"models/tools/Pickaxe.obj",
|
||||
"textures/models/tools/Pickaxe.png",
|
||||
(IRenderTweak) ModItems.wyvernPickaxe));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.draconicPickaxe,
|
||||
new RenderTool(
|
||||
"models/tools/DraconicPickaxe.obj",
|
||||
"textures/models/tools/DraconicPickaxe.png",
|
||||
(IRenderTweak) ModItems.draconicPickaxe));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.draconicAxe,
|
||||
new RenderTool(
|
||||
"models/tools/DraconicLumberAxe.obj",
|
||||
"textures/models/tools/DraconicLumberAxe.png",
|
||||
(IRenderTweak) ModItems.draconicAxe));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.wyvernShovel,
|
||||
new RenderTool(
|
||||
"models/tools/Shovel.obj",
|
||||
"textures/models/tools/Shovel.png",
|
||||
(IRenderTweak) ModItems.wyvernShovel));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.draconicShovel,
|
||||
new RenderTool(
|
||||
"models/tools/DraconicShovel.obj",
|
||||
"textures/models/tools/DraconicShovel.png",
|
||||
(IRenderTweak) ModItems.draconicShovel));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.wyvernSword,
|
||||
new RenderTool(
|
||||
"models/tools/Sword.obj",
|
||||
"textures/models/tools/Sword.png",
|
||||
(IRenderTweak) ModItems.wyvernSword));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.draconicDestructionStaff,
|
||||
new RenderTool(
|
||||
"models/tools/DraconicStaffOfPower.obj",
|
||||
"textures/models/tools/DraconicStaffOfPower.png",
|
||||
(IRenderTweak) ModItems.draconicDestructionStaff));
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
ModItems.draconicHoe,
|
||||
new RenderTool(
|
||||
"models/tools/DraconicHoe.obj",
|
||||
"textures/models/tools/DraconicHoe.png",
|
||||
(IRenderTweak) ModItems.draconicHoe));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicSword, new RenderTool("models/tools/DraconicSword.obj", "textures/models/tools/DraconicSword.png", (IRenderTweak) ModItems.draconicSword));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.wyvernPickaxe, new RenderTool("models/tools/Pickaxe.obj", "textures/models/tools/Pickaxe.png", (IRenderTweak) ModItems.wyvernPickaxe));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicPickaxe, new RenderTool("models/tools/DraconicPickaxe.obj", "textures/models/tools/DraconicPickaxe.png", (IRenderTweak) ModItems.draconicPickaxe));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicAxe, new RenderTool("models/tools/DraconicLumberAxe.obj", "textures/models/tools/DraconicLumberAxe.png", (IRenderTweak) ModItems.draconicAxe));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.wyvernShovel, new RenderTool("models/tools/Shovel.obj", "textures/models/tools/Shovel.png", (IRenderTweak) ModItems.wyvernShovel));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicShovel, new RenderTool("models/tools/DraconicShovel.obj", "textures/models/tools/DraconicShovel.png", (IRenderTweak) ModItems.draconicShovel));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.wyvernSword, new RenderTool("models/tools/Sword.obj", "textures/models/tools/Sword.png", (IRenderTweak) ModItems.wyvernSword));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicDestructionStaff, new RenderTool("models/tools/DraconicStaffOfPower.obj", "textures/models/tools/DraconicStaffOfPower.png", (IRenderTweak) ModItems.draconicDestructionStaff));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicHoe, new RenderTool("models/tools/DraconicHoe.obj", "textures/models/tools/DraconicHoe.png", (IRenderTweak) ModItems.draconicHoe));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new RenderBowModel(true));
|
||||
MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new RenderBowModel(false));
|
||||
}
|
||||
|
||||
MinecraftForgeClient
|
||||
.registerItemRenderer(Item.getItemFromBlock(ModBlocks.draconiumChest), new RenderDraconiumChest());
|
||||
MinecraftForgeClient
|
||||
.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new RenderParticleGen());
|
||||
MinecraftForgeClient
|
||||
.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyInfuser), new RenderEnergyInfuser());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.draconiumChest), new RenderDraconiumChest());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new RenderParticleGen());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyInfuser), new RenderEnergyInfuser());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyCrystal), new RenderCrystal());
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
Item.getItemFromBlock(ModBlocks.reactorStabilizer),
|
||||
new RenderReactorStabilizer());
|
||||
MinecraftForgeClient.registerItemRenderer(
|
||||
Item.getItemFromBlock(ModBlocks.reactorEnergyInjector),
|
||||
new RenderReactorEnergyInjector());
|
||||
MinecraftForgeClient
|
||||
.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorCore), new RenderReactorCore());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.earthBlock), new RenderEarthItem());
|
||||
MinecraftForgeClient
|
||||
.registerItemRenderer(Item.getItemFromBlock(ModBlocks.chaosCrystal), new RenderChaosShard());
|
||||
MinecraftForgeClient
|
||||
.registerItemRenderer(Item.getItemFromBlock(ModBlocks.upgradeModifier), new RenderUpgradeModifier());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorStabilizer), new RenderReactorStabilizer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorEnergyInjector), new RenderReactorEnergyInjector());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.reactorCore), new RenderReactorCore());
|
||||
if (ModBlocks.earthBlock != null) MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.earthBlock), new RenderEarthItem());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.chaosCrystal), new RenderChaosShard());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.upgradeModifier), new RenderUpgradeModifier());
|
||||
|
||||
// ISimpleBlockRendering
|
||||
RenderingRegistry.registerBlockHandler(new RenderTeleporterStand());
|
||||
@@ -248,7 +238,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, new RenderTileCustomSpawner());
|
||||
// ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, new RenderTileCrystal());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyStorageCore.class, new RenderTileEnergyStorageCore());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEarth.class, new RenderTileEarth());
|
||||
if (ModBlocks.earthBlock != null) ClientRegistry.bindTileEntitySpecialRenderer(TileEarth.class, new RenderTileEarth());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyPylon.class, new RenderTileEnergyPylon());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePlacedItem.class, new RenderTilePlacedItem());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileDissEnchanter.class, new RenderTileDissEnchanter());
|
||||
@@ -259,8 +249,7 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileWirelessEnergyTransceiver.class, new RenderTileCrystal());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileReactorCore.class, new RenderTileReactorCore());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileReactorStabilizer.class, new RenderTileReactorStabilizer());
|
||||
ClientRegistry
|
||||
.bindTileEntitySpecialRenderer(TileReactorEnergyInjector.class, new RenderTileReactorEnergyInjector());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileReactorEnergyInjector.class, new RenderTileReactorEnergyInjector());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileChaosShard.class, new RenderTileChaosShard());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileUpgradeModifier.class, new RenderTileUpgradeModifier());
|
||||
|
||||
@@ -272,14 +261,14 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChaosCrystal.class, new RenderChaosCrystal());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityChaosVortex.class, new RenderEntityChaosVortex());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityCustomArrow.class, new RenderEntityCustomArrow());
|
||||
// spotless:on
|
||||
}
|
||||
|
||||
public void registerRenderIDs() {
|
||||
private void registerRenderIDs() {
|
||||
References.idTeleporterStand = RenderingRegistry.getNextAvailableRenderId();
|
||||
References.idPortal = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz,
|
||||
int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType) {
|
||||
if (!worldObj.isRemote) return null;
|
||||
@@ -301,7 +290,6 @@ public class ClientProxy extends CommonProxy {
|
||||
return beam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced,
|
||||
ParticleEnergyField oldBeam, boolean render) {
|
||||
if (!worldObj.isRemote) return null;
|
||||
@@ -323,7 +311,6 @@ public class ClientProxy extends CommonProxy {
|
||||
return beam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) {
|
||||
if (!tile.getWorldObj().isRemote || !(tile instanceof IReactorPart)) return null;
|
||||
ParticleReactorBeam beam = oldBeam;
|
||||
@@ -344,13 +331,12 @@ public class ClientProxy extends CommonProxy {
|
||||
return beam;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Object particle, int range) {
|
||||
if (particle instanceof EntityFX && ((EntityFX) particle).worldObj.isRemote)
|
||||
ParticleHandler.spawnCustomParticle((EntityFX) particle, range);
|
||||
public void spawnParticle(EntityFX particle, int range) {
|
||||
if (particle.worldObj.isRemote) {
|
||||
ParticleHandler.spawnCustomParticle(particle, range);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISound playISound(ISound sound) {
|
||||
FMLClientHandler.instance().getClient().getSoundHandler().playSound(sound);
|
||||
return sound;
|
||||
@@ -361,11 +347,6 @@ public class ClientProxy extends CommonProxy {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinecraftServer getMCServer() {
|
||||
return super.getMCServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getClientWorld() {
|
||||
return Minecraft.getMinecraft().theWorld;
|
||||
@@ -390,4 +371,61 @@ public class ClientProxy extends CommonProxy {
|
||||
public EntityPlayer getClientPlayer() {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClient() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public KeyInputHandler getKeybindHandler() {
|
||||
return keybindHandler;
|
||||
}
|
||||
|
||||
public void displayItem(ItemStack stack) {
|
||||
this.itemDisplay.startDrawing(stack);
|
||||
}
|
||||
|
||||
public int getElapsedTicks() {
|
||||
return this.clientHandler.getElapsedTicks();
|
||||
}
|
||||
|
||||
public float getEnergyCrystalAlpha() {
|
||||
return this.clientHandler.getEnergyCrystalAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tryRepositionPlayerOnMount(int entityId) {
|
||||
this.clientHandler.tryRepositionPlayerOnMount(entityId);
|
||||
}
|
||||
|
||||
public void renderShield(EntityPlayer player, float shieldPowerF) {
|
||||
this.shieldRenderer.renderShield(player, shieldPowerF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInhibitor(TileDislocatorInhibitor tile) {
|
||||
if (tile.hasWorldObj() && tile.getWorldObj().isRemote) {
|
||||
registerInhibitor(this.clientInhibitorsMap, tile);
|
||||
} else {
|
||||
super.registerInhibitor(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterInhibitor(TileDislocatorInhibitor tile) {
|
||||
if (tile.hasWorldObj() && tile.getWorldObj().isRemote) {
|
||||
unregisterInhibitor(this.clientInhibitorsMap, tile);
|
||||
} else {
|
||||
super.unregisterInhibitor(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockedByInhibitor(World world, EntityItem item) {
|
||||
if (world.isRemote) {
|
||||
return isBlockedByInhibitor(this.clientInhibitorsMap, world, item);
|
||||
} else {
|
||||
return super.isBlockedByInhibitor(world, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,11 +66,8 @@ public class GUIDislocatorInhibitor extends GuiContainer implements INEIGuiHandl
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("tile.draconicevolution:dislocatorInhibitor.name"),
|
||||
7,
|
||||
5,
|
||||
0x222222);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("gui.de.dislocatorInhibitor.main.title"), 7, 5, 0x222222);
|
||||
drawGuiText();
|
||||
drawGreyOutSlots();
|
||||
drawButtonIcons();
|
||||
@@ -200,7 +197,12 @@ public class GUIDislocatorInhibitor extends GuiContainer implements INEIGuiHandl
|
||||
25,
|
||||
0x000000,
|
||||
false);
|
||||
fontRendererObj.drawString(String.valueOf(range), range < 10 ? 78 : 75, 25, 0x000000, false);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.numbers", range),
|
||||
range < 10 ? 78 : 75,
|
||||
25,
|
||||
0x000000,
|
||||
false);
|
||||
}
|
||||
|
||||
private void drawButtonIcons() {
|
||||
|
||||
@@ -52,13 +52,18 @@ public class GUIDissEnchanter extends GuiContainer {
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
drawCenteredString(
|
||||
fontRendererObj,
|
||||
StatCollector.translateToLocal("tile.draconicevolution:dissEnchanter.name"),
|
||||
StatCollector.translateToLocal("gui.de.dissEnchanter.main.title"),
|
||||
88,
|
||||
4,
|
||||
0x00FFFF);
|
||||
|
||||
fontRendererObj.drawString("Item", 5, 40, 0x0000ff);
|
||||
fontRendererObj.drawString("Damage: " + (40 - tile.bookPower) + "%", 5, 49, 0x0000ff);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.dissEnchanter.itemDamage1"), 5, 40, 0x0000ff);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector
|
||||
.translateToLocalFormatted("gui.de.dissEnchanter.itemDamage2", (40 - tile.bookPower) + "%"),
|
||||
5,
|
||||
49,
|
||||
0x0000ff);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +99,7 @@ public class GUIDissEnchanter extends GuiContainer {
|
||||
if (flag && player.experienceLevel < tile.dissenchantCost && !player.capabilities.isCreativeMode) flag = false;
|
||||
((GuiButtonAHeight) buttonList.get(0)).enabled = flag;
|
||||
((GuiButtonAHeight) buttonList.get(0)).packedFGColour = cachRecipeValid ? 0x000000 : 0xdf0000;
|
||||
((GuiButtonAHeight) buttonList.get(0)).displayString = "Cost: " + tile.dissenchantCost;
|
||||
((GuiButtonAHeight) buttonList.get(0)).displayString = StatCollector
|
||||
.translateToLocalFormatted("gui.de.dissEnchanter.cost", tile.dissenchantCost);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class GUIDraconiumChest extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
fontRendererObj.drawString(tile.getInventoryName(), 4, 4, 0x222222);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.draconiumChest.main.title"), 4, 4, 0x222222);
|
||||
// fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("button.de.chestAutoFeed.txt"), 4, 180,
|
||||
// 0x00FFFF);
|
||||
|
||||
|
||||
@@ -83,7 +83,11 @@ public class GUIEnergyInfuser extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
fontRendererObj.drawStringWithShadow("Energy Infuser", 49, -9, 0x00FFFF);
|
||||
fontRendererObj.drawStringWithShadow(
|
||||
StatCollector.translateToLocal("gui.de.energyInfuser.main.title"),
|
||||
49,
|
||||
-9,
|
||||
0x00FFFF);
|
||||
|
||||
// bindTexture(texture);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class GUIFlowGate extends GuiScreen {
|
||||
|
||||
drawDefaultBackground();
|
||||
ResourceHandler.bindResource("textures/gui/ToolConfig.png");
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 197, 88);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, 198, 89);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.de.flowGate.name"),
|
||||
guiCrt - (fontRendererObj.getStringWidth(StatCollector.translateToLocal("gui.de.flowGate.name")) / 2),
|
||||
|
||||
@@ -76,7 +76,7 @@ public class GUIGenerator extends GuiContainer {
|
||||
18 - (int) (fuel * 13)); // Power bar
|
||||
|
||||
fontRendererObj.drawStringWithShadow(
|
||||
StatCollector.translateToLocal("tile.draconicevolution:generator.name"),
|
||||
StatCollector.translateToLocal("gui.de.generator.main.title"),
|
||||
guiLeft + 64,
|
||||
guiTop,
|
||||
0x00FFFF);
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -82,7 +83,11 @@ public class GUIGrinder extends GuiContainer {
|
||||
18 - (int) (fuel * 13)); // Power bar
|
||||
if (tile.isExternallyPowered()) drawTexturedModalRect(guiLeft + 100, guiTop + 37, xSize, 66, 13, 13);
|
||||
|
||||
fontRendererObj.drawStringWithShadow("Grinder", guiLeft + 71, guiTop, 0x00FFFF);
|
||||
fontRendererObj.drawStringWithShadow(
|
||||
StatCollector.translateToLocal("gui.de.grinder.main.title"),
|
||||
guiLeft + 71,
|
||||
guiTop,
|
||||
0x00FFFF);
|
||||
|
||||
int x = X - guiLeft;
|
||||
int y = Y - guiTop;
|
||||
|
||||
@@ -86,7 +86,8 @@ public class GUIParticleGenerator extends GuiScreen {
|
||||
@Override
|
||||
public void drawLabel(FontRenderer fontRenderer, int x, int y) {
|
||||
fontRenderer.drawString(label, x, y, 0x000000);
|
||||
fontRenderer.drawString(String.valueOf(value), x, y + 10, 0x000000);
|
||||
fontRenderer
|
||||
.drawString(StatCollector.translateToLocalFormatted("gui.de.numbers", value), x, y + 10, 0x000000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +142,11 @@ public class GUIParticleGenerator extends GuiScreen {
|
||||
public void drawLabel(FontRenderer fontRenderer, int x, int y) {
|
||||
float roundedValue = Math.round(value * scale) / scale;
|
||||
fontRenderer.drawString(label, x, y, 0x000000);
|
||||
fontRenderer.drawString(String.valueOf(roundedValue), x, y + 10, 0x000000);
|
||||
fontRenderer.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.numbers", roundedValue),
|
||||
x,
|
||||
y + 10,
|
||||
0x000000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -75,7 +76,7 @@ public class GUIPlayerDetector extends GuiContainer {
|
||||
public void drawScreen(int x, int y, float partialTicks) {
|
||||
super.drawScreen(x, y, partialTicks);
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
lines.add("Camouflage");
|
||||
lines.add(StatCollector.translateToLocal("gui.de.playerDetector.camouflage"));
|
||||
if ((x - guiLeft > 142 && x - guiLeft < 160) && (y - guiTop > 19 && y - guiTop < 37)
|
||||
&& container.shouldShowInventory()) {
|
||||
drawHoveringText(lines, x, y, fontRendererObj);
|
||||
@@ -88,15 +89,30 @@ public class GUIPlayerDetector extends GuiContainer {
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
if (!isInEditMode) {
|
||||
String mode = isInWhitelistMode ? "White List" : "Black List";
|
||||
String mode = isInWhitelistMode ? StatCollector.translateToLocal("gui.de.playerDetector.whiteList")
|
||||
: StatCollector.translateToLocal("gui.de.playerDetector.blackList");
|
||||
int center = width / 2;
|
||||
buttonList.add(new GuiButton(0, center - 20 - 20, guiTop + 20, 20, 20, "+"));
|
||||
buttonList.add(new GuiButton(1, center + 20, guiTop + 20, 20, 20, "-"));
|
||||
buttonList.add(new GuiButton(3, center - 40, guiTop + 45, 60, 20, mode));
|
||||
buttonList.add(new GuiButton(4, center + 20, guiTop + 45, 20, 20, "!"));
|
||||
buttonList.add(new GuiButton(6, center - 40, guiTop + 70, 80, 20, "Invert Output"));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
6,
|
||||
center - 40,
|
||||
guiTop + 70,
|
||||
80,
|
||||
20,
|
||||
StatCollector.translateToLocal("gui.de.playerDetector.invertOutput")));
|
||||
} else {
|
||||
buttonList.add(new GuiButton(5, guiLeft - 40, guiTop + ySize - 20, 40, 20, "Back"));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
5,
|
||||
guiLeft - 40,
|
||||
guiTop + ySize - 20,
|
||||
40,
|
||||
20,
|
||||
StatCollector.translateToLocal("gui.de.playerDetector.back")));
|
||||
}
|
||||
|
||||
selectedNameText = new GuiTextField(fontRendererObj, 4, -12, 168, 12);
|
||||
@@ -186,7 +202,12 @@ public class GUIPlayerDetector extends GuiContainer {
|
||||
private void drawGuiText() {
|
||||
if (isInEditMode) {
|
||||
if (selectedMameIndex != -1) {
|
||||
drawCenteredString(fontRendererObj, "Press Enter to save", xSize / 2, -22, 0xFF0000);
|
||||
drawCenteredString(
|
||||
fontRendererObj,
|
||||
StatCollector.translateToLocal("gui.de.playerDetector.pressEnter"),
|
||||
xSize / 2,
|
||||
-22,
|
||||
0xFF0000);
|
||||
}
|
||||
for (int row = 0; row < 21; row++) {
|
||||
for (int column = 0; column < 2; column++) {
|
||||
@@ -200,11 +221,31 @@ public class GUIPlayerDetector extends GuiContainer {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
drawCenteredString(fontRendererObj, "Advanced Player Detector", xSize / 2, 5, 0x00FFFF);
|
||||
drawCenteredString(
|
||||
fontRendererObj,
|
||||
StatCollector.translateToLocal("gui.de.playerDetector.main.title"),
|
||||
xSize / 2,
|
||||
5,
|
||||
0x00FFFF);
|
||||
|
||||
fontRendererObj.drawString("Range:", 73, 21, 0x000000, false);
|
||||
fontRendererObj.drawString("Output Inverted: " + isOutputInverted, 33, 97, 0x000000, false);
|
||||
fontRendererObj.drawString(String.valueOf(range), range < 10 ? 85 : 82, 31, 0x000000, false);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("gui.de.playerDetector.range") + ":",
|
||||
73,
|
||||
21,
|
||||
0x000000,
|
||||
false);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.playerDetector.outputInvert", isOutputInverted),
|
||||
33,
|
||||
97,
|
||||
0x000000,
|
||||
false);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.numbers", range),
|
||||
range < 10 ? 85 : 82,
|
||||
31,
|
||||
0x000000,
|
||||
false);
|
||||
}
|
||||
selectedNameText.drawTextBox();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,12 @@ public class GUIUpgradeModifier extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
drawCenteredString(fontRendererObj, tile.getBlockType().getLocalizedName(), xSize / 2, -9, 0x00FFFF);
|
||||
drawCenteredString(
|
||||
fontRendererObj,
|
||||
StatCollector.translateToLocal("gui.de.upgradeModifier.main.title"),
|
||||
xSize / 2,
|
||||
-9,
|
||||
0x00FFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,13 +243,25 @@ public class GUIUpgradeModifier extends GuiContainer {
|
||||
0x00ff00);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("gui.de.cap.txt"), guiLeft + 4, guiTop + 16, 0x000000);
|
||||
fontRendererObj.drawString(">" + coreSlots, guiLeft + 4, guiTop + 25, 0x000000);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.numbers", ">" + coreSlots),
|
||||
guiLeft + 4,
|
||||
guiTop + 25,
|
||||
0x000000);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("gui.de.installed.txt"), guiLeft + 4, guiTop + 37, 0x000000);
|
||||
fontRendererObj.drawString(">" + usedSlots, guiLeft + 4, guiTop + 46, 0x000000);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.numbers", ">" + usedSlots),
|
||||
guiLeft + 4,
|
||||
guiTop + 46,
|
||||
0x000000);
|
||||
fontRendererObj
|
||||
.drawString(StatCollector.translateToLocal("gui.de.free.txt"), guiLeft + 4, guiTop + 58, 0x000000);
|
||||
fontRendererObj.drawString(">" + (coreSlots - usedSlots), guiLeft + 4, guiTop + 67, 0x000000);
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocalFormatted("gui.de.numbers", ">" + (coreSlots - usedSlots)),
|
||||
guiLeft + 4,
|
||||
guiTop + 67,
|
||||
0x000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -53,23 +54,32 @@ public class GUIWeatherController extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("gui.de.charges") + ": " + charges, 90, 25, 0x000000);
|
||||
// drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000);
|
||||
drawCenteredString(fontRendererObj, "Weather Controller", xSize / 2, -15, 0x2a4ed0);
|
||||
drawCenteredString(
|
||||
fontRendererObj,
|
||||
StatCollector.translateToLocal("gui.de.weatherController.main.title"),
|
||||
xSize / 2,
|
||||
-15,
|
||||
0x2a4ed0);
|
||||
}
|
||||
|
||||
public static final String RAIN_ON_TEXT = "Turn rain on";
|
||||
public static final String RAIN_OFF_TEXT = "Turn rain off";
|
||||
public static final String STORM_TEXT = "Thunder Storm";
|
||||
public static final String RAIN_ON_TEXT = "gui.de.rain.on";
|
||||
public static final String RAIN_OFF_TEXT = "gui.de.rain.off";
|
||||
public static final String STORM_TEXT = "gui.de.rain.storm";
|
||||
public static String text;
|
||||
|
||||
private String getModeText(int mode) {
|
||||
if (mode == 0) return StatCollector.translateToLocal(RAIN_OFF_TEXT);
|
||||
else if (mode == 1) return StatCollector.translateToLocal(RAIN_ON_TEXT);
|
||||
else return StatCollector.translateToLocal(STORM_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
buttonList.clear();
|
||||
if (tileWC.mode == 0) text = RAIN_OFF_TEXT;
|
||||
else if (tileWC.mode == 1) text = RAIN_ON_TEXT;
|
||||
else text = STORM_TEXT;
|
||||
text = getModeText(tileWC.mode);
|
||||
// ID
|
||||
buttonList.add(new GuiButton(0, guiLeft + 85, guiTop, 85, 20, text));
|
||||
}
|
||||
@@ -78,9 +88,8 @@ public class GUIWeatherController extends GuiContainer {
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
if (button.id == 0) {
|
||||
DraconicEvolution.network.sendToServer(new ButtonPacket((byte) 0, true));
|
||||
if (button.displayString.equals(STORM_TEXT)) button.displayString = RAIN_OFF_TEXT;
|
||||
else if (button.displayString.equals(RAIN_OFF_TEXT)) button.displayString = RAIN_ON_TEXT;
|
||||
else button.displayString = STORM_TEXT;
|
||||
tileWC.mode = (tileWC.mode + 1) % 3;
|
||||
button.displayString = getModeText(tileWC.mode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.brandon3055.draconicevolution.client.utils.guicomponents.GUIBase;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerAdvTool;
|
||||
import com.brandon3055.draconicevolution.common.handler.ContributorHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.BowHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.IEnergyContainerBowItem;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.network.ContributorPacket;
|
||||
import com.brandon3055.draconicevolution.common.network.ItemConfigPacket;
|
||||
@@ -310,11 +311,11 @@ public class GUIToolConfig extends GUIBase {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
||||
if (slot > -1) editingItem = player.inventory.getStackInSlot(slot);
|
||||
if (slot > -1 && editingItem != null && editingItem.getUnlocalizedName().toLowerCase().contains("bow")) {
|
||||
if (slot > -1 && editingItem != null && editingItem.getItem() instanceof IEnergyContainerBowItem) {
|
||||
BowHandler.BowProperties properties = new BowHandler.BowProperties(editingItem, player);
|
||||
|
||||
if (!properties.canFire() && properties.cantFireMessage != null
|
||||
&& !properties.cantFireMessage.equals("msg.de.outOfArrows.name")) {
|
||||
&& !properties.cantFireMessage.equals("msg.de.outOfArrows.txt")) {
|
||||
fontRendererObj.drawSplitString(
|
||||
StatCollector.translateToLocal(properties.cantFireMessage),
|
||||
0,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.brandon3055.draconicevolution.client.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -10,124 +7,71 @@ import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.handler.ContributorHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.ArmorSummary;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.DraconicArmor;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.WyvernArmor;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.BowHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.DraconicBow;
|
||||
import com.brandon3055.draconicevolution.common.items.weapons.WyvernBow;
|
||||
import com.brandon3055.draconicevolution.common.network.MountUpdatePacket;
|
||||
import com.brandon3055.draconicevolution.common.utils.DataUtils;
|
||||
import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 28/10/2014.
|
||||
*/
|
||||
public class ClientEventHandler {
|
||||
public final class ClientEventHandler {
|
||||
|
||||
public static Map<EntityPlayer, DataUtils.XZPair<Float, Integer>> playerShieldStatus = new HashMap<>();
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
public static int elapsedTicks;
|
||||
private static float previousFOB = 0f;
|
||||
public static float previousSensitivity = 0;
|
||||
public static boolean bowZoom = false;
|
||||
public static boolean lastTickBowZoom = false;
|
||||
public static int tickSet = 0;
|
||||
public static ItemDisplayManager statusDisplayManager = new ItemDisplayManager(60);
|
||||
private static int remountTicksRemaining = 0;
|
||||
private static int remountEntityID = 0;
|
||||
public static float energyCrystalAlphaValue = 0f;
|
||||
public static float energyCrystalAlphaTarget = 0f;
|
||||
public static boolean playerHoldingWrench = false;
|
||||
public static Minecraft mc;
|
||||
private static Random rand = new Random();
|
||||
private static IModelCustom shieldSphere;
|
||||
|
||||
public ClientEventHandler() {
|
||||
shieldSphere = AdvancedModelLoader.loadModel(ResourceHandler.getResource("models/shieldSphere.obj"));
|
||||
}
|
||||
private int elapsedTicks;
|
||||
private int remountTicksRemaining = 0;
|
||||
private int remountEntityID = 0;
|
||||
private float energyCrystalAlphaValue = 0f;
|
||||
private float energyCrystalAlphaTarget = 0f;
|
||||
|
||||
@SubscribeEvent
|
||||
public void tickEnd(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START || event.type != TickEvent.Type.CLIENT || event.side != Side.CLIENT)
|
||||
if (event.phase != TickEvent.Phase.START) {
|
||||
return;
|
||||
|
||||
for (Iterator<Map.Entry<EntityPlayer, DataUtils.XZPair<Float, Integer>>> i = playerShieldStatus.entrySet()
|
||||
.iterator(); i.hasNext();) {
|
||||
Map.Entry<EntityPlayer, DataUtils.XZPair<Float, Integer>> entry = i.next();
|
||||
if (elapsedTicks - entry.getValue().getValue() > 5) i.remove();
|
||||
}
|
||||
|
||||
if (mc == null) mc = Minecraft.getMinecraft();
|
||||
else if (mc.theWorld != null) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.theWorld != null) {
|
||||
elapsedTicks++;
|
||||
HudHandler.clientTick();
|
||||
|
||||
if (bowZoom && !lastTickBowZoom) {
|
||||
previousSensitivity = Minecraft.getMinecraft().gameSettings.mouseSensitivity;
|
||||
Minecraft.getMinecraft().gameSettings.mouseSensitivity = previousSensitivity / 3;
|
||||
} else if (!bowZoom && lastTickBowZoom) {
|
||||
Minecraft.getMinecraft().gameSettings.mouseSensitivity = previousSensitivity;
|
||||
}
|
||||
|
||||
lastTickBowZoom = bowZoom;
|
||||
if (elapsedTicks - tickSet > 10) bowZoom = false;
|
||||
|
||||
if (energyCrystalAlphaValue < energyCrystalAlphaTarget) energyCrystalAlphaValue += 0.01f;
|
||||
if (energyCrystalAlphaValue > energyCrystalAlphaTarget) energyCrystalAlphaValue -= 0.01f;
|
||||
|
||||
if (Math.abs(energyCrystalAlphaTarget - energyCrystalAlphaValue) <= 0.02f)
|
||||
energyCrystalAlphaTarget = rand.nextFloat();
|
||||
|
||||
playerHoldingWrench = mc.thePlayer.getHeldItem() != null
|
||||
&& mc.thePlayer.getHeldItem().getItem() == ModItems.wrench;
|
||||
if (Math.abs(energyCrystalAlphaTarget - energyCrystalAlphaValue) <= 0.02f) {
|
||||
energyCrystalAlphaTarget = RANDOM.nextFloat();
|
||||
}
|
||||
|
||||
searchForPlayerMount();
|
||||
}
|
||||
|
||||
statusDisplayManager.tick();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderGameOverlayEvent(final RenderGameOverlayEvent.Post event) {
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
|
||||
statusDisplayManager.drawItemStack(event.resolution);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void fovUpdate(FOVUpdateEvent event) {
|
||||
|
||||
// region Bow FOV Update
|
||||
if (event.entity.getHeldItem() != null
|
||||
&& (event.entity.getHeldItem().getItem() instanceof WyvernBow
|
||||
|| event.entity.getHeldItem().getItem() instanceof DraconicBow)
|
||||
final ItemStack heldItem = event.entity.getHeldItem();
|
||||
if (heldItem != null && (heldItem.getItem() instanceof WyvernBow || heldItem.getItem() instanceof DraconicBow)
|
||||
&& Minecraft.getMinecraft().gameSettings.keyBindUseItem.getIsKeyPressed()) {
|
||||
|
||||
BowHandler.BowProperties properties = new BowHandler.BowProperties(
|
||||
event.entity.getHeldItem(),
|
||||
event.entity);
|
||||
BowHandler.BowProperties properties = new BowHandler.BowProperties(heldItem, event.entity);
|
||||
|
||||
event.newfov = ((6 - properties.zoomModifier) / 6) * event.fov;
|
||||
|
||||
@@ -142,9 +86,9 @@ public class ClientEventHandler {
|
||||
// endregion
|
||||
|
||||
// region Armor move speed FOV effect cancellation
|
||||
CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.entity);
|
||||
final ArmorSummary summary = ArmorSummary.get(event.entity);
|
||||
|
||||
if (summery != null && summery.speedModifier > 0) {
|
||||
if (summary != null && summary.speedModifier > 0) {
|
||||
IAttributeInstance iattributeinstance = event.entity
|
||||
.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
|
||||
float f = (float) ((iattributeinstance.getAttributeValue()
|
||||
@@ -172,7 +116,7 @@ public class ClientEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void tryRepositionPlayerOnMount(int id) {
|
||||
public void tryRepositionPlayerOnMount(int id) {
|
||||
if (remountTicksRemaining == 500) return;
|
||||
remountTicksRemaining = 500;
|
||||
remountEntityID = id;
|
||||
@@ -186,7 +130,7 @@ public class ClientEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderArmorEvent(RenderPlayerEvent.SetArmorModel event) {
|
||||
if (ConfigHandler.useOriginal3DArmorModel || ConfigHandler.useOldArmorModel || event.isCanceled()) return;
|
||||
if (ConfigHandler.useOriginal3DArmorModel || ConfigHandler.useOldArmorModel) return;
|
||||
if (event.stack != null
|
||||
&& (event.stack.getItem() instanceof DraconicArmor || event.stack.getItem() instanceof WyvernArmor)) {
|
||||
ItemArmor itemarmor = (ItemArmor) event.stack.getItem();
|
||||
@@ -199,52 +143,11 @@ public class ClientEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderPlayerEvent(RenderPlayerEvent.Post event) {
|
||||
if (playerShieldStatus.containsKey(event.entityPlayer)) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
ResourceHandler.bindResource("textures/models/shieldSphere.png");
|
||||
public int getElapsedTicks() {
|
||||
return elapsedTicks;
|
||||
}
|
||||
|
||||
float p = playerShieldStatus.get(event.entityPlayer).getKey();
|
||||
|
||||
EntityPlayer viewingPlayer = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
int i = 5 - (elapsedTicks - playerShieldStatus.get(event.entityPlayer).getValue());
|
||||
|
||||
GL11.glColor4f(1F - p, 0F, p, i / 5F);
|
||||
|
||||
if (viewingPlayer != event.entityPlayer) {
|
||||
double translationXLT = event.entityPlayer.prevPosX - viewingPlayer.prevPosX;
|
||||
double translationYLT = event.entityPlayer.prevPosY - viewingPlayer.prevPosY;
|
||||
double translationZLT = event.entityPlayer.prevPosZ - viewingPlayer.prevPosZ;
|
||||
|
||||
double translationX = translationXLT
|
||||
+ (((event.entityPlayer.posX - viewingPlayer.posX) - translationXLT) * event.partialRenderTick);
|
||||
double translationY = translationYLT
|
||||
+ (((event.entityPlayer.posY - viewingPlayer.posY) - translationYLT) * event.partialRenderTick);
|
||||
double translationZ = translationZLT
|
||||
+ (((event.entityPlayer.posZ - viewingPlayer.posZ) - translationZLT) * event.partialRenderTick);
|
||||
|
||||
GL11.glTranslated(translationX, translationY + 1.1, translationZ);
|
||||
} else {
|
||||
GL11.glTranslated(0, -0.5, 0);
|
||||
}
|
||||
|
||||
GL11.glScaled(1, 1.5, 1);
|
||||
|
||||
shieldSphere.renderAll();
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
public float getEnergyCrystalAlpha() {
|
||||
return energyCrystalAlphaValue;
|
||||
}
|
||||
}
|
||||
@@ -19,45 +19,41 @@ import org.lwjgl.opengl.GL11;
|
||||
import com.brandon3055.draconicevolution.client.gui.GuiHudConfig;
|
||||
import com.brandon3055.draconicevolution.client.utils.GuiHelper;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.ArmorSummary;
|
||||
import com.brandon3055.draconicevolution.common.utils.IHudDisplayBlock;
|
||||
import com.brandon3055.draconicevolution.common.utils.IHudDisplayItem;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 26/01/2015.
|
||||
*/
|
||||
public class HudHandler {
|
||||
public final class HudHandler {
|
||||
|
||||
private static List<String> hudList = null;
|
||||
private static List<String> ltHudList = null;
|
||||
private static float toolTipFadeOut = 0F;
|
||||
private static float armorStatsFadeOut = 0F;
|
||||
private static boolean showShieldHud = false;
|
||||
private static int shieldPercentCharge = 0;
|
||||
private static float shieldPoints = 0F;
|
||||
private static float maxShieldPoints = 0F;
|
||||
private static float shieldEntropy = 0F;
|
||||
private static int rfCharge = 0;
|
||||
private static long rfTotal = 0;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
private List<String> hudList = null;
|
||||
private List<String> ltHudList = null;
|
||||
private float toolTipFadeOut = 0F;
|
||||
private float armorStatsFadeOut = 0F;
|
||||
private boolean showShieldHud = false;
|
||||
private int shieldPercentCharge = 0;
|
||||
private float shieldPoints = 0F;
|
||||
private float maxShieldPoints = 0F;
|
||||
private float shieldEntropy = 0F;
|
||||
private int rfCharge = 0;
|
||||
private long rfTotal = 0;
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void drawHUD(RenderGameOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (event.type != RenderGameOverlayEvent.ElementType.ALL || mc.gameSettings.showDebugInfo
|
||||
|| mc.currentScreen instanceof GuiChat)
|
||||
|| mc.currentScreen instanceof GuiChat) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScaledResolution resolution = event.resolution;
|
||||
width = resolution.getScaledWidth();
|
||||
height = resolution.getScaledHeight();
|
||||
final int width = resolution.getScaledWidth();
|
||||
final int height = resolution.getScaledHeight();
|
||||
FontRenderer fontRenderer = mc.fontRenderer;
|
||||
|
||||
if (ConfigHandler.hudSettings[10] == 1 && hudList != null && toolTipFadeOut > 0) {
|
||||
@@ -86,13 +82,20 @@ public class HudHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// x, y, x, y, scale, scale, fademode, fademode, rotateArmor, armorText
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void clientTick() {
|
||||
@SubscribeEvent
|
||||
public void tickEnd(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().theWorld != null) {
|
||||
this.clientTick();
|
||||
}
|
||||
}
|
||||
|
||||
private void clientTick() {
|
||||
if (ConfigHandler.hudSettings[6] > 0 && toolTipFadeOut > 1F - ((float) ConfigHandler.hudSettings[6] * 0.25F)) {
|
||||
toolTipFadeOut -= 0.1F;
|
||||
}
|
||||
if (hudList != null && (ltHudList == null || !hudList.equals(ltHudList))) toolTipFadeOut = 5F;
|
||||
if (hudList != null && !hudList.equals(ltHudList)) {
|
||||
toolTipFadeOut = 5F;
|
||||
}
|
||||
if (ConfigHandler.hudSettings[7] > 0
|
||||
&& armorStatsFadeOut > 1F - ((float) ConfigHandler.hudSettings[7] * 0.25F)) {
|
||||
armorStatsFadeOut -= 0.1F;
|
||||
@@ -108,7 +111,7 @@ public class HudHandler {
|
||||
|
||||
if (mc.currentScreen != null) {
|
||||
if (mc.currentScreen instanceof GuiHudConfig) {
|
||||
hudList = new ArrayList<String>();
|
||||
hudList = new ArrayList<>();
|
||||
hudList.add(StatCollector.translateToLocal("info.de.hudDisplayConfigTxt1.txt"));
|
||||
hudList.add("");
|
||||
hudList.add("");
|
||||
@@ -130,26 +133,41 @@ public class HudHandler {
|
||||
.getDisplayData(mc.theWorld, mop.blockX, mop.blockY, mop.blockZ);
|
||||
}
|
||||
|
||||
CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(mc.thePlayer);
|
||||
final ArmorSummary summary = ArmorSummary.get(mc.thePlayer);
|
||||
|
||||
if (summery == null) {
|
||||
if (summary == null) {
|
||||
showShieldHud = false;
|
||||
return;
|
||||
}
|
||||
if (!shouldDisplayArmorHud(summary)) {
|
||||
showShieldHud = false;
|
||||
armorStatsFadeOut = 0F;
|
||||
maxShieldPoints = 0F;
|
||||
shieldPoints = 0F;
|
||||
shieldPercentCharge = 0;
|
||||
shieldEntropy = 0F;
|
||||
rfCharge = 0;
|
||||
rfTotal = 0;
|
||||
return;
|
||||
}
|
||||
showShieldHud = armorStatsFadeOut > 0F;
|
||||
|
||||
if (maxShieldPoints != summery.maxProtectionPoints || shieldPoints != summery.protectionPoints
|
||||
|| shieldEntropy != summery.entropy
|
||||
|| rfTotal != summery.totalEnergyStored)
|
||||
if (maxShieldPoints != summary.maxProtectionPoints || shieldPoints != summary.protectionPoints
|
||||
|| shieldEntropy != summary.entropy
|
||||
|| rfTotal != summary.totalEnergyStored)
|
||||
armorStatsFadeOut = 5F;
|
||||
|
||||
maxShieldPoints = summery.maxProtectionPoints;
|
||||
shieldPoints = summery.protectionPoints;
|
||||
shieldPercentCharge = (int) (summery.protectionPoints / summery.maxProtectionPoints * 100D);
|
||||
shieldEntropy = summery.entropy;
|
||||
rfCharge = (int) ((double) summery.totalEnergyStored / Math.max((double) summery.maxTotalEnergyStorage, 1D)
|
||||
maxShieldPoints = summary.maxProtectionPoints;
|
||||
shieldPoints = summary.protectionPoints;
|
||||
shieldPercentCharge = (int) (summary.protectionPoints / summary.maxProtectionPoints * 100D);
|
||||
shieldEntropy = summary.entropy;
|
||||
rfCharge = (int) ((double) summary.totalEnergyStored / Math.max((double) summary.maxTotalEnergyStorage, 1D)
|
||||
* 100D);
|
||||
rfTotal = summery.totalEnergyStored;
|
||||
rfTotal = summary.totalEnergyStored;
|
||||
}
|
||||
|
||||
private boolean shouldDisplayArmorHud(ArmorSummary summary) {
|
||||
return summary.maxProtectionPoints > 0F || summary.maxTotalEnergyStorage > 0;
|
||||
}
|
||||
|
||||
private void drawArmorHUD(int x, int y, boolean rotated, double scale) {
|
||||
|
||||
@@ -2,54 +2,64 @@ package com.brandon3055.draconicevolution.client.handler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
|
||||
public final class ItemDisplayManager {
|
||||
|
||||
private static final RenderItem renderItem = new RenderItem();
|
||||
private static final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
private static final TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
|
||||
private final int ticks;
|
||||
private ItemStack itemStack;
|
||||
private int ticksCounter;
|
||||
private static final RenderItem renderItem = new RenderItem();
|
||||
private static final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
private static final TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
|
||||
public ItemDisplayManager(int ticks) {
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
public void startDrawing(ItemStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
this.itemStack = itemStack == null ? null : itemStack.copy();
|
||||
ticksCounter = ticks;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (--ticksCounter == 0) {
|
||||
itemStack = null;
|
||||
@SubscribeEvent
|
||||
public void tickEnd(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if (--ticksCounter == 0) {
|
||||
itemStack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawItemStack(ScaledResolution resolution) {
|
||||
if (ticksCounter > 0 && itemStack != null && itemStack.getItem() != null) {
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
@SubscribeEvent
|
||||
public void renderGameOverlayEvent(RenderGameOverlayEvent.Post event) {
|
||||
if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
|
||||
if (ticksCounter > 0 && itemStack != null && itemStack.getItem() != null) {
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
final int y = resolution.getScaledHeight();
|
||||
GL11.glTranslatef(7.0f, y * 0.25f, 0);
|
||||
renderItem.renderItemAndEffectIntoGUI(fontRenderer, textureManager, itemStack, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPushMatrix();
|
||||
final int y = event.resolution.getScaledHeight();
|
||||
GL11.glTranslatef(7.0f, y * 0.25f, 0);
|
||||
renderItem.renderItemAndEffectIntoGUI(fontRenderer, textureManager, itemStack, 0, 0);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.brandon3055.draconicevolution.client.handler;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleDistortion;
|
||||
|
||||
@@ -10,16 +9,14 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ParticleHandler {
|
||||
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
private static World theWorld = mc.theWorld;
|
||||
public final class ParticleHandler {
|
||||
|
||||
public static EntityFX spawnParticle(String particleName, double x, double y, double z, double motionX,
|
||||
double motionY, double motionZ, float scale) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) {
|
||||
int var14 = mc.gameSettings.particleSetting;
|
||||
if (var14 == 1 && theWorld.rand.nextInt(3) == 0) {
|
||||
if (var14 == 1 && mc.theWorld.rand.nextInt(3) == 0) {
|
||||
var14 = 2;
|
||||
}
|
||||
double var15 = mc.renderViewEntity.posX - x;
|
||||
@@ -34,7 +31,7 @@ public class ParticleHandler {
|
||||
} else {
|
||||
if (particleName.equals("distortionParticle")) {
|
||||
var21 = new ParticleDistortion(
|
||||
theWorld,
|
||||
mc.theWorld,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
@@ -56,9 +53,10 @@ public class ParticleHandler {
|
||||
}
|
||||
|
||||
public static EntityFX spawnCustomParticle(EntityFX particle, double vewRange) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) {
|
||||
int var14 = mc.gameSettings.particleSetting;
|
||||
if (var14 == 1 && theWorld.rand.nextInt(3) == 0) {
|
||||
if (var14 == 1 && mc.theWorld.rand.nextInt(3) == 0) {
|
||||
var14 = 2;
|
||||
}
|
||||
if (!isInRange(particle.posX, particle.posY, particle.posZ, vewRange)) {
|
||||
@@ -74,14 +72,12 @@ public class ParticleHandler {
|
||||
}
|
||||
|
||||
public static boolean isInRange(double x, double y, double z, double vewRange) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc == null || mc.renderViewEntity == null || mc.effectRenderer == null) return false;
|
||||
|
||||
double var15 = mc.renderViewEntity.posX - x;
|
||||
double var17 = mc.renderViewEntity.posY - y;
|
||||
double var19 = mc.renderViewEntity.posZ - z;
|
||||
if (var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !(var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class ResourceHandler {
|
||||
private static ResourceLocation particles = new ResourceLocation(
|
||||
References.RESOURCESPREFIX + "textures/particle/particles.png");
|
||||
private static Map<String, ResourceLocation> cachedResources = new HashMap<String, ResourceLocation>();
|
||||
public static Map<String, CustomResourceLocation> downloadedImages = new HashMap<String, CustomResourceLocation>();
|
||||
public static Map<String, CustomResourceLocation> downloadedImages = new ConcurrentHashMap<>();
|
||||
|
||||
private static String savePath;
|
||||
private static File saveFolder;
|
||||
@@ -64,7 +65,6 @@ public class ResourceHandler {
|
||||
if (downloadThread.isReloadRequired()) LogHelper.info("Image Download Finished");
|
||||
downloadStatus = downloadThread.wasSuccessful ? 1 : 2;
|
||||
FMLCommonHandler.instance().bus().unregister(this);
|
||||
addRSPack(event != null);
|
||||
downloadThread = null;
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,10 @@ public class ResourceHandler {
|
||||
|
||||
if (event != null) savePath = event.getModConfigurationDirectory().getParentFile().getAbsolutePath()
|
||||
+ "/config/draconicevolution";
|
||||
|
||||
// Register the namespace before FML's final reload; folder-pack files are resolved on demand.
|
||||
getImagesFolder();
|
||||
addRSPack();
|
||||
GUIManual.loadPages();
|
||||
|
||||
downloadThread = new DownloadThread(GUIManual.imageURLs);
|
||||
@@ -83,7 +87,7 @@ public class ResourceHandler {
|
||||
public static class DownloadThread extends Thread {
|
||||
|
||||
private List<String> imageURLs;
|
||||
private boolean isFinished = false;
|
||||
private volatile boolean isFinished = false;
|
||||
private boolean wasSuccessful = true;
|
||||
private boolean reloadRequired = false;
|
||||
|
||||
@@ -171,7 +175,7 @@ public class ResourceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addRSPack(boolean refreash) {
|
||||
private static void addRSPack() {
|
||||
File rspack = new File(getConfigFolder(), "/resources");
|
||||
if (!rspack.exists()) return;
|
||||
|
||||
@@ -200,7 +204,6 @@ public class ResourceHandler {
|
||||
|
||||
f.set(Minecraft.getMinecraft(), defaultResourcePacks);
|
||||
LogHelper.info("RS Added");
|
||||
if (refreash) Minecraft.getMinecraft().refreshResources();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.brandon3055.draconicevolution.client.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.utils.DataUtils;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public final class ShieldRenderHandler {
|
||||
|
||||
private static final IModelCustom SHIELD_SPHERE = AdvancedModelLoader
|
||||
.loadModel(ResourceHandler.getResource("models/shieldSphere.obj"));
|
||||
|
||||
private final HashMap<EntityPlayer, DataUtils.XZPair<Float, Integer>> shieldStatus = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
if (event.world.isRemote) {
|
||||
this.shieldStatus.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void tickEnd(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END && !shieldStatus.isEmpty()) {
|
||||
final int ticks = DraconicEvolution.clientProxy().getElapsedTicks();
|
||||
shieldStatus.entrySet().removeIf(entry -> ticks - entry.getValue().getValue() > 5);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void renderPlayerEvent(RenderPlayerEvent.Post event) {
|
||||
final DataUtils.XZPair<Float, Integer> pair = shieldStatus.get(event.entityPlayer);
|
||||
if (pair != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
ResourceHandler.bindResource("textures/models/shieldSphere.png");
|
||||
|
||||
final float p = pair.getKey();
|
||||
final EntityPlayer viewingPlayer = Minecraft.getMinecraft().thePlayer;
|
||||
final int ticks = DraconicEvolution.clientProxy().getElapsedTicks();
|
||||
final int i = 5 - (ticks - pair.getValue());
|
||||
|
||||
GL11.glColor4f(1F - p, 0F, p, i / 5F);
|
||||
|
||||
if (viewingPlayer != event.entityPlayer) {
|
||||
double translationXLT = event.entityPlayer.prevPosX - viewingPlayer.prevPosX;
|
||||
double translationYLT = event.entityPlayer.prevPosY - viewingPlayer.prevPosY;
|
||||
double translationZLT = event.entityPlayer.prevPosZ - viewingPlayer.prevPosZ;
|
||||
|
||||
double translationX = translationXLT
|
||||
+ (((event.entityPlayer.posX - viewingPlayer.posX) - translationXLT) * event.partialRenderTick);
|
||||
double translationY = translationYLT
|
||||
+ (((event.entityPlayer.posY - viewingPlayer.posY) - translationYLT) * event.partialRenderTick);
|
||||
double translationZ = translationZLT
|
||||
+ (((event.entityPlayer.posZ - viewingPlayer.posZ) - translationZLT) * event.partialRenderTick);
|
||||
|
||||
GL11.glTranslated(translationX, translationY + 1.1, translationZ);
|
||||
} else {
|
||||
GL11.glTranslated(0, -0.5, 0);
|
||||
}
|
||||
|
||||
GL11.glScaled(1, 1.5, 1);
|
||||
|
||||
SHIELD_SPHERE.renderAll();
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderShield(EntityPlayer player, float shieldPowerF) {
|
||||
final int ticks = DraconicEvolution.clientProxy().getElapsedTicks();
|
||||
this.shieldStatus.put(player, new DataUtils.XZPair<>(shieldPowerF, ticks));
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.brandon3055.draconicevolution.client.keybinding;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.integration.ModHelper;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 14/08/2014.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final class KeyBindings {
|
||||
|
||||
public static final KeyBinding placeItem;
|
||||
public static final KeyBinding toolConfig;
|
||||
public static final KeyBinding toolProfileChange;
|
||||
public static final KeyBinding toggleFlight;
|
||||
public static final KeyBinding toggleMagnet;
|
||||
public static KeyBinding toggleMagnetSelfPickup;
|
||||
|
||||
static {
|
||||
placeItem = new KeyBinding("key.placeItem", Keyboard.KEY_V, References.MODNAME);
|
||||
toolConfig = new KeyBinding("key.toolConfig", Keyboard.KEY_NONE, References.MODNAME);
|
||||
toolProfileChange = new KeyBinding("key.toolProfileChange", Keyboard.KEY_NONE, References.MODNAME);
|
||||
toggleFlight = new KeyBinding("key.toggleFlight", Keyboard.KEY_NONE, References.MODNAME);
|
||||
toggleMagnet = new KeyBinding("key.toggleMagnet", Keyboard.KEY_NONE, References.MODNAME);
|
||||
if (ModHelper.isHodgepodgeLoaded) toggleMagnetSelfPickup = new KeyBinding(
|
||||
"key.toggleMagnetSelfPickup",
|
||||
Keyboard.KEY_NONE,
|
||||
References.MODNAME);
|
||||
}
|
||||
|
||||
private KeyBindings() {}
|
||||
|
||||
public static void init() {
|
||||
ClientRegistry.registerKeyBinding(placeItem);
|
||||
ClientRegistry.registerKeyBinding(toolConfig);
|
||||
ClientRegistry.registerKeyBinding(toolProfileChange);
|
||||
ClientRegistry.registerKeyBinding(toggleFlight);
|
||||
ClientRegistry.registerKeyBinding(toggleMagnet);
|
||||
if (ModHelper.isHodgepodgeLoaded) ClientRegistry.registerKeyBinding(toggleMagnetSelfPickup);
|
||||
}
|
||||
}
|
||||
@@ -8,15 +8,18 @@ import javax.annotation.Nonnull;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.Magnet;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.network.ButtonPacket;
|
||||
import com.brandon3055.draconicevolution.common.network.MagnetTogglePacket;
|
||||
import com.brandon3055.draconicevolution.common.network.MagnetToggleSelfPickupPacket;
|
||||
@@ -27,6 +30,7 @@ import com.brandon3055.draconicevolution.common.utils.InventoryUtils;
|
||||
import com.brandon3055.draconicevolution.common.utils.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.integration.ModHelper;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -35,24 +39,56 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
/**
|
||||
* Created by Brandon on 14/08/2014.
|
||||
*/
|
||||
public class KeyInputHandler {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final class KeyInputHandler {
|
||||
|
||||
private final KeyBinding placeItem;
|
||||
private final KeyBinding toolConfig;
|
||||
private final KeyBinding toolProfileChange;
|
||||
private final KeyBinding toggleFlight;
|
||||
private final KeyBinding toggleMagnet;
|
||||
private final KeyBinding toggleMagnetSelfPickup;
|
||||
|
||||
public KeyInputHandler() {
|
||||
placeItem = new KeyBinding("key.placeItem", Keyboard.KEY_V, References.MODNAME);
|
||||
toolConfig = new KeyBinding("key.toolConfig", Keyboard.KEY_NONE, References.MODNAME);
|
||||
toolProfileChange = new KeyBinding("key.toolProfileChange", Keyboard.KEY_NONE, References.MODNAME);
|
||||
toggleFlight = new KeyBinding("key.toggleFlight", Keyboard.KEY_NONE, References.MODNAME);
|
||||
toggleMagnet = new KeyBinding("key.toggleMagnet", Keyboard.KEY_NONE, References.MODNAME);
|
||||
if (ModHelper.isHodgepodgeLoaded) {
|
||||
toggleMagnetSelfPickup = new KeyBinding(
|
||||
"key.toggleMagnetSelfPickup",
|
||||
Keyboard.KEY_NONE,
|
||||
References.MODNAME);
|
||||
} else {
|
||||
toggleMagnetSelfPickup = null;
|
||||
}
|
||||
ClientRegistry.registerKeyBinding(placeItem);
|
||||
ClientRegistry.registerKeyBinding(toolConfig);
|
||||
ClientRegistry.registerKeyBinding(toolProfileChange);
|
||||
ClientRegistry.registerKeyBinding(toggleFlight);
|
||||
ClientRegistry.registerKeyBinding(toggleMagnet);
|
||||
if (toggleMagnetSelfPickup != null) {
|
||||
ClientRegistry.registerKeyBinding(toggleMagnetSelfPickup);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if (KeyBindings.placeItem.isPressed()) {
|
||||
if (this.placeItem.isPressed()) {
|
||||
handlePlaceItemKey();
|
||||
} else if (KeyBindings.toolConfig.isPressed()) {
|
||||
} else if (this.toolConfig.isPressed()) {
|
||||
handleToolConfigKey();
|
||||
} else if (KeyBindings.toolProfileChange.isPressed() && player != null && player.getItemInUse() == null) {
|
||||
} else if (this.toolProfileChange.isPressed() && player != null && player.getItemInUse() == null) {
|
||||
handleToolProfileChangeKey(player);
|
||||
} else if (KeyBindings.toggleFlight.isPressed() && player != null) {
|
||||
} else if (this.toggleFlight.isPressed() && player != null) {
|
||||
handleToggleFlightKey(player);
|
||||
} else if (KeyBindings.toggleMagnet.isPressed()) {
|
||||
} else if (this.toggleMagnet.isPressed()) {
|
||||
handleToggleMagnetKey(player);
|
||||
} else if (ModHelper.isHodgepodgeLoaded && KeyBindings.toggleMagnetSelfPickup.isPressed()) {
|
||||
} else if (this.toggleMagnetSelfPickup != null && this.toggleMagnetSelfPickup.isPressed()) {
|
||||
handleToggleMagnetSelfPickup(player);
|
||||
}
|
||||
}
|
||||
@@ -62,17 +98,17 @@ public class KeyInputHandler {
|
||||
public void onMouseInput(InputEvent.MouseInputEvent event) {
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if (KeyBindings.placeItem.isPressed()) {
|
||||
if (this.placeItem.isPressed()) {
|
||||
handlePlaceItemKey();
|
||||
} else if (KeyBindings.toolConfig.isPressed()) {
|
||||
} else if (this.toolConfig.isPressed()) {
|
||||
handleToolConfigKey();
|
||||
} else if (KeyBindings.toolProfileChange.isPressed() && player != null) {
|
||||
} else if (this.toolProfileChange.isPressed() && player != null) {
|
||||
handleToolProfileChangeKey(player);
|
||||
} else if (KeyBindings.toggleFlight.isPressed() && player != null) {
|
||||
} else if (this.toggleFlight.isPressed() && player != null) {
|
||||
handleToggleFlightKey(player);
|
||||
} else if (KeyBindings.toggleMagnet.isPressed()) {
|
||||
} else if (this.toggleMagnet.isPressed()) {
|
||||
handleToggleMagnetKey(player);
|
||||
} else if (ModHelper.isHodgepodgeLoaded && KeyBindings.toggleMagnetSelfPickup.isPressed()) {
|
||||
} else if (this.toggleMagnetSelfPickup != null && this.toggleMagnetSelfPickup.isPressed()) {
|
||||
handleToggleMagnetSelfPickup(player);
|
||||
}
|
||||
|
||||
@@ -160,4 +196,8 @@ public class KeyInputHandler {
|
||||
if (c == 150 && i < 0) return 152;
|
||||
return c + i;
|
||||
}
|
||||
|
||||
public int toolConfigKeycode() {
|
||||
return this.toolConfig.getKeyCode();
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class ModelRenderOBJ extends ModelRenderer {
|
||||
this.compileDisplayList(scale);
|
||||
}
|
||||
|
||||
ResourceHandler.bindTexture(texture);
|
||||
GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ);
|
||||
|
||||
if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) {
|
||||
@@ -84,7 +85,6 @@ public class ModelRenderOBJ extends ModelRenderer {
|
||||
GL11.glNewList(this.displayList, GL11.GL_COMPILE);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
ResourceHandler.bindTexture(texture);
|
||||
// scale = 1F/15F;
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glRotatef(180, -1, 0, 1);
|
||||
@@ -102,6 +102,7 @@ public class ModelRenderOBJ extends ModelRenderer {
|
||||
this.compileDisplayList(scale);
|
||||
}
|
||||
|
||||
ResourceHandler.bindTexture(texture);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(this.rotationPointX * scale, this.rotationPointY * scale, this.rotationPointZ * scale);
|
||||
if (this.rotateAngleY != 0.0F) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.entity.Entity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
|
||||
/**
|
||||
* DragonWings - brandon3055 Created using Tabula 5.0.0
|
||||
@@ -70,7 +70,8 @@ public class ModelContributorWings extends ModelBase {
|
||||
float baseRot = 0.45906584F;
|
||||
float outerRot = 0.61086524F;
|
||||
|
||||
float animation = (float) Math.sin(((float) ClientEventHandler.elapsedTicks + partialTick) / 20);
|
||||
final int ticks = DraconicEvolution.clientProxy().getElapsedTicks();
|
||||
float animation = (float) Math.sin(((float) ticks + partialTick) / 20);
|
||||
|
||||
if (entity.isSneaking()) {
|
||||
this.leftBaseStem.rotateAngleX = 0.5F;
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityDragonHeart;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
@@ -27,10 +27,11 @@ public class RenderDragonHeart extends Render {
|
||||
|
||||
private void doRender(EntityDragonHeart entity, double x, double y, double z, float f) {
|
||||
|
||||
float sine = (float) Math.abs(Math.cos(ClientEventHandler.elapsedTicks / 1000D));
|
||||
final int ticks = DraconicEvolution.clientProxy().getElapsedTicks();
|
||||
float sine = (float) Math.abs(Math.cos(ticks / 1000D));
|
||||
|
||||
{ // Draw Item
|
||||
// GL11.glRotatef((((float) ClientEventHandler.elapsedTicks) + f) * entity.rotationSpeed, 0f, 1f, 0f);
|
||||
// GL11.glRotatef((((float) ticks) + f) * entity.rotationSpeed, 0f, 1f, 0f);
|
||||
GL11.glRotatef(entity.rotation + f * entity.rotationInc, 0f, 1f, 0f);
|
||||
EntityItem itemEntity = new EntityItem(entity.worldObj, 0, 0, 0, new ItemStack(ModItems.dragonHeart));
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
|
||||
@@ -15,6 +15,12 @@ import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
|
||||
public class RenderMobSoul implements IItemRenderer {
|
||||
|
||||
public static volatile boolean applyTimeRotation = true;
|
||||
|
||||
public static float getRotationAngle() {
|
||||
return (float) (Minecraft.getSystemTime() / -10);
|
||||
}
|
||||
|
||||
private final Minecraft mc;
|
||||
private final String[] randomEntities = new String[] { "Pig", "Sheep", "Enderman", "Zombie", "Creeper", "Cow",
|
||||
"Chicken", "Ozelot", "Witch", "Wolf", "MushroomCow", "Squid", "EntityHorse", "Spider", "Skeleton", "Blaze",
|
||||
@@ -58,7 +64,7 @@ public class RenderMobSoul implements IItemRenderer {
|
||||
GL11.glScalef(13F, 13F, 13F);
|
||||
GL11.glTranslated(1.2, 2.2, 0);
|
||||
GL11.glRotatef(180F, 1F, 0F, 0F);
|
||||
GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F);
|
||||
if (applyTimeRotation) GL11.glRotatef(getRotationAngle(), 0F, 1F, 0F);
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
@@ -67,7 +73,7 @@ public class RenderMobSoul implements IItemRenderer {
|
||||
GL11.glScalef(0.8F, 0.8F, 0.8F);
|
||||
GL11.glTranslated(2, 0.5, 0);
|
||||
GL11.glRotatef(20F, 0F, 0F, 1F);
|
||||
GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F);
|
||||
if (applyTimeRotation) GL11.glRotatef(getRotationAngle(), 0F, 1F, 0F);
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
@@ -76,14 +82,14 @@ public class RenderMobSoul implements IItemRenderer {
|
||||
GL11.glScalef(0.8F, 0.8F, 0.8F);
|
||||
GL11.glTranslated(1, 0.5, 0);
|
||||
GL11.glRotatef(20F, 0F, 0F, 1F);
|
||||
GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F);
|
||||
if (applyTimeRotation) GL11.glRotatef(getRotationAngle(), 0F, 1F, 0F);
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
||||
GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F);
|
||||
if (applyTimeRotation) GL11.glRotatef(getRotationAngle(), 0F, 1F, 0F);
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.brandon3055.draconicevolution.client.render.particle;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.client.handler.ResourceHandler;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utils.Utils;
|
||||
|
||||
@@ -28,19 +30,19 @@ public class ParticleEnergyBeam extends EntityFX {
|
||||
/**
|
||||
* Beam Target X
|
||||
*/
|
||||
private double tX = 0.0D;
|
||||
private double tX;
|
||||
/**
|
||||
* Beam Target Y
|
||||
*/
|
||||
private double tY = 0.0D;
|
||||
private double tY;
|
||||
/**
|
||||
* Beam Target Z
|
||||
*/
|
||||
private double tZ = 0.0D;
|
||||
private double tZ;
|
||||
/**
|
||||
* Modified Target X
|
||||
*/
|
||||
private boolean advanced;
|
||||
private final boolean advanced;
|
||||
|
||||
private boolean renderParticle = true;
|
||||
private float length = 0.0F;
|
||||
@@ -52,10 +54,10 @@ public class ParticleEnergyBeam extends EntityFX {
|
||||
|
||||
// todo make sure not dyrectly up or down on y axis, Set dead when player goes out of range, PaRTICLE eNGINE
|
||||
|
||||
private static ResourceLocation beamTextureBasic = new ResourceLocation(
|
||||
private static final ResourceLocation beamTextureBasic = new ResourceLocation(
|
||||
References.MODID.toLowerCase(),
|
||||
"textures/models/EnergyBeamBlue.png");
|
||||
private static ResourceLocation beamTextureAdvanced = new ResourceLocation(
|
||||
private static final ResourceLocation beamTextureAdvanced = new ResourceLocation(
|
||||
References.MODID.toLowerCase(),
|
||||
"textures/models/EnergyBeamRed.png");
|
||||
|
||||
@@ -192,9 +194,9 @@ public class ParticleEnergyBeam extends EntityFX {
|
||||
GL11.glRotatef(t * 90.0F, 0.0F, -1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (ClientEventHandler.playerHoldingWrench) {
|
||||
var44 = -0.15D * (double) 1;
|
||||
var17 = 0.15D * (double) 1;
|
||||
if (isPlayerHoldingWrench()) {
|
||||
var44 = -0.15D;
|
||||
var17 = 0.15D;
|
||||
|
||||
// GL11.glColor4f(1f, 1f, 1f, 1f);
|
||||
// GL11.glTranslated(0.1, 0, 0);
|
||||
@@ -234,4 +236,13 @@ public class ParticleEnergyBeam extends EntityFX {
|
||||
public void setFlow(int flow) {
|
||||
this.flow = flow;
|
||||
}
|
||||
|
||||
private static boolean isPlayerHoldingWrench() {
|
||||
final EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player != null) {
|
||||
final ItemStack heldItem = player.getHeldItem();
|
||||
return heldItem != null && heldItem.getItem() == ModItems.wrench;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.brandon3055.draconicevolution.client.render.tile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.ITickable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.render.item.RenderMobSoul;
|
||||
import com.brandon3055.draconicevolution.common.items.MobSoul;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TilePlacedItem;
|
||||
import com.brandon3055.draconicevolution.common.utils.ItemNBTHelper;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class PlacedItemDisplayListCache {
|
||||
|
||||
private static final long GLINT_TTL_MS = 33L;
|
||||
private static final long ANIMATED_TTL_MS = 50L;
|
||||
private static final long MOBSOUL_TTL_MS = 1000L;
|
||||
private static final long PRUNE_INTERVAL_MS = 1000L;
|
||||
|
||||
private final Map<TilePlacedItem, CacheEntry> displayListCache = new HashMap<>();
|
||||
private int atlasVersion;
|
||||
private long nextPruneMs;
|
||||
|
||||
public PlacedItemDisplayListCache() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public CacheEntry getOrCompile(TilePlacedItem tile, int meta, Runnable renderBody) {
|
||||
List<ItemStack> stacks = tile.getStacks();
|
||||
CacheEntry entry = displayListCache.get(tile);
|
||||
if (entry == null || !entry.isValid(stacks, meta, tile.rotation, atlasVersion) || entry.needsRefresh()) {
|
||||
dispose(tile);
|
||||
entry = compile(tile, stacks, meta, renderBody);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
private CacheEntry compile(TilePlacedItem tile, List<ItemStack> stacks, int meta, Runnable renderBody) {
|
||||
int listId = GL11.glGenLists(1);
|
||||
// A lone mob soul sits at the block centre, so its spin can be applied outside the list each frame. Souls in
|
||||
// a grid are baked with their current angle instead and the list is refreshed on a short TTL.
|
||||
boolean mobSoul = stacks.size() == 1 && stacks.get(0).getItem() instanceof MobSoul;
|
||||
boolean previousRotationFlag = RenderMobSoul.applyTimeRotation;
|
||||
GL11.glNewList(listId, GL11.GL_COMPILE);
|
||||
try {
|
||||
if (mobSoul) RenderMobSoul.applyTimeRotation = false;
|
||||
renderBody.run();
|
||||
GL11.glEndList();
|
||||
} catch (RuntimeException | Error t) {
|
||||
GL11.glEndList();
|
||||
GL11.glDeleteLists(listId, 1);
|
||||
RenderItem.renderInFrame = false;
|
||||
throw t;
|
||||
} finally {
|
||||
RenderMobSoul.applyTimeRotation = previousRotationFlag;
|
||||
}
|
||||
CacheEntry entry = new CacheEntry(
|
||||
listId,
|
||||
stacks,
|
||||
meta,
|
||||
tile.rotation,
|
||||
getTTL(stacks, mobSoul),
|
||||
mobSoul,
|
||||
atlasVersion);
|
||||
displayListCache.put(tile, entry);
|
||||
return entry;
|
||||
}
|
||||
|
||||
private long getTTL(List<ItemStack> stacks, boolean mobSoulOutsideList) {
|
||||
long ttl = Long.MAX_VALUE; // static (event-invalidated)
|
||||
for (ItemStack stack : stacks) {
|
||||
ttl = Math.min(ttl, getTTL(stack, mobSoulOutsideList));
|
||||
}
|
||||
return ttl;
|
||||
}
|
||||
|
||||
private long getTTL(ItemStack stack, boolean mobSoulOutsideList) {
|
||||
if (stack.getItem() instanceof MobSoul) {
|
||||
// "Any" soul swaps mob every second while named souls only need per-frame rotation outside the list
|
||||
if (isAnyMobSoul(stack)) return MOBSOUL_TTL_MS;
|
||||
return mobSoulOutsideList ? Long.MAX_VALUE : ANIMATED_TTL_MS;
|
||||
}
|
||||
|
||||
if (stack.hasEffect()) return GLINT_TTL_MS; // Glint scroll (~30 fps)
|
||||
if (stack.getItem().getIconIndex(stack) instanceof ITickable) return ANIMATED_TTL_MS; // 20 Hz sprite ticks
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
private boolean isAnyMobSoul(ItemStack stack) {
|
||||
return "Any".equals(ItemNBTHelper.getString(stack, "Name", "Pig"));
|
||||
}
|
||||
|
||||
public void dispose(TilePlacedItem tile) {
|
||||
CacheEntry entry = displayListCache.remove(tile);
|
||||
if (entry != null) GL11.glDeleteLists(entry.listId, 1);
|
||||
}
|
||||
|
||||
private void pruneInvalidEntries() {
|
||||
if (displayListCache.isEmpty()) return;
|
||||
long now = Minecraft.getSystemTime();
|
||||
if (now < nextPruneMs) return;
|
||||
nextPruneMs = now + PRUNE_INTERVAL_MS;
|
||||
|
||||
Iterator<Map.Entry<TilePlacedItem, CacheEntry>> it = displayListCache.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<TilePlacedItem, CacheEntry> entry = it.next();
|
||||
TilePlacedItem tile = entry.getKey();
|
||||
if (tile.isInvalid() || tile.getWorldObj() == null || tile.getDisplayCount() == 0) {
|
||||
GL11.glDeleteLists(entry.getValue().listId, 1);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clearAll() {
|
||||
for (CacheEntry entry : displayListCache.values()) {
|
||||
GL11.glDeleteLists(entry.listId, 1);
|
||||
}
|
||||
displayListCache.clear();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderWorldLast(RenderWorldLastEvent event) {
|
||||
pruneInvalidEntries();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTextureStitch(TextureStitchEvent.Post event) {
|
||||
atlasVersion++;
|
||||
clearAll();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkUnload(ChunkEvent.Unload event) {
|
||||
if (!event.world.isRemote) return;
|
||||
Chunk chunk = event.getChunk();
|
||||
Iterator<Map.Entry<TilePlacedItem, CacheEntry>> it = displayListCache.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<TilePlacedItem, CacheEntry> e = it.next();
|
||||
TilePlacedItem tile = e.getKey();
|
||||
if ((tile.xCoord >> 4) == chunk.xPosition && (tile.zCoord >> 4) == chunk.zPosition) {
|
||||
GL11.glDeleteLists(e.getValue().listId, 1);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
if (!event.world.isRemote) return;
|
||||
clearAll();
|
||||
}
|
||||
|
||||
public static class CacheEntry {
|
||||
|
||||
public final int listId;
|
||||
private final ItemStack[] stacks;
|
||||
private final int[] stackSizes;
|
||||
public final int meta;
|
||||
public final float rotation;
|
||||
public final long ttlMs;
|
||||
/** True when the list holds a single mob soul whose spin is applied by the caller each frame. */
|
||||
public final boolean mobSoul;
|
||||
public final int atlasVersion;
|
||||
private long lastCompileMs;
|
||||
|
||||
private CacheEntry(int listId, List<ItemStack> stacks, int meta, float rotation, long ttlMs, boolean mobSoul,
|
||||
int atlasVersion) {
|
||||
this.listId = listId;
|
||||
this.stacks = stacks.toArray(new ItemStack[0]);
|
||||
this.stackSizes = new int[this.stacks.length];
|
||||
for (int i = 0; i < this.stacks.length; i++) {
|
||||
this.stackSizes[i] = this.stacks[i].stackSize;
|
||||
}
|
||||
this.meta = meta;
|
||||
this.rotation = rotation;
|
||||
this.ttlMs = ttlMs;
|
||||
this.mobSoul = mobSoul;
|
||||
this.atlasVersion = atlasVersion;
|
||||
this.lastCompileMs = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private boolean isValid(List<ItemStack> stacks, int meta, float rotation, int atlasVersion) {
|
||||
if (this.meta != meta || this.rotation != rotation || this.atlasVersion != atlasVersion) return false;
|
||||
if (this.stacks.length != stacks.size()) return false;
|
||||
for (int i = 0; i < this.stacks.length; i++) {
|
||||
// checking the pointer of the stack is enough
|
||||
ItemStack stack = stacks.get(i);
|
||||
if (this.stacks[i] != stack || this.stackSizes[i] != stack.stackSize) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean needsRefresh() {
|
||||
return ttlMs != Long.MAX_VALUE && System.currentTimeMillis() - lastCompileMs >= ttlMs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyRelay;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.energynet.TileEnergyTransceiver;
|
||||
@@ -65,7 +65,8 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
float innerLight = 100f;
|
||||
float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F;
|
||||
final float crystalAlpha = DraconicEvolution.clientProxy().getEnergyCrystalAlpha();
|
||||
float outerLight = 140f + crystalAlpha * 40F;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
@@ -79,7 +80,7 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
|
||||
if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlueAlpha);
|
||||
else bindTexture(crystalRedAlpha);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + crystalAlpha * 0.5f);
|
||||
|
||||
modelCrystal.renderAll();
|
||||
|
||||
@@ -131,7 +132,8 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
|
||||
// RenderHelper.disableStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
float innerLight = 100f;
|
||||
float outerLight = 140f + ClientEventHandler.energyCrystalAlphaValue * 40F;
|
||||
final float crystalAlpha = DraconicEvolution.clientProxy().getEnergyCrystalAlpha();
|
||||
float outerLight = 140f + crystalAlpha * 40F;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, innerLight, innerLight);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
@@ -145,7 +147,7 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
|
||||
if (tileEntity.getPowerTier() == 0) bindTexture(crystalBlueAlpha);
|
||||
else bindTexture(crystalRedAlpha);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + ClientEventHandler.energyCrystalAlphaValue * 0.5f);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f + crystalAlpha * 0.5f);
|
||||
|
||||
modelCrystalTransceiver.renderAll();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -18,10 +19,7 @@ import com.brandon3055.draconicevolution.common.tileentities.TileDissEnchanter;
|
||||
|
||||
public class RenderTileDissEnchanter extends TileEntitySpecialRenderer {
|
||||
|
||||
// private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(),
|
||||
// "textures/models/EnergyInfuserTextureSheet.png");
|
||||
|
||||
// private static float pxl = 1F / 256F;
|
||||
private final EntityItem cachedEntity = new EntityItem(null, 0, 0, 0, new ItemStack(Items.apple));
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
|
||||
@@ -71,10 +69,7 @@ public class RenderTileDissEnchanter extends TileEntitySpecialRenderer {
|
||||
if (tile.getStackInSlot(i) != null) {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
ItemStack stack = tile.getStackInSlot(i).copy();
|
||||
stack.stackSize = 1;
|
||||
EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack);
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
ItemStack stack = tile.getStackInSlot(i);
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(1F, 1F, 1F);
|
||||
@@ -85,7 +80,18 @@ public class RenderTileDissEnchanter extends TileEntitySpecialRenderer {
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
final int stackSize = stack.stackSize;
|
||||
try {
|
||||
stack.stackSize = 1;
|
||||
this.cachedEntity.setEntityItemStack(stack);
|
||||
this.cachedEntity.setWorld(tile.getWorldObj());
|
||||
this.cachedEntity.hoverStart = 0.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(this.cachedEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
} finally {
|
||||
stack.stackSize = stackSize;
|
||||
this.cachedEntity.setEntityItemStack(null);
|
||||
this.cachedEntity.setWorld(null);
|
||||
}
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@@ -32,9 +32,8 @@ public class RenderTileEarth extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) {
|
||||
if (!(tile instanceof TileEarth)) return;
|
||||
if (!(tile instanceof TileEarth tileEarth)) return;
|
||||
|
||||
TileEarth tileEarth = (TileEarth) tile;
|
||||
float scale = 0.01f * tileEarth.getSize();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -17,11 +18,11 @@ import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser;
|
||||
|
||||
public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final float pxl = 1F / 256F;
|
||||
private final ResourceLocation texture = new ResourceLocation(
|
||||
References.MODID.toLowerCase(),
|
||||
"textures/models/EnergyInfuserTextureSheet.png");
|
||||
|
||||
private static float pxl = 1F / 256F;
|
||||
private final EntityItem cachedEntity = new EntityItem(null, 0, 0, 0, new ItemStack(Items.apple));
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
|
||||
@@ -238,8 +239,6 @@ public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
ItemStack stack = tile.getStackInSlot(0);
|
||||
EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0));
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(1F, 1F, 1F);
|
||||
@@ -252,7 +251,15 @@ public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer {
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
try {
|
||||
this.cachedEntity.setEntityItemStack(stack);
|
||||
this.cachedEntity.setWorld(tile.getWorldObj());
|
||||
this.cachedEntity.hoverStart = 0.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(this.cachedEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
} finally {
|
||||
this.cachedEntity.setEntityItemStack(null);
|
||||
this.cachedEntity.setWorld(null);
|
||||
}
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.brandon3055.draconicevolution.client.render.tile;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemBow;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.render.item.RenderMobSoul;
|
||||
import com.brandon3055.draconicevolution.client.render.tile.PlacedItemDisplayListCache.CacheEntry;
|
||||
import com.brandon3055.draconicevolution.common.items.MobSoul;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TilePlacedItem;
|
||||
|
||||
@@ -22,37 +24,85 @@ import com.brandon3055.draconicevolution.common.tileentities.TilePlacedItem;
|
||||
*/
|
||||
public class RenderTilePlacedItem extends TileEntitySpecialRenderer {
|
||||
|
||||
public RenderTilePlacedItem() {}
|
||||
private static final float MOBSOUL_CENTER_X = 0.5F;
|
||||
private static final float MOBSOUL_CENTER_Y = 0.3F;
|
||||
private static final float MOBSOUL_CENTER_Z = 0.5F;
|
||||
|
||||
private final EntityItem cachedEntity = new EntityItem(null, 0, 0, 0, new ItemStack(Items.apple));
|
||||
private final PlacedItemDisplayListCache displayListCache = new PlacedItemDisplayListCache();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float timeSinceLastTick) {
|
||||
if (te == null || !(te instanceof TilePlacedItem)) return;
|
||||
TilePlacedItem tile = (TilePlacedItem) te;
|
||||
if (tile.getStack() == null) return;
|
||||
if (!(te instanceof TilePlacedItem tile)) return;
|
||||
int count = tile.getDisplayCount();
|
||||
if (count == 0) {
|
||||
displayListCache.dispose(tile);
|
||||
return;
|
||||
}
|
||||
if (tile.getWorldObj() == null) return;
|
||||
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
if (meta < 0 || meta > 5) meta = 1;
|
||||
final int gridMeta = meta;
|
||||
CacheEntry entry = displayListCache.getOrCompile(tile, meta, () -> renderGrid(tile, gridMeta));
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glTranslated(x, y, z);
|
||||
renderItem(tile);
|
||||
if (entry.mobSoul) {
|
||||
GL11.glTranslated(MOBSOUL_CENTER_X, MOBSOUL_CENTER_Y, MOBSOUL_CENTER_Z);
|
||||
GL11.glRotatef(RenderMobSoul.getRotationAngle(), 0F, 1F, 0F);
|
||||
GL11.glTranslated(-MOBSOUL_CENTER_X, -MOBSOUL_CENTER_Y, -MOBSOUL_CENTER_Z);
|
||||
}
|
||||
GL11.glCallList(entry.listId);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderItem(TilePlacedItem tile) {
|
||||
ItemStack stack = tile.getStack();
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, stack);
|
||||
int meta = world.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
// itemEntity.getEntityItem().stackSize = 1;
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
boolean is3D = stack.getItem().isFull3D();
|
||||
boolean isBlock = stack.getItem() instanceof ItemBlock;
|
||||
/**
|
||||
* Renders every item on the display laid out in a grid on the mounting face. This is the body that gets compiled
|
||||
* into the cached display list.
|
||||
*/
|
||||
private void renderGrid(TilePlacedItem tile, int meta) {
|
||||
int count = tile.getDisplayCount();
|
||||
int gridSize = TilePlacedItem.getGridSize(count);
|
||||
float cell = 1F / gridSize;
|
||||
float[] pivot = TilePlacedItem.FACE_PIVOT[meta];
|
||||
float[] axisU = TilePlacedItem.FACE_AXIS_U[meta];
|
||||
float[] axisV = TilePlacedItem.FACE_AXIS_V[meta];
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
ItemStack stack = tile.getStack(i);
|
||||
if (stack == null) continue;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
if (gridSize > 1) {
|
||||
float[] offset = TilePlacedItem.getCellOffset(i, count);
|
||||
float u = offset[0];
|
||||
float v = offset[1];
|
||||
|
||||
GL11.glTranslatef(
|
||||
pivot[0] + axisU[0] * u + axisV[0] * v,
|
||||
pivot[1] + axisU[1] * u + axisV[1] * v,
|
||||
pivot[2] + axisU[2] * u + axisV[2] * v);
|
||||
GL11.glScalef(cell, cell, cell);
|
||||
GL11.glTranslatef(-pivot[0], -pivot[1], -pivot[2]);
|
||||
}
|
||||
renderItem(tile, stack, meta);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public void renderItem(TilePlacedItem tile, ItemStack stack, int meta) {
|
||||
final Item item = stack.getItem();
|
||||
boolean is3D = item.isFull3D();
|
||||
boolean isBlock = item instanceof ItemBlock;
|
||||
|
||||
if (isBlock) {
|
||||
GL11.glTranslatef(0.5F, 0.25F, 0.5F);
|
||||
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
||||
metaAdjustBlock(meta);
|
||||
GL11.glRotatef(tile.rotation, 0F, 1F, 0F);
|
||||
} else if (is3D || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow) {
|
||||
} else if (is3D || item instanceof ItemArmor || item instanceof ItemBow) {
|
||||
GL11.glScalef(2F, 2F, 2F);
|
||||
GL11.glRotatef(90F, -1F, 0F, 0F);
|
||||
GL11.glTranslatef(0.25F, -0.45F, 0.02F);
|
||||
@@ -60,9 +110,8 @@ public class RenderTilePlacedItem extends TileEntitySpecialRenderer {
|
||||
GL11.glTranslatef(0.0F, 0.21F, 0.0F);
|
||||
GL11.glRotatef(tile.rotation, 0F, 0F, 1F);
|
||||
GL11.glTranslatef(0.0F, -0.21F, 0.0F);
|
||||
} else if (stack.getItem() instanceof MobSoul) {
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.3F, 0.5F);
|
||||
} else if (item instanceof MobSoul) {
|
||||
GL11.glTranslatef(MOBSOUL_CENTER_X, MOBSOUL_CENTER_Y, MOBSOUL_CENTER_Z);
|
||||
} else {
|
||||
GL11.glRotatef(90F, -1F, 0F, 0F);
|
||||
GL11.glTranslatef(0.5F, -0.65F, 0.02F);
|
||||
@@ -74,7 +123,15 @@ public class RenderTilePlacedItem extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
try {
|
||||
this.cachedEntity.setEntityItemStack(stack);
|
||||
this.cachedEntity.setWorld(tile.getWorldObj());
|
||||
this.cachedEntity.hoverStart = 0.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(this.cachedEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
} finally {
|
||||
this.cachedEntity.setEntityItemStack(null);
|
||||
this.cachedEntity.setWorld(null);
|
||||
}
|
||||
RenderItem.renderInFrame = false;
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.brandon3055.draconicevolution.client.render.tile;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -10,6 +8,7 @@ import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -33,11 +32,11 @@ import com.brandon3055.draconicevolution.common.utils.Utils;
|
||||
*/
|
||||
public class RenderTileTeleporterStand extends TileEntitySpecialRenderer {
|
||||
|
||||
ModelTeleporterStand model = new ModelTeleporterStand();
|
||||
|
||||
private final ModelTeleporterStand model = new ModelTeleporterStand();
|
||||
private final ResourceLocation texture = new ResourceLocation(
|
||||
References.MODID.toLowerCase(),
|
||||
"textures/models/TeleporterStand.png");
|
||||
private final EntityItem cachedEntity = new EntityItem(null, 0, 0, 0, new ItemStack(Items.apple));
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
@@ -69,27 +68,29 @@ public class RenderTileTeleporterStand extends TileEntitySpecialRenderer {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderItem(TileEntity tile, ItemStack item, float f) {
|
||||
if (item.getItem() == null) return;
|
||||
public void renderItem(TileEntity tile, ItemStack stack, float f) {
|
||||
if (stack.getItem() == null) return;
|
||||
GL11.glPushMatrix();
|
||||
|
||||
EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, item);
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
|
||||
if (item.getItem() instanceof TeleporterMKII) {
|
||||
if (stack.getItem() instanceof TeleporterMKII) {
|
||||
GL11.glTranslatef(0F, 0.18F, 0.864F);
|
||||
GL11.glRotated(180, 0, 0, 1);
|
||||
GL11.glRotated(30, 1, 0, 0);
|
||||
GL11.glScalef(1F, 1F, 1F);
|
||||
} else {
|
||||
GL11.glTranslatef(0F, 0.22F, 0.84F);
|
||||
GL11.glRotated(180, 0, 0, 1);
|
||||
GL11.glRotated(30, 1, 0, 0);
|
||||
GL11.glScalef(1F, 1F, 1F);
|
||||
}
|
||||
GL11.glRotated(180, 0, 0, 1);
|
||||
GL11.glRotated(30, 1, 0, 0);
|
||||
GL11.glScalef(1F, 1F, 1F);
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
try {
|
||||
this.cachedEntity.setEntityItemStack(stack);
|
||||
this.cachedEntity.setWorld(tile.getWorldObj());
|
||||
this.cachedEntity.hoverStart = 0.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(this.cachedEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
} finally {
|
||||
this.cachedEntity.setEntityItemStack(null);
|
||||
this.cachedEntity.setWorld(null);
|
||||
}
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
@@ -126,9 +127,6 @@ public class RenderTileTeleporterStand extends TileEntitySpecialRenderer {
|
||||
GL11.glRotated(180, 0, 1, 0);
|
||||
GL11.glTranslated(0, -40, 0);
|
||||
|
||||
Point.Double p1 = new Point.Double(tileentity.xCoord + 0.5, tileentity.zCoord + 0.5);
|
||||
Point.Double p2 = new Point.Double(player.posX, player.posZ);
|
||||
|
||||
double xDiff = player.posX - (tileentity.xCoord + 0.5);
|
||||
double yDiff = player.posY - (tileentity.yCoord + 0.5);
|
||||
double zDiff = player.posZ - (tileentity.zCoord + 0.5);
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -16,7 +17,8 @@ import com.brandon3055.draconicevolution.common.tileentities.TileUpgradeModifier
|
||||
|
||||
public class RenderTileUpgradeModifier extends TileEntitySpecialRenderer {
|
||||
|
||||
private static float pxl = 1F / 256F;
|
||||
private static final float pxl = 1F / 256F;
|
||||
private final EntityItem cachedEntity = new EntityItem(null, 0, 0, 0, new ItemStack(Items.apple));
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
|
||||
@@ -207,8 +209,6 @@ public class RenderTileUpgradeModifier extends TileEntitySpecialRenderer {
|
||||
GL11.glPushMatrix();
|
||||
|
||||
ItemStack stack = tile.getStackInSlot(0);
|
||||
EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0));
|
||||
itemEntity.hoverStart = 0.0F;
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(1F, 1F, 1F);
|
||||
@@ -220,7 +220,15 @@ public class RenderTileUpgradeModifier extends TileEntitySpecialRenderer {
|
||||
}
|
||||
|
||||
RenderItem.renderInFrame = true;
|
||||
RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
try {
|
||||
this.cachedEntity.setEntityItemStack(stack);
|
||||
this.cachedEntity.setWorld(tile.getWorldObj());
|
||||
this.cachedEntity.hoverStart = 0.0F;
|
||||
RenderManager.instance.renderEntityWithPosYaw(this.cachedEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||
} finally {
|
||||
this.cachedEntity.setEntityItemStack(null);
|
||||
this.cachedEntity.setWorld(null);
|
||||
}
|
||||
RenderItem.renderInFrame = false;
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package com.brandon3055.draconicevolution.common;
|
||||
|
||||
import net.minecraft.client.audio.ISound;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.creativetab.DETab;
|
||||
import com.brandon3055.draconicevolution.client.gui.GuiHandler;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.ParticleReactorBeam;
|
||||
import com.brandon3055.draconicevolution.common.achievements.Achievements;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityChaosBolt;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityChaosCrystal;
|
||||
@@ -33,6 +36,7 @@ import com.brandon3055.draconicevolution.common.handler.ContributorHandler;
|
||||
import com.brandon3055.draconicevolution.common.handler.CraftingHandler;
|
||||
import com.brandon3055.draconicevolution.common.handler.FMLEventHandler;
|
||||
import com.brandon3055.draconicevolution.common.handler.MinecraftForgeEventHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.magic.EnchantmentReaper;
|
||||
@@ -102,6 +106,8 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -109,12 +115,28 @@ import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
private Achievements achievements;
|
||||
private CustomArmorHandler armorHandler;
|
||||
private DragonChunkLoader dragonChunkLoader;
|
||||
private final Map<World, List<TileDislocatorInhibitor>> serverInhibitorsMap = new HashMap<>();
|
||||
|
||||
public CommonProxy() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
FileHandler.init(event);
|
||||
ProcessHandler.init();
|
||||
ConfigHandler.init(event.getSuggestedConfigurationFile());
|
||||
BalanceConfigHandler.init(event.getModConfigurationDirectory());
|
||||
registerEventListeners(event.getSide());
|
||||
MinecraftForge.EVENT_BUS.register(new MinecraftForgeEventHandler());
|
||||
this.achievements = new Achievements();
|
||||
MinecraftForge.EVENT_BUS.register(this.achievements);
|
||||
FMLCommonHandler.instance().bus().register(this.achievements);
|
||||
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
|
||||
this.armorHandler = new CustomArmorHandler();
|
||||
MinecraftForge.EVENT_BUS.register(armorHandler);
|
||||
FMLCommonHandler.instance().bus().register(armorHandler);
|
||||
ModBlocks.init();
|
||||
ModItems.init();
|
||||
ContributorHandler.init();
|
||||
@@ -124,7 +146,7 @@ public class CommonProxy {
|
||||
|
||||
DraconicEvolution.reaperEnchant = new EnchantmentReaper(ConfigHandler.reaperEnchantID);
|
||||
|
||||
Achievements.addModAchievements();
|
||||
this.achievements.addModAchievements();
|
||||
LogHelper.info("Finished PreInitialization");
|
||||
}
|
||||
|
||||
@@ -136,18 +158,30 @@ public class CommonProxy {
|
||||
DETab.initialize();
|
||||
PotionHandler.init();
|
||||
CCOCIntegration.init();
|
||||
DragonChunkLoader.init();
|
||||
this.dragonChunkLoader = new DragonChunkLoader();
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(DraconicEvolution.instance, this.dragonChunkLoader);
|
||||
LogHelper.info("Finished Initialization");
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
BalanceConfigHandler.finishLoading();
|
||||
OreDoublingRegistry.init();
|
||||
Achievements.registerAchievementPane();
|
||||
this.achievements.registerAchievementPane();
|
||||
LogHelper.info("Finished PostInitialization");
|
||||
}
|
||||
|
||||
public void initializeNetwork() {
|
||||
public void onServerStopped(FMLServerStoppedEvent event) {
|
||||
this.serverInhibitorsMap.clear();
|
||||
this.dragonChunkLoader.onServerStopped();
|
||||
this.armorHandler.onServerStopped();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
this.serverInhibitorsMap.remove(event.world);
|
||||
}
|
||||
|
||||
private void initializeNetwork() {
|
||||
// spotless:off
|
||||
DraconicEvolution.network = NetworkRegistry.INSTANCE.newSimpleChannel(DraconicEvolution.networkChannelName);
|
||||
DraconicEvolution.network.registerMessage(ButtonPacket.Handler.class, ButtonPacket.class, 0, Side.SERVER);
|
||||
@@ -178,7 +212,7 @@ public class CommonProxy {
|
||||
// spotless:on
|
||||
}
|
||||
|
||||
public void registerTileEntities() {
|
||||
private void registerTileEntities() {
|
||||
// spotless:off
|
||||
GameRegistry.registerTileEntity(TileWeatherController.class, References.RESOURCESPREFIX + "TileWeatherController");
|
||||
GameRegistry.registerTileEntity(TileSunDial.class, References.RESOURCESPREFIX + "TileSunDial");
|
||||
@@ -191,7 +225,7 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(TileCustomSpawner.class, References.RESOURCESPREFIX + "TileCustomSpawner");
|
||||
GameRegistry.registerTileEntity(TileGenerator.class, References.RESOURCESPREFIX + "TileGenerator");
|
||||
GameRegistry.registerTileEntity(TileEnergyStorageCore.class, References.RESOURCESPREFIX + "TileEnergyStorageCore");
|
||||
GameRegistry.registerTileEntity(TileEarth.class, References.RESOURCESPREFIX + "TileEarth");
|
||||
if (ModBlocks.earthBlock != null) GameRegistry.registerTileEntity(TileEarth.class, References.RESOURCESPREFIX + "TileEarth");
|
||||
GameRegistry.registerTileEntity(TileInvisibleMultiblock.class, References.RESOURCESPREFIX + "TileInvisibleMultiblock");
|
||||
GameRegistry.registerTileEntity(TileEnergyPylon.class, References.RESOURCESPREFIX + "TileEnergyPylon");
|
||||
GameRegistry.registerTileEntity(TileEnderResurrection.class, References.RESOURCESPREFIX + "TileEnderResurrection");
|
||||
@@ -216,13 +250,6 @@ public class CommonProxy {
|
||||
// spotless:on
|
||||
}
|
||||
|
||||
public void registerEventListeners(Side s) {
|
||||
MinecraftForge.EVENT_BUS.register(new MinecraftForgeEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new Achievements());
|
||||
FMLCommonHandler.instance().bus().register(new Achievements());
|
||||
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
|
||||
}
|
||||
|
||||
public void registerGuiHandeler() {
|
||||
new GuiHandler();
|
||||
}
|
||||
@@ -268,26 +295,6 @@ public class CommonProxy {
|
||||
// spotless:on
|
||||
}
|
||||
|
||||
public ParticleEnergyBeam energyBeam(World worldObj, double x, double y, double z, double tx, double ty, double tz,
|
||||
int powerFlow, boolean advanced, ParticleEnergyBeam oldBeam, boolean render, int beamType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced,
|
||||
ParticleEnergyField oldBeam, boolean render) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ParticleReactorBeam reactorBeam(TileEntity tile, ParticleReactorBeam oldBeam, boolean render) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void spawnParticle(Object particle, int range) {}
|
||||
|
||||
public ISound playISound(ISound sound) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDedicatedServer() {
|
||||
return true;
|
||||
}
|
||||
@@ -315,4 +322,70 @@ public class CommonProxy {
|
||||
public EntityPlayer getClientPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isClient() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void triggerAchievement(EntityPlayer player, String name) {
|
||||
this.achievements.triggerAchievement(player, name);
|
||||
}
|
||||
|
||||
public DragonChunkLoader getDragonChunkLoader() {
|
||||
return dragonChunkLoader;
|
||||
}
|
||||
|
||||
public void tryRepositionPlayerOnMount(int entityId) {}
|
||||
|
||||
public void registerInhibitor(TileDislocatorInhibitor tile) {
|
||||
if (tile.hasWorldObj()) {
|
||||
registerInhibitor(this.serverInhibitorsMap, tile);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void registerInhibitor(Map<World, List<TileDislocatorInhibitor>> map,
|
||||
TileDislocatorInhibitor tile) {
|
||||
final List<TileDislocatorInhibitor> list = map.computeIfAbsent(tile.getWorldObj(), k -> new ArrayList<>());
|
||||
if (!list.contains(tile)) {
|
||||
list.add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterInhibitor(TileDislocatorInhibitor tile) {
|
||||
if (tile.hasWorldObj()) {
|
||||
unregisterInhibitor(this.serverInhibitorsMap, tile);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void unregisterInhibitor(Map<World, List<TileDislocatorInhibitor>> map,
|
||||
TileDislocatorInhibitor tile) {
|
||||
final List<TileDislocatorInhibitor> list = map.get(tile.getWorldObj());
|
||||
if (list != null) {
|
||||
list.remove(tile);
|
||||
if (list.isEmpty()) {
|
||||
map.remove(tile.getWorldObj());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlockedByInhibitor(World world, EntityItem item) {
|
||||
return isBlockedByInhibitor(this.serverInhibitorsMap, world, item);
|
||||
}
|
||||
|
||||
protected static boolean isBlockedByInhibitor(Map<World, List<TileDislocatorInhibitor>> map, World world,
|
||||
EntityItem item) {
|
||||
final List<TileDislocatorInhibitor> list = map.get(world);
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
// noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
final TileDislocatorInhibitor tile = list.get(i);
|
||||
if (tile.shouldBeActive() && tile.isInRange(item.posX, item.posY, item.posZ)
|
||||
&& tile.isBlockingItem(item.getEntityItem())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class ModBlocks {
|
||||
customSpawner = new CustomSpawner();
|
||||
generator = new Generator();
|
||||
energyStorageCore = new EnergyStorageCore();
|
||||
earthBlock = new Earth();
|
||||
if (!ConfigHandler.disableEarthBlock) earthBlock = new Earth();
|
||||
draconiumBlock = new DraconiumBlock();
|
||||
invisibleMultiblock = new InvisibleMultiblock();
|
||||
energyPylon = new EnergyPylon();
|
||||
|
||||
@@ -21,38 +21,31 @@ import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
*/
|
||||
public class Achievements {
|
||||
|
||||
private static AchievementPage achievementsPage;
|
||||
private static HashMap<String, Achievement> achievementsList = new HashMap<String, Achievement>();
|
||||
private static HashMap<String, AchievementCondition> achievementItems = new HashMap<String, AchievementCondition>();
|
||||
private final HashMap<String, Achievement> achievementsList = new HashMap<>();
|
||||
private final HashMap<String, AchievementCondition> achievementItems = new HashMap<>();
|
||||
|
||||
public static void addAchievement(String name, Achievement achievement, ItemStack stack, String triggerCondition) {
|
||||
private void addAchievement(String name, Achievement achievement, ItemStack stack, String triggerCondition) {
|
||||
if (stack == null || stack.getItem() == null) return;
|
||||
achievementsList.put(name, achievement.registerStat());
|
||||
achievementItems.put(stack.getUnlocalizedName(), new AchievementCondition(name, triggerCondition));
|
||||
}
|
||||
|
||||
public static void addAchievement(String name, Achievement achievement, String triggerCondition) {
|
||||
private void addAchievement(String name, Achievement achievement, String triggerCondition) {
|
||||
addAchievement(name, achievement, achievement.theItemStack, triggerCondition);
|
||||
}
|
||||
|
||||
public static void addAchievement(String name, Achievement achievement) {
|
||||
addAchievement(name, achievement, achievement.theItemStack, "null");
|
||||
}
|
||||
|
||||
public static Achievement getAchievement(String name) {
|
||||
private Achievement getAchievement(String name) {
|
||||
return achievementsList.get(name);
|
||||
}
|
||||
|
||||
public static void triggerAchievement(EntityPlayer player, String name) {
|
||||
|
||||
public void triggerAchievement(EntityPlayer player, String name) {
|
||||
Achievement ach = getAchievement(name);
|
||||
|
||||
if (ach != null) {
|
||||
player.triggerAchievement(ach);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addModAchievements() {
|
||||
public void addModAchievements() {
|
||||
int x = 5;
|
||||
addAchievement(
|
||||
"draconicevolution.dust",
|
||||
@@ -442,11 +435,11 @@ public class Achievements {
|
||||
"craft");
|
||||
}
|
||||
|
||||
public static void registerAchievementPane() {
|
||||
public void registerAchievementPane() {
|
||||
Achievement[] achievements = new Achievement[achievementsList.size()];
|
||||
|
||||
achievements = achievementsList.values().toArray(achievements);
|
||||
achievementsPage = new AchievementPage(
|
||||
AchievementPage achievementsPage = new AchievementPage(
|
||||
StatCollector.translateToLocal("draconicevolution.achievementPage.name"),
|
||||
achievements);
|
||||
AchievementPage.registerAchievementPage(achievementsPage);
|
||||
@@ -458,7 +451,7 @@ public class Achievements {
|
||||
stack.stackSize = 1;
|
||||
if (achievementItems.containsKey(stack.getUnlocalizedName())
|
||||
&& achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("pickup")) {
|
||||
triggerAchievement(event.entityPlayer, achievementItems.get(stack.getUnlocalizedName()).getName());
|
||||
triggerAchievement(event.entityPlayer, achievementItems.get(stack.getUnlocalizedName()).name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +461,7 @@ public class Achievements {
|
||||
stack.stackSize = 1;
|
||||
if (achievementItems.containsKey(stack.getUnlocalizedName())
|
||||
&& achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("craft")) {
|
||||
triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).getName());
|
||||
triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,13 +471,13 @@ public class Achievements {
|
||||
stack.stackSize = 1;
|
||||
if (achievementItems.containsKey(stack.getUnlocalizedName())
|
||||
&& achievementItems.get(stack.getUnlocalizedName()).isCorrectCondition("smelt")) {
|
||||
triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).getName());
|
||||
triggerAchievement(event.player, achievementItems.get(stack.getUnlocalizedName()).name);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AchievementCondition {
|
||||
|
||||
private final String name;
|
||||
public final String name;
|
||||
public final String condition;
|
||||
|
||||
public AchievementCondition(String name, String condition) {
|
||||
@@ -495,9 +488,5 @@ public class Achievements {
|
||||
public boolean isCorrectCondition(String s) {
|
||||
return s.equals(condition);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,47 +147,61 @@ public class PlacedItem extends BlockDE {
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem) te).getStack() != null) {
|
||||
TilePlacedItem tile = (TilePlacedItem) te;
|
||||
|
||||
float spawnX = x + world.rand.nextFloat();
|
||||
float spawnY = y + world.rand.nextFloat();
|
||||
float spawnZ = z + world.rand.nextFloat();
|
||||
|
||||
EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, tile.getStack());
|
||||
tile.setStack(null);
|
||||
|
||||
float multiplier = 0.05F;
|
||||
|
||||
droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier;
|
||||
droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier;
|
||||
droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier;
|
||||
|
||||
world.spawnEntityInWorld(droppedItem);
|
||||
if (te instanceof TilePlacedItem tile) {
|
||||
ItemStack stack;
|
||||
while ((stack = tile.removeLastItem()) != null) {
|
||||
dropStack(world, x, y, z, stack);
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
private static void dropStack(World world, int x, int y, int z, ItemStack stack) {
|
||||
float spawnX = x + world.rand.nextFloat();
|
||||
float spawnY = y + world.rand.nextFloat();
|
||||
float spawnZ = z + world.rand.nextFloat();
|
||||
|
||||
EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack);
|
||||
|
||||
float multiplier = 0.05F;
|
||||
|
||||
droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier;
|
||||
droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier;
|
||||
droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier;
|
||||
|
||||
world.spawnEntityInWorld(droppedItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_,
|
||||
float p_149727_7_, float p_149727_8_, float p_149727_9_) {
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
|
||||
float hitY, float hitZ) {
|
||||
TilePlacedItem tile = (world.getTileEntity(x, y, z) != null
|
||||
&& world.getTileEntity(x, y, z) instanceof TilePlacedItem)
|
||||
? (TilePlacedItem) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile == null) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
return true;
|
||||
}
|
||||
if (player.isSneaking()) {
|
||||
TilePlacedItem tile = (world.getTileEntity(x, y, z) != null
|
||||
&& world.getTileEntity(x, y, z) instanceof TilePlacedItem)
|
||||
? (TilePlacedItem) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile == null) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
tile.rotation += 5.625F;
|
||||
} else {
|
||||
if (!world.isRemote) breakBlock(world, x, y, z, this, world.getBlockMetadata(x, y, z));
|
||||
world.setBlockToAir(x, y, z);
|
||||
// Remove the item the player clicked on; the block is removed once the last one is taken.
|
||||
if (!world.isRemote) {
|
||||
int index = tile.getStackIndexAt(world.getBlockMetadata(x, y, z), hitX, hitY, hitZ);
|
||||
ItemStack stack = tile.removeItem(index);
|
||||
if (stack != null) {
|
||||
dropStack(world, x, y, z, stack);
|
||||
}
|
||||
if (tile.getDisplayCount() == 0) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
@@ -195,45 +209,42 @@ public class PlacedItem extends BlockDE {
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
TilePlacedItem tile = (world.getTileEntity(x, y, z) != null
|
||||
&& world.getTileEntity(x, y, z) instanceof TilePlacedItem)
|
||||
? (TilePlacedItem) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile == null) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
tile.rotation += 22.5F;
|
||||
} else {
|
||||
TilePlacedItem tile = (world.getTileEntity(x, y, z) != null
|
||||
&& world.getTileEntity(x, y, z) instanceof TilePlacedItem)
|
||||
? (TilePlacedItem) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile == null) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
tile.rotation -= 22.5F;
|
||||
TilePlacedItem tile = (world.getTileEntity(x, y, z) != null
|
||||
&& world.getTileEntity(x, y, z) instanceof TilePlacedItem)
|
||||
? (TilePlacedItem) world.getTileEntity(x, y, z)
|
||||
: null;
|
||||
if (tile == null) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
return;
|
||||
}
|
||||
tile.rotation += player.isSneaking() ? 22.5F : -22.5F;
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem) te).getStack() != null) {
|
||||
TilePlacedItem tile = (TilePlacedItem) te;
|
||||
if (tile.getStack() != null && tile.getStack().getItem() instanceof ItemBlock)
|
||||
return Block.getBlockFromItem(tile.getStack().getItem()).getLightValue();
|
||||
int light = 0;
|
||||
if (te instanceof TilePlacedItem tile) {
|
||||
for (ItemStack stack : tile.getStacks()) {
|
||||
if (stack != null && stack.getItem() instanceof ItemBlock) {
|
||||
light = Math.max(light, Block.getBlockFromItem(stack.getItem()).getLightValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TilePlacedItem && ((TilePlacedItem) te).getStack() != null) {
|
||||
TilePlacedItem tile = (TilePlacedItem) te;
|
||||
return tile.getStack();
|
||||
if (te instanceof TilePlacedItem tile && target != null && target.hitVec != null) {
|
||||
int index = tile.getStackIndexAt(
|
||||
world.getBlockMetadata(x, y, z),
|
||||
(float) (target.hitVec.xCoord - x),
|
||||
(float) (target.hitVec.yCoord - y),
|
||||
(float) (target.hitVec.zCoord - z));
|
||||
return tile.getStack(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,18 +94,6 @@ public class DislocatorInhibitor extends BlockDE implements ITileEntityProvider
|
||||
updateRedstoneStatus(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, int x, int y, int z, Block blockBroken, int meta) {
|
||||
TileEntity tile = worldIn.getTileEntity(x, y, z);
|
||||
if (tile != null) {
|
||||
if (tile instanceof TileDislocatorInhibitor) {
|
||||
((TileDislocatorInhibitor) tile).unregister();
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(worldIn, x, y, z, blockBroken, meta);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.common.blocks.machine;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -98,6 +99,22 @@ public class DissEnchanter extends BlockCustomDrop {
|
||||
@Override
|
||||
protected void getCustomTileEntityDrops(TileEntity te, List<ItemStack> droppes) {}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World worldIn, int x, int y, int z, Block neighbor) {
|
||||
boolean powered = worldIn.isBlockIndirectlyGettingPowered(x, y, z)
|
||||
|| worldIn.isBlockIndirectlyGettingPowered(x, y - 1, z);
|
||||
int meta = worldIn.getBlockMetadata(x, y, z);
|
||||
boolean metaUnpowered = (meta & 8) == 0;
|
||||
|
||||
if (powered && metaUnpowered) {
|
||||
if (worldIn.getTileEntity(x, y, z) instanceof TileDissEnchanter tde) tde.buttonClick(null);
|
||||
worldIn.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
|
||||
return;
|
||||
}
|
||||
if (powered || metaUnpowered) return;
|
||||
worldIn.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
@@ -8,6 +8,9 @@ import net.minecraft.world.World;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.render.particle.Particles;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 30/9/2015.
|
||||
*/
|
||||
@@ -62,37 +65,17 @@ public class EntityChaosBolt extends Entity {
|
||||
|
||||
if (ticks == 10 && !burst) {
|
||||
if (worldObj.isRemote) {
|
||||
DraconicEvolution.proxy.spawnParticle(
|
||||
new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 10),
|
||||
32);
|
||||
spawnParticles(10);
|
||||
}
|
||||
setDead();
|
||||
} else if (ticks > 10) {
|
||||
if (ticks < 25) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
if (worldObj.isRemote) DraconicEvolution.proxy.spawnParticle(
|
||||
new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 0),
|
||||
32);
|
||||
if (worldObj.isRemote) {
|
||||
spawnParticles(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ticks > 40 && !worldObj.isRemote) {
|
||||
// if (ticks % 5 == 0)
|
||||
// {
|
||||
// double dist = Utills.getDistanceAtoB(posX, posY, posZ, shardX, shardY, shardZ);
|
||||
// Vec3 dir = Vec3.createVectorHelper((shardX - posX) / dist, (shardY - posY) / dist, (shardZ -
|
||||
// posZ) / dist);
|
||||
// MovingObjectPosition movingobjectposition =
|
||||
// this.worldObj.//func_147447_a(Vec3.createVectorHelper(posX, posY, posZ), dir, false, true, false);
|
||||
// Entity entity = movingobjectposition.entityHit; //WorldUtil.rayTraceEntities(worldObj,
|
||||
// Vec3.createVectorHelper(posX, posY, posZ), dir, 20);
|
||||
//
|
||||
// LogHelper.info(movingobjectposition);
|
||||
// if (entity instanceof EntityLivingBase) {
|
||||
// entity.hurtResistantTime = 0;
|
||||
// entity.attackEntityFrom(chaosBurst, 50F);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
if (ticks > 60) {
|
||||
@@ -102,6 +85,13 @@ public class EntityChaosBolt extends Entity {
|
||||
ticks++;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnParticles(int mode) {
|
||||
DraconicEvolution.clientProxy().spawnParticle(
|
||||
new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, mode),
|
||||
32);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound compound) {
|
||||
// if (compound.hasKey("ShardPos")){
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.brandon3055.draconicevolution.common.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -25,10 +24,10 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileChaosShard;
|
||||
import com.brandon3055.draconicevolution.common.utils.DamageSourceChaos;
|
||||
import com.brandon3055.draconicevolution.common.utils.DragonChunkLoader;
|
||||
import com.brandon3055.draconicevolution.common.utils.Utils;
|
||||
|
||||
/**
|
||||
@@ -92,7 +91,7 @@ public class EntityChaosGuardian extends EntityDragon { // summon DraconicEvolut
|
||||
public float circlePosition = 0;
|
||||
public float circleDirection = 1;
|
||||
|
||||
public EnumBehaviour behaviour = EnumBehaviour.ROAMING;
|
||||
private EnumBehaviour behaviour = EnumBehaviour.ROAMING;
|
||||
|
||||
public EntityChaosGuardian(World par1World) {
|
||||
super(par1World);
|
||||
@@ -171,13 +170,17 @@ public class EntityChaosGuardian extends EntityDragon { // summon DraconicEvolut
|
||||
dataWatcher.updateObject(23, crystalZ);
|
||||
updateTarget();
|
||||
|
||||
if (worldObj.getClosestPlayer(posX, posY, posZ, 500) == null && getDistance(homeX, homeY, homeZ) < 100)
|
||||
DragonChunkLoader.stopLoading(this);
|
||||
else {
|
||||
if (getHealth() > 0) DragonChunkLoader.updateLoaded(this);
|
||||
if (getDistance(homeX, homeY, homeZ) < 100 && worldObj.getClosestPlayer(posX, posY, posZ, 500) == null) {
|
||||
DraconicEvolution.proxy.getDragonChunkLoader().stopLoading(this);
|
||||
} else {
|
||||
if (getHealth() > 0) {
|
||||
DraconicEvolution.proxy.getDragonChunkLoader().updateLoaded(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (deathTicks > 0) DragonChunkLoader.stopLoading(this);
|
||||
if (deathTicks > 0) {
|
||||
DraconicEvolution.proxy.getDragonChunkLoader().stopLoading(this);
|
||||
}
|
||||
|
||||
customAIUpdate();
|
||||
if (behaviour == EnumBehaviour.FIREBOMB
|
||||
@@ -651,14 +654,11 @@ public class EntityChaosGuardian extends EntityDragon { // summon DraconicEvolut
|
||||
.expand(100, 100, 100))
|
||||
: null;
|
||||
|
||||
if (targets != null && targets.size() > 0) {
|
||||
Iterator<EntityPlayer> i = targets.iterator();
|
||||
while (i.hasNext()) {
|
||||
if (i.next().capabilities.isCreativeMode) i.remove();
|
||||
}
|
||||
if (targets != null && !targets.isEmpty()) {
|
||||
targets.removeIf(entityPlayer -> entityPlayer.capabilities.isCreativeMode);
|
||||
}
|
||||
|
||||
if (attackTarget == null && targets != null && targets.size() > 0)
|
||||
if (attackTarget == null && targets != null && !targets.isEmpty())
|
||||
attackTarget = targets.get(rand.nextInt(targets.size()));
|
||||
if (attackTarget == null) return;
|
||||
|
||||
@@ -896,7 +896,7 @@ public class EntityChaosGuardian extends EntityDragon { // summon DraconicEvolut
|
||||
List<EntityPlayer> targets = worldObj
|
||||
.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(150, 150, 150));
|
||||
target = null;
|
||||
while (targets.size() > 0 && target == null) {
|
||||
while (!targets.isEmpty() && target == null) {
|
||||
EntityPlayer potentialTarget = targets.get(rand.nextInt(targets.size()));
|
||||
if (worldObj.rayTraceBlocks(
|
||||
Vec3.createVectorHelper(posX, posY, posZ),
|
||||
@@ -994,7 +994,7 @@ public class EntityChaosGuardian extends EntityDragon { // summon DraconicEvolut
|
||||
return true;
|
||||
}
|
||||
|
||||
private static enum EnumBehaviour {
|
||||
private enum EnumBehaviour {
|
||||
|
||||
/**
|
||||
* Will roam around home until a player is spotted
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.brandon3055.draconicevolution.common.network.GenericParticlePacket;
|
||||
import com.brandon3055.draconicevolution.common.utils.handlers.ProcessHandler;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by brandon3055 on 3/10/2015.
|
||||
@@ -40,20 +42,21 @@ public class EntityChaosVortex extends Entity {
|
||||
if (!worldObj.isRemote) dataWatcher.updateObject(20, ticksExisted);
|
||||
else ticksExisted = dataWatcher.getWatchableObjectInt(20);
|
||||
|
||||
if (ticksExisted < 30 && ticksExisted % 5 == 0 && worldObj.isRemote) DraconicEvolution.proxy
|
||||
.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, false), 512);
|
||||
if (ticksExisted >= 100 && ticksExisted < 130 && ticksExisted % 5 == 0 && worldObj.isRemote)
|
||||
DraconicEvolution.proxy
|
||||
.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, true), 512);
|
||||
if (ticksExisted < 30 && ticksExisted % 5 == 0 && worldObj.isRemote) {
|
||||
spawnChaosParticles(false);
|
||||
}
|
||||
if (ticksExisted >= 100 && ticksExisted < 130 && ticksExisted % 5 == 0 && worldObj.isRemote) {
|
||||
spawnChaosParticles(true);
|
||||
}
|
||||
if (ticksExisted < 100) return;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
double x = posX - 18 + rand.nextDouble() * 36;
|
||||
double y = posY - 8 + rand.nextDouble() * 16;
|
||||
double z = posZ - 18 + rand.nextDouble() * 36;
|
||||
if (worldObj.isRemote) DraconicEvolution.proxy.spawnParticle(
|
||||
new Particles.AdvancedSeekerParticle(worldObj, x, y, z, posX, posY, posZ, 2, 1f, 1f, 1f, 100),
|
||||
128);
|
||||
if (worldObj.isRemote) {
|
||||
spawnSeekerParticles(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if (ticksExisted > 130 && worldObj.isRemote && ticksExisted % 2 == 0) shakeScreen();
|
||||
@@ -68,6 +71,19 @@ public class EntityChaosVortex extends Entity {
|
||||
if (ticksExisted > 620) setDead();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnChaosParticles(boolean shrink) {
|
||||
DraconicEvolution.clientProxy()
|
||||
.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, shrink), 512);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnSeekerParticles(double x, double y, double z) {
|
||||
DraconicEvolution.clientProxy().spawnParticle(
|
||||
new Particles.AdvancedSeekerParticle(worldObj, x, y, z, posX, posY, posZ, 2, 1f, 1f, 1f, 100),
|
||||
128);
|
||||
}
|
||||
|
||||
private void shakeScreen() {
|
||||
double intensity = (ticksExisted - 130) / 100D;
|
||||
if (intensity > 1D) intensity = 1D;
|
||||
|
||||
@@ -15,7 +15,9 @@ public class ConfigHandler {
|
||||
public static Configuration config;
|
||||
|
||||
// GENERAL
|
||||
public static boolean disableEarthBlock;
|
||||
public static int teleporterUsesPerPearl;
|
||||
public static int placedItemStackLimit;
|
||||
public static int soulDropChance;
|
||||
public static int passiveSoulDropChance;
|
||||
public static int cometRarity;
|
||||
@@ -104,11 +106,22 @@ public class ConfigHandler {
|
||||
// 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0);
|
||||
// disableXrayBlock = config.get(Configuration.CATEGORY_GENERAL, "Disable Xray Block", 0, "Disable
|
||||
// Distortion Flame 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0);
|
||||
disableEarthBlock = config
|
||||
.get(Configuration.CATEGORY_GENERAL, "Disable Earth block", false, "Disables the Earth block")
|
||||
.getBoolean(false);
|
||||
teleporterUsesPerPearl = config.get(
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
"Teleporter Uses PerPearl",
|
||||
1,
|
||||
"Charm of Dislocation uses per Ender pearl").getInt(1);
|
||||
placedItemStackLimit = snapToAllowedStackLimit(
|
||||
config.get(
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
"Placed Item Stack Limit",
|
||||
4,
|
||||
"Maximum number of items that can be placed in the same block with the Place Item key. Valid values: 1, 2, 4, 8, 16",
|
||||
1,
|
||||
16).getInt(4));
|
||||
bowBlockDamage = config.get(
|
||||
Configuration.CATEGORY_GENERAL,
|
||||
"Bow Block Damage",
|
||||
@@ -474,6 +487,16 @@ public class ConfigHandler {
|
||||
if (config.hasChanged()) config.save();
|
||||
}
|
||||
}
|
||||
|
||||
private static int snapToAllowedStackLimit(int value) {
|
||||
int snapped = 1;
|
||||
for (int allowed : new int[] { 1, 2, 4, 8, 16 }) {
|
||||
if (value >= allowed) {
|
||||
snapped = allowed;
|
||||
}
|
||||
}
|
||||
return snapped;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* { //config.load(); disableSunDial = config.getInt("Disable Sun Dial", Configuration.CATEGORY_GENERAL, disableSunDial,
|
||||
|
||||
@@ -36,10 +36,10 @@ import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
*/
|
||||
public class ContributorHandler {
|
||||
|
||||
public static Map<String, Contributor> contributors = new LinkedHashMap<String, Contributor>();
|
||||
public static Map<String, Contributor> contributors = new LinkedHashMap<>();
|
||||
public static boolean successfulLoad = false;
|
||||
private static DLThread thread;
|
||||
private static ModelContributorWings wings = new ModelContributorWings();
|
||||
private static final ModelContributorWings wings = new ModelContributorWings();
|
||||
|
||||
public static void init() {
|
||||
thread = new DLThread();
|
||||
@@ -58,8 +58,8 @@ public class ContributorHandler {
|
||||
}
|
||||
|
||||
public static boolean isPlayerContributor(EntityPlayer player) {
|
||||
return contributors.containsKey(player.getCommandSenderName())
|
||||
&& contributors.get(player.getCommandSenderName()).isUserValid(player);
|
||||
final Contributor contributor = contributors.get(player.getCommandSenderName());
|
||||
return contributor != null && contributor.isUserValid(player);
|
||||
}
|
||||
|
||||
private static void renderWings(RenderPlayerEvent event) {
|
||||
@@ -175,14 +175,14 @@ public class ContributorHandler {
|
||||
Contributor contributor = new Contributor();
|
||||
|
||||
while (reader.hasNext()) {
|
||||
String name = reader.nextName();
|
||||
|
||||
if (name.equals("name")) contributor.name = reader.nextString();
|
||||
else if (name.equals("ign")) contributor.ign = reader.nextString();
|
||||
else if (name.equals("contribution")) contributor.contribution = reader.nextString();
|
||||
else if (name.equals("details")) contributor.details = reader.nextString();
|
||||
else if (name.equals("website")) contributor.website = reader.nextString();
|
||||
else if (name.equals("contributionLevel")) contributor.contributionLevel = reader.nextInt();
|
||||
switch (reader.nextName()) {
|
||||
case "name" -> contributor.name = reader.nextString();
|
||||
case "ign" -> contributor.ign = reader.nextString();
|
||||
case "contribution" -> contributor.contribution = reader.nextString();
|
||||
case "details" -> contributor.details = reader.nextString();
|
||||
case "website" -> contributor.website = reader.nextString();
|
||||
case "contributionLevel" -> contributor.contributionLevel = reader.nextInt();
|
||||
}
|
||||
}
|
||||
|
||||
contributors.put(contributor.ign, contributor);
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.ArmorSummary;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
|
||||
@@ -26,13 +26,6 @@ public class FMLEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
|
||||
CustomArmorHandler.onPlayerTick(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverTickEvent(TickEvent event) {
|
||||
ContributorHandler.tick();
|
||||
@@ -41,8 +34,8 @@ public class FMLEventHandler {
|
||||
@SubscribeEvent
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.player.onGround) {
|
||||
CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(event.player);
|
||||
if (summery != null && summery.flight[0]) {
|
||||
final ArmorSummary summary = ArmorSummary.get(event.player);
|
||||
if (summary != null && summary.flight[0]) {
|
||||
event.player.capabilities.isFlying = true;
|
||||
event.player.sendPlayerAbilities();
|
||||
}
|
||||
|
||||
@@ -34,11 +34,8 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
@@ -48,11 +45,10 @@ import net.minecraftforge.event.world.WorldEvent;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.achievements.Achievements;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon;
|
||||
import com.brandon3055.draconicevolution.common.entity.EntityDragonHeart;
|
||||
import com.brandon3055.draconicevolution.common.entity.ExtendedPlayer;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.ArmorSummary;
|
||||
import com.brandon3055.draconicevolution.common.network.MountUpdatePacket;
|
||||
import com.brandon3055.draconicevolution.common.network.SpeedRequestPacket;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGrinder;
|
||||
@@ -71,22 +67,22 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class MinecraftForgeEventHandler {
|
||||
|
||||
Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
private static Method becomeAngryAt;
|
||||
private static final Field persistenceRequired;
|
||||
|
||||
public static double maxSpeed = 10F;
|
||||
public static int ticksSinceRequest = 0;
|
||||
public static boolean speedNeedsUpdating = true;
|
||||
|
||||
private Field persistenceRequired = null;
|
||||
|
||||
public MinecraftForgeEventHandler() {
|
||||
static {
|
||||
Field f = null;
|
||||
try {
|
||||
persistenceRequired = ReflectionHelper
|
||||
.findField(EntityLiving.class, "field_82179_bU", "persistenceRequired");
|
||||
f = ReflectionHelper.findField(EntityLiving.class, "field_82179_bU", "persistenceRequired");
|
||||
} catch (Exception e) {
|
||||
LogHelper.error("Unable to find field \"persistenceRequired\"");
|
||||
}
|
||||
persistenceRequired = f;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -131,38 +127,15 @@ public class MinecraftForgeEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingHurt(LivingHurtEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
CustomArmorHandler.onPlayerHurt(event);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onLivingDeath(LivingDeathEvent event) {
|
||||
if (event.entityLiving instanceof EntityPlayer) {
|
||||
CustomArmorHandler.onPlayerDeath(event);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingJumpEvent(LivingEvent.LivingJumpEvent event) {
|
||||
if (!(event.entityLiving instanceof EntityPlayer)) return;
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery().getSummery(player);
|
||||
|
||||
if (summery != null && summery.jumpModifier > 0) {
|
||||
player.motionY += (double) (summery.jumpModifier * 0.1F);
|
||||
if (!(event.entityLiving instanceof EntityPlayer player)) return;
|
||||
final ArmorSummary summary = ArmorSummary.get(player);
|
||||
if (summary != null && summary.jumpModifier > 0) {
|
||||
player.motionY += (summary.jumpModifier * 0.1F);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onLivingAttack(LivingAttackEvent event) {
|
||||
if (!(event.entityLiving instanceof EntityPlayer)) return;
|
||||
|
||||
CustomArmorHandler.onPlayerAttacked(event);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onDropEvent(LivingDropsEvent event) {
|
||||
if (!event.entity.worldObj.isRemote
|
||||
@@ -222,7 +195,7 @@ public class MinecraftForgeEventHandler {
|
||||
EntityLivingBase entity = event.entityLiving;
|
||||
Entity attacker = event.source.getEntity();
|
||||
|
||||
if (attacker == null || !(attacker instanceof EntityPlayer)) {
|
||||
if (!(attacker instanceof EntityPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,7 +216,7 @@ public class MinecraftForgeEventHandler {
|
||||
ItemNBTHelper.setInteger(soul, "SkeletonType", ((EntitySkeleton) entity).getSkeletonType());
|
||||
}
|
||||
world.spawnEntityInWorld(new EntityItem(world, entity.posX, entity.posY, entity.posZ, soul));
|
||||
Achievements.triggerAchievement((EntityPlayer) attacker, "draconicevolution.soul");
|
||||
DraconicEvolution.proxy.triggerAchievement((EntityPlayer) attacker, "draconicevolution.soul");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,16 +378,15 @@ public class MinecraftForgeEventHandler {
|
||||
public void getBreakSpeed(PlayerEvent.BreakSpeed event) {
|
||||
if (event.entityPlayer != null) {
|
||||
float newDigSpeed = event.originalSpeed;
|
||||
CustomArmorHandler.ArmorSummery summery = new CustomArmorHandler.ArmorSummery()
|
||||
.getSummery(event.entityPlayer);
|
||||
if (summery == null) return;
|
||||
final ArmorSummary summary = ArmorSummary.get(event.entityPlayer);
|
||||
if (summary == null) return;
|
||||
|
||||
if (event.entityPlayer.isInsideOfMaterial(Material.water)) {
|
||||
if (summery.flight[0]) newDigSpeed *= 5f;
|
||||
if (summary.flight[0]) newDigSpeed *= 5f;
|
||||
}
|
||||
|
||||
if (!event.entityPlayer.onGround) {
|
||||
if (summery.flight[0]) newDigSpeed *= 5f;
|
||||
if (summary.flight[0]) newDigSpeed *= 5f;
|
||||
}
|
||||
|
||||
if (event.newSpeed > 1) {
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.brandon3055.draconicevolution.common.items.armor;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.utils.IUpgradableItem;
|
||||
import com.brandon3055.draconicevolution.common.utils.ItemNBTHelper;
|
||||
|
||||
public final class ArmorSummary {
|
||||
|
||||
private ArmorSummary() {}
|
||||
|
||||
public static ArmorSummary get(EntityPlayer player) {
|
||||
// TODO if allocation is a problem replace with
|
||||
// a cached reusable thread local
|
||||
return new ArmorSummary().process(player);
|
||||
}
|
||||
|
||||
/*---- Shield ----*/
|
||||
/**
|
||||
* Max protection points from all equipped armor peaces
|
||||
*/
|
||||
public float maxProtectionPoints = 0F;
|
||||
/**
|
||||
* Total protection points from all equipped armor peaces
|
||||
*/
|
||||
public float protectionPoints = 0F;
|
||||
/**
|
||||
* Number of quipped armor peaces
|
||||
*/
|
||||
public int peaces = 0;
|
||||
/**
|
||||
* Point Allocation, The number of points on each peace
|
||||
*/
|
||||
public float[] allocation;
|
||||
/**
|
||||
* How many points have been drained from each armor peace
|
||||
*/
|
||||
public float[] pointsDown;
|
||||
/**
|
||||
* The armor peaces (Index will contain null if peace is not present)
|
||||
*/
|
||||
public ItemStack[] armorStacks;
|
||||
/**
|
||||
* Mean Fatigue
|
||||
*/
|
||||
public float entropy = 0F;
|
||||
/**
|
||||
* Mean Recovery Points
|
||||
*/
|
||||
public int meanRecoveryPoints = 0;
|
||||
/**
|
||||
* Total RF stored in the armor
|
||||
*/
|
||||
public long totalEnergyStored = 0;
|
||||
/**
|
||||
* Total Max RF storage for the armor
|
||||
*/
|
||||
public long maxTotalEnergyStorage = 0;
|
||||
/**
|
||||
* RF stored in each armor peace
|
||||
*/
|
||||
public int[] energyAllocation;
|
||||
/*---- Effects ----*/
|
||||
public boolean[] flight = new boolean[] { false, false, false };
|
||||
public float flightVModifier = 0F;
|
||||
public float speedModifier = 0F;
|
||||
public float jumpModifier = 0F;
|
||||
public float fireResistance = 0F;
|
||||
public float flightSpeedModifier = 0;
|
||||
public boolean hasHillStep = false;
|
||||
public boolean hasDraconic = false;
|
||||
|
||||
private ArmorSummary process(EntityPlayer player) {
|
||||
final ItemStack[] armorSlots = player.inventory.armorInventory;
|
||||
float totalEntropy = 0;
|
||||
int totalRecoveryPoints = 0;
|
||||
boolean needInit = true;
|
||||
|
||||
for (int i = 0; i < armorSlots.length; i++) {
|
||||
final ItemStack stack = armorSlots[i];
|
||||
if (stack == null || !(stack.getItem() instanceof ICustomArmor armor)) continue;
|
||||
if (needInit) {
|
||||
needInit = false;
|
||||
allocation = new float[armorSlots.length];
|
||||
armorStacks = new ItemStack[armorSlots.length];
|
||||
pointsDown = new float[armorSlots.length];
|
||||
energyAllocation = new int[armorSlots.length];
|
||||
}
|
||||
peaces++;
|
||||
allocation[i] = ItemNBTHelper.getFloat(stack, "ProtectionPoints", 0);
|
||||
protectionPoints += allocation[i];
|
||||
totalEntropy += ItemNBTHelper.getFloat(stack, "ShieldEntropy", 0);
|
||||
armorStacks[i] = stack;
|
||||
totalRecoveryPoints += IUpgradableItem.EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack);
|
||||
final float maxPoints = armor.getProtectionPoints(stack);
|
||||
pointsDown[i] = maxPoints - allocation[i];
|
||||
maxProtectionPoints += maxPoints;
|
||||
energyAllocation[i] = armor.getEnergyStored(stack);
|
||||
totalEnergyStored += energyAllocation[i];
|
||||
maxTotalEnergyStorage += armor.getMaxEnergyStored(stack);
|
||||
if (stack.getItem() instanceof DraconicArmor) hasDraconic = true;
|
||||
|
||||
fireResistance += armor.getFireResistance(stack);
|
||||
|
||||
switch (i) {
|
||||
case 2:
|
||||
flight = armor.hasFlight(stack);
|
||||
if (flight[0]) {
|
||||
flightVModifier = armor.getFlightVModifier(stack, player);
|
||||
flightSpeedModifier = armor.getFlightSpeedModifier(stack, player);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
speedModifier = armor.getSpeedModifier(stack, player);
|
||||
break;
|
||||
case 0:
|
||||
hasHillStep = armor.hasHillStep(stack, player);
|
||||
jumpModifier = armor.getJumpModifier(stack, player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (peaces == 0) return null;
|
||||
|
||||
entropy = totalEntropy / peaces;
|
||||
meanRecoveryPoints = totalRecoveryPoints / peaces;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.brandon3055.draconicevolution.common.items.armor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
@@ -17,89 +17,65 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.handler.BalanceConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.network.ShieldHitPacket;
|
||||
import com.brandon3055.draconicevolution.common.utils.IUpgradableItem;
|
||||
import com.brandon3055.draconicevolution.common.utils.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
import com.brandon3055.draconicevolution.integration.ModHelper;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 13/11/2014.
|
||||
*/
|
||||
public class CustomArmorHandler {
|
||||
public final class CustomArmorHandler {
|
||||
|
||||
public static final UUID WALK_SPEED_UUID = UUID.fromString("0ea6ce8e-d2e8-11e5-ab30-625662870761");
|
||||
private static final UUID WALK_SPEED_UUID = UUID.fromString("0ea6ce8e-d2e8-11e5-ab30-625662870761");
|
||||
private static final DamageSource ADMIN_KILL = new DamageSource("administrative.kill")
|
||||
.setDamageAllowedInCreativeMode().setDamageBypassesArmor().setDamageIsAbsolute();
|
||||
public static Map<EntityPlayer, Boolean> playersWithFlight = new WeakHashMap<EntityPlayer, Boolean>();
|
||||
public static List<String> playersWithUphillStep = new ArrayList<String>();
|
||||
|
||||
public static void onPlayerHurt(LivingHurtEvent event) {
|
||||
// EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
// ArmorSummery summery = new ArmorSummery().getSummery(player);
|
||||
// if (summery == null || summery.protectionPoints <= 0) return;
|
||||
// float newEntropy = Math.min(summery.entropy + Math.min(3, event.ammount/5) +
|
||||
// player.worldObj.rand.nextFloat(), 100F);
|
||||
//
|
||||
// //Divide the damage between the armor peaces based on how many of the protection points each peace has
|
||||
// float totalAbsorbed = 0;
|
||||
// for (int i = 0; i < summery.allocation.length; i++){
|
||||
// if (summery.allocation[i] == 0) continue;
|
||||
// ItemStack armorPeace = summery.armorStacks[i];
|
||||
//
|
||||
// float dmgShear = summery.allocation[i] / summery.protectionPoints;
|
||||
// float dmg = dmgShear * event.ammount;
|
||||
//
|
||||
// float absorbed = Math.min(dmg, summery.allocation[i]);
|
||||
// dmg -= absorbed;
|
||||
// totalAbsorbed += absorbed;
|
||||
// summery.allocation[i]-=absorbed;
|
||||
// ItemNBTHelper.setFloat(armorPeace, "ProtectionPoints", summery.allocation[i]);
|
||||
// ItemNBTHelper.setInteger(armorPeace, "ShieldHitTimer", 20);
|
||||
// ItemNBTHelper.setFloat(armorPeace, "ShieldEntropy", newEntropy);
|
||||
//
|
||||
//// if (dmg > 0 && absorbed >= dmgShear*20F){
|
||||
//// int energyCost = (int)(dmg * OVER_DRAIN_COST);
|
||||
//// int extracted = ((IEnergyContainerItem)armorPeace.getItem()).extractEnergy(armorPeace, energyCost,
|
||||
// false);
|
||||
//// dmg = (energyCost-extracted) / OVER_DRAIN_COST;
|
||||
//// totalAbsorbed += extracted / OVER_DRAIN_COST;
|
||||
//// ItemNBTHelper.setFloat(armorPeace, "ShieldEntropy", 100);
|
||||
//// }
|
||||
//
|
||||
//// LogHelper.info(dmg);
|
||||
// }
|
||||
//
|
||||
// event.ammount-=totalAbsorbed;
|
||||
// if (event.ammount <= 0) event.setCanceled(true);
|
||||
// player.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).removeModifier(new
|
||||
// AttributeModifier(KB_ATTRIB_UUID, SharedMonsterAttributes.knockbackResistance.getAttributeUnlocalizedName(),
|
||||
// 100, 0));
|
||||
// LogHelper.info("hurt");
|
||||
// Collection that will be populated with client and server players when playing on integrated server
|
||||
private final Set<EntityPlayer> playersWithFlight = Collections.synchronizedSet(new HashSet<>());
|
||||
private boolean clientPlayerHasHillStep;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldUnload(WorldEvent.Unload event) {
|
||||
if (event.world.isRemote) {
|
||||
clientPlayerHasHillStep = false;
|
||||
}
|
||||
if (!playersWithFlight.isEmpty()) {
|
||||
synchronized (playersWithFlight) {
|
||||
playersWithFlight.removeIf(p -> event.world == p.worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void onPlayerAttacked(LivingAttackEvent event) {
|
||||
if (event.isCanceled()) {
|
||||
public void onServerStopped() {
|
||||
this.playersWithFlight.clear();
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onLivingAttack(LivingAttackEvent event) {
|
||||
if (!(event.entityLiving instanceof EntityPlayer player)) return;
|
||||
|
||||
final ArmorSummary summary = ArmorSummary.get(player);
|
||||
|
||||
float hitAmount = ModHelper.applyModDamageAdjustments(summary, event);
|
||||
|
||||
if (applyArmorDamageBlocking(event, summary)) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ArmorSummery summery = new ArmorSummery().getSummery(player);
|
||||
|
||||
float hitAmount = ModHelper.applyModDamageAdjustments(summery, event);
|
||||
|
||||
if (applyArmorDamageBlocking(event, summery)) {
|
||||
return;
|
||||
}
|
||||
if (summery == null || summery.protectionPoints <= 0 || event.source == ADMIN_KILL) {
|
||||
if (summary == null || summary.protectionPoints <= 0 || event.source == ADMIN_KILL) {
|
||||
return;
|
||||
}
|
||||
event.setCanceled(true);
|
||||
@@ -110,29 +86,29 @@ public class CustomArmorHandler {
|
||||
}
|
||||
if ((float) player.hurtResistantTime > (float) player.maxHurtResistantTime / 2.0F) return;
|
||||
|
||||
float newEntropy = Math.min(summery.entropy + 1 + (hitAmount / 20), 100F);
|
||||
float newEntropy = Math.min(summary.entropy + 1 + (hitAmount / 20), 100F);
|
||||
|
||||
// Divide the damage between the armor peaces based on how many of the protection points each peace has
|
||||
float totalAbsorbed = 0;
|
||||
int remainingPoints = 0;
|
||||
for (int i = 0; i < summery.allocation.length; i++) {
|
||||
if (summery.allocation[i] == 0) continue;
|
||||
ItemStack armorPeace = summery.armorStacks[i];
|
||||
float remainingPoints = 0;
|
||||
for (int i = 0; i < summary.allocation.length; i++) {
|
||||
if (summary.allocation[i] == 0) continue;
|
||||
ItemStack armorPeace = summary.armorStacks[i];
|
||||
|
||||
float dmgShear = summery.allocation[i] / summery.protectionPoints;
|
||||
float dmgShear = summary.allocation[i] / summary.protectionPoints;
|
||||
float dmg = dmgShear * hitAmount;
|
||||
|
||||
float absorbed = Math.min(dmg, summery.allocation[i]);
|
||||
float absorbed = Math.min(dmg, summary.allocation[i]);
|
||||
totalAbsorbed += absorbed;
|
||||
summery.allocation[i] -= absorbed;
|
||||
remainingPoints += summery.allocation[i];
|
||||
ItemNBTHelper.setFloat(armorPeace, "ProtectionPoints", summery.allocation[i]);
|
||||
summary.allocation[i] -= absorbed;
|
||||
remainingPoints += summary.allocation[i];
|
||||
ItemNBTHelper.setFloat(armorPeace, "ProtectionPoints", summary.allocation[i]);
|
||||
ItemNBTHelper.setFloat(armorPeace, "ShieldEntropy", newEntropy);
|
||||
}
|
||||
|
||||
if (summery.protectionPoints > 0) {
|
||||
if (summary.protectionPoints > 0) {
|
||||
DraconicEvolution.network.sendToAllAround(
|
||||
new ShieldHitPacket(player, summery.protectionPoints / summery.maxProtectionPoints),
|
||||
new ShieldHitPacket(player, summary.protectionPoints / summary.maxProtectionPoints),
|
||||
new NetworkRegistry.TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 64));
|
||||
player.worldObj.playSoundEffect(
|
||||
player.posX + 0.5D,
|
||||
@@ -150,42 +126,46 @@ public class CustomArmorHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void onPlayerDeath(LivingDeathEvent event) {
|
||||
if (event.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onLivingDeath(LivingDeathEvent event) {
|
||||
if (!(event.entityLiving instanceof EntityPlayer player)) return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
ArmorSummery summery = new ArmorSummery().getSummery(player);
|
||||
final ArmorSummary summary = ArmorSummary.get(player);
|
||||
|
||||
if (summery == null || event.source == ADMIN_KILL) return;
|
||||
if (summary == null || event.source == ADMIN_KILL) return;
|
||||
|
||||
if (summery.protectionPoints > 500) {
|
||||
if (summary.protectionPoints > 500) {
|
||||
event.setCanceled(true);
|
||||
event.entityLiving.setHealth(10);
|
||||
// LogHelper.warn("Something is trying to bypass the draconic shield. [Culprit: {Damage Type=" +
|
||||
// event.source.damageType + ", Damage Class=" + event.source.toString() + "]");
|
||||
if (DraconicEvolution.debug) {
|
||||
LogHelper.warn(
|
||||
"Something is trying to bypass the draconic shield. [Culprit: {Damage Type="
|
||||
+ event.source.damageType
|
||||
+ ", Damage Class="
|
||||
+ event.source
|
||||
+ "]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!summery.hasDraconic) return;
|
||||
if (!summary.hasDraconic) return;
|
||||
|
||||
int[] charge = new int[summery.armorStacks.length];
|
||||
int[] charge = new int[summary.armorStacks.length];
|
||||
int totalCharge = 0;
|
||||
for (int i = 0; i < summery.armorStacks.length; i++) {
|
||||
if (summery.armorStacks[i] != null) {
|
||||
charge[i] = ((IEnergyContainerItem) summery.armorStacks[i].getItem())
|
||||
.getEnergyStored(summery.armorStacks[i]);
|
||||
for (int i = 0; i < summary.armorStacks.length; i++) {
|
||||
if (summary.armorStacks[i] != null) {
|
||||
charge[i] = ((IEnergyContainerItem) summary.armorStacks[i].getItem())
|
||||
.getEnergyStored(summary.armorStacks[i]);
|
||||
totalCharge += charge[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (totalCharge < BalanceConfigHandler.draconicArmorBaseStorage) return;
|
||||
|
||||
for (int i = 0; i < summery.armorStacks.length; i++) {
|
||||
if (summery.armorStacks[i] != null) {
|
||||
((IEnergyContainerItem) summery.armorStacks[i].getItem()).extractEnergy(
|
||||
summery.armorStacks[i],
|
||||
for (int i = 0; i < summary.armorStacks.length; i++) {
|
||||
if (summary.armorStacks[i] != null) {
|
||||
((IEnergyContainerItem) summary.armorStacks[i].getItem()).extractEnergy(
|
||||
summary.armorStacks[i],
|
||||
(int) ((charge[i] / (double) totalCharge) * BalanceConfigHandler.draconicArmorBaseStorage),
|
||||
false);
|
||||
}
|
||||
@@ -198,107 +178,102 @@ public class CustomArmorHandler {
|
||||
player.setHealth(1);
|
||||
}
|
||||
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
|
||||
EntityPlayer player = event.player;
|
||||
ArmorSummery summery = new ArmorSummery().getSummery(player);
|
||||
|
||||
tickShield(summery, player);
|
||||
tickArmorEffects(summery, player);
|
||||
}
|
||||
|
||||
public static void tickShield(ArmorSummery summery, EntityPlayer player) {
|
||||
if (summery == null || (summery.maxProtectionPoints - summery.protectionPoints < 0.01 && summery.entropy == 0)
|
||||
|| player.worldObj.isRemote)
|
||||
return;
|
||||
|
||||
float totalPointsToAdd = Math
|
||||
.min(summery.maxProtectionPoints - summery.protectionPoints, summery.maxProtectionPoints / 60F);
|
||||
totalPointsToAdd *= (1F - (summery.entropy / 100F));
|
||||
totalPointsToAdd = Math.min(
|
||||
totalPointsToAdd,
|
||||
summery.totalEnergyStored
|
||||
/ (summery.hasDraconic ? BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint
|
||||
: BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint));
|
||||
if (totalPointsToAdd < 0F) totalPointsToAdd = 0F;
|
||||
|
||||
summery.entropy -= (summery.meanRecoveryPoints * 0.01F);
|
||||
if (summery.entropy < 0) summery.entropy = 0;
|
||||
|
||||
for (int i = 0; i < summery.armorStacks.length; i++) {
|
||||
ItemStack stack = summery.armorStacks[i];
|
||||
if (stack == null || summery.totalEnergyStored <= 0) continue;
|
||||
float maxForPeace = ((ICustomArmor) stack.getItem()).getProtectionPoints(stack);
|
||||
int energyAmount = ((ICustomArmor) summery.armorStacks[i].getItem()).getEnergyPerProtectionPoint();
|
||||
((IEnergyContainerItem) stack.getItem()).extractEnergy(
|
||||
stack,
|
||||
(int) (((double) summery.energyAllocation[i] / (double) summery.totalEnergyStored)
|
||||
* (totalPointsToAdd * energyAmount)),
|
||||
false);
|
||||
float pointsForPeace = (summery.pointsDown[i]
|
||||
/ Math.max(1, summery.maxProtectionPoints - summery.protectionPoints)) * totalPointsToAdd;
|
||||
summery.allocation[i] += pointsForPeace;
|
||||
if (summery.allocation[i] > maxForPeace || maxForPeace - summery.allocation[i] < 0.1F)
|
||||
summery.allocation[i] = maxForPeace;
|
||||
ItemNBTHelper.setFloat(stack, "ProtectionPoints", summery.allocation[i]);
|
||||
if (player.hurtResistantTime <= 0) ItemNBTHelper.setFloat(stack, "ShieldEntropy", summery.entropy);
|
||||
@SubscribeEvent
|
||||
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
final EntityPlayer player = event.player;
|
||||
final ArmorSummary summary = ArmorSummary.get(player);
|
||||
tickShield(summary, player);
|
||||
tickArmorEffects(summary, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void tickArmorEffects(ArmorSummery summery, EntityPlayer player) {
|
||||
private void tickShield(ArmorSummary summary, EntityPlayer player) {
|
||||
if (summary == null || summary.maxProtectionPoints - summary.protectionPoints < 0.01 && summary.entropy == 0
|
||||
|| player.worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
float totalPointsToAdd = Math
|
||||
.min(summary.maxProtectionPoints - summary.protectionPoints, summary.maxProtectionPoints / 60F);
|
||||
totalPointsToAdd *= (1F - (summary.entropy / 100F));
|
||||
totalPointsToAdd = Math.min(
|
||||
totalPointsToAdd,
|
||||
summary.totalEnergyStored
|
||||
/ (summary.hasDraconic ? BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint
|
||||
: BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint));
|
||||
if (totalPointsToAdd < 0F) totalPointsToAdd = 0F;
|
||||
|
||||
summary.entropy -= (summary.meanRecoveryPoints * 0.01F);
|
||||
if (summary.entropy < 0) summary.entropy = 0;
|
||||
|
||||
for (int i = 0; i < summary.armorStacks.length; i++) {
|
||||
ItemStack stack = summary.armorStacks[i];
|
||||
if (stack == null || summary.totalEnergyStored <= 0) continue;
|
||||
float maxForPeace = ((ICustomArmor) stack.getItem()).getProtectionPoints(stack);
|
||||
int energyAmount = ((ICustomArmor) summary.armorStacks[i].getItem()).getEnergyPerProtectionPoint();
|
||||
((IEnergyContainerItem) stack.getItem()).extractEnergy(
|
||||
stack,
|
||||
(int) (((double) summary.energyAllocation[i] / (double) summary.totalEnergyStored)
|
||||
* (totalPointsToAdd * energyAmount)),
|
||||
false);
|
||||
float pointsForPeace = (summary.pointsDown[i]
|
||||
/ Math.max(1, summary.maxProtectionPoints - summary.protectionPoints)) * totalPointsToAdd;
|
||||
summary.allocation[i] += pointsForPeace;
|
||||
if (summary.allocation[i] > maxForPeace || maxForPeace - summary.allocation[i] < 0.1F)
|
||||
summary.allocation[i] = maxForPeace;
|
||||
ItemNBTHelper.setFloat(stack, "ProtectionPoints", summary.allocation[i]);
|
||||
if (player.hurtResistantTime <= 0) ItemNBTHelper.setFloat(stack, "ShieldEntropy", summary.entropy);
|
||||
}
|
||||
}
|
||||
|
||||
private void tickArmorEffects(ArmorSummary summary, EntityPlayer player) {
|
||||
|
||||
// region/*----------------- Flight ------------------*/
|
||||
if (ConfigHandler.enableFlight) {
|
||||
if (summery != null && summery.flight[0]) {
|
||||
playersWithFlight.put(player, true);
|
||||
if (summary != null && summary.flight[0]) {
|
||||
playersWithFlight.add(player);
|
||||
player.capabilities.allowFlying = true;
|
||||
if (summery.flight[1]) player.capabilities.isFlying = true;
|
||||
if (summary.flight[1]) {
|
||||
player.capabilities.isFlying = true;
|
||||
}
|
||||
|
||||
if (player.worldObj.isRemote) setPlayerFlySpeed(player, 0.05F + (0.05F * summery.flightSpeedModifier));
|
||||
if (player.worldObj.isRemote) {
|
||||
player.capabilities.setFlySpeed(0.05F + (0.05F * summary.flightSpeedModifier));
|
||||
}
|
||||
|
||||
if ((!player.onGround && player.capabilities.isFlying) && player.motionY != 0
|
||||
&& summery.flightVModifier > 0) {
|
||||
// float percentIncrease = summery.flightVModifier;
|
||||
if (!player.onGround && player.capabilities.isFlying
|
||||
&& player.motionY != 0
|
||||
&& summary.flightVModifier > 0) {
|
||||
// float percentIncrease = summary.flightVModifier;
|
||||
|
||||
if (DraconicEvolution.proxy.isSpaceDown() && !DraconicEvolution.proxy.isShiftDown()) {
|
||||
// LogHelper.info(player.motionY);
|
||||
player.motionY = 0.225F * summery.flightVModifier;
|
||||
player.motionY = 0.225F * summary.flightVModifier;
|
||||
}
|
||||
|
||||
if (DraconicEvolution.proxy.isShiftDown() && !DraconicEvolution.proxy.isSpaceDown()) {
|
||||
player.motionY = -0.225F * summery.flightVModifier;
|
||||
player.motionY = -0.225F * summary.flightVModifier;
|
||||
}
|
||||
}
|
||||
|
||||
if (summery.flight[2] && player.moveForward == 0
|
||||
if (summary.flight[2] && player.moveForward == 0
|
||||
&& player.moveStrafing == 0
|
||||
&& player.capabilities.isFlying) {
|
||||
player.motionX *= 0.5;
|
||||
player.motionZ *= 0.5;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!playersWithFlight.containsKey(player)) {
|
||||
playersWithFlight.put(player, false);
|
||||
}
|
||||
|
||||
if (playersWithFlight.get(player) && !player.worldObj.isRemote) {
|
||||
playersWithFlight.put(player, false);
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
player.capabilities.allowFlying = false;
|
||||
player.capabilities.isFlying = false;
|
||||
} else if (playersWithFlight.remove(player)) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
player.capabilities.allowFlying = false;
|
||||
player.capabilities.isFlying = false;
|
||||
if (!player.worldObj.isRemote) {
|
||||
player.sendPlayerAbilities();
|
||||
}
|
||||
}
|
||||
|
||||
if (player.worldObj.isRemote && playersWithFlight.get(player)) {
|
||||
playersWithFlight.put(player, false);
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
player.capabilities.allowFlying = false;
|
||||
player.capabilities.isFlying = false;
|
||||
}
|
||||
setPlayerFlySpeed(player, 0.05F);
|
||||
if (player.worldObj.isRemote) {
|
||||
player.capabilities.setFlySpeed(0.05F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,8 +282,8 @@ public class CustomArmorHandler {
|
||||
// region/*---------------- Swiftness ----------------*/
|
||||
|
||||
IAttribute speedAttr = SharedMonsterAttributes.movementSpeed;
|
||||
if (summery != null && summery.speedModifier > 0) {
|
||||
double value = summery.speedModifier;
|
||||
if (summary != null && summary.speedModifier > 0) {
|
||||
double value = summary.speedModifier;
|
||||
if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID) == null) {
|
||||
player.getEntityAttribute(speedAttr).applyModifier(
|
||||
new AttributeModifier(WALK_SPEED_UUID, speedAttr.getAttributeUnlocalizedName(), value, 1));
|
||||
@@ -319,8 +294,9 @@ public class CustomArmorHandler {
|
||||
new AttributeModifier(WALK_SPEED_UUID, speedAttr.getAttributeUnlocalizedName(), value, 1));
|
||||
}
|
||||
|
||||
if (!player.onGround && player.ridingEntity == null)
|
||||
player.jumpMovementFactor = 0.02F + (0.02F * summery.speedModifier);
|
||||
if (!player.onGround && player.ridingEntity == null) {
|
||||
player.jumpMovementFactor = 0.02F + (0.02F * summary.speedModifier);
|
||||
}
|
||||
} else if (player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID) != null) {
|
||||
player.getEntityAttribute(speedAttr)
|
||||
.removeModifier(player.getEntityAttribute(speedAttr).getModifier(WALK_SPEED_UUID));
|
||||
@@ -329,161 +305,50 @@ public class CustomArmorHandler {
|
||||
// endregion
|
||||
|
||||
// region/*---------------- HillStep -----------------*/
|
||||
if (summery != null && player.worldObj.isRemote) {
|
||||
boolean highStepListed = playersWithUphillStep.contains(player.getDisplayName()) && player.stepHeight >= 1f;
|
||||
boolean hasHighStep = summery.hasHillStep;
|
||||
|
||||
if (hasHighStep && !highStepListed) {
|
||||
playersWithUphillStep.add(player.getDisplayName());
|
||||
player.stepHeight = 1f;
|
||||
}
|
||||
|
||||
if (!hasHighStep && highStepListed) {
|
||||
playersWithUphillStep.remove(player.getDisplayName());
|
||||
player.stepHeight = 0.5F;
|
||||
}
|
||||
if (player.worldObj.isRemote) {
|
||||
handleHillStepClient(summary, player);
|
||||
}
|
||||
// endregion
|
||||
}
|
||||
|
||||
private static void setPlayerFlySpeed(EntityPlayer player, float speed) {
|
||||
player.capabilities.setFlySpeed(speed);
|
||||
@SideOnly(value = Side.CLIENT)
|
||||
private void handleHillStepClient(ArmorSummary summary, EntityPlayer player) {
|
||||
if (player == Minecraft.getMinecraft().thePlayer) {
|
||||
final boolean hasHillStep = player.stepHeight >= 1f && clientPlayerHasHillStep;
|
||||
final boolean shouldHaveHillStep = summary != null && summary.hasHillStep;
|
||||
|
||||
if (shouldHaveHillStep && !hasHillStep) {
|
||||
clientPlayerHasHillStep = true;
|
||||
player.stepHeight = 1f;
|
||||
}
|
||||
|
||||
if (!shouldHaveHillStep && hasHillStep) {
|
||||
clientPlayerHasHillStep = false;
|
||||
player.stepHeight = 0.5F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean applyArmorDamageBlocking(LivingAttackEvent event, ArmorSummery summery) {
|
||||
if (summery == null) return false;
|
||||
private static boolean applyArmorDamageBlocking(LivingAttackEvent event, ArmorSummary summary) {
|
||||
if (summary == null) return false;
|
||||
|
||||
if (event.source.isFireDamage() && summery.fireResistance >= 1F) {
|
||||
if (event.source.isFireDamage() && summary.fireResistance >= 1F) {
|
||||
event.setCanceled(true);
|
||||
event.entityLiving.extinguish();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.source.damageType.equals("fall") && summery.jumpModifier > 0F) {
|
||||
if (event.ammount < summery.jumpModifier * 5F) event.setCanceled(true);
|
||||
if (event.source.damageType.equals("fall") && summary.jumpModifier > 0F) {
|
||||
if (event.ammount < summary.jumpModifier * 5F) event.setCanceled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((event.source.damageType.equals("inWall") || event.source.damageType.equals("drown"))
|
||||
&& summery.armorStacks[3] != null) {
|
||||
&& summary.armorStacks[3] != null) {
|
||||
if (event.ammount <= 2f) event.setCanceled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class ArmorSummery {
|
||||
|
||||
/*---- Shield ----*/
|
||||
/**
|
||||
* Max protection points from all equipped armor peaces
|
||||
*/
|
||||
public float maxProtectionPoints = 0F;
|
||||
/**
|
||||
* Total protection points from all equipped armor peaces
|
||||
*/
|
||||
public float protectionPoints = 0F;
|
||||
/**
|
||||
* Number of quipped armor peaces
|
||||
*/
|
||||
public int peaces = 0;
|
||||
/**
|
||||
* Point Allocation, The number of points on each peace
|
||||
*/
|
||||
public float[] allocation;
|
||||
/**
|
||||
* How many points have been drained from each armor peace
|
||||
*/
|
||||
public float[] pointsDown;
|
||||
/**
|
||||
* The armor peaces (Index will contain null if peace is not present)
|
||||
*/
|
||||
public ItemStack[] armorStacks;
|
||||
/**
|
||||
* Mean Fatigue
|
||||
*/
|
||||
public float entropy = 0F;
|
||||
/**
|
||||
* Mean Recovery Points
|
||||
*/
|
||||
public int meanRecoveryPoints = 0;
|
||||
/**
|
||||
* Total RF stored in the armor
|
||||
*/
|
||||
public long totalEnergyStored = 0;
|
||||
/**
|
||||
* Total Max RF storage for the armor
|
||||
*/
|
||||
public long maxTotalEnergyStorage = 0;
|
||||
/**
|
||||
* RF stored in each armor peace
|
||||
*/
|
||||
public int[] energyAllocation;
|
||||
/*---- Effects ----*/
|
||||
public boolean[] flight = new boolean[] { false, false, false };
|
||||
public float flightVModifier = 0F;
|
||||
public float speedModifier = 0F;
|
||||
public float jumpModifier = 0F;
|
||||
public float fireResistance = 0F;
|
||||
public float flightSpeedModifier = 0;
|
||||
public boolean hasHillStep = false;
|
||||
public boolean hasDraconic = false;
|
||||
|
||||
public ArmorSummery getSummery(EntityPlayer player) {
|
||||
ItemStack[] armorSlots = player.inventory.armorInventory;
|
||||
float totalEntropy = 0;
|
||||
int totalRecoveryPoints = 0;
|
||||
|
||||
allocation = new float[armorSlots.length];
|
||||
armorStacks = new ItemStack[armorSlots.length];
|
||||
pointsDown = new float[armorSlots.length];
|
||||
energyAllocation = new int[armorSlots.length];
|
||||
|
||||
for (int i = 0; i < armorSlots.length; i++) {
|
||||
ItemStack stack = armorSlots[i];
|
||||
if (stack == null || !(stack.getItem() instanceof ICustomArmor)) continue;
|
||||
ICustomArmor armor = (ICustomArmor) stack.getItem();
|
||||
peaces++;
|
||||
allocation[i] = ItemNBTHelper.getFloat(stack, "ProtectionPoints", 0);
|
||||
protectionPoints += allocation[i];
|
||||
totalEntropy += ItemNBTHelper.getFloat(stack, "ShieldEntropy", 0);
|
||||
armorStacks[i] = stack;
|
||||
totalRecoveryPoints += IUpgradableItem.EnumUpgrade.SHIELD_RECOVERY.getUpgradePoints(stack);
|
||||
float maxPoints = armor.getProtectionPoints(stack);
|
||||
pointsDown[i] = maxPoints - allocation[i];
|
||||
maxProtectionPoints += maxPoints;
|
||||
energyAllocation[i] = armor.getEnergyStored(stack);
|
||||
totalEnergyStored += energyAllocation[i];
|
||||
maxTotalEnergyStorage += armor.getMaxEnergyStored(stack);
|
||||
if (stack.getItem() instanceof DraconicArmor) hasDraconic = true;
|
||||
|
||||
fireResistance += armor.getFireResistance(stack);
|
||||
|
||||
switch (i) {
|
||||
case 2:
|
||||
flight = armor.hasFlight(stack);
|
||||
if (flight[0]) {
|
||||
flightVModifier = armor.getFlightVModifier(stack, player);
|
||||
flightSpeedModifier = armor.getFlightSpeedModifier(stack, player);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
speedModifier = armor.getSpeedModifier(stack, player);
|
||||
break;
|
||||
case 0:
|
||||
hasHillStep = armor.hasHillStep(stack, player);
|
||||
jumpModifier = armor.getJumpModifier(stack, player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (peaces == 0) return null;
|
||||
|
||||
entropy = totalEntropy / peaces;
|
||||
meanRecoveryPoints = totalRecoveryPoints / peaces;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@ import com.brandon3055.draconicevolution.common.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.items.ItemDE;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileDislocatorInhibitor;
|
||||
import com.brandon3055.draconicevolution.common.utils.IConfigurableItem;
|
||||
import com.brandon3055.draconicevolution.common.utils.InfoHelper;
|
||||
import com.brandon3055.draconicevolution.common.utils.InventoryUtils;
|
||||
@@ -62,8 +61,10 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem {
|
||||
DELAY,
|
||||
NEVER;
|
||||
|
||||
public static final SelfPickUpMode[] VALUES = values();
|
||||
|
||||
public SelfPickUpMode next() {
|
||||
final SelfPickUpMode[] values = SelfPickUpMode.values();
|
||||
final SelfPickUpMode[] values = SelfPickUpMode.VALUES;
|
||||
return values[(this.ordinal() + 1) % values.length];
|
||||
}
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem {
|
||||
|
||||
for (EntityItem item : items) {
|
||||
if (item.getEntityItem() == null || ModHelper.isAE2EntityFloatingItem(item)
|
||||
|| TileDislocatorInhibitor.isBlockedByInhibitor(world, item)) {
|
||||
|| DraconicEvolution.proxy.isBlockedByInhibitor(world, item)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -266,7 +267,7 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem {
|
||||
|
||||
private static SelfPickUpMode getSelfPickupStatus(ItemStack itemStack) {
|
||||
final short mode = getSelfPickupStatusShort(itemStack);
|
||||
return SelfPickUpMode.values()[mode];
|
||||
return SelfPickUpMode.VALUES[mode];
|
||||
}
|
||||
|
||||
public static void toggleSelfPickupStatus(ItemStack itemStack) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.keybinding.KeyBindings;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.network.ToolModePacket;
|
||||
@@ -228,10 +227,13 @@ public class ToolBase extends RFItemBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addAditionalInformation(ItemStack stack, EntityPlayer player, List list, boolean extended) {
|
||||
String key;
|
||||
if (KeyBindings.toolConfig.getKeyCode() >= 0 && KeyBindings.toolConfig.getKeyCode() < Keyboard.KEYBOARD_SIZE)
|
||||
key = Keyboard.getKeyName(KeyBindings.toolConfig.getKeyCode());
|
||||
else key = Mouse.getButtonName(KeyBindings.toolConfig.getKeyCode() + 101);
|
||||
final int configKeyCode = DraconicEvolution.clientProxy().getKeybindHandler().toolConfigKeycode();
|
||||
final String key;
|
||||
if (configKeyCode >= 0 && configKeyCode < Keyboard.KEYBOARD_SIZE) {
|
||||
key = Keyboard.getKeyName(configKeyCode);
|
||||
} else {
|
||||
key = Mouse.getButtonName(configKeyCode + 101);
|
||||
}
|
||||
|
||||
list.add(
|
||||
StatCollector.translateToLocal("info.de.press.txt") + " "
|
||||
|
||||
@@ -158,8 +158,8 @@ public class BowHandler {
|
||||
|
||||
public int calculateEnergyCost() {
|
||||
updateValues();
|
||||
double rfCost = (bow.getItem() instanceof IEnergyContainerWeaponItem)
|
||||
? ((IEnergyContainerWeaponItem) bow.getItem()).getEnergyPerAttack()
|
||||
double rfCost = (bow.getItem() instanceof IEnergyContainerBowItem)
|
||||
? ((IEnergyContainerBowItem) bow.getItem()).getEnergyPerAttack()
|
||||
: 80;
|
||||
|
||||
rfCost *= 1 + arrowDamage;
|
||||
@@ -175,7 +175,7 @@ public class BowHandler {
|
||||
updateValues();
|
||||
|
||||
if (player == null) return false;
|
||||
if (!(bow.getItem() instanceof IEnergyContainerWeaponItem)) {
|
||||
if (!(bow.getItem() instanceof IEnergyContainerBowItem)) {
|
||||
cantFireMessage = "[Error] This bow is not a valid energy container (This is a bug, Please report on the Draconic Evolution github)";
|
||||
return false;
|
||||
} else if (!energyBolt && shockWavePower > 0) {
|
||||
@@ -184,7 +184,7 @@ public class BowHandler {
|
||||
} else if (energyBolt && explosionPower > 0) {
|
||||
cantFireMessage = "msg.de.explosiveNotForEnergyBolts.txt";
|
||||
return false;
|
||||
} else if (calculateEnergyCost() > ((IEnergyContainerWeaponItem) bow.getItem()).getEnergyStored(bow)
|
||||
} else if (calculateEnergyCost() > ((IEnergyContainerBowItem) bow.getItem()).getEnergyStored(bow)
|
||||
&& !player.capabilities.isCreativeMode) {
|
||||
cantFireMessage = "msg.de.insufficientPowerToFire.txt";
|
||||
return false;
|
||||
@@ -223,7 +223,7 @@ public class BowHandler {
|
||||
public boolean consumeArrowAndEnergy() {
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
((IEnergyContainerWeaponItem) bow.getItem()).extractEnergy(bow, calculateEnergyCost(), false);
|
||||
((IEnergyContainerBowItem) bow.getItem()).extractEnergy(bow, calculateEnergyCost(), false);
|
||||
|
||||
if (!energyBolt && EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, bow) == 0
|
||||
&& !player.capabilities.isCreativeMode) {
|
||||
|
||||
@@ -39,7 +39,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class DraconicBow extends ItemBow
|
||||
implements IInventoryTool, IUpgradableItem, IEnergyContainerWeaponItem, IHudDisplayItem {
|
||||
implements IInventoryTool, IUpgradableItem, IEnergyContainerBowItem, IHudDisplayItem {
|
||||
|
||||
public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" };
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.brandon3055.draconicevolution.common.items.weapons;
|
||||
|
||||
public interface IEnergyContainerBowItem extends IEnergyContainerWeaponItem {
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class WyvernBow extends ItemBow
|
||||
implements IInventoryTool, IUpgradableItem, IEnergyContainerWeaponItem, IHudDisplayItem {
|
||||
implements IInventoryTool, IUpgradableItem, IEnergyContainerBowItem, IHudDisplayItem {
|
||||
|
||||
public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" };
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.Magnet;
|
||||
import com.brandon3055.draconicevolution.common.utils.InventoryUtils;
|
||||
import com.brandon3055.draconicevolution.integration.ModHelper;
|
||||
@@ -49,7 +49,7 @@ public final class MagnetToggleAckPacket implements IMessage {
|
||||
if (magnetOptional.isPresent()) {
|
||||
ItemStack itemStack = magnetOptional.get();
|
||||
Magnet.setStatus(itemStack, message.status);
|
||||
ClientEventHandler.statusDisplayManager.startDrawing(itemStack.copy());
|
||||
DraconicEvolution.clientProxy().displayItem(itemStack);
|
||||
if (ModHelper.isGTNHLibLoaded) Magnet.renderHUDStatusChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.items.tools.Magnet;
|
||||
import com.brandon3055.draconicevolution.common.utils.InventoryUtils;
|
||||
import com.brandon3055.draconicevolution.integration.ModHelper;
|
||||
@@ -49,7 +49,7 @@ public final class MagnetToggleSelfPickupAckPacket implements IMessage {
|
||||
if (magnetOptional.isPresent()) {
|
||||
ItemStack itemStack = magnetOptional.get();
|
||||
Magnet.setSelfPickupStatus(itemStack, message.status);
|
||||
ClientEventHandler.statusDisplayManager.startDrawing(itemStack.copy());
|
||||
DraconicEvolution.clientProxy().displayItem(itemStack);
|
||||
if (ModHelper.isGTNHLibLoaded) Magnet.renderHUDSelfPickupStatusChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.brandon3055.draconicevolution.common.network;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -45,7 +45,7 @@ public class MountUpdatePacket implements IMessage {
|
||||
return null;
|
||||
}
|
||||
|
||||
ClientEventHandler.tryRepositionPlayerOnMount(message.entityID);
|
||||
DraconicEvolution.proxy.tryRepositionPlayerOnMount(message.entityID);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,19 @@ public class PlacedItemPacket implements IMessage {
|
||||
World world = ctx.getServerHandler().playerEntity.worldObj;
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
|
||||
if (!world.isAirBlock(x, y, z) || player.getHeldItem() == null
|
||||
|| !ModBlocks.isEnabled(ModBlocks.placedItem))
|
||||
if (player.getHeldItem() == null || !ModBlocks.isEnabled(ModBlocks.placedItem)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Aiming directly at an existing placed item display adds the held item to it.
|
||||
if (addToExistingDisplay(world, message.blockX, message.blockY, message.blockZ, player)
|
||||
|| addToExistingDisplay(world, x, y, z, player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent(
|
||||
new BlockSnapshot(world, x, y, z, ModBlocks.placedItem, 0),
|
||||
@@ -93,5 +103,26 @@ public class PlacedItemPacket implements IMessage {
|
||||
player.destroyCurrentEquippedItem();
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean addToExistingDisplay(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if (!(world.getTileEntity(x, y, z) instanceof TilePlacedItem tile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent(
|
||||
new BlockSnapshot(world, x, y, z, ModBlocks.placedItem, world.getBlockMetadata(x, y, z)),
|
||||
world.getBlock(x, y, z),
|
||||
player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
if (event.isCanceled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!tile.addItem(player.getHeldItem().copy())) {
|
||||
return false;
|
||||
}
|
||||
player.destroyCurrentEquippedItem();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.handler.ClientEventHandler;
|
||||
import com.brandon3055.draconicevolution.common.utils.DataUtils;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -46,9 +45,9 @@ public class ShieldHitPacket implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(ShieldHitPacket message, MessageContext ctx) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.playerID);
|
||||
if (entity instanceof EntityPlayer) ClientEventHandler.playerShieldStatus.put(
|
||||
(EntityPlayer) entity,
|
||||
new DataUtils.XZPair<>(message.shieldPowerF, ClientEventHandler.elapsedTicks));
|
||||
if (entity instanceof EntityPlayer player) {
|
||||
DraconicEvolution.clientProxy().renderShield(player, message.shieldPowerF);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ public class TileChaosShard extends TileEntity {
|
||||
|
||||
public void detonate() {
|
||||
if (!worldObj.isRemote
|
||||
&& locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId))
|
||||
&& locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) {
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
else {
|
||||
} else {
|
||||
EntityChaosVortex vortex = new EntityChaosVortex(worldObj);
|
||||
vortex.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
|
||||
worldObj.spawnEntityInWorld(vortex);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -16,8 +12,8 @@ import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerDislocatorInhibitor;
|
||||
|
||||
@@ -26,7 +22,6 @@ public class TileDislocatorInhibitor extends TileEntity implements IInventory {
|
||||
public static final int MAXIMUM_RANGE = 16;
|
||||
public static final int MINIMUM_RANGE = 1;
|
||||
public static final int FILTER_SLOTS = 8;
|
||||
public static final HashMap<World, HashSet<TileDislocatorInhibitor>> inhibitors = new HashMap<>();
|
||||
|
||||
private boolean redstoneActive = false;
|
||||
private ActivityControlType activityControlType = ActivityControlType.ALWAYS_ACTIVE;
|
||||
@@ -36,42 +31,27 @@ public class TileDislocatorInhibitor extends TileEntity implements IInventory {
|
||||
private boolean whitelist = false;
|
||||
private final ItemStack[] filter = new ItemStack[FILTER_SLOTS];
|
||||
|
||||
public static boolean isBlockedByInhibitor(World world, EntityItem item) {
|
||||
HashSet<TileDislocatorInhibitor> list = inhibitors.get(world);
|
||||
if (list == null) {
|
||||
return false;
|
||||
}
|
||||
for (TileDislocatorInhibitor inhibitor : list) {
|
||||
if (!inhibitor.shouldBeActive()) {
|
||||
continue;
|
||||
}
|
||||
if (!inhibitor.isBlockingItem(item.getEntityItem())) {
|
||||
continue;
|
||||
}
|
||||
if (inhibitor.isInRange(item.posX, item.posY, item.posZ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!registered) {
|
||||
HashSet<TileDislocatorInhibitor> map = inhibitors.computeIfAbsent(this.worldObj, k -> new HashSet<>());
|
||||
map.add(this);
|
||||
DraconicEvolution.proxy.registerInhibitor(this);
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
this.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
this.unregister();
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
if (inhibitors.containsKey(this.worldObj)) {
|
||||
HashSet<TileDislocatorInhibitor> list = inhibitors.get(this.worldObj);
|
||||
list.remove(this);
|
||||
if (list.isEmpty()) {
|
||||
inhibitors.remove(this.worldObj);
|
||||
}
|
||||
}
|
||||
DraconicEvolution.proxy.unregisterInhibitor(this);
|
||||
}
|
||||
|
||||
public int getRange() {
|
||||
@@ -124,11 +104,12 @@ public class TileDislocatorInhibitor extends TileEntity implements IInventory {
|
||||
}
|
||||
|
||||
public boolean isInRange(double x, double y, double z) {
|
||||
return x >= this.xCoord - range && x <= this.xCoord + range + 1
|
||||
&& y >= this.yCoord - range
|
||||
&& y <= this.yCoord + range + 1
|
||||
&& z >= this.zCoord - range
|
||||
&& z <= this.zCoord + range + 1;
|
||||
final int r = range;
|
||||
return x >= this.xCoord - r && x <= this.xCoord + r + 1
|
||||
&& y >= this.yCoord - r
|
||||
&& y <= this.yCoord + r + 1
|
||||
&& z >= this.zCoord - r
|
||||
&& z <= this.zCoord + r + 1;
|
||||
}
|
||||
|
||||
public void setActivityControl(int index) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import static com.brandon3055.draconicevolution.DraconicEvolution.isAutomagyLoaded;
|
||||
import static com.brandon3055.draconicevolution.DraconicEvolution.isEioLoaded;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@@ -18,6 +22,11 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.utils.ItemNBTHelper;
|
||||
import com.gtnewhorizon.gtnhlib.geometry.CubeIterator;
|
||||
|
||||
import crazypants.enderio.machine.obelisk.xp.TileExperienceObelisk;
|
||||
import crazypants.enderio.xp.ExperienceContainer;
|
||||
import tuhljin.automagy.tiles.TileEntityJarXP;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 27/06/2014.
|
||||
@@ -89,7 +98,64 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
|
||||
|
||||
public void buttonClick(EntityPlayer player) {
|
||||
if (!isValidRecipe) return;
|
||||
if (player.experienceLevel < dissenchantCost && !player.capabilities.isCreativeMode) return;
|
||||
if (player != null) {
|
||||
if (player.experienceLevel < dissenchantCost && !player.capabilities.isCreativeMode) return;
|
||||
} else if (dissenchantCost > 0) {
|
||||
ArrayList<TileEntityJarXP> jarsToEmpty = new ArrayList<>();
|
||||
ArrayList<ExperienceContainer> obelisksToEmpty = new ArrayList<>();
|
||||
int xpCost = dissenchantCost < 16 ? dissenchantCost * 17
|
||||
: dissenchantCost < 30 ? Math.round(dissenchantCost * (1.5f * dissenchantCost - 29.5f)) + 360
|
||||
: Math.round(dissenchantCost * (3.5f * dissenchantCost - 151.5f)) + 2220;
|
||||
int xp;
|
||||
absorb: {
|
||||
if (isAutomagyLoaded) {
|
||||
CubeIterator iter = new CubeIterator(8);
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
if (worldObj.getTileEntity(
|
||||
iter.n + xCoord,
|
||||
iter.l + yCoord,
|
||||
iter.m + zCoord) instanceof TileEntityJarXP jar) {
|
||||
xp = jar.getXP();
|
||||
if (xp >= xpCost) {
|
||||
if (!worldObj.isRemote) {
|
||||
jarsToEmpty.forEach(j -> j.setXP(0));
|
||||
jar.setXP(xp - xpCost);
|
||||
}
|
||||
break absorb;
|
||||
}
|
||||
xpCost -= xp;
|
||||
jarsToEmpty.add(jar);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isEioLoaded) {
|
||||
CubeIterator iter = new CubeIterator(8);
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
if (worldObj.getTileEntity(
|
||||
iter.n + xCoord,
|
||||
iter.l + yCoord,
|
||||
iter.m + zCoord) instanceof TileExperienceObelisk obelisk) {
|
||||
ExperienceContainer cont = obelisk.getContainer();
|
||||
xp = cont.getExperienceTotal();
|
||||
if (xp >= xpCost) {
|
||||
if (!worldObj.isRemote) {
|
||||
jarsToEmpty.forEach(j -> j.setXP(0));
|
||||
obelisksToEmpty.forEach(o -> o.drain(null, Integer.MAX_VALUE, true));
|
||||
cont.drain(null, Integer.MAX_VALUE, true);
|
||||
cont.addExperience(Math.max(0, xp - xpCost));
|
||||
}
|
||||
break absorb;
|
||||
}
|
||||
xpCost -= xp;
|
||||
obelisksToEmpty.add(cont);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ItemStack input = items[0];
|
||||
ItemStack enchantedBook = new ItemStack(Items.enchanted_book);
|
||||
Map enchants = EnchantmentHelper.getEnchantments(input);
|
||||
@@ -119,21 +185,21 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
|
||||
compound.removeTag(tagName);
|
||||
if (list.tagCount() > 0) input.setTagInfo(tagName, list);
|
||||
if (input.getItem() == Items.enchanted_book && list.tagCount() == 0) setInventorySlotContents(0, null);
|
||||
if (!player.capabilities.isCreativeMode) player.addExperienceLevel(-dissenchantCost);
|
||||
if (player != null && !player.capabilities.isCreativeMode) player.addExperienceLevel(-dissenchantCost);
|
||||
if (items[0] != null && ItemNBTHelper.getInteger(items[0], "RepairCost", 0) > 0) ItemNBTHelper.setInteger(
|
||||
items[0],
|
||||
"RepairCost",
|
||||
ItemNBTHelper.getInteger(items[0], "RepairCost", 0)
|
||||
- Math.min(2, ItemNBTHelper.getInteger(items[0], "RepairCost", 0)));
|
||||
if (!player.capabilities.isCreativeMode) decrStackSize(1, 1);
|
||||
if (player == null || !player.capabilities.isCreativeMode) decrStackSize(1, 1);
|
||||
int maxDamage = items[0] != null ? items[0].getMaxDamage() : 0;
|
||||
float damageF = (40f - bookPower) / 100f;
|
||||
int damage = (int) (damageF * (float) maxDamage);
|
||||
int damageResult = items[0] != null ? items[0].getItemDamage() + damage : 0;
|
||||
|
||||
if (!player.capabilities.isCreativeMode && damageResult > maxDamage && maxDamage > 0) {
|
||||
if ((player == null || !player.capabilities.isCreativeMode) && damageResult > maxDamage && maxDamage > 0) {
|
||||
setInventorySlotContents(0, null);
|
||||
} else if (!player.capabilities.isCreativeMode && maxDamage > 0 && items[0] != null) {
|
||||
} else if ((player == null || !player.capabilities.isCreativeMode) && maxDamage > 0 && items[0] != null) {
|
||||
items[0].setItemDamage(damageResult);
|
||||
}
|
||||
onInventoryChanged();
|
||||
@@ -231,13 +297,13 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
if (i == 1 && itemstack.getItem().equals(Items.book)) return true;
|
||||
return false;
|
||||
return i == 1 ? itemstack.getItem().equals(Items.book)
|
||||
: i == 0 ? EnchantmentHelper.getEnchantments(itemstack).size() != 0 : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1) {
|
||||
return new int[] { 1 };
|
||||
return var1 == 0 ? new int[] { 0, 2 } : new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,7 +313,7 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack item, int side) {
|
||||
return true;
|
||||
return slot != 0 || EnchantmentHelper.getEnchantments(item).size() == 0;
|
||||
}
|
||||
|
||||
// ===========================================================================================================//
|
||||
@@ -284,4 +350,5 @@ public class TileDissEnchanter extends TileEntity implements ISidedInventory {
|
||||
bookPower = compound.getFloat("ServivalChance");
|
||||
super.readFromNBT(compound);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.ModBlocks;
|
||||
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
|
||||
/**
|
||||
@@ -17,13 +21,37 @@ import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
*/
|
||||
public class TilePlacedItem extends TileEntity {
|
||||
|
||||
public ItemStack stack;
|
||||
public static final int ABSOLUTE_MAX_STACKS = 16;
|
||||
|
||||
/**
|
||||
* Pivot point on the mounting face and the two in-plane axes used to lay out the item grid, indexed by block
|
||||
* metadata (the side the display is attached to). Shared by the renderer and the hit test so that the stack a
|
||||
* player clicks on is the one they see.
|
||||
*/
|
||||
public static final float[][] FACE_PIVOT = { { 0.5F, 1F, 0.5F }, { 0.5F, 0F, 0.5F }, { 0.5F, 0.5F, 1F },
|
||||
{ 0.5F, 0.5F, 0F }, { 1F, 0.5F, 0.5F }, { 0F, 0.5F, 0.5F } };
|
||||
public static final float[][] FACE_AXIS_U = { { 1F, 0F, 0F }, { 1F, 0F, 0F }, { 1F, 0F, 0F }, { 1F, 0F, 0F },
|
||||
{ 0F, 0F, 1F }, { 0F, 0F, 1F } };
|
||||
public static final float[][] FACE_AXIS_V = { { 0F, 0F, 1F }, { 0F, 0F, 1F }, { 0F, 1F, 0F }, { 0F, 1F, 0F },
|
||||
{ 0F, 1F, 0F }, { 0F, 1F, 0F } };
|
||||
|
||||
private final List<ItemStack> stacks = new ArrayList<>(ABSOLUTE_MAX_STACKS);
|
||||
public float rotation = 0F;
|
||||
private boolean hasUpdated = false;
|
||||
private AxisAlignedBB renderBoundingBox;
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
if (renderBoundingBox == null) {
|
||||
renderBoundingBox = AxisAlignedBB
|
||||
.getBoundingBox(xCoord - 2, yCoord - 2, zCoord - 2, xCoord + 2, yCoord + 2, zCoord + 2);
|
||||
}
|
||||
return renderBoundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!hasUpdated && stack != null) {
|
||||
if (!hasUpdated && !stacks.isEmpty()) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
hasUpdated = true;
|
||||
}
|
||||
@@ -39,44 +67,188 @@ public class TilePlacedItem extends TileEntity {
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readFromNBT(pkt.func_148857_g());
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
stacks.clear();
|
||||
if (stack != null) {
|
||||
stacks.add(stack);
|
||||
}
|
||||
worldObj.scheduleBlockUpdate(xCoord, yCoord, zCoord, ModBlocks.placedItem, 20);
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
/**
|
||||
* Adds an item to this display if there is room for it. The limit is the lower of the configured stack limit and
|
||||
* {@link #ABSOLUTE_MAX_STACKS}.
|
||||
*
|
||||
* @return true if the item was added.
|
||||
*/
|
||||
public boolean addItem(ItemStack stack) {
|
||||
if (stack == null || stacks.size() >= getStackLimit()) {
|
||||
return false;
|
||||
}
|
||||
stacks.add(stack);
|
||||
markDirtyAndSync();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and returns the most recently added item, or null if empty.
|
||||
*/
|
||||
public ItemStack removeLastItem() {
|
||||
if (stacks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = stacks.remove(stacks.size() - 1);
|
||||
markDirtyAndSync();
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and returns the item at {@code index}, or null if the index is out of range.
|
||||
*/
|
||||
public ItemStack removeItem(int index) {
|
||||
if (index < 0 || index >= stacks.size()) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = stacks.remove(index);
|
||||
markDirtyAndSync();
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of columns (and maximum rows) in the grid used to display {@code count} items.
|
||||
*/
|
||||
public static int getGridSize(int count) {
|
||||
return (int) Math.ceil(Math.sqrt(count));
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes where the centre of grid cell {@code index} sits relative to the face pivot, in block units along
|
||||
* {@link #FACE_AXIS_U} and {@link #FACE_AXIS_V}. Rows are centred so a partially filled last row does not hang to
|
||||
* one side.
|
||||
*
|
||||
* @return {u, v}
|
||||
*/
|
||||
public static float[] getCellOffset(int index, int count) {
|
||||
int gridSize = getGridSize(count);
|
||||
if (gridSize <= 1) {
|
||||
return new float[] { 0F, 0F };
|
||||
}
|
||||
int rows = (count + gridSize - 1) / gridSize;
|
||||
float cell = 1F / gridSize;
|
||||
int row = index / gridSize;
|
||||
int col = index % gridSize;
|
||||
int rowLength = Math.min(gridSize, count - row * gridSize);
|
||||
return new float[] { (col - (rowLength - 1) / 2F) * cell, ((rows - 1) / 2F - row) * cell };
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the stack whose grid cell is closest to a point on this block.
|
||||
*
|
||||
* @param meta the block metadata (mounting side)
|
||||
* @param hitX x of the hit, relative to the block (0..1)
|
||||
* @param hitY y of the hit, relative to the block (0..1)
|
||||
* @param hitZ z of the hit, relative to the block (0..1)
|
||||
* @return the index of the closest stack, or -1 if the display is empty
|
||||
*/
|
||||
public int getStackIndexAt(int meta, float hitX, float hitY, float hitZ) {
|
||||
int count = stacks.size();
|
||||
if (count == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (meta < 0 || meta > 5) {
|
||||
meta = 1;
|
||||
}
|
||||
float[] pivot = FACE_PIVOT[meta];
|
||||
float[] axisU = FACE_AXIS_U[meta];
|
||||
float[] axisV = FACE_AXIS_V[meta];
|
||||
float dx = hitX - pivot[0];
|
||||
float dy = hitY - pivot[1];
|
||||
float dz = hitZ - pivot[2];
|
||||
float u = dx * axisU[0] + dy * axisU[1] + dz * axisU[2];
|
||||
float v = dx * axisV[0] + dy * axisV[1] + dz * axisV[2];
|
||||
|
||||
int closest = 0;
|
||||
float closestDistSq = Float.MAX_VALUE;
|
||||
for (int i = 0; i < count; i++) {
|
||||
float[] offset = getCellOffset(i, count);
|
||||
float du = u - offset[0];
|
||||
float dv = v - offset[1];
|
||||
float distSq = du * du + dv * dv;
|
||||
if (distSq < closestDistSq) {
|
||||
closestDistSq = distSq;
|
||||
closest = i;
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
public static int getStackLimit() {
|
||||
return Math.min(ConfigHandler.placedItemStackLimit, ABSOLUTE_MAX_STACKS);
|
||||
}
|
||||
|
||||
private void markDirtyAndSync() {
|
||||
markDirty();
|
||||
if (worldObj != null) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the first stack in this display, or null if empty. Retained for the single-item code paths (pick block,
|
||||
* collision box).
|
||||
*/
|
||||
public ItemStack getStack() {
|
||||
return stacks.isEmpty() ? null : stacks.get(0);
|
||||
}
|
||||
|
||||
public ItemStack getStack(int index) {
|
||||
return index >= 0 && index < stacks.size() ? stacks.get(index) : null;
|
||||
}
|
||||
|
||||
public List<ItemStack> getStacks() {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public int getDisplayCount() {
|
||||
return stacks.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
NBTTagCompound[] tag = new NBTTagCompound[1];
|
||||
tag[0] = new NBTTagCompound();
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(tag[0]);
|
||||
compound.setByte("Count", (byte) stacks.size());
|
||||
for (int i = 0; i < stacks.size(); i++) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
stacks.get(i).writeToNBT(tag);
|
||||
compound.setTag("Item" + i, tag);
|
||||
}
|
||||
compound.setTag("Item" + 0, tag[0]);
|
||||
compound.setFloat("Rotation", rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
super.readFromNBT(compound);
|
||||
NBTTagCompound[] tag = new NBTTagCompound[1];
|
||||
tag[0] = compound.getCompoundTag("Item" + 0);
|
||||
stack = ItemStack.loadItemStackFromNBT(tag[0]);
|
||||
if (stack == null) {
|
||||
// the stack can be null if the placed item was
|
||||
// an item that got removed in between mod updates
|
||||
stack = new ItemStack(Blocks.stone);
|
||||
stacks.clear();
|
||||
// Old worlds have no Count tag and always stored a single stack in Item0.
|
||||
int count = compound.hasKey("Count") ? compound.getByte("Count") : 1;
|
||||
for (int i = 0; i < count && i < ABSOLUTE_MAX_STACKS; i++) {
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Item" + i));
|
||||
if (stack != null) {
|
||||
stacks.add(stack);
|
||||
} else {
|
||||
// the stack can be null if the placed item was
|
||||
// an item that got removed in between mod updates
|
||||
LogHelper.error(
|
||||
"Cannot load a Placed Item stack at location "
|
||||
+ Vec3.createVectorHelper(this.xCoord, this.yCoord, this.zCoord)
|
||||
+ " because the associated item is null, it will be removed.");
|
||||
}
|
||||
}
|
||||
if (stacks.isEmpty()) {
|
||||
this.invalidate();
|
||||
LogHelper.error(
|
||||
"Cannot load the Placed Item at location "
|
||||
+ Vec3.createVectorHelper(this.xCoord, this.yCoord, this.zCoord)
|
||||
+ " because the associated item is null, it will be removed.");
|
||||
}
|
||||
rotation = compound.getFloat("Rotation");
|
||||
}
|
||||
|
||||
@@ -11,17 +11,14 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
|
||||
public class TileWeatherController extends TileEntity implements IInventory {
|
||||
|
||||
int tick = 0;
|
||||
boolean running = false;
|
||||
public boolean lastTickInput = false;
|
||||
public int mode = 0;
|
||||
private static final boolean debug = DraconicEvolution.debug;
|
||||
|
||||
private ItemStack[] items;
|
||||
private final ItemStack[] items;
|
||||
public int charges;
|
||||
|
||||
public TileWeatherController() {
|
||||
|
||||
@@ -47,19 +47,16 @@ public class TileEnergyRelay extends TileRemoteEnergyBase {
|
||||
super.updateEntity();
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
ring = DraconicEvolution.proxy.energyField(
|
||||
worldObj,
|
||||
xCoord + 0.5,
|
||||
yCoord + 0.5,
|
||||
zCoord + 0.5,
|
||||
0,
|
||||
powerTier == 1,
|
||||
ring,
|
||||
inView > 0);
|
||||
return;
|
||||
spawnEnergyField();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnEnergyField() {
|
||||
ring = DraconicEvolution.clientProxy()
|
||||
.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, powerTier == 1, ring, inView > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
super.writeToNBT(compound);
|
||||
|
||||
@@ -78,7 +78,14 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.isRemote) particle = DraconicEvolution.proxy
|
||||
if (worldObj.isRemote) {
|
||||
spawnParticle();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnParticle() {
|
||||
particle = DraconicEvolution.clientProxy()
|
||||
.energyField(worldObj, getBeamX(), getBeamY(), getBeamZ(), 1, powerTier == 1, particle, inView > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,19 +100,7 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
|
||||
rType = 1;
|
||||
else rType = 0;
|
||||
}
|
||||
device.beam = DraconicEvolution.proxy.energyBeam(
|
||||
worldObj,
|
||||
getBeamX(),
|
||||
getBeamY(),
|
||||
getBeamZ(),
|
||||
remoteTile.getBeamX(),
|
||||
remoteTile.getBeamY(),
|
||||
remoteTile.getBeamZ(),
|
||||
(int) device.energyFlow,
|
||||
getPowerTier() == 1,
|
||||
device.beam,
|
||||
true,
|
||||
rType);
|
||||
updateBeam(device, remoteTile, rType);
|
||||
} else {
|
||||
double difference = getCapacity() - remoteTile.getCapacity();
|
||||
double energyToEqual = Math
|
||||
@@ -137,6 +125,23 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateBeam(LinkedEnergyDevice device, IRemoteEnergyHandler remoteTile, int rType) {
|
||||
device.beam = DraconicEvolution.clientProxy().energyBeam(
|
||||
worldObj,
|
||||
getBeamX(),
|
||||
getBeamY(),
|
||||
getBeamZ(),
|
||||
remoteTile.getBeamX(),
|
||||
remoteTile.getBeamY(),
|
||||
remoteTile.getBeamZ(),
|
||||
(int) device.energyFlow,
|
||||
getPowerTier() == 1,
|
||||
device.beam,
|
||||
true,
|
||||
rType);
|
||||
}
|
||||
|
||||
protected void detectAndSendChanges(int index) {
|
||||
if (worldObj.isRemote) return;
|
||||
|
||||
|
||||
@@ -62,32 +62,13 @@ public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase {
|
||||
super.updateEntity();
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
ring = DraconicEvolution.proxy.energyField(
|
||||
worldObj,
|
||||
xCoord + 0.5,
|
||||
yCoord + 0.5,
|
||||
zCoord + 0.5,
|
||||
2,
|
||||
powerTier == 1,
|
||||
ring,
|
||||
inView > 0);
|
||||
spawnEnergyField();
|
||||
|
||||
for (LinkedReceiver receiver : receiverList) {
|
||||
int particleValue = 200;
|
||||
if (receiver.particleEnergyCounter > particleValue) {
|
||||
receiver.particleEnergyCounter -= particleValue;
|
||||
|
||||
// todo detect box size
|
||||
DraconicEvolution.proxy.spawnParticle(
|
||||
new Particles.TransceiverParticle(
|
||||
worldObj,
|
||||
xCoord + 0.5,
|
||||
yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4),
|
||||
zCoord + 0.5,
|
||||
receiver.xCoord + worldObj.rand.nextDouble(),
|
||||
receiver.yCoord + worldObj.rand.nextDouble(),
|
||||
receiver.zCoord + worldObj.rand.nextDouble()),
|
||||
64);
|
||||
spawnParticles(receiver);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -120,6 +101,27 @@ public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase {
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnEnergyField() {
|
||||
ring = DraconicEvolution.clientProxy()
|
||||
.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 2, powerTier == 1, ring, inView > 0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void spawnParticles(LinkedReceiver receiver) {
|
||||
// todo detect box size
|
||||
DraconicEvolution.clientProxy().spawnParticle(
|
||||
new Particles.TransceiverParticle(
|
||||
worldObj,
|
||||
xCoord + 0.5,
|
||||
yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4),
|
||||
zCoord + 0.5,
|
||||
receiver.xCoord + worldObj.rand.nextDouble(),
|
||||
receiver.yCoord + worldObj.rand.nextDouble(),
|
||||
receiver.zCoord + worldObj.rand.nextDouble()),
|
||||
64);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveObjectFromServer(int index, Object object) {
|
||||
|
||||
@@ -92,7 +92,7 @@ public class TilePortalBlock extends TileEntity {
|
||||
}
|
||||
}
|
||||
}
|
||||
DraconicEvolution.proxy.spawnParticle(
|
||||
DraconicEvolution.clientProxy().spawnParticle(
|
||||
new Particles.PortalParticle(worldObj, sourceX, sourceY, sourceZ, targetX, targetY, targetZ),
|
||||
256);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class TileReactorCore extends TileObjectSync implements IInventory {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateSound() {
|
||||
if (reactorSound == null) {
|
||||
reactorSound = (ReactorSound) DraconicEvolution.proxy.playISound(new ReactorSound(this));
|
||||
reactorSound = (ReactorSound) DraconicEvolution.clientProxy().playISound(new ReactorSound(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TileReactorEnergyInjector extends TileEntity implements IReactorPar
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateBeam() {
|
||||
beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
|
||||
beam = DraconicEvolution.clientProxy().reactorBeam(this, beam, true);
|
||||
}
|
||||
|
||||
public void onPlaced() {
|
||||
|
||||
@@ -98,7 +98,7 @@ public class TileReactorStabilizer extends TileEntity
|
||||
beam = null;
|
||||
}
|
||||
if (isValid) {
|
||||
beam = DraconicEvolution.proxy.reactorBeam(this, beam, true);
|
||||
beam = DraconicEvolution.clientProxy().reactorBeam(this, beam, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,19 +18,13 @@ import com.brandon3055.draconicevolution.common.entity.EntityChaosGuardian;
|
||||
/**
|
||||
* Created by brandon3055 on 21/10/2015.
|
||||
*/
|
||||
public class DragonChunkLoader implements LoadingCallback {
|
||||
public final class DragonChunkLoader implements LoadingCallback {
|
||||
|
||||
public static DragonChunkLoader instance;
|
||||
public static Map<EntityChaosGuardian, Ticket> ticketList = new HashMap<>();
|
||||
public static boolean hasReportedIssue = false;
|
||||
private final Map<EntityChaosGuardian, Ticket> ticketList = new HashMap<>();
|
||||
private boolean hasReportedIssue = false;
|
||||
|
||||
public static void init() {
|
||||
instance = new DragonChunkLoader();
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(DraconicEvolution.instance, instance);
|
||||
}
|
||||
|
||||
public static void updateLoaded(EntityChaosGuardian guardian) {
|
||||
Ticket ticket;
|
||||
public void updateLoaded(EntityChaosGuardian guardian) {
|
||||
final Ticket ticket;
|
||||
|
||||
if (ticketList.containsKey(guardian)) {
|
||||
ticket = ticketList.get(guardian);
|
||||
@@ -90,7 +84,7 @@ public class DragonChunkLoader implements LoadingCallback {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void stopLoading(EntityChaosGuardian guardian) {
|
||||
public void stopLoading(EntityChaosGuardian guardian) {
|
||||
if (!ticketList.containsKey(guardian)) return;
|
||||
ForgeChunkManager.releaseTicket(ticketList.get(guardian));
|
||||
ticketList.remove(guardian);
|
||||
@@ -107,4 +101,8 @@ public class DragonChunkLoader implements LoadingCallback {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onServerStopped() {
|
||||
this.ticketList.clear();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.items.armor.CustomArmorHandler.ArmorSummery;
|
||||
import com.brandon3055.draconicevolution.common.items.armor.ArmorSummary;
|
||||
import com.brandon3055.draconicevolution.common.utils.LogHelper;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
@@ -67,8 +67,8 @@ public class ModHelper {
|
||||
&& player.getHeldItem().getItem().equals(avaritiaSword);
|
||||
}
|
||||
|
||||
public static float applyModDamageAdjustments(ArmorSummery summery, LivingAttackEvent event) {
|
||||
if (summery == null) return event.ammount;
|
||||
public static float applyModDamageAdjustments(ArmorSummary summary, LivingAttackEvent event) {
|
||||
if (summary == null) return event.ammount;
|
||||
EntityPlayer attacker = event.source.getEntity() instanceof EntityPlayer
|
||||
? (EntityPlayer) event.source.getEntity()
|
||||
: null;
|
||||
@@ -81,10 +81,10 @@ public class ModHelper {
|
||||
event.entityLiving.hurtResistantTime = 0;
|
||||
return 300F;
|
||||
} else if (event.source.isUnblockable() || event.source.canHarmInCreative()) {
|
||||
summery.entropy += 3;
|
||||
summary.entropy += 3;
|
||||
|
||||
if (summery.entropy > 100) {
|
||||
summery.entropy = 100;
|
||||
if (summary.entropy > 100) {
|
||||
summary.entropy = 100;
|
||||
}
|
||||
|
||||
return event.ammount * 2;
|
||||
|
||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 7.2 KiB |
@@ -547,6 +547,36 @@ button.de.rotate.txt=Rotate
|
||||
button.de.numeric.txt=Numeric:
|
||||
|
||||
//Gui ----------------------------------------------------------------------------------------------------------------------------------------
|
||||
gui.de.numbers=%s
|
||||
|
||||
gui.de.charges=Charges
|
||||
gui.de.rain.on=Turn rain on
|
||||
gui.de.rain.off=Turn rain off
|
||||
gui.de.rain.storm=Thunder Storm
|
||||
|
||||
gui.de.weatherController.main.title=Weather Controller
|
||||
gui.de.playerDetector.main.title=Advanced Player Detector
|
||||
gui.de.grinder.main.title=Grinder
|
||||
gui.de.energyInfuser.main.title=Energy Infuser
|
||||
gui.de.generator.main.title=Generator
|
||||
gui.de.dissEnchanter.main.title=Disenchanter
|
||||
gui.de.draconiumChest.main.title=Draconic Chest
|
||||
gui.de.upgradeModifier.main.title=Upgrade Modifier
|
||||
gui.de.dislocatorInhibitor.main.title=Dislocator Inhibitor
|
||||
|
||||
gui.de.playerDetector.whiteList=White List
|
||||
gui.de.playerDetector.blackList=Black List
|
||||
gui.de.playerDetector.camouflage=Camouflage
|
||||
gui.de.playerDetector.invertOutput=Invert Output
|
||||
gui.de.playerDetector.back=Back
|
||||
gui.de.playerDetector.pressEnter=Press Enter to save
|
||||
gui.de.playerDetector.range=Range
|
||||
gui.de.playerDetector.outputInvert=Output Inverted: %s
|
||||
|
||||
gui.de.dissEnchanter.itemDamage1=Item
|
||||
gui.de.dissEnchanter.itemDamage2=Damage: %s
|
||||
gui.de.dissEnchanter.cost=Cost: %s
|
||||
|
||||
gui.de.flowGate.name=Flow Control
|
||||
gui.de.flowGatePartialSignal.name=The actual flow will vary between the two given values depending on the strength of the redstone signal being supplied to the block.
|
||||
gui.de.flowGateCurrentFlow.name=Flow
|
||||
|
||||
@@ -10,7 +10,7 @@ tile.draconicevolution:particleGenerator.name=粒子发生器
|
||||
tile.draconicevolution:playerDetector.name=玩家探测器
|
||||
tile.draconicevolution:playerDetectorAdvanced.name=高级玩家探测器
|
||||
tile.draconicevolution:energyInfuser.name=能量注入器
|
||||
tile.draconicevolution:earth.name=地
|
||||
tile.draconicevolution:earth.name=地球
|
||||
tile.draconicevolution:customSpawner.name=稳定刷怪笼
|
||||
tile.draconicevolution:longRangeDislocator.name=长距离错位宝石
|
||||
tile.draconicevolution:longRangeDislocator1.name=创造错位宝石
|
||||
@@ -31,7 +31,7 @@ tile.draconicevolution:draconicBlock.name=觉醒龙块
|
||||
tile.draconicevolution:infusedObsidian.name=注入龙力的黑曜石
|
||||
tile.draconicevolution:dislocatorReceptacle.name=错位容器
|
||||
tile.draconicevolution:portal.name=门
|
||||
tile.draconicevolution:flowGate.name=门
|
||||
tile.draconicevolution:flowGate.name=阀门
|
||||
tile.draconicevolution:flowGateFlux.name=能量阀门
|
||||
tile.draconicevolution:flowGateFluid.name=流体阀门
|
||||
tile.draconicevolution:reactorCore.name=反应堆核心
|
||||
@@ -50,7 +50,7 @@ tile.draconicevolution:energyCrystal2.name=能量收发器
|
||||
tile.draconicevolution:energyCrystal3.name=高级能量收发器
|
||||
tile.draconicevolution:energyCrystal4.name=无线能量收发器
|
||||
tile.draconicevolution:energyCrystal5.name=高级无线收发器
|
||||
tile.draconicevolution:dislocatorInhibitor.name=错位宝石抑制器
|
||||
tile.draconicevolution:dislocatorInhibitor.name=磁力屏蔽器
|
||||
|
||||
|
||||
//Item Information ----------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -147,7 +147,7 @@ msg.teleporterUnSet.txt=§c你在传送之前必须首先设置目的地(Shift +
|
||||
msg.teleporterBound.txt=§a传送器绑定到:
|
||||
msg.teleporterLowHealth.txt= 你生命值低
|
||||
msg.teleporterSentMob.txt=实体已被送到
|
||||
msg.teleporterEntityDimensional.txt=§c你不能把生物跨纬度传送!
|
||||
msg.teleporterEntityDimensional.txt=§c你不能跨维度传送生物!
|
||||
msg.teleporterAlreadySet.txt=§c[错误]传送石只能被绑定到一个位置!
|
||||
msg.teleporterOutOfFuel.txt=§c燃料耗尽! ! !
|
||||
msg.teleporterOutOfPearls.txt=§c末影珍珠耗尽! ! !
|
||||
@@ -247,9 +247,9 @@ info.de.obliterationMode.txt=删除模式
|
||||
info.de.obliterationModetrue.txt=激活
|
||||
info.de.obliterationModefalse.txt=未激活
|
||||
info.de.miningMode.txt=挖掘模式
|
||||
info.de.changeMiningMode.txt=按Shift并右键来改变挖掘模式
|
||||
info.de.changeMiningMode.txt=按住Shift并右键来改变挖掘模式
|
||||
info.de.toggleOblit.txt=右键切换 删除模式
|
||||
info.de.oblitInfo.txt=删除模式 破坏不重要的方块
|
||||
info.de.oblitInfo.txt=删除模式会销毁不重要的方块
|
||||
info.de.attackDamage.txt=攻击伤害
|
||||
info.de.bonusHealthDamage.txt=生物生命值
|
||||
info.de.press.txt=按下
|
||||
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.6 KiB |