Don't Drop Chest In Creative
All checks were successful
Twine/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-06-15 11:22:30 -04:00
parent 8695aface5
commit 0ec13d83fd

View File

@ -110,21 +110,23 @@ public class MixinBoatEntity implements BoatUtil {
} }
@Unique @Unique
private void dropItemsOnDestroy() { private void dropItemsOnDestroy(boolean isCreative) {
if (((BoatEntity) (Object) this).getEntityWorld().getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { 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(); dropItems();
} }
} }
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/vehicle/BoatEntity;remove()V"), method = "damage") @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) { 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") @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) { public void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition, CallbackInfo info) {
dropItemsOnDestroy(); dropItemsOnDestroy(false);
} }
@Unique @Unique