Skip to content

Commit

Permalink
+boats -chests and surtrum tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Apr 26, 2024
1 parent 41f4eab commit ded800c
Show file tree
Hide file tree
Showing 49 changed files with 175 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ sapling, add(flowerPotId, new FlowerPotBlock(sapling, flowerPotSettings)),
add(leavesId, new LeavesBlock(leavesSettings), flammableLeaves, cutoutMippedRenderLayer),
planks, add(plankStairsId, new ParadiseLostStairsBlock(planks.getDefaultState(), plankSettings), flammablePlanks), add(plankSlabId, new SlabBlock(plankSettings), flammablePlanks),
add(fenceId, new FenceBlock(plankSettings), flammablePlanks), add(fenceGateId, new FenceGateBlock(plankSettings), flammablePlanks),
add(doorId, new DoorBlock(doorSettings)), add(trapdoorId, new TrapdoorBlock(trapdoorSettings)),
add(doorId, new DoorBlock(doorSettings), cutoutMippedRenderLayer), add(trapdoorId, new TrapdoorBlock(trapdoorSettings), cutoutMippedRenderLayer),
add(buttonId, new WoodenButtonBlock(buttonSettings)), add(pressurePlateId, new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, pressurePlateSettings))
);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ private static WoodBlockSet registerWoodBlockSet(
leaves,
planks, add(plankStairsId, new ParadiseLostStairsBlock(planks.getDefaultState(), plankSettings), flammablePlanks), add(plankSlabId, new SlabBlock(plankSettings), flammablePlanks),
add(fenceId, new FenceBlock(plankSettings), flammablePlanks), add(fenceGateId, new FenceGateBlock(plankSettings), flammablePlanks),
add(doorId, new DoorBlock(doorSettings)), add(trapdoorId, new TrapdoorBlock(trapdoorSettings)),
add(doorId, new DoorBlock(doorSettings), cutoutMippedRenderLayer), add(trapdoorId, new TrapdoorBlock(trapdoorSettings), cutoutMippedRenderLayer),
add(buttonId, new WoodenButtonBlock(buttonSettings)), add(pressurePlateId, new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, pressurePlateSettings))
);
}
Expand Down Expand Up @@ -216,7 +216,7 @@ sapling, add(flowerPotId, new FlowerPotBlock(sapling, flowerPotSettings)),
leaves,
planks, add(plankStairsId, new ParadiseLostStairsBlock(planks.getDefaultState(), plankSettings), flammablePlanks), add(plankSlabId, new SlabBlock(plankSettings), flammablePlanks),
add(fenceId, new FenceBlock(plankSettings), flammablePlanks), add(fenceGateId, new FenceGateBlock(plankSettings), flammablePlanks),
add(doorId, new DoorBlock(doorSettings)), add(trapdoorId, new TrapdoorBlock(trapdoorSettings)),
add(doorId, new DoorBlock(doorSettings), cutoutMippedRenderLayer), add(trapdoorId, new TrapdoorBlock(trapdoorSettings), cutoutMippedRenderLayer),
add(buttonId, new WoodenButtonBlock(buttonSettings)), add(pressurePlateId, new PressurePlateBlock(PressurePlateBlock.ActivationRule.EVERYTHING, pressurePlateSettings))
);
}
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,6 @@ private static Settings cherineTorch() {
//dungeon
// public static final DungeonSwitchBlock DUNGEON_SWITCH = add("dungeonswitch", new DungeonSwitchBlock(of(Material.METAL, MapColor.BLUE).strength(-1.0F, 3600000.0F)));

// Chests
// public static final ChestBlock CRYSTAL_CHEST = add("crystal_chest", CRYSTAL_CHEST_FACTORY.chest);
// public static final ChestBlock MOTHER_AUREL_CHEST = add("golden_oak_chest", MOTHER_AUREL_CHEST_FACTORY.chest);
// public static final ChestBlock ORANGE_CHEST = ORANGE.chestFactory().chest;
// public static final ChestBlock AUREL_CHEST = add("skyroot_chest", AUREL_CHEST_FACTORY.chest);
// public static final ChestBlock WISTERIA_CHEST = WISTERIA.chestFactory().chest;

public static void init() {
ParadiseLostRegistryQueues.BLOCK.register();
}
Expand All @@ -342,9 +335,6 @@ TexturedRenderLayers.SIGNS_ATLAS_TEXTURE, new Identifier("entity/signs/" + signS
)
);
}
// AUREL_CHEST_FACTORY.registerChestRenderers();
// MOTHER_AUREL_CHEST_FACTORY.registerChestRenderers();
// CRYSTAL_CHEST_FACTORY.registerChestRenderers();
}


