@@ -39,18 +39,8 @@ public class TurtleSeatEntity extends Entity implements HasCustomInventoryScreen
3939 private ITurtleAccess turtle = null ;
4040 private int life = 0 ;
4141
42- private boolean forwardKey = false ;
43- private boolean backKey = false ;
44- private boolean leftKey = false ;
45- private boolean rightKey = false ;
46- private boolean upKey = false ;
47- private boolean downKey = false ;
48- private boolean forwardKeyOld = false ;
49- private boolean backKeyOld = false ;
50- private boolean leftKeyOld = false ;
51- private boolean rightKeyOld = false ;
52- private boolean upKeyOld = false ;
53- private boolean downKeyOld = false ;
42+ private InputKeySet inputs = InputKeySet .NONE ;
43+ private InputKeySet oldInputs = InputKeySet .NONE ;
5444
5545 public TurtleSeatEntity (EntityType <?> type , Level world ) {
5646 super (type , world );
@@ -158,41 +148,31 @@ public void tick() {
158148 return ;
159149 }
160150 ServerComputer computer = this .getServerComputer ();
161- if (computer != null ) {
162- if (this .forwardKey != this .forwardKeyOld ) {
163- this .forwardKeyOld = this .forwardKey ;
164- computer .queueEvent ("saddle_control" , new Object []{"forward" , this .forwardKey });
151+ if (computer != null && this .inputs != this .oldInputs ) {
152+ if (this .inputs .forward () != this .oldInputs .forward ()) {
153+ computer .queueEvent ("saddle_control" , new Object []{"forward" , this .inputs .forward ()});
165154 }
166- if (this .backKey != this .backKeyOld ) {
167- this .backKeyOld = this .backKey ;
168- computer .queueEvent ("saddle_control" , new Object []{"back" , this .backKey });
155+ if (this .inputs .back () != this .oldInputs .back ()) {
156+ computer .queueEvent ("saddle_control" , new Object []{"back" , this .inputs .back ()});
169157 }
170- if (this .leftKey != this .leftKeyOld ) {
171- this .leftKeyOld = this .leftKey ;
172- computer .queueEvent ("saddle_control" , new Object []{"left" , this .leftKey });
158+ if (this .inputs .left () != this .oldInputs .left ()) {
159+ computer .queueEvent ("saddle_control" , new Object []{"left" , this .inputs .left ()});
173160 }
174- if (this .rightKey != this .rightKeyOld ) {
175- this .rightKeyOld = this .rightKey ;
176- computer .queueEvent ("saddle_control" , new Object []{"right" , this .rightKey });
161+ if (this .inputs .right () != this .oldInputs .right ()) {
162+ computer .queueEvent ("saddle_control" , new Object []{"right" , this .inputs .right ()});
177163 }
178- if (this .upKey != this .upKeyOld ) {
179- this .upKeyOld = this .upKey ;
180- computer .queueEvent ("saddle_control" , new Object []{"up" , this .upKey });
164+ if (this .inputs .up () != this .oldInputs .up ()) {
165+ computer .queueEvent ("saddle_control" , new Object []{"up" , this .inputs .up ()});
181166 }
182- if (this .downKey != this .downKeyOld ) {
183- this .downKeyOld = this .downKey ;
184- computer .queueEvent ("saddle_control" , new Object []{"down" , this .downKey });
167+ if (this .inputs .down () != this .oldInputs .down ()) {
168+ computer .queueEvent ("saddle_control" , new Object []{"down" , this .inputs .down ()});
185169 }
170+ this .oldInputs = this .inputs ;
186171 }
187172 }
188173
189174 public void handleSaddleTurtleControlPacket (SaddleTurtleControlPacket packet ) {
190- this .forwardKey = packet .forward ;
191- this .backKey = packet .back ;
192- this .leftKey = packet .left ;
193- this .rightKey = packet .right ;
194- this .upKey = packet .up ;
195- this .downKey = packet .down ;
175+ this .inputs = packet .inputs ;
196176 }
197177
198178 @ Override
0 commit comments