Added size-based stacking rule/config and fail sound into 1.11

This commit is contained in:
Purplicious_Cow 2018-04-04 08:14:52 +02:00
parent 1231bb02ac
commit 5bd299a9d1
2 changed files with 46 additions and 25 deletions

View File

@ -71,7 +71,7 @@ public class Configs {
@Comment("Maximum stack limit for entities") @Comment("Maximum stack limit for entities")
public int maxEntityStackLimit = 20; public int maxEntityStackLimit = 20;
@Comment("Whether entities size matters when stacking or not") @Comment("Whether entities' size matters when stacking or not")
public boolean entitySizeMattersStacking = true; public boolean entitySizeMattersStacking = true;
} }

View File

@ -10,6 +10,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
@ -138,8 +139,12 @@ public class ItemEntityEvents
if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && !entityHeld.isDead && !entity.isDead) { if (!world.isRemote && entityHeld.getUniqueID() != entity.getUniqueID() && !entityHeld.isDead && !entity.isDead) {
double sizeEntity = entity.height * entity.width;
double sizeHeldEntity = entityHeld.height * entityHeld.width;
//if no riders //if no riders
if (!entity.isBeingRidden()) { if (!entity.isBeingRidden()) {
//if entity size matters in stacking
if ((CarryOnConfig.settings.entitySizeMattersStacking && sizeHeldEntity <= sizeEntity) || !CarryOnConfig.settings.entitySizeMattersStacking) {
//Tame Horse so it doens't buck rider //Tame Horse so it doens't buck rider
if (entity instanceof EntityHorse) { if (entity instanceof EntityHorse) {
EntityHorse horse = (EntityHorse) entity; EntityHorse horse = (EntityHorse) entity;
@ -160,6 +165,10 @@ public class ItemEntityEvents
world.spawnEntity(entityHeld); world.spawnEntity(entityHeld);
entityHeld.startRiding(entity, false); entityHeld.startRiding(entity, false);
} }
} else {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
world.spawnEntity(entityHeld);
}
//if multiple riders, loop through and add next to top (elevator style) //if multiple riders, loop through and add next to top (elevator style)
} else { } else {
@ -187,16 +196,28 @@ public class ItemEntityEvents
entity.setPosition(tempX, tempY + 2.6, tempZ); entity.setPosition(tempX, tempY + 2.6, tempZ);
world.spawnEntity(entityHeld); world.spawnEntity(entityHeld);
if (entityTry != null) { if (entityTry != null) {
//if entity size matters in stacking
if ((CarryOnConfig.settings.entitySizeMattersStacking && sizeHeldEntity <= sizeEntity) || !CarryOnConfig.settings.entitySizeMattersStacking) {
entityHeld.startRiding(entityTry, false); entityHeld.startRiding(entityTry, false);
entityHeld.setPositionAndUpdate(tempX, tempY, tempZ); entityHeld.setPositionAndUpdate(tempX, tempY, tempZ);
} else {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
}
} }
} else { } else {
world.spawnEntity(entityHeld); world.spawnEntity(entityHeld);
if ((CarryOnConfig.settings.entitySizeMattersStacking && sizeHeldEntity <= sizeEntity) || !CarryOnConfig.settings.entitySizeMattersStacking) {
entityHeld.startRiding(entityTry, false); entityHeld.startRiding(entityTry, false);
} else {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_NOTE_BASS, SoundCategory.PLAYERS, 0.5F, 1.5F);
}
} }
} }
if ((CarryOnConfig.settings.entitySizeMattersStacking && sizeHeldEntity <= sizeEntity) || !CarryOnConfig.settings.entitySizeMattersStacking) {
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F); world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_HORSE_SADDLE, SoundCategory.PLAYERS, 0.5F, 1.5F);
}
ItemEntity.clearEntityData(main); ItemEntity.clearEntityData(main);
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256)); CarryOn.network.sendToAllAround(new CarrySlotPacket(9, player.getEntityId()), new TargetPoint(world.provider.getDimension(), player.posX, player.posY, player.posZ, 256));