Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • IExtendedEntityProperties player Datawatcher affecting all players on server?
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
gummby8

IExtendedEntityProperties player Datawatcher affecting all players on server?

By gummby8, April 16, 2016 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 16, 2016

Trying to sync an IExtendedEntityProperties variable to the client from the server.

 

When a player moves over a custom block it sets a datawatcher from 0 to 1. On the client this sets the clients shader.

 

I have a 1.8 test server on my pc and also launch 2 seperate clients on the same machine, both with different usernames, mine and my wifes.

 

When either player runs over a block, both clients get the shader applied. Been banging my head against this wall for a few hours now, not sure where I am going wrong.

 

 

subscribed event

@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
	if (event.entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.entity;
		MBExtendedPlayer.get(player).onUpdate();
	}
}

 

 

 

Extended player class

 

 

package com.Splosions.ModularBosses.entity.player;

import com.Splosions.ModularBosses.proxy.ClientProxy;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;

public class MBExtendedPlayer implements IExtendedEntityProperties {

public final static String EXT_PROP_NAME = "MBExtendedPlayer";

private EntityPlayer player;


public int limboTime;
public int preLimbo;
public static final int LIMBO_WATCHER = 27;


public MBExtendedPlayer(EntityPlayer player)
{
this.player = player;
//Every player starts out of limbo.
this.preLimbo = 0;
this.limboTime = 0;
player.getDataWatcher().addObject(LIMBO_WATCHER, 0);
}


/**
* Used to register these extended properties for the player during EntityConstructing event
* This method is for convenience only; it will make your code look nicer
*/
public static final void register(EntityPlayer player)
{
player.registerExtendedProperties(MBExtendedPlayer.EXT_PROP_NAME, new MBExtendedPlayer(player));
}


/**
* Returns ExtendedPlayer properties for player
* This method is for convenience only; it will make your code look nicer
*/
public static final MBExtendedPlayer get(EntityPlayer player){
return (MBExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME);
}



public void onUpdate() {

	int limbo = this.player.getDataWatcher().getWatchableObjectInt(LIMBO_WATCHER);


	/*
	 * Sets the datawatcher based on limboTime on the server
	 */
	if (this.limboTime > 0 && !this.player.getEntityWorld().isRemote){
		this.player.getDataWatcher().updateObject(LIMBO_WATCHER, 1);
	} else if (!this.player.getEntityWorld().isRemote){
		this.player.getDataWatcher().updateObject(LIMBO_WATCHER ,0);
	}


	/*
	 * Sets the shader when the datawatcher changes to 1 clientside
	 */
	if (this.player.getEntityWorld().isRemote && this.preLimbo != limbo && limbo == 1){
		ClientProxy.sobelShader();
	}

	/*
	 * Clears the shader when the datawatcher changes to 0 clientside
	 */
	if (this.player.getEntityWorld().isRemote && this.preLimbo != limbo && limbo == 0){
		ClientProxy.clearShader();
	}

	this.preLimbo = limbo;		
	this.limboTime -= (this.limboTime > 0) ? 1 : 0;		
}









@Override
public void saveNBTData(NBTTagCompound compound) {

}

@Override
public void loadNBTData(NBTTagCompound compound) {

}

@Override
public void init(Entity entity, World world) {
	// TODO Auto-generated method stub

}






}

 

 

 

 

  • Quote

Share this post


Link to post
Share on other sites

coolAlias    745

coolAlias

coolAlias    745

  • Reality Controller
  • coolAlias
  • Members
  • 745
  • 2805 posts
Posted April 16, 2016

How are you running 2 clients at once? My guess is that that is the culprit, not your code. Try joining via LAN with a separate computer and I bet it will work.

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 16, 2016

Well buckets. Tried using my wifes pc and mine and the problem persists. The moment either client touches the fire it sets both clients to use the sobel shader

 

Once a player touches the fire it sets their limboTime to 100 server side

 

@Override
    public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
    {
        if (entityIn instanceof EntityPlayer && !worldIn.isRemote){
        	MBExtendedPlayer.get((EntityPlayer)entityIn).limboTime = 100;
        }
        worldIn.setBlockToAir(pos);
    }

 

Based on that, the server sets the datawatcher to 1

 

To avoid setting the shader every single tick I used a preLimbo variable in the onUpdate to use to detect changes in teh datawatcher.

 

My events class uses this variable to make the players look "Ghostly" when the preLimbo variable is set to 1

 

