Jump to content

Elix_x

Members
  • Posts

    878
  • Joined

  • Last visited

Posts posted by Elix_x

  1. Okay, so is it smart to create a packet taking in the keys id and the entity and then in the packethandler it updates the position?

    Better would be to send where player wants to go and check for key presses per client. Like that, if players use arrow keys instead of WASD to move, they will be able to configure it personally.

    Also, no need to send player or vehicle: from context of message (that you get in your handler along with message), you can get player that sent that message. And from player you can get entity it's riding or entity it's ridden by...

    Then best option would be to create directional fields in tile entity and change those from packet. Then depending on those fields, in update method, you move your entity...

    Oh and last thing: on client before sending a packet, check that player rides your entity, to save performance :) ...

  2. Yea, omg why did i check the key first am i stupid? And can't i just check if its client and then simulate the movement on client(eg with other variables) and send it to the server with a packet?

    Bad idea - opens big doors to cheaters... You should send packets to server describing which action user wants to perform (send packet each time key state changes and not each tick while it's pressed)... Also, i highly recomend making keys configurable using key handler (so don't send key W pressed, but check if move froward key has changed and then send packet to server saying that move forward state changed)...

  3. Let's begin with problems:

     

     
      if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
      if (Keyboard.isKeyDown(Keyboard.KEY_D) ) {
      if(Keyboard.isKeyDown(Keyboard.KEY_W)){
      if(Keyboard.isKeyDown(Keyboard.KEY_S)){
      if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)){
    

    Wow... Apearenly you really don't know that there's no keyboard on server...

     

      
          if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
             if(worldObj.isRemote)
             RealLifeMod.network.sendToServer(new MountVehicleMessage(this));
          }
    

    Really? First you check for key press and then you check for client...

     

     
                      Minecraft.getMinecraft().objectMouseOver.getBlockPos().getX(),
                      Minecraft.getMinecraft().objectMouseOver.getBlockPos().getY(),
                      Minecraft.getMinecraft().objectMouseOver.getBlockPos().getZ())
    

    Seriously? You have onItemUse, and you use this???

     

    In total, you need to

    -Know what is server stuff and what is client stuff... Go and learn it RIGHT NOW!

    -Know how to use packets... No, seriously, until you learn packets good enough do not try to do client server sync needed stuff... Plenty o tutorials...

    -Know what key handler is and how to use it... Again, Plenty o tutorials...

     

     

  4. First, potion items don't use potion ids, but strange data values system:

    Bits 0-3 (1, 2, 4 and 8) determine the potion effect. The highest legitimately available is currently 14 decimal = 1110 binary.

    Bits 0-5 (1, 2, 4, 8, 16, 32) determine the potion's name.

    If bit 5 (32) is true, the potion is a level II potion (or, in some cases, a reverted potion).

    If bit 6 (64) is true, the potion is an extended potion (or, in some cases, a reverted potion).

    Potions with bits 5 and 6 set to true cannot be brewed.

    Bits 13 and 14 (8192 and 16384) determines whether the potion is a drinkable potion or a splash potion. If bit 13 is true, it's drinkable. If 14 is true, it's a splash potion.

    Bits 7-12 and 15 are ignored, so many potions with distinct data values will have the same properties.

    Also, this gave you "A Bungling Potion", because... http://minecraft.gamepedia.com/Potion#Unused_potions

  5. Got it. Thank you very much, but I'd still like to know if there's a way in which I can include both

    GameRegistry#findItem

    and

    GameRegistry#findBlock

    .

     

    Also, the string that users will have to use will be item id instead of unlocalized name... Those are different...

     

    What's the difference? How do I switch over to that? There doesn't appear to be any

    setItemId

    in the Block or Item class...

    1) findItem also gives you blocks, because those are items too (while in your inventory, aren't they items?)

    2) Item id is modid + : + string that you register your item with GameRegistry.registerItem.

  6. EntityPlayer#getItemInUse

    is marked as

    @SideOnly(Side.CLIENT)

    , which means that it doesn't exist on the server.

     

    To access the

    EntityPlayer#itemInUse

    field on the server, you'll need to use reflection or an access transformer.

    Why is it so? It's illogical...

    The Dedicated Server doesn't have a lot of the client-side code because it's not necessary if there's no local client.  I guess none of the dedicated server code needs to access itemInUse from outside EntityPlayer, so they never added a getter on that side.

     

    Anyhow as Choonster said you can either use Reflection, an Access Transformer, or alternatively PlayerUseItemEvent  and isUsingItem().

     

    If you just want to access a private field it's pretty easy, eg

     

    @SideOnly(Side.CLIENT)
    public class KeyBindingInterceptor 
    {
      private static final Field pressTimeField = ReflectionHelper.findField(KeyBinding.class, "pressTime", "field_151474_i");  // unobfuscated name, and obfuscatedname
    
      //...
        int value = 0;
        try {
          value = pressTimeField.getInt(keyBinding, 0);
        } catch (Exception e) {
          throw Throwables.propagate(e);
        }
    }
    

     

    -TGG

    I know how to use both reflection and ats to be friendly with obfuscation, don''t worry. The thing is that i have to check it every tick for each player. So the question of performance is here...

     

    Also, why can't forge add their both sides getter method? Perhaps, i could add it myself, if only i could install forge on my pc, but i can't: running

    gradlew setupForge

    in cloned forge, stops at

    :git

    and then

    build failed

    . Where should i report this, by the way???

  7. Hello!

    Today, i'm here with really strange issue, caused by something unknown to me:

    I did not happen to me, but of one users who downloaded the mod, put it on server and joined server.

    Here's part of server log that contains the issue:

    [22:14:34] [server thread/ERROR] [FML/]: Exception caught during firing event cpw.mods.fml.common.gameevent.TickEvent$PlayerTickEvent@862de2b:
    java.lang.NoSuchMethodError: net.minecraft.entity.player.EntityPlayer.func_71011_bu()Lnet/minecraft/item/ItemStack;
    at code.elix_x.mods.teleplates.teleplates.TeleportationManager.onPlayerUpdate(TeleportationManager.java:50) ~[TeleportationManager.class:?]
    at code.elix_x.mods.teleplates.events.OnPlayerTickEvent.tick(OnPlayerTickEvent.java:17) ~[OnPlayerTickEvent.class:?]
    at cpw.mods.fml.common.eventhandler.ASMEventHandler_470_OnPlayerTickEvent_tick_PlayerTickEvent.invoke(.dynamic) ~[?:?]
    at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?]
    at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) [EventBus.class:?]
    at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345) [FMLCommonHandler.class:?]
    at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:220) [yz.class:?]
    at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:295) [mw.class:?]
    at net.minecraft.network.NetHandlerPlayServer.func_147347_a(NetHandlerPlayServer.java:303) [nh.class:?]
    at net.minecraft.network.play.client.C03PacketPlayer.func_148833_a(SourceFile:137) [jd.class:?]
    at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.func_148833_a(SourceFile:20) [jf.class:?]
    at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212) [ej.class:?]
    at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:165) [nc.class:?]
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:659) [MinecraftServer.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334) [lt.class:?]
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:427) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?]
    

    The issue happens on line 50 of TeleportationManager, so here's line 50 of TeleportationManager:

    if(player.rotationPitch == 90 && ((block == TeleplatesBase.teleplate && EnergyManager.canTeleportFromTeleplate(player)) || (player.getItemInUse() != null && player.getItemInUse().getItem() == TeleplatesBase.portableTeleplate && EnergyManager.canTeleportFromPortableTeleplate(player)))){

    As you can see,

    EntityPlayer.func_71011_bu()

    can only be

    player.getItemInUse()

    (it's the only called 1 param player method that returns ItemStack).

    So apearently, something wrong went with obfuscation of the mod... Although BUILD SUCESSFULL...

    In total, i'm confused in what have caused this... It seems that something else caused this error. Obfuscator? Different forge versions? MCP mappings? 3rd party coremod? What?

     

    Original issue topic: http://www.minecraftforge.net/forum/index.php/topic,33187

     

    Thanks for help!

    If you have any questions - just ask!

  8. This should not happen at all... Or mappings are different or what?

    This is line that gives NoSuchMethodError:

    if(player.rotationPitch == 90 && ((block == TeleplatesBase.teleplate && EnergyManager.canTeleportFromTeleplate(player)) || (player.getItemInUse() != null && player.getItemInUse().getItem() == TeleplatesBase.portableTeleplate && EnergyManager.canTeleportFromPortableTeleplate(player)))){

    As you can see, nothing wrong here and

    EntityPlayer.func_71011_bu()Lnet/minecraft/item/ItemStack;

    method can only be

    player.getItemInUse()

    .

    So i'm confused. It seems that something else caused this error. Compiler? Different forge versions? MCP mappings? 3rd party coremod? What?

     

    EDIT: if somebody is interested, this issue on modder support page with some more detailed description: http://www.minecraftforge.net/forum/index.php/topic,33194

  9. Never crossed my mind, which are possible? And if both how are both done?

    The first one will use world saved data (google it).

    The second one is more complicated and requires new class holding your variables which saves and loads to file using either save and load or server start and stop events.

    In both cases server to clients variables synchronisation is required...

  10. Stackmap frames are a huge pain in the butt.

    You can try and work around it by using the COMPUTE_FRAMES flag instead of just COMPUTE_MAXS, but this is not guaranteed to work (why? Because unlike javac (the java compiler) ASM does not have all classes available to it so it can't reliable perform this task).

    Welp, this didn't work (because exactly what you) (i'm sure that nobody needs that new crash, but whatever) :

    java.lang.VerifyError: Bad type on operand stack
    Exception Details:
      Location:
        net/minecraft/world/chunk/Chunk.getBlockMetadata(III)I @17: areturn
      Reason:
        Type integer (current frame, stack[0]) is not assignable to reference type
      Current Frame:
        bci: @17
        flags: { }
        locals: { 'net/minecraft/world/chunk/Chunk', integer, integer, integer }
        stack: { integer }
      Bytecode:
        0x0000000: 2a1b 1c1d b801 619a 000b 2a1b 1c1d b801
        0x0000010: 65b0 1c07 7a2a b400 44be a100 0503 ac2a
        0x0000020: b400 441c 077a 323a 0419 04c6 0011 1904
        0x0000030: 1b1c 100f 7e1d b601 68a7 0004 03ac     
      Stackmap Table:
        same_frame(@18)
        same_frame(@31)
        append_frame(@60,Object[#66])
        same_locals_1_stack_item_frame(@61,Integer)
    

    Welp... I'll have to deal with these stackmap frames myself...

  11. Good day.

    I'm having issues with my coremod:

    I'm trying to patch Chunk.getBlockMetadata (don't ask me why, it's a long story). And i'm having problems with it:

    When trying to use this transformer on method:

    public class InvisiZonesTransformer implements IClassTransformer{
    
    public static Logger logger = LogManager.getLogger("IZ Core");
    
    @Override
    public byte[] transform(String name, String transformedName, byte[] bytes) {
    	if(name.equals(InvisiZonesTranslator.getMapedClassName("world.chunk.Chunk"))){
    		logger.info("##################################################");
    		logger.info("Patching Chunk");
    		byte[] b = patchChunk(name, bytes);
    		logger.info("Patching Chunk Completed");
    		logger.info("##################################################");
    		return b;
    	}
    	return bytes;
    }
    
    private byte[] patchChunk(String name, byte[] bytes) {
    	String getBlock = InvisiZonesTranslator.getMapedMethodName("Chunk", "func_150810_a", "getBlock");
    	String getBlockDesc = InvisiZonesTranslator.getMapedMethodDesc("Chunk", "func_150810_a", "(III)Lnet/minecraft/block/Block;");
    	String getBlockMetadata = InvisiZonesTranslator.getMapedMethodName("Chunk", "func_76628_c", "getBlockMetadata");
    	String getBlockMetadataDesc = InvisiZonesTranslator.getMapedMethodDesc("Chunk", "func_76628_c", "(III)I");
    	String getTileEntityUnsafe = "getTileEntityUnsafe";
    	String func_150806_e = InvisiZonesTranslator.getMapedMethodName("Chunk", "func_150806_e", "func_150806_e");
    	String func_150806_eDesc = InvisiZonesTranslator.getMapedMethodDesc("Chunk", "func_150806_e", "(III)Lnet/minecraft/tileentity/TileEntity;");
    
    	ClassNode classNode = new ClassNode();
    	ClassReader classReader = new ClassReader(bytes);
    	classReader.accept(classNode, 0);
    
    	for(MethodNode method : classNode.methods){
    		if(method.name.equals(getBlockMetadata) && method.desc.equals(getBlockMetadataDesc)){
    			try{
    				logger.info("**************************************************");
    				logger.info("Patching getBlockMetadata");
    
    				LabelNode skipTo = new LabelNode();
    
    				InsnList list = new InsnList();
    				list.add(new LabelNode());
    				list.add(new VarInsnNode(Opcodes.ALOAD, 0));
    				list.add(new VarInsnNode(Opcodes.ILOAD, 1));
    				list.add(new VarInsnNode(Opcodes.ILOAD, 2));
    				list.add(new VarInsnNode(Opcodes.ILOAD, 3));
    				list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "code.elix_x.coremods.invisizones.core.InvisiZoneHooks".replace(".", "/"), "doGetBlockMetadataInsideChunk", "(L" + InvisiZonesTranslator.getMapedClassName("world.chunk.Chunk").replace(".", "/") + ";III)Z", false));
    				list.add(new JumpInsnNode(Opcodes.IFNE, skipTo));
    				list.add(new LabelNode());
    				list.add(new VarInsnNode(Opcodes.ALOAD, 0));
    				list.add(new VarInsnNode(Opcodes.ILOAD, 1));
    				list.add(new VarInsnNode(Opcodes.ILOAD, 2));
    				list.add(new VarInsnNode(Opcodes.ILOAD, 3));
    				list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "code.elix_x.coremods.invisizones.core.InvisiZoneHooks".replace(".", "/"), "getBlockMetadataInsideChunk", "(L" + InvisiZonesTranslator.getMapedClassName("world.chunk.Chunk").replace(".", "/") + ";III)I", false));
    				list.add(new InsnNode(Opcodes.ARETURN));
    				list.add(skipTo);
    				method.instructions.insert(list);
    
    				logger.info("Patching getBlockMetadata Completed");
    				logger.info("**************************************************");
    			}catch(Exception e){
    				logger.info("Patching getBlockMetadata Failed With Exception:");
    				e.printStackTrace();
    				logger.info("**************************************************");
    			}
    		}
    	}
    
    	ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    	classNode.accept(writer);
    	return writer.toByteArray();
    }
    
    }
    

    Gives me this log when patching:

    [13:46:46] [server thread/INFO] [iZ Core]: ##################################################
    [13:46:46] [server thread/INFO] [iZ Core]: Patching Chunk
    [13:46:46] [server thread/INFO] [iZ Core]: **************************************************
    [13:46:46] [server thread/INFO] [iZ Core]: Patching getBlockMetadata
    [13:46:46] [server thread/INFO] [iZ Core]: Patching getBlockMetadata Completed
    [13:46:46] [server thread/INFO] [iZ Core]: **************************************************
    [13:46:46] [server thread/INFO] [iZ Core]: Patching Chunk Completed
    [13:46:46] [server thread/INFO] [iZ Core]: ##################################################
    [13:46:46] [server thread/ERROR]: Encountered an unexpected exception
    java.lang.VerifyError: Expecting a stackmap frame at branch target 18
    Exception Details:
      Location:
        net/minecraft/world/chunk/Chunk.getBlock(III)Lnet/minecraft/block/Block; @7: ifne
      Reason:
        Expected stackmap frame at this location.
      Bytecode:
        0x0000000: 2a1b 1c1d b801 2f9a 000b 2a1b 1c1d b801
        0x0000010: 33b0 b200 a33a 041c 077a 2ab4 0044 bea2
        0x0000020: 0055 2ab4 0044 1c07 7a32 3a05 1905 c600
        0x0000030: 4619 051b 1c10 0f7e 1db6 0136 3a04 a700
        0x0000040: 363a 0619 0613 0138 b801 3e3a 0719 0713
        0x0000050: 0140 b601 443a 0819 0813 0146 bb00 0759
        0x0000060: 2a1b 1c1d b701 49b6 014f bb01 5159 1907
        0x0000070: b701 54bf 1904 b0                      
      Exception Handler Table:
        bci [49, 62] => handler: 65
      Stackmap Table:
        full_frame(@65,{Object[#2],Integer,Integer,Integer,Object[#129],Object[#66]},{Object[#297]})
        chop_frame(@116,1)
    
    at net.minecraft.world.gen.ChunkProviderServer.<init>(ChunkProviderServer.java:57) ~[ChunkProviderServer.class:?]
    at net.minecraft.world.WorldServer.createChunkProvider(WorldServer.java:693) ~[WorldServer.class:?]
    at net.minecraft.world.World.<init>(World.java:281) ~[World.class:?]
    at net.minecraft.world.WorldServer.<init>(WorldServer.java:102) ~[WorldServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63) ~[integratedServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96) ~[integratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
    [13:46:46] [server thread/ERROR]: This crash report has been saved to: C:\my\mcmodding\mods\Invisi-Zones\eclipse\.\crash-reports\crash-2015-08-14_13.46.46-server.txt
    [13:46:46] [server thread/INFO] [FML]: Applying holder lookups
    [13:46:46] [server thread/INFO] [FML]: Holder lookups applied
    [13:46:47] [server thread/INFO] [invisiZonesManager]: Clearing zones on: CLIENT
    [13:46:47] [server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STARTING and forced into state SERVER_STOPPED. Errors may have been discarded.
    [13:46:47] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----
    // Don't do that.
    
    Time: 14.08.15 13:46
    Description: Exception in server tick loop
    
    java.lang.VerifyError: Expecting a stackmap frame at branch target 18
    Exception Details:
      Location:
        net/minecraft/world/chunk/Chunk.getBlock(III)Lnet/minecraft/block/Block; @7: ifne
      Reason:
        Expected stackmap frame at this location.
      Bytecode:
        0x0000000: 2a1b 1c1d b801 2f9a 000b 2a1b 1c1d b801
        0x0000010: 33b0 b200 a33a 041c 077a 2ab4 0044 bea2
        0x0000020: 0055 2ab4 0044 1c07 7a32 3a05 1905 c600
        0x0000030: 4619 051b 1c10 0f7e 1db6 0136 3a04 a700
        0x0000040: 363a 0619 0613 0138 b801 3e3a 0719 0713
        0x0000050: 0140 b601 443a 0819 0813 0146 bb00 0759
        0x0000060: 2a1b 1c1d b701 49b6 014f bb01 5159 1907
        0x0000070: b701 54bf 1904 b0                      
      Exception Handler Table:
        bci [49, 62] => handler: 65
      Stackmap Table:
        full_frame(@65,{Object[#2],Integer,Integer,Integer,Object[#129],Object[#66]},{Object[#297]})
        chop_frame(@116,1)
    
    at net.minecraft.world.gen.ChunkProviderServer.<init>(ChunkProviderServer.java:57)
    at net.minecraft.world.WorldServer.createChunkProvider(WorldServer.java:693)
    at net.minecraft.world.World.<init>(World.java:281)
    at net.minecraft.world.WorldServer.<init>(WorldServer.java:102)
    at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:63)
    at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:96)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:445)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
    
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- System Details --
    Details:
    Minecraft Version: 1.7.10
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.8.0_25, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 896957152 bytes (855 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1492 5 mods loaded, 5 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAA	FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar) 
    UCHIJAA	Forge{10.13.4.1492} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1492-1.7.10.jar) 
    UCHIJAA	excore{1.0} [EXCore] (bin) 
    UCHIJAA	invisizones{1.0} [invisi Zones] (bin) 
    GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
    Profiler Position: N/A (disabled)
    Player Count: 0 / 8; []
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    [13:46:47] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-08-14_13.46.46-server.txt
    AL lib: (EE) alc_cleanup: 1 device not closed
    Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
    JDWP exit error JVMTI_ERROR_WRONG_PHASE(112): cannot get thread local storage [threadControl.c:195]
    

    And the thing is taht:

    1) It's expecting stack map frame in the middle of actions

    2) I have never met those things (errors), although i succesfully coded 4 coremods, they work and never asked for this.

    3) I have no idea what and why exactly should i do with it in middle of actions.

     

    Yes, i know that it's coremod and i'm kinda on my own, but... Never met it, never dealt with it, never solved it...

     

    Thanks for help!

    If you have any questions - just ask!

     

  12. @SideOnly(Side.CLIENT)
    public int getBlockColor(){
    	return ColorizerGrass.getGrassColor(0.5D, 1.0D);
    }
    
    @SideOnly(Side.CLIENT)
    public int getRenderColor(IBlockState state){
    	return this.getBlockColor();
    }
    
    @SideOnly(Side.CLIENT)
        public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
        {
            return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
        }
    

     

    Note, that you can't jusy copy these methods from grass block, otherwise all mimiced blocks will be recolored... And you will get green planks...

     

    Thanks for telling me that.  I had a feeling, but wasn't sure.  However, I did test the wood and it comes out fine, but then I tested tall grass and redstone.  The tall grass was gray and the redstone was green:p

     

    So I looked at the code from both classes and came up with something that seemed to have worked.

     

    It takes the only blocks that actually use this color coding stuff, or atleast the ones I currently know about... So I will be patching it as I see others that need it

    @SideOnly(Side.CLIENT)
    public int getRenderColor(IBlockState state){
    	if(state == Blocks.redstone_wire.getDefaultState()){//This will make the mimiced redstone line look like it's off (red)
    		float f1 = 0.3F;
    		float f2 = 0.0F;
    		float f3 = 0.0F;
    
    		int j = MathHelper.clamp_int((int)(f1 * 255.0F), 0, 255);
            int k = MathHelper.clamp_int((int)(f2 * 255.0F), 0, 255);
            int l = MathHelper.clamp_int((int)(f3 * 255.0F), 0, 255);
            return -16777216 | j << 16 | k << 8 | l;
    	}
    
    	return this.getBlockColor();
    }
    
    @SideOnly(Side.CLIENT)
        public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
        {
    	TileEntity tile_entity;
    	IBlockState state = worldIn.getBlockState(pos);
    	if(worldIn.getTileEntity(pos) instanceof TileEntityMimicBlock){
    		tile_entity = (TileEntityMimicBlock)worldIn.getTileEntity(pos);
    		state = ((TileEntityMimicBlock) tile_entity).getState();
    		if(state == Blocks.grass.getDefaultState() || state.getBlock() == Blocks.tallgrass)
    			return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
    		return getRenderColor(state);
    	}
    	return getRenderColor(state);
        }
    

    I would still recomend you to use mimicedBlock.colorMultiplier instead, because you already missed some customly colored blocks: leaves, vines, grass block, double tall grass block, flowers...

  13. The event itself does not damage entity. But it allows you to change damage value or cancel it. This is how events work. They are hooked by forge in to methods, where they are called in begining/end of method, which allows cancellation, changing parameters or doing anything else. So if you want to hurt entity, call attckEntityFrom... And don't forget that new event with your damage source will be posted on top of first one...

  14. You should now about damage sources that:

    1) There are passive sources, such as fire, and event my contain those. In this case, getSourceOfDamage returns null.

    2) There are indirect entity sources, such as arrow, and event my contain those. In this case, getSourceOfDamage returns entity that damaged directly and getEntity entity that indirectly damaged entity.

    3) There are direct entity sources, such as hitting with sword, and event may contain those. In this case, getSourceOfDamage and getEntity return entity that damaged entity.

  15. Thanks a bunch!  I copied this over from the grass block and I've tested it and it seems to work.

     

    @SideOnly(Side.CLIENT)
    public int getBlockColor(){
    	return ColorizerGrass.getGrassColor(0.5D, 1.0D);
    }
    
    @SideOnly(Side.CLIENT)
    public int getRenderColor(IBlockState state){
    	return this.getBlockColor();
    }
    
    @SideOnly(Side.CLIENT)
        public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
        {
            return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
        }
    

     

    out of curiosity, would you know whether or not I should copy the block's Model In my TileEntity?

    Note, that you can't jusy copy these methods from grass block, otherwise all mimiced blocks will be recolored... And you will get green planks...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.