Skip to content

Commit

Permalink
Merge branch 'dev-1.19.4' of github.com:JDKDigital/productive-bees in…
Browse files Browse the repository at this point in the history
…to dev-1.20.0
  • Loading branch information
JaisDK committed May 23, 2023
2 parents 74db193 + f123d2f commit cc5bda5
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

version=11.6.1
version=11.6.2
mc_version=1.19.4
forgeversion=45.0.64
jei_version=13.1.0.9
Expand Down
5 changes: 5 additions & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.19.4-11.6.2

- Bumblebees can carry passengers again


1.19.4-11.6.1

- Ported to 1.19.4
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -56,6 +57,21 @@ public TagKey<Block> getNestingTag() {
return ModTags.BUMBLE_BEE_NESTS;
}

@Nullable
@Override
public LivingEntity getControllingPassenger() {
if (this.isSaddled()) {
Entity entity = this.getFirstPassenger();
if (entity instanceof Player) {
Player player = (Player)entity;
if (player.getMainHandItem().is(ModItems.TREAT_ON_A_STICK.get()) || player.getOffhandItem().is(ModItems.TREAT_ON_A_STICK.get())) {
return player;
}
}
}
return null;
}

@Override
public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
if (BOOST_TIME.equals(key) && this.level.isClientSide) {
Expand All @@ -71,34 +87,6 @@ protected void defineSynchedData() {
this.entityData.define(BOOST_TIME, 0);
}

@Override
protected void dropEquipment() {
super.dropEquipment();
if (this.isSaddled()) {
this.spawnAtLocation(Items.SADDLE);
}
}

private boolean canBeControlledBy(Entity entity) {
if (!(entity instanceof Player playerEntity)) {
return false;
} else {
return playerEntity.getMainHandItem().getItem() == ModItems.TREAT_ON_A_STICK.get() || playerEntity.getOffhandItem().getItem() == ModItems.TREAT_ON_A_STICK.get();
}
}

@Nullable
public LivingEntity getControllingPassenger() {
if (!this.isNoAi()) {
Entity entity = this.getFirstPassenger();
if (entity instanceof Mob && this.canBeControlledBy(entity)) {
return (Mob)entity;
}
}

return null;
}

@Override
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
Expand All @@ -121,6 +109,14 @@ public boolean isSaddleable() {
return this.isAlive() && !this.isBaby();
}

@Override
protected void dropEquipment() {
super.dropEquipment();
if (this.isSaddled()) {
this.spawnAtLocation(Items.SADDLE);
}
}

@Override
public void equipSaddle(@Nullable SoundSource soundCategory) {
this.steering.setSaddle(true);
Expand All @@ -130,17 +126,15 @@ public void equipSaddle(@Nullable SoundSource soundCategory) {
}

@Override
public float getSizeModifier() {
return 1.25F;
protected void tickRidden(LivingEntity rider, Vec3 direction) {
super.tickRidden(rider, direction);
this.setRot(rider.getYRot(), rider.getXRot() * 0.5F);
this.yRotO = this.yBodyRot = this.yHeadRot = this.getYRot();
this.steering.tickBoost();
}

@Override
public boolean boost() {
return this.steering.boost(this.getRandom());
}

@Override
public Vec3 getRiddenInput(LivingEntity rider, Vec3 travelVec) {
public @NotNull Vec3 getRiddenInput(LivingEntity rider, Vec3 travelVec) {
return new Vec3(0.0D, 0.0D, 1.0D);
}

Expand All @@ -149,11 +143,20 @@ protected float getRiddenSpeed(LivingEntity rider) {
return (float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * this.steering.boostFactor();
}

@Override
public boolean boost() {
return this.steering.boost(this.getRandom());
}

@Override
public float getSizeModifier() {
return 1.25F;
}

@Override
@Nonnull
public InteractionResult mobInteract(Player player, InteractionHand hand) {
boolean flag = this.isFood(player.getItemInHand(hand));
// this.level.broadcastEntityEvent(this, (byte) 18);
if (!flag && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
if (!this.level.isClientSide) {
if (player instanceof ServerPlayer) {
Expand All @@ -167,4 +170,27 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) {
}
return super.mobInteract(player, hand);
}

@Override
public void travel(Vec3 vec3) {
super.travel(vec3);

if (this.hasPlayerPassenger()) {
var dy = !level.isEmptyBlock(blockPosition().below(3)) ? .1D : level.isEmptyBlock(blockPosition().below(1)) ? -0.05D : 0.0D;
if (dy != 0f) {
Vec3 vec = this.getDeltaMovement();
this.setDeltaMovement(vec.x(), vec.y() + dy, vec.z());
}
}
}

private boolean hasPlayerPassenger() {
if (this.isSaddled()) {
Entity entity = this.getFirstPassenger();
if (entity instanceof Player) {
return true;
}
}
return false;
}
}

0 comments on commit cc5bda5

Please sign in to comment.