Skip to content

Commit

Permalink
Prefix custom mixin methods to prevent conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
LXGaming committed Jan 30, 2019
1 parent 063af34 commit 973d260
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ public abstract class MixinEntity_Teleport {

@Inject(method = "setPortal", at = @At(value = "HEAD"), cancellable = true)
private void onSetPortal(CallbackInfo callbackInfo) {
if (shouldRemove((IMixinEntity) this)) {
if (sledgehammer$shouldRemove((IMixinEntity) this)) {
callbackInfo.cancel();
}
}

@Inject(method = "changeDimension(I)Lnet/minecraft/entity/Entity;", at = @At(value = "HEAD"))
private void onChangeDimension(int dimension, CallbackInfoReturnable<Entity> callbackInfoReturnable) {
IMixinEntity mixinEntity = (IMixinEntity) this;
if (shouldRemove(mixinEntity)) {
if (sledgehammer$shouldRemove(mixinEntity)) {
mixinEntity.remove();

Sledgehammer.getInstance().getConfig().map(Config::getMessageCategory).map(MessageCategory::getItemTeleport).filter(StringUtils::isNotBlank).ifPresent(message -> {
Expand All @@ -65,7 +65,7 @@ private void onChangeDimension(int dimension, CallbackInfoReturnable<Entity> cal
}
}

private boolean shouldRemove(IMixinEntity mixinEntity) {
private boolean sledgehammer$shouldRemove(IMixinEntity mixinEntity) {
if (!(mixinEntity instanceof Item || mixinEntity instanceof Minecart) || mixinEntity.isRemoved()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public abstract class MixinEntity_Teleport {
@Inject(method = "changeDimension(ILnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;", at = @At(value = "HEAD"), remap = false)
private void onChangeDimension(int dimension, ITeleporter teleporter, CallbackInfoReturnable<Entity> callbackInfoReturnable) {
IMixinEntity mixinEntity = (IMixinEntity) this;
if (shouldRemove(mixinEntity)) {
if (sledgehammer$shouldRemove(mixinEntity)) {
mixinEntity.remove();

Sledgehammer.getInstance().getConfig().map(Config::getMessageCategory).map(MessageCategory::getItemTeleport).filter(StringUtils::isNotBlank).ifPresent(message -> {
Expand All @@ -58,7 +58,7 @@ private void onChangeDimension(int dimension, ITeleporter teleporter, CallbackIn
}
}

private boolean shouldRemove(IMixinEntity mixinEntity) {
private boolean sledgehammer$shouldRemove(IMixinEntity mixinEntity) {
if (!(mixinEntity instanceof Item || mixinEntity instanceof Minecart) || mixinEntity.isRemoved()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ public MixinEntityVillager(World worldIn, int careerId) {
@Inject(method = "populateBuyingList", at = @At(value = "RETURN"), cancellable = true)
private void onPopulateBuyingListReturn(CallbackInfo callbackInfo) {
if (Sponge.getPluginManager().isLoaded("primitivemobs") && StringUtils.equals(((Entity) this).getType().getId(), "primitivemobs:travelingmerchant")) {
populateTravelingMerchant();
sledgehammer$populateTravelingMerchant();
}
}

@Inject(method = "processInteract", at = @At(value = "HEAD"), cancellable = true)
private void onProcessInteract(EntityPlayer player, EnumHand hand, CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
if (Sponge.getPluginManager().isLoaded("primitivemobs") && StringUtils.equals(((Entity) this).getType().getId(), "primitivemobs:travelingmerchant")) {
populateTravelingMerchant();
sledgehammer$populateTravelingMerchant();
}
}

@SuppressWarnings("deprecation")
private void populateTravelingMerchant() {
private void sledgehammer$populateTravelingMerchant() {
if (this.buyingList != null && !this.buyingList.isEmpty()) {
return;
}
Expand Down

0 comments on commit 973d260

Please sign in to comment.