Skip to content

Commit

Permalink
fix some porting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Sep 9, 2024
1 parent 3227767 commit c8169ff
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public ColonyEventTypeRegistryEntry(@NotNull final TriFunction<IColony, Compound
* @param compound the nbt to deserialize the event from.
* @return the deserialized event.
*/
public IColonyEvent deserializeEvent(@Nonnull final IColony colony, @Nonnull final CompoundTag compound)
public IColonyEvent deserializeEvent(@Nonnull final IColony colony, @NotNull final HolderLookup.Provider provider, @Nonnull final CompoundTag compound)
{
return eventCreator.apply(colony, compound, colony.getWorld().registryAccess());
return eventCreator.apply(colony, compound, provider);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void readFromNBT(@NotNull final HolderLookup.Provider provider, @NotNull
continue;
}

final IColonyEvent colonyEvent = registryEntry.deserializeEvent(colony, tagCompound);
final IColonyEvent colonyEvent = registryEntry.deserializeEvent(colony, provider, tagCompound);
events.put(colonyEvent.getID(), colonyEvent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,7 @@ private IState eat()

citizen.swing(InteractionHand.MAIN_HAND);
citizen.playSound(SoundEvents.GENERIC_EAT, (float) BASIC_VOLUME, (float) SoundUtils.getRandomPitch(citizen.getRandom()));
new ItemParticleEffectMessage(foodStack,
citizen.getX(),
citizen.getY(),
citizen.getZ(),
citizen.getXRot(),
citizen.getYRot(),
citizen.getEyeHeight()).sendToTrackingEntity(citizen);
new ItemParticleEffectMessage(foodStack, citizen.getX(), citizen.getY(), citizen.getZ(), citizen.getXRot(), citizen.getYRot(), citizen.getEyeHeight()).sendToTrackingEntity(citizen);

waitingTicks++;
if (waitingTicks < REQUIRED_TIME_TO_EAT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected void doAttack(final LivingEntity target)

final float inaccuracy = 99f / level;
final Holder<MobEffect> effect;
final ItemStack stack = new ItemStack(Items.SPLASH_POTION);
final ItemStack stack = Items.SPLASH_POTION.getDefaultInstance();
boolean gotMaterial = false;
BiPredicate<LivingEntity, MobEffect> predicate;
if (user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(DRUID_USE_POTIONS) > 0
Expand All @@ -151,7 +151,7 @@ protected void doAttack(final LivingEntity target)
predicate = (entity, eff) -> !AbstractEntityAIGuard.isAttackableTarget(user, entity);
}

stack.set(DataComponents.POTION_CONTENTS, new PotionContents(Holder.direct(new Potion(new MobEffectInstance(effect, time, gotMaterial ? 2 : 0)))));
stack.set(DataComponents.POTION_CONTENTS, PotionContents.EMPTY.withEffectAdded((new MobEffectInstance(effect, time, gotMaterial ? 2 : 0))));
DruidPotionEntity.throwPotionAt(stack, target, user, user.getCommandSenderWorld(), POTION_VELOCITY, inaccuracy, predicate);

if (gotMaterial)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,11 @@ private void childFoodInteraction(final ItemStack usedStack, final Player player

if (!level().isClientSide())
{
ItemStackUtils.consumeFood(usedStack, this, player.getInventory());
addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 300));

playSound(SoundEvents.GENERIC_EAT, 1.5f, (float) SoundUtils.getRandomPitch(getRandom()));
new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight())
.sendToTrackingEntity(this);
new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()).sendToTrackingEntity(this);
ItemStackUtils.consumeFood(usedStack, this, player.getInventory());
}
}
else
Expand Down Expand Up @@ -626,12 +625,10 @@ private void eatFoodInteraction(final ItemStack usedStack, final Player player,
{
if (!level().isClientSide())
{
ItemStackUtils.consumeFood(usedStack, this, player.getInventory());

playSound(SoundEvents.GENERIC_EAT, 1.5f, (float) SoundUtils.getRandomPitch(getRandom()));
// Position needs to be centered on citizen, Eat AI wrong too?
new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight())
.sendToTrackingEntity(this);
new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()).sendToTrackingEntity(this);
ItemStackUtils.consumeFood(usedStack, this, player.getInventory());
}

interactionCooldown = 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,16 +513,9 @@ private InteractionResult directPlayerInteraction(final Player player, final Int
{
if (!level().isClientSide())
{
ItemStackUtils.consumeFood(usedStack, this, player.getInventory());
playSound(SoundEvents.GENERIC_EAT, 1.5f, (float) SoundUtils.getRandomPitch(getRandom()));
new ItemParticleEffectMessage(usedStack,
getX(),
getY(),
getZ(),
getXRot(),
getYRot(),
getEyeHeight()).sendToTrackingEntity(this);

new ItemParticleEffectMessage(usedStack, getX(), getY(), getZ(), getXRot(), getYRot(), getEyeHeight()).sendToTrackingEntity(this);
ItemStackUtils.consumeFood(usedStack, this, player.getInventory());
MessageUtils.forCitizen(this, MESSAGE_INTERACTION_VISITOR_FOOD).sendTo(player);
}
return InteractionResult.CONSUME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public List<OverlayBox> getOverlayBoxes(@NotNull final Level world, @NotNull fin
{
final OverlayBox anchorBox = new OverlayBox(buildingId.id(), RED_OVERLAY, 0.02f, true);

if (box != null)
if (box != null && box.getA() != null && box.getB() != null)
{
final AABB bounds = AABB.encapsulatingFullBlocks(box.getA(), box.getB().offset(1, 1, 1)).inflate(1);
// inflate(1) is due to implementation of BlockPosUtil.isInArea
Expand Down

0 comments on commit c8169ff

Please sign in to comment.