/*
 * used to make the player look ghostly when in limbo. 
 */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
	if (MBExtendedPlayer.get((EntityPlayer)event.entity).preLimbo > 0){
		GlStateManager.enableBlend();
		GlStateManager.disableAlpha();
		GlStateManager.blendFunc(1, 1);
	}
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Post event) {
        GlStateManager.disableBlend();
        GlStateManager.enableAlpha();
}

 

 

So both the shader and the ghostly players are triggered by the datawatcher. But the ghostly players look, is working properly. Only the player that stepped into the fire takes on a ghostly appearance, but everyone gets the shader applied to their client.

 

If I put the CLientProxy.sobelShader(); in an item and apply it on use, only the one client that swung the item gets the shader.

 

 

The shader is applied in the client proxy

 

public static void sobelShader(){
	try {
		f_loadShader.invoke(Minecraft.getMinecraft().entityRenderer, new ResourceLocation("shaders/post/sobel.json"));
	} catch (Throwable e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}


public static void clearShader(){
	try{
		ReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, false, new String[]{"field_175083_ad", "useShader"});
	} catch (Throwable e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}

 

 

 

TLDR the ghost affect & the shader both are triggered by the datawatcher. The ghost affect only affects the 1 player it should while the shaders are applying to everyone.

  • Quote

Share this post


Link to post
Share on other sites

coolAlias    745

coolAlias

coolAlias    745

  • Reality Controller
  • coolAlias
  • Members
  • 745
  • 2805 posts
Posted April 16, 2016

Try making your shader methods non-static and calling via 'Main.proxy.sobelShader()' etc. Not that I necessarily think that will work, but I don't have any other ideas :\

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 16, 2016

Ok

 

In my main class I added

public static ClientProxy clientProxy;

 

removed the static from the method in the client proxy

 

tried this in the extended player class

 

	/*
	 * Sets the shader when the datawatcher changes to 1 clientside
	 */
	if (this.player.getEntityWorld().isRemote && this.preLimbo != limbo && limbo == 1){
		com.Splosions.ModularBosses.ModularBosses.clientProxy.sobelShader();
	}

 

 

and crashed the client stating that the changed line is the problem

 

---- Minecraft Crash Report ----

WARNING: coremods are present:
Contact their authors BEFORE contacting forge

// Oops.

Time: 4/16/16 9:21 AM
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
at com.Splosions.ModularBosses.entity.player.MBExtendedPlayer.onUpdate(MBExtendedPlayer.java:72)
at com.Splosions.ModularBosses.client.MBEvents.onLivingUpdate(MBEvents.java:50)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_35_MBEvents_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:334)
at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:1577)
at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:294)
at net.minecraft.client.entity.EntityPlayerSP.func_70071_h_(EntityPlayerSP.java:119)
at net.minecraft.world.World.func_72866_a(World.java:1880)
at net.minecraft.world.World.func_72870_g(World.java:1850)
at net.minecraft.world.World.func_72939_s(World.java:1679)
at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:2095)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1029)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:345)
at net.minecraft.client.main.Main.main(SourceFile:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at com.Splosions.ModularBosses.entity.player.MBExtendedPlayer.onUpdate(MBExtendedPlayer.java:72)
at com.Splosions.ModularBosses.client.MBEvents.onLivingUpdate(MBEvents.java:50)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_35_MBEvents_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic)
at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:55)
at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:140)
at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:334)
at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:1577)
at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:294)
at net.minecraft.client.entity.EntityPlayerSP.func_70071_h_(EntityPlayerSP.java:119)
at net.minecraft.world.World.func_72866_a(World.java:1880)
at net.minecraft.world.World.func_72870_g(World.java:1850)

-- Entity being ticked --
Details:
Entity Type: null (net.minecraft.client.entity.EntityPlayerSP)
Entity ID: 235
Entity Name: gummby8
Entity's Exact location: 244.00, 80.00, 266.96
Entity's Block location: 243.00,80.00,266.00 - World: (243,80,266), Chunk: (at 3,5,10 in 15,16; contains blocks 240,0,256 to 255,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Entity's Momentum: -0.08, -0.08, -0.08
Entity's Rider: ~~ERROR~~ NullPointerException: null
Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
at net.minecraft.world.World.func_72939_s(World.java:1679)