Expand Down
46 changes: 38 additions & 8 deletions src/main/java/net/id/paradiselost/items/ParadiseLostItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,29 @@
import net.id.paradiselost.items.tools.bloodstone.OlviteBloodstoneItem;
import net.id.paradiselost.registry.ParadiseLostRegistryQueues;
import net.id.incubus_core.util.RegistryQueue.Action;
import net.id.paradiselost.util.EnumExtender;
import net.minecraft.block.Block;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.SignBlock;
import net.minecraft.block.TallFlowerBlock;
import net.minecraft.block.TallPlantBlock;
import net.minecraft.block.WallSignBlock;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.*;
import net.minecraft.item.Item.Settings;
import net.minecraft.sound.SoundEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Rarity;
import net.minecraft.util.SignType;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Iterator;
import java.util.Locale;

import static net.id.paradiselost.ParadiseLost.MOD_ID;
import static net.id.paradiselost.ParadiseLost.locate;
import static net.id.paradiselost.items.ParadiseLostItemActions.*;
import static net.minecraft.entity.EquipmentSlot.*;
Expand Down Expand Up @@ -309,7 +320,6 @@ private static FabricItemSettings decoration() {

private static final FabricItemSettings decoration = decoration();
private static final FabricItemSettings sign = decoration().maxCount(16);
private static final FabricItemSettings boat = decoration().maxCount(1);
private static final FabricItemSettings hat = decoration().equipmentSlot(stack -> HEAD);

// saplings
Expand Down Expand Up @@ -434,12 +444,12 @@ private static FabricItemSettings decoration() {
//TODO: Implement dungeon switch block
// public static final BlockItem DUNGEON_SWITCH = add("dungeonswitch", ParadiseLostBlocks.DUNGEON_SWITCH, decoration);

// Chests
// public static final BlockItem AUREL_CHEST = add("skyroot_chest", ParadiseLostBlocks.AUREL_CHEST, new FabricItemSettings().group(ParadiseLostItemGroups.PARADISE_LOST_DECORATIONS));
// public static final BlockItem MOTHER_AUREL_CHEST = add("golden_oak_chest", ParadiseLostBlocks.MOTHER_AUREL_CHEST, new FabricItemSettings().group(ParadiseLostItemGroups.PARADISE_LOST_DECORATIONS));
// public static final BlockItem ORANGE_CHEST = add("orange_chest", ParadiseLostBlocks.ORANGE_CHEST, new FabricItemSettings().group(ParadiseLostItemGroups.PARADISE_LOST_DECORATIONS));
// public static final BlockItem CRYSTAL_CHEST = add("crystal_chest", ParadiseLostBlocks.CRYSTAL_CHEST, new FabricItemSettings().group(ParadiseLostItemGroups.PARADISE_LOST_DECORATIONS));
// public static final BlockItem WISTERIA_CHEST = add("wisteria_chest", ParadiseLostBlocks.WISTERIA_CHEST, new FabricItemSettings().group(ParadiseLostItemGroups.PARADISE_LOST_DECORATIONS));
public static final BoatSet AUREL_BOATS = addBoatItems("aurel", ParadiseLostBlocks.AUREL_WOODSTUFF.plank());
public static final BoatSet MOTHER_AUREL_BOATS = addBoatItems("mother_aurel", ParadiseLostBlocks.MOTHER_AUREL_WOODSTUFF.plank());
public static final BoatSet ORANGE_BOATS = addBoatItems("orange", ParadiseLostBlocks.ORANGE_WOODSTUFF.plank());
public static final BoatSet WISTERIA_BOATS = addBoatItems("wisteria", ParadiseLostBlocks.WISTERIA_WOODSTUFF.plank());

public static final BoatSet[] BOAT_SETS = new BoatSet[] {AUREL_BOATS, MOTHER_AUREL_BOATS, ORANGE_BOATS, WISTERIA_BOATS};

public static void init() {
ParadiseLostRegistryQueues.ITEM.register();
Expand All @@ -457,13 +467,23 @@ private static BlockItem add(String id, Block block, Settings settings, Action<?
return add(id,
(block instanceof DoorBlock
|| block instanceof TallPlantBlock
|| block instanceof TallFlowerBlock
)
? new TallBlockItem(block, settings)
: new BlockItem(block, settings),
additionalActions);
}

private static BoatSet addBoatItems(String woodId, Block plankBlock) {
String boatId = (MOD_ID + "_" + woodId);

BoatEntity.Type boatType = EnumExtender.add(BoatEntity.Type.class, boatId.toUpperCase(Locale.ROOT), plankBlock, boatId);

BoatItem boat = add(woodId + "_boat", new BoatItem(false, boatType, decoration().maxCount(1)));
BoatItem chestBoat = add(woodId + "_chest_boat", new BoatItem(true, boatType, decoration().maxCount(1)));

return new BoatSet(boatType, boat, chestBoat);
}

// For access to protected constructors:

private static class ParadiseLostPickaxeItem extends PickaxeItem {
Expand All @@ -490,4 +510,14 @@ protected ParadiseLostMusicDiscItem(int comparatorValueIn, SoundEvent soundIn, S
super(comparatorValueIn, soundIn, settings, 0);
}
}

public record BoatSet(
BoatEntity.Type type,
BoatItem boat,
BoatItem chestBoat
) implements Iterable<Item> {
public @NotNull Iterator<Item> iterator() {
return Arrays.stream(new Item[]{boat, chestBoat}).iterator();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
public class ParadiseLostArmorMaterials {

public static final ArmorMaterial OLVITE = ArmorMaterialsAccessor.callInit("PARADISE_LOST_OLVITE", -1,
"paradise_lost_olvite", 15, new int[]{2, 5, 6, 2}, 9, ParadiseLostSoundEvents.ITEM_ARMOR_EQUIP_OLVITE,
"paradise_lost_olvite", 15, new int[]{2, 4, 6, 2}, 9, ParadiseLostSoundEvents.ITEM_ARMOR_EQUIP_OLVITE,
0f, 0f, IngredientUtil.itemIngredient(ParadiseLostItems.OLVITE));
public static final ArmorMaterial GLAZED_GOLD = ArmorMaterialsAccessor.callInit("PARADISE_LOST_GLAZED_GOLD", -1,
"paradise_lost_glazed_gold", 14, new int[]{1, 3, 5, 2}, 25, ParadiseLostSoundEvents.ITEM_ARMOR_EQUIP_GLAZED_GOLD,
0f, 0f, IngredientUtil.itemIngredient(ParadiseLostItems.GOLDEN_AMBER));
public static final ArmorMaterial SURTRUM = ArmorMaterialsAccessor.callInit("PARADISE_LOST_SURTRUM", -1,
"paradise_lost_surtrum", 15, new int[]{3, 6, 8, 3}, 15, ParadiseLostSoundEvents.ITEM_ARMOR_EQUIP_SURTRUM,
"paradise_lost_surtrum", 15, new int[]{2, 5, 6, 3}, 15, ParadiseLostSoundEvents.ITEM_ARMOR_EQUIP_SURTRUM,
0f, 0.1f, IngredientUtil.itemIngredient(ParadiseLostItems.REFINED_SURTRUM));


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.id.paradiselost.mixin.entity;

import net.id.paradiselost.items.ParadiseLostItems;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.item.Item;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BoatEntity.class)
public abstract class BoatEntityMixin {
@Shadow
public abstract BoatEntity.Type getBoatType();

@Inject(method = "asItem", at = @At(value = "FIELD", target = "Lnet/minecraft/item/Items;OAK_BOAT:Lnet/minecraft/item/Item;", opcode = Opcodes.GETSTATIC), cancellable = true)
private void checkCustomBoats(CallbackInfoReturnable<Item> cir) {
BoatEntity.Type type = this.getBoatType();
if (type != BoatEntity.Type.OAK) {
for (var entry : ParadiseLostItems.BOAT_SETS){
if (type == entry.type()){
cir.setReturnValue(entry.boat());
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.id.paradiselost.mixin.entity;

import net.id.paradiselost.util.EnumExtender;
import net.minecraft.block.Block;
import net.minecraft.entity.vehicle.BoatEntity;
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 java.util.Arrays;

@Mixin(BoatEntity.Type.class)
public class BoatEntityTypeMixin {
@SuppressWarnings("ShadowTarget")
@Shadow
@Mutable
@Final
private static BoatEntity.Type[] field_7724;

static {
EnumExtender.register(BoatEntity.Type.class, (name, args) -> {
BoatEntity.Type entry = (BoatEntity.Type) (Object) new BoatEntityTypeMixin(name, field_7724.length, (Block) args[0], (String) args[1]);
field_7724 = Arrays.copyOf(field_7724, field_7724.length + 1);
return field_7724[field_7724.length - 1] = entry;
});
}

private BoatEntityTypeMixin(String valueName, int ordinal, Block baseBlock, String name) {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.id.paradiselost.mixin.entity;

import net.id.paradiselost.items.ParadiseLostItems;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.ChestBoatEntity;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(ChestBoatEntity.class)
public class ChestBoatEntityMixin extends BoatEntity {

public ChestBoatEntityMixin(EntityType<? extends BoatEntity> entityType, World world) {
super(entityType, world);
}

@Inject(method = "asItem", at = @At(value = "FIELD", target = "Lnet/minecraft/item/Items;OAK_CHEST_BOAT:Lnet/minecraft/item/Item;", opcode = Opcodes.GETSTATIC), cancellable = true)
private void checkCustomBoats(CallbackInfoReturnable<Item> cir) {
BoatEntity.Type type = this.getBoatType();
if (type != BoatEntity.Type.OAK) {
for (var entry : ParadiseLostItems.BOAT_SETS){
if (type == entry.type()){
cir.setReturnValue(entry.chestBoat());
}
}
}
}
}
26 changes: 26 additions & 0 deletions src/main/java/net/id/paradiselost/util/EnumExtender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.id.paradiselost.util;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;

public class EnumExtender {
private static final Map<Class<? extends Enum<?>>, BiFunction<String, Object[], ? extends Enum<?>>> extensibles = new HashMap<>();

public static <T extends Enum<T>> void register(Class<T> extensible, BiFunction<String, Object[], T> callback) {
extensibles.put(extensible, callback);
}

@SuppressWarnings("unchecked")
public static <T extends Enum<T>> T add(Class<T> to, String name, Object... arguments) {
if (extensibles.containsKey(to)) {
try {
return (T) extensibles.get(to).apply(name, arguments);
} catch (ClassCastException | IndexOutOfBoundsException e) {
throw new IllegalArgumentException("Invalid arguments for entry " + name + " of enum " + to + ". Arguments must match the enum constructor.");
}
} else {
throw new UnsupportedOperationException("Attempted to extend inextensible enum " + to + ". Create a mixin for it from the template in EnumExtender.");
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 0 additions & 6 deletions src/main/resources/data/c/tags/blocks/chests.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/resources/data/paradise_lost/recipes/aurel_chest.json

This file was deleted.

Loading

0 comments on commit ded800c

Please sign in to comment.