Jump to content

[1.7.10] Changing light value of shadow of block to be displayed....


Recommended Posts

Posted

Hi there, thanks for opening this topic.

I was looking in vanilla source code trying to find a way to change light that block recieves to display shadow...

In short, here's my problem:

Q6Yz66Q.png

If you have any ideas how i could do this, please tell me...

 

IF you have any questions - just ask!

 

 

Posted

Block#setLightOpacity(0);

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

And then new map with light opacities to change it back in certain conditions...

Maybe, but there's no other way? (btw, my mod to do this already uses asm, so use it once more somewhere will not be hard... (but where exactly, i can't find...))

 

EDIT: maybe directly getLightOpacity with coords in block???

  • 2 weeks later...
Posted

And then new map with light opacities to change it back in certain conditions...

Maybe, but there's no other way? (btw, my mod to do this already uses asm, so use it once more somewhere will not be hard... (but where exactly, i can't find...))

 

EDIT: maybe directly getLightOpacity with coords in block???

Okay, i tried to pacth it, and now i'm getting very strange error:

[12:00:14] [main/INFO] [iZ Core]: ##################################################
[12:00:14] [main/INFO] [iZ Core]: Patching Block
[12:00:14] [main/INFO] [iZ Core]: **************************************************
[12:00:14] [main/INFO] [iZ Core]: Patching getLightOpacity
[12:00:14] [main/INFO] [iZ Core]: Patching getLightOpacity Completed
[12:00:14] [main/INFO] [iZ Core]: **************************************************
[12:00:14] [main/ERROR] [LaunchWrapper]: Unable to launch
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
Caused by: java.lang.NoClassDefFoundError: net/minecraft/block/Block
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:323) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:141) ~[Main.class:?]
... 8 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.block.Block
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:323) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:141) ~[Main.class:?]
... 8 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 66
at java.lang.String.charAt(Unknown Source) ~[?:1.8.0_25]
at org.objectweb.asm.Type.getArgumentsAndReturnSizes(Type.java:417) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.MethodWriter.visitMethodInsn(MethodWriter.java:906) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.tree.MethodInsnNode.accept(MethodInsnNode.java:133) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.tree.InsnList.accept(InsnList.java:162) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:816) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:726) ~[asm-debug-all-5.0.3.jar:5.0.3]
at org.objectweb.asm.tree.ClassNode.accept(ClassNode.java:412) ~[asm-debug-all-5.0.3.jar:5.0.3]
at code.elix_x.coremods.invisizones.core.InvisiZonesTransformer.patchBlock(InvisiZonesTransformer.java:98) ~[bin/:?]
at code.elix_x.coremods.invisizones.core.InvisiZonesTransformer.transform(InvisiZonesTransformer.java:44) ~[bin/:?]
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.11.jar:?]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:457) ~[bootstrap.class:?]
at net.minecraft.client.Minecraft.<init>(Minecraft.java:323) ~[Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:141) ~[Main.class:?]
... 8 more
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

And block transformer method:

private byte[] patchBlock(String name, byte[] bytes) {
	String getLightOpacity = "getLightOpacity";
	String getLightOpacityDesc = "(L" + InvisiZonesTranslator.getMapedClassName("world.IBlockAccess").replace(".", "/") + ";III)I";

	ClassNode classNode = new ClassNode();
	ClassReader classReader = new ClassReader(bytes);
	classReader.accept(classNode, 0);

	for(MethodNode method : classNode.methods){
		if(method.name.equals(getLightOpacity) && method.desc.equals(getLightOpacityDesc)){
			try{
				logger.info("**************************************************");
				logger.info("Patching getLightOpacity");

				InsnList list = new InsnList();
				list.add(new VarInsnNode(Opcodes.ALOAD, 0));
				list.add(new VarInsnNode(Opcodes.ALOAD, 1));
				list.add(new VarInsnNode(Opcodes.ILOAD, 2));
				list.add(new VarInsnNode(Opcodes.ILOAD, 3));
				list.add(new VarInsnNode(Opcodes.ILOAD, 4));
				list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "code.elix_x.coremods.invisizones.core.InvisiZoneHooks".replace(".", "/"), "getLightOpacity", "(L" + InvisiZonesTranslator.getMapedClassName("block.Block").replace(".", "/") + ";L" + InvisiZonesTranslator.getMapedClassName("world.IBlockAccess").replace(".", "/") + "III)I", false));
				list.add(new InsnNode(Opcodes.IRETURN));
				list.add(new LabelNode());
				method.instructions.insert(list);

				logger.info("Patching getLightOpacity Completed");
				logger.info("**************************************************");
			}catch(Exception e){
				logger.info("Patching getLightOpacity Failed With Exception:");
				e.printStackTrace();
				logger.info("**************************************************");
			}
		}
	}

	ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
	classNode.accept(writer);
	return writer.toByteArray();
}

 

Any ideas, why is it happening?

 

EDIT: Forgot one semicolon, now this is working...

Posted

Well, i got some progress, but it still isn't as i want...

From left to right: air, glass, what i'm doing.

yNKVkNT.png

As you can see, with glass all looks like air, but what i do is not...

What i tried to do: setting (or returning) opacity of blocks in zone to 0.

Do you have any ideas???

Posted

What are you returning for the isOpaqueCube() function in your block?

Problem is: these are not my blocks, these not even known blocks... What i'm trying ot do is with selection of zone, make all blocks within invisible... And this ligting is only problem left. I know about isOpaqueCube, and want to know if there's position sensitive version for it (like for opacity for example), Because otherwise it would be too much patching... OR there's other way around???

 

And also, i misspressed button :) , pressed thank you instead of quote... well... doesn't matter...

  • 5 weeks later...
Posted

Problem is: these are not my blocks, these not even known blocks... What i'm trying ot do is with selection of zone, make all blocks within invisible...

 

If you're not replacing the blocks with your own custom invisible block, how are you making those blocks invisible? Are you intercepting the rendering somehow?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Why don't you just replace the blocks with your own custom invisible blocks, and have each invisible block have what block it replaced in its NBT, so you swap them back and forth.

Posted

 

Problem is: these are not my blocks, these not even known blocks... What i'm trying ot do is with selection of zone, make all blocks within invisible...

 

If you're not replacing the blocks with your own custom invisible block, how are you making those blocks invisible? Are you intercepting the rendering somehow?

 

 

 

Problem is: these are not my blocks, these not even known blocks... What i'm trying ot do is with selection of zone, make all blocks within invisible...

 

If you're not replacing the blocks with your own custom invisible block, how are you making those blocks invisible? Are you intercepting the rendering somehow?

 

 

The thing is that if camera is inside zone, it must be rendered, if outside - not. If camera has glasses on and it's zone owner - yes... And mod needs to be server compatible (replacing blocks on client, next sync will break everything)... That's why i can't simply replace blocks with invisible blocks...

 

And actually, this is the last issue that i need to fix before releasing...

 

Oh and yes, i intercept rendring in world renderer...

Posted

Oh, just remembered another reason: if i would replace blocks, tilentities would be down so, i would need to store te data too, but also, while player is outside, everything would stop working... so yeah... Any more ideas of "Changing light value of shadow of block to be displayed..."???

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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