-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d157e9
commit 2230dcb
Showing
11 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
src/main/java/net/dakotapride/garnished/entity/GarnishedBoatTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.dakotapride.garnished.entity; | ||
|
||
import net.minecraft.world.entity.vehicle.Boat; | ||
|
||
public class GarnishedBoatTypes { | ||
static { | ||
Boat.Type.values(); | ||
} | ||
|
||
public static Boat.Type NUT; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/net/dakotapride/garnished/item/wood/NutBoatItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package net.dakotapride.garnished.item.wood; | ||
|
||
import net.dakotapride.garnished.entity.GarnishedBoatTypes; | ||
import net.minecraft.world.entity.vehicle.Boat; | ||
import net.minecraft.world.item.BoatItem; | ||
|
||
public class NutBoatItem extends BoatItem { | ||
public NutBoatItem(Properties properties) { | ||
super(false, GarnishedBoatTypes.NUT, properties); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/net/dakotapride/garnished/item/wood/NutChestBoatItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package net.dakotapride.garnished.item.wood; | ||
|
||
import net.dakotapride.garnished.entity.GarnishedBoatTypes; | ||
import net.minecraft.world.item.BoatItem; | ||
|
||
public class NutChestBoatItem extends BoatItem { | ||
public NutChestBoatItem(Properties properties) { | ||
super(true, GarnishedBoatTypes.NUT, properties); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/net/dakotapride/garnished/mixin/BoatMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.dakotapride.garnished.mixin; | ||
|
||
import net.dakotapride.garnished.entity.GarnishedBoatTypes; | ||
import net.dakotapride.garnished.registry.GarnishedItems; | ||
import net.minecraft.world.entity.vehicle.Boat; | ||
|
||
import net.minecraft.world.item.Item; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(Boat.class) | ||
public class BoatMixin { | ||
|
||
//CREDIT TO nyuppo/fabric-boat-example ON GITHUB | ||
|
||
@Inject(method = "getDropItem", at = @At("RETURN"), cancellable = true) | ||
public void wilderWild$getModdedBoats(CallbackInfoReturnable<Item> info) { | ||
var boat = Boat.class.cast(this); | ||
if (boat.getVariant() == GarnishedBoatTypes.NUT) { | ||
info.setReturnValue(GarnishedItems.NUT_BOAT.get()); | ||
} | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/net/dakotapride/garnished/mixin/BoatTypeMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package net.dakotapride.garnished.mixin; | ||
|
||
import net.dakotapride.garnished.entity.GarnishedBoatTypes; | ||
import net.dakotapride.garnished.registry.GarnishedBlocks; | ||
import net.minecraft.world.entity.vehicle.Boat; | ||
|
||
import net.minecraft.world.level.block.Block; | ||
|
||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
@Mixin(Boat.Type.class) | ||
public class BoatTypeMixin { | ||
|
||
//CREDIT TO nyuppo/fabric-boat-example ON GITHUB | ||
|
||
@SuppressWarnings("ShadowTarget") | ||
@Final | ||
@Shadow | ||
@Mutable | ||
private static Boat.Type[] $VALUES; | ||
|
||
@SuppressWarnings("InvokerTarget") | ||
@Invoker("<init>") | ||
private static Boat.Type newType(String internalName, int internalId, Block baseBlock, String name) { | ||
throw new AssertionError(); | ||
} | ||
|
||
@Inject(method = "<clinit>", at = @At(value = "FIELD", | ||
opcode = Opcodes.PUTSTATIC, | ||
target = "Lnet/minecraft/world/entity/vehicle/Boat$Type;$VALUES:[Lnet/minecraft/world/entity/vehicle/Boat$Type;", | ||
shift = At.Shift.AFTER)) | ||
private static void wilderWild$addCustomBoatType(CallbackInfo info) { | ||
var types = new ArrayList<>(Arrays.asList($VALUES)); | ||
var last = types.get(types.size() - 1); | ||
|
||
var nut = newType("NUT", last.ordinal() + 1, GarnishedBlocks.NUT_PLANKS.get(), "nut"); | ||
GarnishedBoatTypes.NUT = nut; | ||
types.add(nut); | ||
|
||
$VALUES = types.toArray(new Boat.Type[0]); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/net/dakotapride/garnished/mixin/ChestBoatMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package net.dakotapride.garnished.mixin; | ||
|
||
import net.dakotapride.garnished.entity.GarnishedBoatTypes; | ||
import net.dakotapride.garnished.registry.GarnishedItems; | ||
import net.minecraft.world.entity.vehicle.Boat; | ||
import net.minecraft.world.entity.vehicle.ChestBoat; | ||
import net.minecraft.world.item.Item; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(ChestBoat.class) | ||
public class ChestBoatMixin { | ||
|
||
//CREDIT TO nyuppo/fabric-boat-example ON GITHUB | ||
|
||
@Inject(method = "getDropItem", at = @At("RETURN"), cancellable = true) | ||
public void wilderWild$getModdedBoats(CallbackInfoReturnable<Item> info) { | ||
var boat = Boat.class.cast(this); | ||
if (boat.getVariant() == GarnishedBoatTypes.NUT) { | ||
info.setReturnValue(GarnishedItems.NUT_CHEST_BOAT.get()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.33 KB
src/main/resources/assets/minecraft/textures/entity/chest_boat/nut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters