Skip to content

Commit

Permalink
Nasty fix to the jockeys clipping in walls (every ride tick)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cam authored Jan 16, 2022
1 parent 986fbd5 commit d236d97
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
17 changes: 14 additions & 3 deletions src/main/java/jockeyCreator/mixin/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static net.minecraft.entity.EntityType.*;


@Mixin(Entity.class)
public abstract class EntityMixin {
@Inject(method = "removePassenger(Lnet/minecraft/entity/Entity;)V", at = @At("HEAD"))
private void stopJockeySuffocating(Entity ridingEntity, CallbackInfo ci){
private void makeZombiesClipAgain(Entity ridingEntity, CallbackInfo ci){
Entity rideEntity = (Entity)(Object)this;
if(ridingEntity != null && rideEntity.getType() == EntityType.CHICKEN && ( ridingEntity.getType() == EntityType.ZOMBIE || ridingEntity.getType() == EntityType.ZOMBIE_VILLAGER || ridingEntity.getType() == EntityType.ZOMBIFIED_PIGLIN) ){
ridingEntity.noClip = false;
EntityType ridingEntityType = ridingEntity.getType();
if ((ridingEntityType == ZOMBIE) || (ridingEntityType == ZOMBIE_VILLAGER) || (ridingEntityType == ZOMBIFIED_PIGLIN))
if ((ridingEntity != null) && (rideEntity.getType() == CHICKEN)) ridingEntity.noClip = false;
}

@Inject(method= "tickRiding()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;updatePassengerPosition(Lnet/minecraft/entity/Entity;)V", shift = At.Shift.AFTER))
private void makeJockeysNoClipOnRiding(CallbackInfo ci){
Entity zzz = (Entity)(Object)this;
if((zzz.getVehicle().getType() == CHICKEN) && ! zzz.noClip && ((zzz.getType() == ZOMBIE) || (zzz.getType() == ZOMBIE_VILLAGER) || (zzz.getType() == ZOMBIFIED_PIGLIN))){
zzz.noClip = true;
zzz.getVehicle().setSprinting(true);
}
}
}
31 changes: 20 additions & 11 deletions src/main/java/jockeyCreator/mixin/ZombieEntityMixin.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
package jockeyCreator.mixin;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.entity.passive.ChickenEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Objects;

import static net.minecraft.entity.EntityType.CHICKEN;
import static net.minecraft.item.Items.EGG;

@Mixin(ZombieEntity.class)
public class ZombieEntityMixin {
@Inject(method= "canPickupItem(Lnet/minecraft/item/ItemStack;)Z", at = @At("HEAD"), cancellable = true)
private void createJokey(ItemStack stack, CallbackInfoReturnable<Boolean> cir){
ZombieEntity zzz = (ZombieEntity)(Object)this;
if(stack.isOf(Items.EGG) && zzz.isBaby() && !zzz.hasVehicle())
if(stack.isOf(EGG) && zzz.isBaby() && !zzz.hasVehicle())
{
stack.decrement(1);
ChickenEntity ccc = EntityType.CHICKEN.create(zzz.getWorld());
ccc.refreshPositionAndAngles(zzz.getX(), zzz.getY(), zzz.getZ(), zzz.getYaw(), 0.0f);
ccc.initialize(zzz.getServer().getWorld(zzz.getEntityWorld().getRegistryKey()), zzz.getEntityWorld().getLocalDifficulty(zzz.getBlockPos()), SpawnReason.JOCKEY, null, null);
ccc.setHasJockey(true);
ccc.setSprinting(true);
zzz.noClip=true;
zzz.startRiding(ccc);
zzz.getWorld().spawnEntity(ccc);
ChickenEntity ccc = CHICKEN.create(zzz.getWorld());
if (ccc != null) {
ccc.refreshPositionAndAngles(zzz.getX(), zzz.getY(), zzz.getZ(), zzz.getYaw(), 0.0f);
ccc.initialize(Objects.requireNonNull(zzz.getServer()).getWorld(zzz.getEntityWorld().getRegistryKey()), zzz.getEntityWorld().getLocalDifficulty(zzz.getBlockPos()), SpawnReason.JOCKEY, null, null);
ccc.setHasJockey(true);
ccc.setSprinting(true);
zzz.noClip=true; //stop zombies from clipping
zzz.startRiding(ccc);
zzz.getWorld().spawnEntity(ccc);
}

cir.setReturnValue(false);
}
}


}

0 comments on commit d236d97

Please sign in to comment.