-- Affected level --
Details:
Level name: MpServer
All players: 2 total; [EntityPlayerSP['gummby8'/235, l='MpServer', x=244.00, y=80.00, z=266.96], EntityOtherPlayerMP['Desyrel'/234, l='MpServer', x=241.56, y=80.00, z=267.22]]
Chunk stats: MultiplayerChunkCache: 440, 440
Level seed: 0
Level generator: ID 00 - default, ver 1. Features enabled: false
Level generator options: 
Level spawn location: 238.00,64.00,237.00 - World: (238,64,237), Chunk: (at 14,4,13 in 14,14; contains blocks 224,0,224 to 239,255,239), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
Level time: 54224 game time, 9575 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 79 total; [EntityBat['Bat'/128, l='MpServer', x=207.76, y=17.24, z=331.40], EntityCreeper['Creeper'/129, l='MpServer', x=226.50, y=14.00, z=304.50], EntityZombie['Zombie'/131, l='MpServer', x=242.16, y=47.00, z=209.75], EntityBat['Bat'/387, l='MpServer', x=215.74, y=13.95, z=251.59], EntityBat['Bat'/388, l='MpServer', x=220.10, y=15.97, z=250.91], EntityPatronEffect['unknown'/132, l='MpServer', x=241.56, y=80.00, z=267.22], EntityCreeper['Creeper'/145, l='MpServer', x=281.59, y=25.00, z=224.91], EntityCreeper['Creeper'/146, l='MpServer', x=283.41, y=25.00, z=229.91], EntityCreeper['Creeper'/147, l='MpServer', x=281.69, y=25.00, z=232.31], EntitySquid['Squid'/151, l='MpServer', x=299.72, y=46.75, z=205.00], EntityBat['Bat'/407, l='MpServer', x=317.47, y=26.18, z=296.80], EntityCreeper['Creeper'/152, l='MpServer', x=292.50, y=25.00, z=237.50], EntityBat['Bat'/408, l='MpServer', x=315.68, y=27.02, z=294.46], EntityBat['Bat'/409, l='MpServer', x=311.74, y=23.36, z=294.28], EntityZombie['Zombie'/154, l='MpServer', x=291.50, y=23.00, z=289.50], EntitySkeleton['Skeleton'/155, l='MpServer', x=300.50, y=23.00, z=290.50], EntityMinecartChest['container.minecart'/156, l='MpServer', x=294.50, y=27.06, z=313.50], EntityMinecartChest['container.minecart'/157, l='MpServer', x=292.50, y=27.06, z=311.47], EntitySkeleton['Skeleton'/158, l='MpServer', x=303.50, y=27.00, z=309.50], EntityBat['Bat'/287, l='MpServer', x=306.25, y=27.00, z=282.75], EntitySquid['Squid'/161, l='MpServer', x=304.28, y=57.09, z=242.56], EntityZombie['Zombie'/162, l='MpServer', x=304.50, y=24.00, z=244.50], EntityCreeper['Creeper'/163, l='MpServer', x=310.50, y=24.00, z=240.50], EntityCreeper['Creeper'/164, l='MpServer', x=319.50, y=23.00, z=281.88], EntityMinecartChest['container.minecart'/165, l='MpServer', x=317.50, y=18.06, z=284.50], EntityChicken['Chicken'/166, l='MpServer', x=309.50, y=23.00, z=273.50], EntityCreeper['Creeper'/167, l='MpServer', x=319.47, y=23.00, z=281.06], EntityCreeper['Creeper'/168, l='MpServer', x=315.50, y=27.00, z=292.50], EntityMinecartChest['container.minecart'/170, l='MpServer', x=308.50, y=27.00, z=295.50], EntityZombie['Zombie'/171, l='MpServer', x=310.63, y=27.00, z=295.75], EntityZombie['Zombie'/172, l='MpServer', x=304.94, y=23.00, z=294.41], EntitySkeleton['Skeleton'/173, l='MpServer', x=322.25, y=23.00, z=285.75], EntitySkeleton['Skeleton'/174, l='MpServer', x=308.53, y=27.00, z=301.06], EntitySkeleton['Skeleton'/175, l='MpServer', x=304.50, y=27.00, z=311.50], EntityCreeper['Creeper'/176, l='MpServer', x=305.50, y=27.00, z=312.50], EntityPlayerSP['gummby8'/235, l='MpServer', x=244.00, y=80.00, z=266.96], EntityCreeper['Creeper'/177, l='MpServer', x=305.50, y=27.00, z=311.50], EntityOtherPlayerMP['Desyrel'/234, l='MpServer', x=241.56, y=80.00, z=267.22], EntityCreeper['Creeper'/178, l='MpServer', x=307.50, y=27.00, z=309.50], EntityCreeper['Creeper'/179, l='MpServer', x=308.50, y=27.00, z=309.50], EntityCreeper['Creeper'/180, l='MpServer', x=308.34, y=27.00, z=305.03], EntityZombie['Zombie'/440, l='MpServer', x=324.50, y=18.00, z=298.50], EntityEnderman['Enderman'/187, l='MpServer', x=324.50, y=23.00, z=283.50], EntitySkeleton['Skeleton'/444, l='MpServer', x=171.50, y=46.00, z=248.50], EntityZombie['Zombie'/189, l='MpServer', x=317.81, y=23.00, z=271.28], EntityBat['Bat'/191, l='MpServer', x=323.22, y=21.10, z=285.59], EntitySkeleton['Skeleton'/448, l='MpServer', x=210.50, y=17.00, z=316.50], EntityBat['Bat'/195, l='MpServer', x=323.88, y=25.10, z=292.75], EntitySkeleton['Skeleton'/460, l='MpServer', x=176.50, y=29.02, z=268.50], EntityCreeper['Creeper'/461, l='MpServer', x=233.50, y=31.01, z=209.50], EntitySpider['Spider'/78, l='MpServer', x=173.50, y=45.00, z=189.50], EntityCreeper['Creeper'/462, l='MpServer', x=231.50, y=31.01, z=209.50], EntityZombie['Zombie'/79, l='MpServer', x=183.03, y=57.00, z=211.47], EntityZombie['Zombie'/463, l='MpServer', x=235.50, y=31.01, z=213.50], EntityWitch['Witch'/80, l='MpServer', x=175.50, y=19.00, z=252.50], EntityZombie['Zombie'/464, l='MpServer', x=233.50, y=31.01, z=211.50], EntityCreeper['Creeper'/81, l='MpServer', x=174.00, y=26.00, z=266.66], EntitySpider['Spider'/84, l='MpServer', x=175.88, y=55.00, z=265.88], EntitySkeleton['Skeleton'/85, l='MpServer', x=175.50, y=54.00, z=271.50], EntityZombie['Zombie'/87, l='MpServer', x=178.47, y=53.00, z=274.47], EntityBat['Bat'/346, l='MpServer', x=173.50, y=54.09, z=262.41], EntityCreeper['Creeper'/103, l='MpServer', x=184.50, y=47.00, z=229.50], EntityBat['Bat'/104, l='MpServer', x=180.61, y=25.02, z=270.02], EntityBat['Bat'/105, l='MpServer', x=197.56, y=31.61, z=298.58], EntityOtherPlayerMP['Desyrel'/234, l='MpServer', x=241.56, y=80.00, z=267.22], EntityZombie['Zombie'/106, l='MpServer', x=176.34, y=51.00, z=258.34], EntitySquid['Squid'/108, l='MpServer', x=192.13, y=58.16, z=320.84], EntitySquid['Squid'/110, l='MpServer', x=194.94, y=54.44, z=313.97], EntitySquid['Squid'/111, l='MpServer', x=198.03, y=60.97, z=331.44], EntityWitch['Witch'/116, l='MpServer', x=211.50, y=36.00, z=234.50], EntitySkeleton['Skeleton'/372, l='MpServer', x=173.50, y=58.00, z=256.50], EntityBat['Bat'/117, l='MpServer', x=209.50, y=38.10, z=233.43], EntityCreeper['Creeper'/118, l='MpServer', x=222.94, y=65.00, z=266.56], EntityZombie['Zombie'/119, l='MpServer', x=219.44, y=10.00, z=345.09], EntitySkeleton['Skeleton'/120, l='MpServer', x=234.50, y=13.00, z=250.50], EntitySkeleton['Skeleton'/121, l='MpServer', x=235.50, y=13.00, z=250.50], EntitySkeleton['Skeleton'/122, l='MpServer', x=235.50, y=13.00, z=251.50], EntityBat['Bat'/126, l='MpServer', x=226.69, y=25.68, z=293.69], EntityCreeper['Creeper'/127, l='MpServer', x=226.50, y=24.00, z=295.50]]
Retry entities: 0 total; []
Server brand: fml,forge
Server type: Non-integrated multiplayer server
Stacktrace:
at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:351)
at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2503)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:366)
at net.minecraft.client.main.Main.main(SourceFile:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.8
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: 240362968 bytes (229 MB) / 456028160 bytes (434 MB) up to 1060372480 bytes (1011 MB)
Mod Pack: 1.8-SNAPSHOT-r372-b53-2015-09-09_11-36-17
LiteLoader Mods: 1 loaded mod(s)
          - WorldEditCUI version 1.8.0_03
LaunchWrapper: 20 active transformer(s)
          - Transformer: net.minecraftforge.fml.common.asm.transformers.PatchingTransformer
          - Transformer: $wrapper.net.minecraftforge.fml.common.asm.transformers.BlamingTransformer
          - Transformer: $wrapper.net.minecraftforge.fml.common.asm.transformers.SideTransformer
          - Transformer: $wrapper.net.minecraftforge.fml.common.asm.transformers.EventSubscriptionTransformer
          - Transformer: $wrapper.net.minecraftforge.fml.common.asm.transformers.EventSubscriberTransformer
          - Transformer: $wrapper.net.minecraftforge.classloading.FluidIdTransformer
          - Transformer: com.mumfrey.liteloader.transformers.event.EventProxyTransformer
          - Transformer: com.mumfrey.liteloader.launch.LiteLoaderTransformer
          - Transformer: com.mumfrey.liteloader.client.transformers.CrashReportTransformer
          - Transformer: net.minecraftforge.fml.common.asm.transformers.DeobfuscationTransformer
          - Transformer: net.minecraftforge.fml.common.asm.transformers.AccessTransformer
          - Transformer: net.minecraftforge.fml.common.asm.transformers.ModAccessTransformer
          - Transformer: net.minecraftforge.fml.common.asm.transformers.ItemStackTransformer
          - Transformer: net.minecraftforge.fml.common.asm.transformers.TerminalTransformer
          - Transformer: com.mumfrey.liteloader.transformers.event.EventTransformer
          - Transformer: com.mumfrey.liteloader.common.transformers.LiteLoaderPacketTransformer
          - Transformer: com.mumfrey.liteloader.client.transformers.LiteLoaderEventInjectionTransformer
          - Transformer: com.mumfrey.liteloader.client.transformers.MinecraftTransformer
          - Transformer: com.mumfrey.liteloader.transformers.event.json.ModEventInjectionTransformer
          - Transformer: net.minecraftforge.fml.common.asm.transformers.ModAPITransformer
JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1521 9 mods loaded, 9 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHIJA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
UCHIJA	FML{8.0.99.99} [Forge Mod Loader] (forge-1.8-11.14.3.1521.jar) 
UCHIJA	Forge{11.14.3.1521} [Minecraft Forge] (forge-1.8-11.14.3.1521.jar) 
UCHIJA	iChunUtil{5.5.0} [iChunUtil] (iChunUtil-5.5.0.jar) 
UCHIJA	LunatriusCore{1.1.2.30} [LunatriusCore] (LunatriusCore-1.8-1.1.2.30-universal.jar) 
UCHIJA	mb{1.0} [Modular Bosses] (mb-1.0.jar) 
UCHIJA	Schematica{1.7.7.140} [schematica] (Schematica-1.8-1.7.7.140-universal.jar) 
UCHIJA	Tabula{5.1.0} [Tabula] (Tabula-5.1.0.jar) 
UCHIJA	worldedit{6.1} [WorldEdit] (worldedit-forge-mc1.8-6.1.jar) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 361.75' Renderer: 'GeForce GTX 960/PCIe/SSE2'
Launched Version: 1.8-forge1.8-11.14.3.1521
LWJGL: 2.9.1
OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.5.0 NVIDIA 361.75, NVIDIA Corporation
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: [converted-old-zeldaLTTP-converted-1407124408682.zip, The Legend of Zelda Pack.zip]
Current Language: English (US)
Profiler Position: N/A (disabled)

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 16, 2016

So if I run out of render distance from the second client, only one client will apply the shader.

 

Further testing. Only when the client proxy method is called from the MBExtendedPlayer#onUpdate() method.

 

If I call the sobelShader method from anywhere else, it only affects the one client.

 

Further testing

 

Added a client event to test to see if all players are actualy tirggering the event.

 

	if (this.player.getEntityWorld().isRemote && this.preLimbo != this.limbo && this.limbo == 1){
		ClientProxy.sobelShader();
		this.player.performHurtAnimation();
	}

 

Only the player that walks into the fire shudders like they were hurt, but everyone in render distance gets the shader applied

 

I am so confused

  • Quote

Share this post


Link to post
Share on other sites

UberAffe    27

UberAffe

UberAffe    27

  • Diamond Finder
  • UberAffe
  • Forge Modder
  • 27
  • 316 posts
Posted April 16, 2016

You should have something like this in your main class:

@SidedProxy(clientSide = Refs.CLIENTPROXY, serverSide = Refs.SERVERPROXY)
public static CommonProxy proxy;

This proxy will be an instance of ClientProxy if the game is running a client. If it is ONLY running a server then it will be an instance of your ServerProxy(what ever serverSide is equal to)

 

You should be using this proxy instance. If you declare a Clientproxy and your ClientProxy class has any references to ClientSide only classes then a dedicated server will crash.

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 16, 2016

Ok got that, nope still applies the shader to both clients. On 2 separate machines

 

MBExtendedPlayer

package com.Splosions.ModularBosses.entity.player;

import com.Splosions.ModularBosses.ModularBosses;
import com.Splosions.ModularBosses.proxy.ClientProxy;

import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.common.IExtendedEntityProperties;

public class MBExtendedPlayer implements IExtendedEntityProperties {

public final static String EXT_PROP_NAME = "MBExtendedPlayer";

public EntityPlayer player;


public int limboTime;
public int preLimbo;
public int limbo;

public static final int LIMBO_WATCHER = 27;


public MBExtendedPlayer(EntityPlayer player)
{
this.player = player;
//Every player starts out of limbo.
this.limbo = 0;
this.preLimbo = 0;
this.limboTime = 0;
player.getDataWatcher().addObject(LIMBO_WATCHER, 0);
}


/**
* Used to register these extended properties for the player during EntityConstructing event
* This method is for convenience only; it will make your code look nicer
*/
public static final void register(EntityPlayer player)
{
player.registerExtendedProperties(MBExtendedPlayer.EXT_PROP_NAME, new MBExtendedPlayer(player));
}


/**
* Returns ExtendedPlayer properties for player
* This method is for convenience only; it will make your code look nicer
*/
public static final MBExtendedPlayer get(EntityPlayer player){
return (MBExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME);
}



public void onUpdate() {

	if (this.player.getEntityWorld().isRemote){
		this.limbo = this.player.getDataWatcher().getWatchableObjectInt(LIMBO_WATCHER);
	}

	/*
	 * Sets the datawatcher based on limboTime on the server
	 */
	if (this.limboTime > 0 && !this.player.getEntityWorld().isRemote){
		this.player.getDataWatcher().updateObject(LIMBO_WATCHER, 1);
	} else if (!this.player.getEntityWorld().isRemote){
		this.player.getDataWatcher().updateObject(LIMBO_WATCHER ,0);
	}


	/*
	 * Sets the shader when the datawatcher changes to 1 clientside
	 */
	if (this.player.getEntityWorld().isRemote && this.preLimbo != this.limbo && this.limbo == 1){
		((ClientProxy) ModularBosses.proxy).sobelShader();
		this.player.performHurtAnimation();
	}

	/*
	 * Clears the shader when the datawatcher changes to 0 clientside
	 */
	if (this.player.getEntityWorld().isRemote && this.preLimbo != this.limbo && this.limbo == 0){
		ClientProxy.clearShader();
	}



	if (this.player.getEntityWorld().isRemote){
		this.preLimbo = this.limbo;
	}

	if (!this.player.getEntityWorld().isRemote){
		this.limboTime -= (this.limboTime > 0) ? 1 : 0;
	}
}









@Override
public void saveNBTData(NBTTagCompound compound) {

}

@Override
public void loadNBTData(NBTTagCompound compound) {

}

@Override
public void init(Entity entity, World world) {
	// TODO Auto-generated method stub

}






}

 

 

Event Handler

package com.Splosions.ModularBosses.client;

import com.Splosions.ModularBosses.entity.player.MBExtendedPlayer;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class MBEvents {

/*
 * used to make the player look ghostly when in limbo. 
 */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
	if (MBExtendedPlayer.get((EntityPlayer)event.entity).preLimbo > 0){
		GlStateManager.enableBlend();
		GlStateManager.disableAlpha();
		GlStateManager.blendFunc(1, 1);
	}
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Post event) {
        GlStateManager.disableBlend();
        GlStateManager.enableAlpha();
}


@SubscribeEvent
public void onEntityConstructing(EntityConstructing event){
	if (event.entity instanceof EntityPlayer && MBExtendedPlayer.get((EntityPlayer) event.entity) == null)
		MBExtendedPlayer.register((EntityPlayer) event.entity);
	if (event.entity instanceof EntityPlayer && event.entity.getExtendedProperties(MBExtendedPlayer.EXT_PROP_NAME) == null)
		event.entity.registerExtendedProperties(MBExtendedPlayer.EXT_PROP_NAME, new MBExtendedPlayer((EntityPlayer) event.entity));
}


@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
	if (event.entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.entity;
		MBExtendedPlayer.get(player).onUpdate();
	}
}


}

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 16, 2016

