Skip to content

Commit

Permalink
cleaned up code from experimental phase
Browse files Browse the repository at this point in the history
  • Loading branch information
MalkContent committed Oct 11, 2021
1 parent 7505b5d commit 82e0f9a
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class WatermillBlockEntity extends IEBaseBlockEntity implements IETickabl
public boolean multiblock = false;
private boolean beingBroken = false;
public double perTick;
private static final int globalSyncDelay = 10*20;
private static final int globalSyncDelay = 20*20;
private int globalSyncDelayCounter = 1;

public WatermillBlockEntity(BlockEntityType<WatermillBlockEntity> type, BlockPos pos, BlockState state)
Expand All @@ -63,6 +63,8 @@ public void tickClient()
@Override
public void tickServer()
{
// if(isDummy())
// return;
if(isBlocked())//TODO throttle?
{
setPerTickAndAdvance(0);
Expand Down Expand Up @@ -112,6 +114,8 @@ public void tickServer()

private void setPerTickAndAdvance(double newValue)
{
if(isDummy())
return;
if(newValue!=perTick)
{
globalSyncDelayCounter = globalSyncDelay;
Expand All @@ -120,10 +124,9 @@ private void setPerTickAndAdvance(double newValue)
}
else if(globalSyncDelayCounter >= 0)
globalSyncDelayCounter--;

if(globalSyncDelayCounter==0)
{
float newrot = syncedRot();
float newrot = (float)(level.getGameTime()*perTick);
if(rotation!=newrot)
{
rotation = newrot;
Expand All @@ -132,7 +135,8 @@ else if(globalSyncDelayCounter >= 0)
}
}
else
rotation = (float)(rotation+perTick)%1;
rotation += perTick;
rotation %= 1;
}

private boolean canUse(@Nullable BlockEntity tileEntity)
Expand Down Expand Up @@ -350,9 +354,4 @@ public void breakDummies(BlockPos pos, BlockState state)
}
}
}

private float syncedRot()
{
return ((float)(level.getGameTime()*perTick))%1;
}
}

0 comments on commit 82e0f9a

Please sign in to comment.