Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
LXGaming committed Sep 22, 2019
1 parent c7dbf53 commit b4025f8
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {
provided("mrtjp:ProjectRed:1.12.2-4.9.1.92:mechanical") {
exclude(module: "jei_1.12.2")
}
provided("no-tree-punching:notreepunching:2.0.13")
provided("p455w0rds-library:p455w0rdslib:1.12.2:2.2.151")
provided("primalcore:PrimalCore:1.12.2:0.6.51")
provided("primitive-mobs:primitivemobs:1.2.3a")
Expand Down Expand Up @@ -160,6 +161,7 @@ jar {
+ "mixins.sledgehammer.immersiveengineering.json,"
+ "mixins.sledgehammer.matteroverdrive.json,"
+ "mixins.sledgehammer.morph.json,"
+ "mixins.sledgehammer.notreepunching.json,"
+ "mixins.sledgehammer.p455w0rdslib.json,"
+ "mixins.sledgehammer.platform.json,"
+ "mixins.sledgehammer.primitivemobs.json,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.github.lxgaming.sledgehammer.configuration.category.mixin.ImmersiveEngineeringMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.MatterOverdriveMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.MorphMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.NoTreePunchingMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.P455w0rdsLibMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.PrimitiveMobsMixinCategory;
import io.github.lxgaming.sledgehammer.configuration.category.mixin.ProjectRedMixinCategory;
Expand Down Expand Up @@ -63,6 +64,9 @@ public class MixinCategory {
@Setting(value = "morph", comment = "Morph")
private MorphMixinCategory morphMixinCategory = new MorphMixinCategory();

@Setting(value = "no-tree-punching", comment = "No Tree Punching")
private NoTreePunchingMixinCategory noTreePunchingMixinCategory = new NoTreePunchingMixinCategory();

@Setting(value = "p455w0rdslib", comment = "p455w0rd's Library")
private P455w0rdsLibMixinCategory p455w0rdsLibMixinCategory = new P455w0rdsLibMixinCategory();

Expand Down Expand Up @@ -130,6 +134,10 @@ public MorphMixinCategory getMorphMixinCategory() {
return morphMixinCategory;
}

public NoTreePunchingMixinCategory getNoTreePunchingMixinCategory() {
return noTreePunchingMixinCategory;
}

public P455w0rdsLibMixinCategory getP455w0rdsLibMixinCategory() {
return p455w0rdsLibMixinCategory;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2019 Alex Thomson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.lxgaming.sledgehammer.configuration.category.mixin;

import io.github.lxgaming.sledgehammer.configuration.annotation.Mapping;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

@ConfigSerializable
public class NoTreePunchingMixinCategory {

@Mapping(value = "notreepunching.ModEventHandlerMixin", dependencies = {"notreepunching"})
@Setting(value = "harvest-block", comment = "If 'true', fixes NullPointerException in ModEventHandler::harvestBlock")
private boolean harvestBlock = false;

public boolean isHarvestBlock() {
return harvestBlock;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2019 Alex Thomson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.lxgaming.sledgehammer.mixin.notreepunching;

import com.alcatrazescapee.notreepunching.ModEventHandler;
import com.alcatrazescapee.notreepunching.common.capability.IPlayerItem;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = ModEventHandler.class, priority = 1337, remap = false)
public abstract class ModEventHandlerMixin {

/**
* no-tree-punching doesn't check if the ItemStack contained in the Capability is null.
*/
@Redirect(method = "harvestBlock",
at = @At(value = "INVOKE",
target = "Lcom/alcatrazescapee/notreepunching/common/capability/IPlayerItem;getStack()Lnet/minecraft/item/ItemStack;"
)
)
private static ItemStack onGetStack(IPlayerItem playerItem) {
ItemStack itemStack = playerItem.getStack();
if (itemStack != null) {
return itemStack;
}

return ItemStack.EMPTY;
}
}
15 changes: 15 additions & 0 deletions src/main/resources/mixins.sledgehammer.notreepunching.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": false,
"minVersion": "0.7.10",
"package": "io.github.lxgaming.sledgehammer.mixin.notreepunching",
"refmap": "mixins.sledgehammer.refmap.json",
"plugin": "io.github.lxgaming.sledgehammer.mixin.plugin.CorePlugin",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ModEventHandlerMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit b4025f8

Please sign in to comment.