welp no idea what is causing it.

 

I put the sobel shader part in the block onColide part instead. The clearShader method works just fine for each client individually.

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 17, 2016

OK I take it back the clearShader method also affects all clients within render distance when called from the MBExtendedPlayer class.

 

This makes no sense.

 

 

EDIT So I think I know what is going on. The MBExtendedPlayer.onUpdate() method is firing for any EntityPlayer within render distance. So when one of the other players meet the qualifications to apply the renderer it triggers the sobelShader method.

 

How can I check if the player being checked is the player of the current client? Is that the EntityPlayerMP class?

 

would if(this.player instanceof EntityPlayerMP) work?

 

not at home to test yet

  • Quote

Share this post


Link to post
Share on other sites

coolAlias    745

coolAlias

coolAlias    745

  • Reality Controller
  • coolAlias
  • Members
  • 745
  • 2805 posts
Posted April 17, 2016

EntityPlayerMP is the server-side player class, and EVERY player will match that check when checking on the server side, just as every player would match the client-side corollary if checking on the client side. Instanceof cannot help you here, and despite LivingUpdateEvent being a poor choice for your purpose (one of the PlayerTick events would be better), I don't think that's the issue.

 

Your problem is much more likely to be in your actual implementation and has nothing to do with the current client-player 'being everybody.'

 

