Don't Drop Chest In Creative
Twine/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-06-15 11:22:30 -04:00
parent 8695aface5
commit 0ec13d83fd
1 changed files with 6 additions and 4 deletions

View File

@ -110,21 +110,23 @@ public class MixinBoatEntity implements BoatUtil {
}
@Unique
private void dropItemsOnDestroy() {
private void dropItemsOnDestroy(boolean isCreative) {
if (((BoatEntity) (Object) this).getEntityWorld().getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
((BoatEntity) (Object) this).dropStack(new ItemStack(getChestItem()));
if (!isCreative) {
((BoatEntity) (Object) this).dropStack(new ItemStack(getChestItem()));
}
dropItems();
}
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/BoatEntity;remove()V"), method = "damage")
public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) {
dropItemsOnDestroy();
dropItemsOnDestroy(source.getAttacker() instanceof PlayerEntity && ((PlayerEntity) source.getAttacker()).isCreative());
}
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/BoatEntity;remove()V"), method = "fall")
public void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition, CallbackInfo info) {
dropItemsOnDestroy();
dropItemsOnDestroy(false);
}
@Unique