Skip to content

Commit

Permalink
[version patch] 1.14.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AeroStun committed Oct 13, 2020
1 parent 5567284 commit 50b91d3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 44 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Current available options are:

V1.0.0-rc2:
- Full French (France) translation

V1.0.0-rc1:
- Initial release
- 1.16.3 and 1.15.2 support
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.17
minecraft_version=1.14.4
yarn_mappings=1.14.4+build.18
loader_version=0.10.0+build.208

# Mod Properties
Expand All @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.23.0+build.328-1.15
fabric_version=0.23.0+build.264-1.14
16 changes: 1 addition & 15 deletions src/main/java/org/scbrm/fidelity/WhipItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import java.util.Random;

public class WhipItem extends Item {
private static final Random random = new Random();

public WhipItem(Settings settings) {
super(settings);
}
Expand Down Expand Up @@ -49,22 +47,10 @@ public boolean useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity enti
iequine.setMasterUuid(null);
user.sendMessage(new TranslatableText("fidelity.text.setstate." + state.toString()));
} else if(equine.isAlive() && !equine.isTame() && user.world.isClient) {
spawnParticles(entity, false);
((IHorseBaseEntity)equine).spawnPlayerReactionParticles( false);
}
}
return true;
}

private void spawnParticles(LivingEntity entity, boolean positive) {
ParticleEffect particleEffect = positive ? ParticleTypes.HEART : ParticleTypes.SMOKE;

for(int i = 0; i < 7; ++i) {
double d = random.nextGaussian() * 0.02D;
double e = random.nextGaussian() * 0.02D;
double f = random.nextGaussian() * 0.02D;
entity.world.addParticle(particleEffect, entity.getParticleX(1.0D), entity.getRandomBodyY() + 0.5D, entity.getParticleZ(1.0D), d, e, f);
}

}

}
2 changes: 2 additions & 0 deletions src/main/java/org/scbrm/fidelity/bridge/IHorseBaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ default boolean isMaster(LivingEntity entity) {
@NotNull
State getState();
void setState(@NotNull State state);

void spawnPlayerReactionParticles(boolean positive);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.scbrm.fidelity.entity.ai.goal;

import net.minecraft.block.BlockState;
import org.scbrm.fidelity.bridge.IHorseBaseEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.Goal;
Expand All @@ -8,14 +9,14 @@
import net.minecraft.entity.ai.pathing.PathNodeType;
import net.minecraft.entity.passive.HorseBaseEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.world.CollisionView;

import java.util.Optional;

public class ObeyMasterGoal extends Goal {
private final HorseBaseEntity equine;
private LivingEntity master;
private final WorldView world;
private final CollisionView world;
private final double speed;
private final EntityNavigation navigation;
private int updateCountdownTicks;
Expand Down Expand Up @@ -97,25 +98,20 @@ private void tryTeleport() {
}

private boolean tryTeleportTo(int x, int y, int z) {
if (Math.abs((double)x - this.master.getX()) < 2.0D && Math.abs((double)z - this.master.getZ()) < 2.0D) {
if (Math.abs((double)x - this.master.x) < 2.0D && Math.abs((double)z - this.master.z) < 2.0D) {
return false;
} else if (!this.canTeleportTo(new BlockPos(x, y, z))) {
return false;
} else {
this.equine.refreshPositionAndAngles((double)((float)x + 0.5F), (double)y, (double)((float)z + 0.5F), this.equine.yaw, this.equine.pitch);
this.equine.refreshPositionAndAngles((double)((float)x + 0.5F), (double)y + 1, (double)((float)z + 0.5F), this.equine.yaw, this.equine.pitch);
this.navigation.stop();
return true;
}
}

private boolean canTeleportTo(BlockPos pos) {
PathNodeType pathNodeType = LandPathNodeMaker.getPathNodeType(this.world, pos.getX(), pos.getY(), pos.getZ());
if (pathNodeType != PathNodeType.WALKABLE) {
return false;
} else {
final BlockPos blockPos = pos.subtract(new BlockPos(this.equine));
return this.world.doesNotCollide(this.equine, this.equine.getBoundingBox().offset(blockPos));
}
final BlockState blockState = this.world.getBlockState(pos);
return blockState.allowsSpawning(this.world, pos, this.equine.getType()) && this.world.isAir(pos.up()) && this.world.isAir(pos.up(2));
}

private Optional<Boolean> isStateRelevant() {
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/org/scbrm/fidelity/mixin/HorseBaseEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -30,7 +31,8 @@ public abstract class HorseBaseEntityMixin extends AnimalEntity implements IHors
private static final TrackedData<Optional<UUID>> MASTER_UUID = DataTracker.registerData(HorseBaseEntity.class, TrackedDataHandlerRegistry.OPTIONAL_UUID);
private State state = State.ROAMING_FREE;

/*@Shadow protected abstract void spawnPlayerReactionParticles(boolean positive);*/
@Shadow
public abstract void spawnPlayerReactionParticles(boolean positive);

protected HorseBaseEntityMixin(EntityType<? extends HorseBaseEntity> entityType, World world) {
super(entityType, world);
Expand Down Expand Up @@ -77,26 +79,22 @@ public void setState(@NotNull State state) {
@Inject(at = @At("TAIL"), method = "writeCustomDataToTag(Lnet/minecraft/nbt/CompoundTag;)V")
public void _writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
if (this.getMasterUuid() != null) {
tag.putUuid("Master", this.getMasterUuid());
tag.putString("MasterUUID", this.getMasterUuid().toString());
}

tag.putByte("FidelityState", (byte)this.state.ordinal());
}

@Inject(at = @At("TAIL"), method = "readCustomDataFromTag(Lnet/minecraft/nbt/CompoundTag;)V")
public void _readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
final UUID uuid = tag.containsUuid("Master") ?
tag.getUuid("Master") :
UUID.fromString(ServerConfigHandler.getPlayerUuidByName(this.getServer(), tag.getString("Master")));

if (uuid != null) {
try {
this.setMasterUuid(uuid);
this.state = State.values()[tag.getByte("FidelityState")];
} catch (Throwable e) {
this.state = State.ROAMING_FREE;
}
}
final String uuidStr = tag.contains("MasterUUID", 8) ?
tag.getString("MasterUUID") :
ServerConfigHandler.getPlayerUuidByName(this.getServer(), tag.getString("Master"));

if (!uuidStr.isEmpty())
this.setMasterUuid(UUID.fromString(uuidStr));

this.state = tag.contains("FidelityState") ? State.values()[tag.getByte("FidelityState")] : State.ROAMING_FREE;
}

@Inject(at = @At("HEAD"), method = "putPlayerOnBack(Lnet/minecraft/entity/player/PlayerEntity;)V", cancellable = true)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.15.x"
"minecraft": "1.14.x"
},
"suggests": {
"flamingo": "*"
Expand Down

0 comments on commit 50b91d3

Please sign in to comment.