Skip to content

Commit 2302083

Browse files
committed
🎨 formatting
1 parent ffc67d7 commit 2302083

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

‎Common/src/main/java/dev/upcraft/poppingpresents/entity/PresentEntity.java‎

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ public class PresentEntity extends Entity implements GeoEntity, OwnableEntity, C
4848

4949
public static final EntityDataAccessor<Boolean> DATA_ID_OPEN = SynchedEntityData.defineId(PresentEntity.class, EntityDataSerializers.BOOLEAN);
5050
public static final EntityDataAccessor<Holder<PresentType>> DATA_ID_PRESENT_TYPE = SynchedEntityData.defineId(PresentEntity.class, PPEntityDataSerializers.PRESENT_TYPE);
51+
public static final String NBT_KEY_PRESENT_TYPE = "PresentType";
52+
public static final String NBT_KEY_OWNER = "Owner";
5153
protected static final EntityDataAccessor<Integer> DATA_ID_HURT = SynchedEntityData.defineId(PresentEntity.class, EntityDataSerializers.INT);
5254
protected static final EntityDataAccessor<Integer> DATA_ID_HURTDIR = SynchedEntityData.defineId(PresentEntity.class, EntityDataSerializers.INT);
5355
protected static final EntityDataAccessor<Float> DATA_ID_DAMAGE = SynchedEntityData.defineId(PresentEntity.class, EntityDataSerializers.FLOAT);
54-
public static final String NBT_KEY_PRESENT_TYPE = "PresentType";
55-
public static final String NBT_KEY_OWNER = "Owner";
5656
private static final int MAX_SLOTS = 27;
5757

5858
private final AnimatableInstanceCache geoCache = GeckoLibUtil.createInstanceCache(this);
59-
private NonNullList<ItemStack> inventory = NonNullList.withSize(MAX_SLOTS, ItemStack.EMPTY);
60-
private @Nullable ResourceKey<LootTable> lootTable;
61-
private long lootTableSeed = 0L;
62-
private @Nullable EntityReference<LivingEntity> owner;
63-
6459
// FIXME write custom openers counter that works with entities
6560
private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
6661
@Override
@@ -89,6 +84,10 @@ public boolean isOwnContainer(Player player) {
8984
&& chest.getContainer() == PresentEntity.this;
9085
}
9186
};
87+
private NonNullList<ItemStack> inventory = NonNullList.withSize(MAX_SLOTS, ItemStack.EMPTY);
88+
private @Nullable ResourceKey<LootTable> lootTable;
89+
private long lootTableSeed = 0L;
90+
private @Nullable EntityReference<LivingEntity> owner;
9291