Specifically, I don't see where you ever set limboTime to be anything other than zero. Also, why not nest your entire bunch of code in the same world.isRemote check? You're checking the same conditions over and over again.

if (this.player.getEntityWorld().isRemote) { // common condition of all the following logic
this.limbo = this.player.getDataWatcher().getWatchableObjectInt(LIMBO_WATCHER);
if (this.preLimbo != this.limbo) { // common condition of both of the following
	if (this.limbo == 1) {
		// ((ClientProxy) ModularBosses.proxy).sobelShader(); // if you need to class cast, you are doing it wrong...
		ModularBosses.proxy.sobelShader(); // this is what it should look like
		this.player.performHurtAnimation();
	} else {
		ModularBosses.proxy.clearShader();
	}
}
this.preLimbo = this.limbo;
// don't see how the following does anything, since you never set limboTime as far as I can see
this.limboTime -= (this.limboTime > 0) ? 1 : 0;
} else {
this.player.getDataWatcher().updateObject(LIMBO_WATCHER, (this.limboTime > 0 ? 1 : 0));
}

  • Quote

Share this post


Link to post
Share on other sites

gummby8    26

gummby8

gummby8    26

  • Diamond Finder
  • gummby8
  • Members
  • 26
  • 479 posts
Posted April 17, 2016

