Skip to content

Commit 5a383e0

Browse files
committed
general fixes
- improve lectern handling - fix water check exception - update hippogryph rabbit food list when needed - fix issue where hippogryph attack target bounces upward - fix #5014 - fix #5008 - fix #5006
1 parent 8bae67d commit 5a383e0

File tree

7 files changed

+44
-18
lines changed

7 files changed

+44
-18
lines changed

src/main/java/com/github/alexthe666/iceandfire/entity/EntityHippogryph.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,9 @@ public void travel(@NotNull Vec3 pTravelVector) {
786786
float vertical = this.isGoingUp() ? 1.0F : this.isGoingDown() ? -1.0F : 0F;
787787

788788
float speedFactor = 1.0f;
789-
if (this.isFlying() || this.isHovering()) {
789+
boolean isFlying = this.isFlying() || this.isHovering();
790+
791+
if (isFlying) {
790792
speedFactor *= flightSpeedFactor;
791793
// Let server know we're flying before they kick us
792794
this.setNoGravity(true);
@@ -811,7 +813,9 @@ public void travel(@NotNull Vec3 pTravelVector) {
811813

812814
// Vanilla travel has a smaller friction factor for Y axis
813815
// Add more friction in case moving too fast on Y axis
814-
if (this.isFlying() || this.isHovering()) {
816+
if (isFlying) {
817+
// See LivingEntity#getFrictionInfluencedSpeed -> flyingSpeed (default: 0.02) is used when not on ground
818+
this.flyingSpeed = getSpeed();
815819
this.setDeltaMovement(this.getDeltaMovement().multiply(1.0f, 0.92f, 1.0f));
816820
}
817821
} else if (rider instanceof Player) {
@@ -820,16 +824,18 @@ public void travel(@NotNull Vec3 pTravelVector) {
820824
// Happens when stepping up blocks
821825
// Might because client & server's onGround flag is out of sync
822826
// I can't get it fixed, so it's disabled
823-
this.noPhysics = DISABLE_MOVEMENT_CHECK;
827+
// this.noPhysics = DISABLE_MOVEMENT_CHECK;
824828
}
825829

826-
this.calculateEntityAnimation(this, false);
830+
this.calculateEntityAnimation(this, isFlying);
827831
this.tryCheckInsideBlocks();
828832
} else {
829833
this.setNoGravity(false);
830834
this.noPhysics = false;
831835

832836
this.setSpeed(0.02F);
837+
flyingSpeed = getSpeed();
838+
833839
super.travel(pTravelVector);
834840
}
835841
} else {
@@ -849,6 +855,7 @@ public boolean doHurtTarget(@NotNull Entity entityIn) {
849855
return false;
850856
}
851857

858+
// FIXME :: Unused
852859
public ItemEntity createEgg(EntityHippogryph partner) {
853860
int i = Mth.floor(this.getX());
854861
int j = Mth.floor(this.getY());
@@ -895,13 +902,16 @@ public void aiStep() {
895902
if (dist < 8) {
896903
attackTarget.hurt(DamageSource.mobAttack(this), ((int) this.getAttribute(Attributes.ATTACK_DAMAGE).getValue()));
897904
attackTarget.hasImpulse = true;
905+
/*
906+
// Disabled because it causes the target (player) to bounce upward
898907
float f = Mth.sqrt((float) (0.5 * 0.5 + 0.5 * 0.5));
899908
attackTarget.setDeltaMovement(attackTarget.getDeltaMovement().add(-0.5 / (double) f, 1, -0.5 / (double) f));
900909
attackTarget.setDeltaMovement(attackTarget.getDeltaMovement().multiply(0.5D, 1, 0.5D));
901910
902911
if (attackTarget.isOnGround()) {
903912
attackTarget.setDeltaMovement(attackTarget.getDeltaMovement().add(0, 0.3, 0));
904913
}
914+
*/
905915
}
906916
}
907917
if (!level.isClientSide && !this.isOverAir() && this.getNavigation().isDone() && attackTarget != null && attackTarget.getY() - 3 > this.getY() && this.getRandom().nextInt(15) == 0 && this.canMove() && !this.isHovering() && !this.isFlying()) {

src/main/java/com/github/alexthe666/iceandfire/entity/ai/HippogryphAITargetItems.java

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public boolean canUse() {
5555
return false;
5656
}
5757

58+
return updateList();
59+
}
60+
61+
private boolean updateList() {
5862
if (this.mob.level.getGameTime() % 4 == 0) // only update the list every 4 ticks
5963
list = this.mob.level.getEntitiesOfClass(ItemEntity.class, this.getTargetableArea(this.getFollowDistance()), this.targetEntitySelector);
6064

@@ -96,6 +100,8 @@ public void tick() {
96100
hippo.setOrderedToSit(true);
97101
}
98102
stop();
103+
} else {
104+
updateList();
99105
}
100106
}
101107

src/main/java/com/github/alexthe666/iceandfire/entity/tile/TileEntityLectern.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,25 @@ private List<EnumBestiaryPages> getPossiblePages() {
125125

126126
@Override
127127
public void setItem(int index, ItemStack stack) {
128-
boolean flag = !stack.isEmpty() && ItemStack.isSame(stack, this.stacks.get(index)) && ItemStack.matches(stack, this.stacks.get(index));
128+
boolean isSame = !stack.isEmpty() && ItemStack.isSame(stack, this.stacks.get(index)) && ItemStack.matches(stack, this.stacks.get(index));
129129
this.stacks.set(index, stack);
130130

131131
if (!stack.isEmpty() && stack.getCount() > this.getMaxStackSize()) {
132132
stack.setCount(this.getMaxStackSize());
133133
}
134-
if (index == 0 && !flag) {
134+
135+
if (!isSame) {
135136
this.setChanged();
136-
selectedPages = randomizePages(getItem(0), getItem(1));
137-
}
138137

138+
if (/* Manuscripts */ this.stacks.get(1).isEmpty()) {
139+
selectedPages[0] = null;
140+
selectedPages[1] = null;
141+
selectedPages[2] = null;
142+
IceAndFire.sendMSGToAll(new MessageUpdateLectern(worldPosition.asLong(), -1, -1, -1, false, 0));
143+
} else {
144+
selectedPages = randomizePages(getItem(0), getItem(1));
145+
}
146+
}
139147
}
140148

141149
public EnumBestiaryPages[] randomizePages(ItemStack bestiary, ItemStack manuscript) {

src/main/java/com/github/alexthe666/iceandfire/pathfinding/raycoms/SurfaceType.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@ public static boolean isWater(final BlockGetter world, final BlockPos pos, @Null
118118
fluidState = world.getFluidState(pos);
119119
}
120120

121-
if (fluidState == null || fluidState.isEmpty()) {
121+
if (fluidState.isEmpty()) {
122122
return false;
123123
}
124124

125-
if (state.getBlock() instanceof TrapDoorBlock || state.getBlock() instanceof HorizontalDirectionalBlock && !state.getValue(TrapDoorBlock.OPEN) && state.getValue(TrapDoorBlock.HALF) == Half.TOP)
126-
{
127-
return false;
125+
if (state.getBlock() instanceof TrapDoorBlock || state.getBlock() instanceof HorizontalDirectionalBlock) {
126+
// getvalue() will throw an exception if the property does not exist
127+
if (state.hasProperty(TrapDoorBlock.OPEN) && !state.getValue(TrapDoorBlock.OPEN) && state.hasProperty(TrapDoorBlock.HALF) && state.getValue(TrapDoorBlock.HALF) == Half.TOP) {
128+
return false;
129+
}
128130
}
129131

130132
final Fluid fluid = fluidState.getType();

src/main/resources/data/iceandfire/recipes/dragonsteel_fire_axe.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"type": "minecraft:crafting_shaped",
33
"pattern": [
44
"DD",
5-
"TD",
6-
"T "
5+
"DT",
6+
" T"
77
],
88
"key": {
99
"D": {

src/main/resources/data/iceandfire/recipes/dragonsteel_ice_axe.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"type": "minecraft:crafting_shaped",
33
"pattern": [
44
"DD",
5-
"TD",
6-
"T "
5+
"DT",
6+
" T"
77
],
88
"key": {
99
"D": {

src/main/resources/data/iceandfire/recipes/dragonsteel_lightning_axe.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"type": "minecraft:crafting_shaped",
33
"pattern": [
44
"DD",
5-
"TD",
6-
"T "
5+
"DT",
6+
" T "
77
],
88
"key": {
99
"D": {

0 commit comments

Comments
 (0)