
Ghoul159
Members-
Posts
42 -
Joined
-
Last visited
Everything posted by Ghoul159
-
ah thats make sense thanks^^
-
currently i'm doin it just with a server-sided proxy: package TempCraft.common; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import net.minecraft.block.Block; public class CommonProxyTempCraft { public void registerRenderThings() { TickRegistry.registerTickHandler(new ServerTickHandler(), Side.SERVER); TickRegistry.registerTickHandler(new ServerTickWorldHandler(), Side.SERVER); } }
-
almost everything works but in singleplayer the serverside stuff won't be executed... i thought it were merged together ssp and smp... right?
-
ah i see sry about so many questins i read a lot about mc modding but wasn't 100% shure about this whole client - server thing i 've already a sided proxy but i just tried a simple write chat massage code in my server tick from above and it worked as server but not in singleplayer, oehm do you know why? and how can i get a server World tick too? i think if i know that i am able to rewrite my code in a few minutes
-
how do i trace if it's singleplayer or multiplayer because i still need my client stuff for the singleplayer right? and why can't i hurt the player in singleplayer with the modloader.....player... stuff? btw thanks for your great help!
-
ok i think i got something like that already : public class ServerTickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) {} @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { if(type.equals(EnumSet.of(TickType.PLAYER))) { onTickInGame(); } } public EnumSet ticks() { return EnumSet.of(TickType.PLAYER); } public String getLabel() { return null; } private void onTickInGame() { //put here any code that needs to be done server side, like set WorldGeneration, and let entities spawn on the first server tick. //also put all the code in a if(world != null && !world.isRemote) statement, makes it so that you don't get NPEs from that. } }
-
ok then i'll have to rewrite some stuff^^ i have to hurt him in an ingame tick... sort of he is alive and is in that biome hurt him (for example) and have an additional question: how do i get the specific player from the server if i would want to get the player in an biome or under the sun or in water?
-
player.attackEntityFrom() No, it is not possible and should never be done. The client is dumb and only tells lies*. Never ever trust the client. Always do everything on the server. Period. *Of course this is not true, but it is the way you should think while developing. Clients can be evil and do stuff you don't expect in your wildest dreams yea i noticed some strange behaviours of the client nevertheless i set some things up there and i have to tell the server to hurt the player... so i thought about someting like this: 1. i'll write a little method "server-side" to hurt the player and call it from "client-side" 2. my PROBLEM: how do i get the player instance on the server without using the evil modloader stuff... maybe i should have been more specific^^
-
Is there a easy way to tell the server to hurt the player? i need to call the hurt method in a client tick... is it possible to tell the server (out of a client side class) to perform one server mehod to hurt the player?
-
now i know what you mean! ^^ but the problem is how do i know that the house/structure is sealed?
-
ok dont need it anymore
-
im drawing a custom AxisAlignedBB around the player to detect all blocks within.... is there a way to make this box visible?
-
do you remember something i could type in for the search i just cant find it
-
is there any way that i can display the bounding boxes for debugging?
-
i would like to know how to check if the player is inside a closed building? is there a good way to do that?
-
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
i got it workin ,i think many people could need this code so i'll share it here... i don't know if there is an easyer way but this works plz give me a "Thank You" if my code was usefull the code compares if certain blocks are near the player... The following code is in an clientSide TickHandler class: in the onTick method: //player coordinates int plX = (int)Minecraft.getMinecraft().thePlayer.posX; int plY = (int)Minecraft.getMinecraft().thePlayer.posY; int plZ = (int)Minecraft.getMinecraft().thePlayer.posZ; //the radius of your player->Block detection double boundingBoxRadius = 3; //that it'll work only if the player is there if(Minecraft.getMinecraft().thePlayer != null) { //set the box for collision detection with other boxes AxisAlignedBB var4 = AxisAlignedBB.getBoundingBox(plX, plY, plZ, plX + 1.0D, plY + 1.0D, plZ + 1.0D).expand(boundingBoxRadius , boundingBoxRadius , boundingBoxRadius); //get all colliding boundingBoxes with our var4 box List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4); //only work if theres something in the list if(list != null) { //go through the list for(int j = 0; j < list.size(); j++) { //send the current colliding box to get the blockID and compare it if(StringToBlockID(list.get(j).toString(),"first") == Block.torchWood.blockID || StringToBlockID(list.get(j).toString(),"second") == Block.torchWood.blockID) System.out.println("FOUND TORCH!"); //this does someting for each block that matches the compared block } } } and this is my created method (also in the same class) to get the specific Block id: public static int StringToBlockID(String line, String whichOne) { //MADE BY Ghoul159 int posStart = line.indexOf("["); int commaFirst = line.indexOf(","); int commaSecond = line.indexOf(",",commaFirst+1); int posEnd = line.indexOf("->"); if(whichOne == "second") { posStart = line.indexOf("->")+1; commaFirst = line.indexOf(",",posStart); commaSecond = line.indexOf(",",commaFirst+1); posEnd = line.indexOf("]"); } String BlockX = line.substring(posStart + 1, commaFirst); String BlockY = line.substring(commaFirst + 2, commaSecond); String BlockZ = line.substring(commaSecond + 2, posEnd); int BlockPosX = (int)Double.parseDouble(BlockX); int BlockPosY = (int)Double.parseDouble(BlockY); int BlockPosZ = (int)Double.parseDouble(BlockZ); int blockId = Minecraft.getMinecraft().theWorld.getBlockId(BlockPosX,BlockPosY,BlockPosZ); return blockId; } -
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
ok got it working i think many people could use this so i'll write this short tutorial plz give me a Thank you if my code was helpful and maybe write me into your credits if you just copy my code This following code is used inside a clientSide TickHandler class: inside of the tick: AxisAlignedBB var4 = AxisAlignedBB.getBoundingBox(plX, plY, plZ, plX + 1.0D, plY + 1.0D, plZ + 1.0D).expand(heatRadius, heatRadius, heatRadius); List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4); Iterator var6 = list.iterator(); AxisAlignedBB var7; int i = 0; if(list != null) { for(int j = 0; j < list.size(); j++) { if(StringToBlockID(list.get(j).toString(),"first") == Block.torchWood.blockID) System.out.println("FOUND TORCH!"); if(StringToBlockID(list.get(j).toString(),"second") == Block.torchWood.blockID) System.out.println("FOUND TORCH!"); } -
looks like you are using the vars even if "worldObj.getBlockTileEntity(xCoord+1, yCoord, zCoord);" is null ...
-
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
i'll try that tomorrow and write if it works... have to go to sleep...^^ -
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
this should work thanks alot!!! havent thought about this way even its an easy one -
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
yeah but the problem is i need an area / radius around the player... so only if the player is near the torch... do stuff... btw thanks for your dedicated help! -
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
yeah saw it a moment ago^^ so this works: AxisAlignedBB var4 = AxisAlignedBB.getBoundingBox(plX, plY, plZ, plX + 1.0D, plY + 1.0D, plZ + 1.0D).expand(4D, 2D, 4D); List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4); Iterator var6 = list.iterator(); AxisAlignedBB var7; if(list != null) while (var6.hasNext()) { var7 = (AxisAlignedBB)var6.next(); } i get these boxes: box[-295.0, 68.0, 277.0 -> -294.0, 69.0, 278.0], box[-295.0, 69.0, 277.0 -> -294.0, 70.0, 278.0],... now i have to find out if there is a torch under it do you know a easy way? -
[N Help/Advice Modding] Detection Player->specificBlock [solved]
Ghoul159 replied to Ghoul159's topic in Modder Support
if(!list) is red underlined i took if(list != null)... but the game crashes in the while at: var7 = (EntityPlayer)var6.next(); edit: nevermind saw my bug^^ AxisAlignedBB var4 = AxisAlignedBB.getBoundingBox(plX, plY, plZ, plX + 1.0D, plY + 1.0D, plZ + 1.0D).expand(4D, 2D, 4D); List list = Minecraft.getMinecraft().theWorld.getAllCollidingBoundingBoxes(var4); Iterator var6 = list.iterator(); EntityPlayer var7; if(list != null) while (var6.hasNext()) { var7 = (EntityPlayer)var6.next(); } String ing = list.toString(); System.out.println(ing);