I'm trying to use Malisis Core in my project, but I just can't figure out, what I am doing wrong. The thing is - I have a button and I want to make it move smoothly when pressed/unpressed, so I'm using MalisisRenderer as a custom renderer and onBlockActivated. I call "tileentity.timer.start" both at the server and a client, otherwise animation just doesn't want to work (although you can see "!world.isRemote" onBlockActivated in the Malisis Doors sources). So, afterwards I schedule a block update to "unpress" the button automatically. Problem is updateTick is called always on a server side only. So, everything works but the animation (the same reason as with onBlockActivated - timer set on server only). What should I do to solve this nonsense?
Block:
...
@Override
public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
//if(world.isRemote) return true;
TEFancyButton te = TileEntityUtils.getTileEntity(TEFancyButton.class, world, x, y, z);
if (te == null)
return true;
if(te.getState() != TEFancyButton.State.IDLE)
return true;
te.pushMe();
if(te.getState() == TEFancyButton.State.PUSHING)
world.scheduleBlockUpdate(x, y, z, this, te.getPressDelay());
return true;
}
@Override
public void updateTick(World world, int x, int y, int z, Random rand)
{
if(world.isRemote)System.out.println("updateTick on client");
else System.out.println("updateTick on server");
TEFancyButton te = TileEntityUtils.getTileEntity(TEFancyButton.class, world, x, y, z);
if (te == null)
return;
if (te.getState() != TEFancyButton.State.PUSHED)
return;
te.pushMe();
te.notifyNeighbors();
world.markBlockForUpdate(x, y, z);
}
...
TEFancyButton:
...
public void pushMe()
{
State newState = (state == State.IDLE) ? State.PUSHING : State.IDELING;
setNewState(newState);
}
public void setNewState(State newState)
{
if (state == newState)
return;
state = newState;
if (worldObj == null) {
return;
}
if (state == State.IDELING || state == State.PUSHING)
{
if (moving)
{
long s = timer.elapsedTime() - Timer.tickToTime(animationLengthTicks);
timer.setRelativeStart(s);
}
else
{
timer.start(); // This one needs to be the same on a client and a server
moving = true;
}
}
else
{
moving = false;
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
...
Hello, guys!
I'm trying to use Malisis Core in my project, but I just can't figure out, what I am doing wrong. The thing is - I have a button and I want to make it move smoothly when pressed/unpressed, so I'm using MalisisRenderer as a custom renderer and onBlockActivated. I call "tileentity.timer.start" both at the server and a client, otherwise animation just doesn't want to work (although you can see "!world.isRemote" onBlockActivated in the Malisis Doors sources). So, afterwards I schedule a block update to "unpress" the button automatically. Problem is updateTick is called always on a server side only. So, everything works but the animation (the same reason as with onBlockActivated - timer set on server only). What should I do to solve this nonsense?
Block:
TEFancyButton:
Ok, nevermind! Thanks to the Ordinastie for pointing me to the TE sync