Thank you for cleaning up my mess of ifs, was going to do it once I figured out what the problem was.

 

The shader method is a client affecting method (no idea how else to describe it). If it fires for any reason on any client it will apply the shader.

 

On the client if a player was in range that met the requirements it would fire the shader method, thus triggering the shader for all clients in render range.

 

So I had to ensure it was only firing on the clients who's players should be affected

 

public void onUpdate() {
	if (this.player.getEntityWorld().isRemote) {
		this.limbo = this.player.getDataWatcher().getWatchableObjectInt(LIMBO_WATCHER);
		if (this.preLimbo != this.limbo && this.player == Minecraft.getMinecraft().thePlayer) {
			if (this.limbo == 1) {
				ClientProxy.sobelShader();
			} else {
				ClientProxy.clearShader();
			}
		}
		this.preLimbo = this.limbo;
	} else {
		this.player.getDataWatcher().updateObject(LIMBO_WATCHER, (this.limboTime > 0 ? 1 : 0));
	}
	this.limboTime -= (this.limboTime > 0) ? 1 : 0;
}

 

Cool you were right the static had nothing to do with it so I changed it back. Not sure why eclipse is complaining and forcing me to cast the other way, I'll work to figure that out since it appears to not be correct. Also will move this to Player tick events.

 