9392
public PresentEntity(EntityType<PresentEntity> entityType, Level level) {
9493
super(entityType, level);
@@ -114,7 +113,7 @@ protected void defineSynchedData(SynchedEntityData.Builder builder) {
114113
@Override
115114
public void baseTick() {
116115
super.baseTick();
117-
if(this.tickCount % 5 == 0) {
116+
if (this.tickCount % 5 == 0) {
118117
openersCounter.recheckOpeners(level(), blockPosition(), Blocks.BEDROCK.defaultBlockState());
119118
}
120119
}
@@ -184,6 +183,11 @@ public Holder<PresentType> getPresentType() {
184183
return entityData.get(DATA_ID_PRESENT_TYPE);
185184
}
186185

186+
public void setPresentType(Holder<PresentType> value) {
187+
entityData.set(DATA_ID_PRESENT_TYPE, value);
188+
refreshDimensions();
189+
}
190+
187191
public int getHurtTime() {
188192
return this.entityData.get(DATA_ID_HURT);
189193
}
@@ -208,11 +212,6 @@ public void setDamage(float damage) {
208212
this.entityData.set(DATA_ID_DAMAGE, damage);
209213
}
210214

211-
public void setPresentType(Holder<PresentType> value) {
212-
entityData.set(DATA_ID_PRESENT_TYPE, value);
213-
refreshDimensions();
214-
}
215-
216215
public Holder<PresentType> getDefaultPresentType() {
217216
var registry = PresentType.registry(level());
218217
return registry.getOrThrow(PresentType.REGISTRY_DEFAULT_KEY);
@@ -221,7 +220,7 @@ public Holder<PresentType> getDefaultPresentType() {
221220
@Override
222221
public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
223222
super.onSyncedDataUpdated(key);
224-
if(DATA_ID_PRESENT_TYPE.equals(key)) {
223+
if (DATA_ID_PRESENT_TYPE.equals(key)) {
225224
refreshDimensions();
226225
}
227226
}
@@ -243,16 +242,16 @@ public EntityDimensions getDimensions(Pose pose) {
243242

244243
@Override
245244
public boolean canBeCollidedWith(@Nullable Entity other) {
246-
if(!this.isAlive()) {
245+
if (!this.isAlive()) {
247246
return false;
248247
}
249248

250-
if(other instanceof LivingEntity livingEntity) {
251-
if(livingEntity.isShiftKeyDown()) {
249+
if (other instanceof LivingEntity livingEntity) {
250+
if (livingEntity.isShiftKeyDown()) {
252251
return false;
253252
}
254253

255-
if(owner != null) {
254+
if (owner != null) {
256255
return owner.matches(livingEntity);
257256
}
258257

@@ -275,31 +274,33 @@ public boolean isPickable() {
275274
@Override
276275
public void registerControllers(AnimatableManager.ControllerRegistrar controllers) {
277276
controllers.add(new AnimationController<>(AnimationControllers.MAIN, test -> {
278-
if(this.isOpen()) {
277+
System.out.print("EVAL: ");
278+
if (this.isOpen()) {
279279
System.out.println("OPEN!!");
280280
return test.setAndContinue(Animations.STATE_OPEN);
281281
}
282282

283+
System.out.println("STOP");
283284
return PlayState.STOP;
284285
})
285-
.triggerableAnim(AnimationTriggers.TRIGGER_OPEN, Animations.INTERACT_OPEN)
286-
.triggerableAnim(AnimationTriggers.TRIGGER_CLOSE, Animations.INTERACT_CLOSE)
286+
.triggerableAnim(AnimationTriggers.TRIGGER_OPEN, Animations.INTERACT_OPEN)
287+
.triggerableAnim(AnimationTriggers.TRIGGER_CLOSE, Animations.INTERACT_CLOSE)
287288
);
288289
}
289290

290291
@Override
291292
public InteractionResult interact(Player player, InteractionHand hand) {
292-
if(!this.isAlive()) {
293+
if (!this.isAlive()) {
293294
return InteractionResult.PASS;
294295
}
295296

296297
var superResult = super.interact(player, hand);
297-
if(superResult != InteractionResult.PASS) {
298+
if (superResult != InteractionResult.PASS) {
298299
return superResult;
299300
}
300301

301302
var tryOpenResult = this.interactWithContainerVehicle(player);
302-
if(tryOpenResult.consumesAction()) {
303+
if (tryOpenResult.consumesAction()) {
303304
this.gameEvent(GameEvent.ENTITY_INTERACT, player);
304305
return tryOpenResult;
305306
}
@@ -308,14 +309,14 @@ public InteractionResult interact(Player player, InteractionHand hand) {
308309
}
309310

310311
public void animateOpen() {
311-
if(!level().isClientSide()) {
312+
if (!level().isClientSide()) {
312313
stopTriggeredAnim(AnimationControllers.MAIN, AnimationTriggers.TRIGGER_CLOSE);
313314
triggerAnim(AnimationControllers.MAIN, AnimationTriggers.TRIGGER_OPEN);
314315
}
315316
}
316317

317318
public void animateClose() {
318-
if(!level().isClientSide()) {
319+
if (!level().isClientSide()) {
319320
stopTriggeredAnim(AnimationControllers.MAIN, AnimationTriggers.TRIGGER_OPEN);
320321
triggerAnim(AnimationControllers.MAIN, AnimationTriggers.TRIGGER_CLOSE);
321322
}
@@ -408,14 +409,14 @@ public void clearContent() {
408409

409410
@Override
410411
public void startOpen(ContainerUser user) {
411-
if(this.isAlive() && !user.getLivingEntity().isSpectator()) {
412+
if (this.isAlive() && !user.getLivingEntity().isSpectator()) {
412413
openersCounter.incrementOpeners(user.getLivingEntity(), level(), blockPosition(), Blocks.BEDROCK.defaultBlockState(), user.getContainerInteractionRange());
413414
}
414415
}
415416

416417
@Override
417418
public void stopOpen(ContainerUser user) {
418-
if(this.isAlive() && !user.getLivingEntity().isSpectator()) {
419+
if (this.isAlive() && !user.getLivingEntity().isSpectator()) {
419420
openersCounter.incrementOpeners(user.getLivingEntity(), level(), blockPosition(), Blocks.BEDROCK.defaultBlockState(), user.getContainerInteractionRange());
420421
}
421422
}

0 commit comments

Comments
 (0)