To answer your previous question the limboTime is set in the collision method in the block

 

@Override
    public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
    {
        if (entityIn instanceof EntityPlayer && !worldIn.isRemote){
        	MBExtendedPlayer.get((EntityPlayer)entityIn).limboTime = 100;
        }
        
        worldIn.setBlockToAir(pos);
    }

 

 

everything works now

 

Yay

 

width=800 height=225https://dl.dropbox.com/s/xehj279ehfvnnte/Shader.PNG?dl=0[/img]

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45709 posts
Posted April 18, 2016

Do not use DataWatchers for this... please.

Even in 1.9 where more IDs than 31 are available they are still dependent on initialization order. And you are not even using 1.9. So: get out of other people's DataWatchers!

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Jaffaaaaa
      ScreenGui does nothing

      By Jaffaaaaa · Posted 11 minutes ago

      bump. anyone help?
    • JMAS
      net.minecraftforge.oredict.OreDictionary missing from 1.14.4 MDK

      By JMAS · Posted 14 minutes ago

      Regarding the Oredict question above: NonNullList<ItemStack> seed = OreDictionary.getOres("seed");
    • Carbonx_09
      Minearchy | 1.14.4 Towny | Releasing Mid December | Balanced player economies | Join discord: discord.gg/vUEAanV

      By Carbonx_09 · Posted 25 minutes ago

      Hey guys, you should definitely join our discord server! We're going to be releasing in one week! https://discord.gg/vUEAanV
    • solitone
      Distinguish singleplayer vs. multiplayer

      By solitone · Posted 45 minutes ago

      @Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { // [...] String separator = getSeparator(); String scriptName = nbtTagCompound.getString("scriptName"); String scriptPath = "pythontool" + separator + scriptName; proxy.runPython(world, player, scriptPath); // [...] }   ^^^ This is how I refactored onItemRightClick(). The runPython() method does nothing on the dedicated server, while on the client:   public class ClientOnlyProxy extends CommonProxy { // [...] @Override public void runPython(World world, EntityPlayer player, String scriptPath) { super.runPython(world, player, scriptPath); if (world.isRemote) { // client side if (!Minecraft.getMinecraft().isSingleplayer()) { // client talks to dedicated server (multiplayer game) ClientCommandHandler.instance.executeCommand(player, "/lpython " + scriptPath); } } else { // server side if (player.isSneaking()) { // shift pressed. Run new parallel script Minecraft.getMinecraft().thePlayer.getServer().getCommandManager().executeCommand(player, "/apy " + scriptPath); } else { // shift not pressed. Cancel previous scripts and run new script world.getMinecraftServer().getCommandManager().executeCommand(player, "/python " + scriptPath); } } } }   I still need to figure out why they used two different approaches to execute commands on the integrated server--Minecraft.getMinecraft().thePlayer.getServer().getCommandManager().executeCommand() vs. world.getMinecraftServer().getCommandManager().executeCommand().   public abstract class CommonProxy { // [...] public void runPython(World world, EntityPlayer player, String scriptPath) {} }   public class PythonTool { // [...] @SidedProxy(clientSide="pythontool.ClientOnlyProxy", serverSide="pythontool.DedicatedServerProxy") public static CommonProxy proxy; // [...] }   Are still there significant mistakes? Thanks again!
    • salvestrom
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By salvestrom · Posted 48 minutes ago

      Please show your render class. And please use the <> function in the reply box to copy and paste your class. Don't just use screenshots.
  • Topics

    • Jaffaaaaa
      1
      ScreenGui does nothing

      By Jaffaaaaa
      Started Yesterday at 07:03 PM

    • JMAS
      5
      net.minecraftforge.oredict.OreDictionary missing from 1.14.4 MDK

      By JMAS
      Started 4 hours ago

    • Carbonx_09
      1
      Minearchy | 1.14.4 Towny | Releasing Mid December | Balanced player economies | Join discord: discord.gg/vUEAanV

      By Carbonx_09
      Started Yesterday at 08:30 PM

    • solitone
      18
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started December 5

    • DragonITA
      34
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

  • Who's Online (See full list)

    • Sivonja
    • JMAS
    • Jaffaaaaa
    • dylandmrl
    • deerangle
    • loordgek
    • Pyre540
    • bluemetalsword
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • IExtendedEntityProperties player Datawatcher affecting all players on server?
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community