Skip to content

Commit

Permalink
Merge branch '1.19' into 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ljfa-ag committed Jun 27, 2023
2 parents 6aa26b9 + ff47096 commit f58a7c0
Show file tree
Hide file tree
Showing 26 changed files with 179 additions and 138 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft {
mappings channel: mappings_channel, version: mappings_version

// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

runs {
client {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "totemic:block/cedar_sign"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "totemic:block/cedar_sign"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"textures": {
"particle": "totemic:block/cedar_planks"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "totemic:item/cedar_sign"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"totemic:cedar_sign"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"totemic:cedar_wall_sign"
]
}
5 changes: 5 additions & 0 deletions src/generated/resources/data/minecraft/tags/items/signs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"totemic:cedar_sign"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_planks": {
"conditions": {
"items": [
{
"items": [
"totemic:cedar_planks"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "totemic:cedar_sign"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_planks",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"totemic:cedar_sign"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "totemic:cedar_sign"
}
],
"rolls": 1.0
}
]
}
21 changes: 21 additions & 0 deletions src/generated/resources/data/totemic/recipes/cedar_sign.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:crafting_shaped",
"group": "totemic:wooden_sign",
"key": {
"#": {
"item": "totemic:cedar_planks"
},
"X": {
"item": "minecraft:stick"
}
},
"pattern": [
"###",
"###",
" X "
],
"result": {
"count": 3,
"item": "totemic:cedar_sign"
}
}
4 changes: 3 additions & 1 deletion src/main/java/pokefenn/totemic/Totemic.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.gui.ForgeIngameGui;
Expand Down Expand Up @@ -90,6 +91,7 @@ public Totemic() {
private void commonSetup(FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
ModBlocks.setFireInfo();
ModBlocks.addCedarSignToSignBlockEntityType();
ModCriteriaTriggers.init();
});

Expand All @@ -107,7 +109,7 @@ private void clientSetup(FMLClientSetupEvent event) {
event.enqueueWork(() -> {
ModItems.baykok_bow.get().registerItemProperties();
ModItems.medicine_bag.get().registerItemProperties();
//Sheets.addWoodType(ModBlocks.CEDAR_WOOD_TYPE);
Sheets.addWoodType(ModBlocks.CEDAR_WOOD_TYPE);
});

IEventBus eventBus = MinecraftForge.EVENT_BUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void playMusic(Level level, Vec3 pos, @Nullable Entity entity, MusicInstr

level.getProfiler().push("totemic.playMusic");
MiscUtil.spawnServerParticles(ParticleTypes.NOTE, level, pos, 6, new Vec3(0.5, 0.5, 0.5), 0.0);
//TODO: Implement caching in case this performs too poorly
List<MusicAcceptor> list = BlockUtil.getBlockEntitiesInRange(null, level, new BlockPos(pos), range)
.map(tile -> tile.getCapability(TotemicCapabilities.MUSIC_ACCEPTOR))
.filter(LazyOptional::isPresent)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package pokefenn.totemic.ceremony;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.util.Map;
import java.util.UUID;
import java.util.function.Predicate;

import net.minecraft.Util;
Expand All @@ -15,23 +12,19 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.monster.ZombieVillager;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import pokefenn.totemic.api.TotemicEntityUtil;
import pokefenn.totemic.api.ceremony.CeremonyEffectContext;
import pokefenn.totemic.api.ceremony.CeremonyInstance;
import pokefenn.totemic.util.MethodHandleUtil;
import pokefenn.totemic.util.MiscUtil;

public enum CleansingCeremony implements CeremonyInstance {
INSTANCE;

private static final int RANGE = 8;

private static final MethodHandle startConverting = MethodHandleUtil.findMethod(ZombieVillager.class, "m_34383_", MethodType.methodType(void.class, UUID.class, int.class));

//Map of all conversions done by this ceremony, except ZombieVillager -> Villager, which is handled specially
private static final Map<EntityType<? extends Mob>, EntityType<? extends Mob>> conversions = Map.of(
EntityType.ZOMBIFIED_PIGLIN, EntityType.PIGLIN,
Expand All @@ -49,7 +42,7 @@ public void effect(Level level, BlockPos pos, CeremonyEffectContext context) {
var uuid = context.getInitiatingPlayer().map(Player::getUUID).orElse(null);
for(var zombieVillager : level.getEntities(EntityType.ZOMBIE_VILLAGER, aabb, hasWeakness)) {
//This method ensures the player gets all the beneficial effects for curing Zombie Villagers
startConverting.invokeExact(zombieVillager, uuid, 1);
zombieVillager.startConverting(uuid, 1);
}
}
catch(Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void registerStatesAndModels() {
fenceBlock(ModBlocks.cedar_fence.get(), cedarPlankTex);
fenceGateBlock(ModBlocks.cedar_fence_gate.get(), cedarPlankTex);
pressurePlateBlock(ModBlocks.cedar_pressure_plate.get(), cedarPlankTex);
//signBlock(ModBlocks.cedar_sign.get(), ModBlocks.cedar_wall_sign.get(), cedarPlankTex);
signBlock(ModBlocks.cedar_sign.get(), ModBlocks.cedar_wall_sign.get(), cedarPlankTex);
slabBlock(ModBlocks.cedar_slab.get(), ModBlocks.cedar_planks.getId(), cedarPlankTex, cedarPlankTex, cedarPlankTex);
stairsBlock(ModBlocks.cedar_stairs.get(), cedarPlankTex);
doorBlock(ModBlocks.cedar_door.get(), modLoc("block/cedar_door_bottom"), modLoc("block/cedar_door_top"));
Expand All @@ -76,7 +76,7 @@ protected void registerStatesAndModels() {

//Item Blocks
var im = itemModels();
final Set<ResourceLocation> blocksWithCustomItemModel = Set.of(ModBlocks.cedar_sapling.getId(), ModBlocks.cedar_button.getId(), ModBlocks.cedar_fence.getId(), ModBlocks.cedar_door.getId(), ModBlocks.cedar_trapdoor.getId()/*, ModBlocks.cedar_sign.getId(), ModBlocks.cedar_wall_sign.getId()*/, ModBlocks.potted_cedar_sapling.getId(), ModBlocks.totem_torch.getId(), ModBlocks.tipi.getId(), ModBlocks.dummy_tipi.getId(), ModBlocks.totem_base.getId(), ModBlocks.totem_pole.getId());
final Set<ResourceLocation> blocksWithCustomItemModel = Set.of(ModBlocks.cedar_sapling.getId(), ModBlocks.cedar_button.getId(), ModBlocks.cedar_fence.getId(), ModBlocks.cedar_door.getId(), ModBlocks.cedar_trapdoor.getId(), ModBlocks.cedar_sign.getId(), ModBlocks.cedar_wall_sign.getId(), ModBlocks.potted_cedar_sapling.getId(), ModBlocks.totem_torch.getId(), ModBlocks.tipi.getId(), ModBlocks.dummy_tipi.getId(), ModBlocks.totem_base.getId(), ModBlocks.totem_pole.getId());
for(var blockO: ModBlocks.REGISTER.getEntries()) {
if(blocksWithCustomItemModel.contains(blockO.getId()))
continue;
Expand All @@ -89,7 +89,7 @@ protected void registerStatesAndModels() {
im.withExistingParent(ModBlocks.cedar_fence.getId().toString(), "block/fence_inventory").texture("texture", cedarPlankTex);
im.basicItem(ModBlocks.cedar_door.getId());
im.withExistingParent(ModBlocks.cedar_trapdoor.getId().toString(), modLoc("block/cedar_trapdoor_bottom"));
//im.basicItem(ModBlocks.cedar_sign.getId());
im.basicItem(ModBlocks.cedar_sign.getId());
im.withExistingParent(ModBlocks.totem_torch.getId().toString(), modLoc("block/totem_torch"))
.transforms()
.transform(TransformType.THIRD_PERSON_RIGHT_HAND)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ protected void addTags() {
tag(BlockTags.WOODEN_SLABS).add(ModBlocks.cedar_slab.get());
tag(BlockTags.WOODEN_FENCES).add(ModBlocks.cedar_fence.get());
tag(BlockTags.FENCE_GATES).add(ModBlocks.cedar_fence_gate.get());
tag(BlockTags.STANDING_SIGNS).add(ModBlocks.cedar_sign.get());
tag(BlockTags.WALL_SIGNS).add(ModBlocks.cedar_wall_sign.get());
tag(BlockTags.WOODEN_PRESSURE_PLATES).add(ModBlocks.cedar_pressure_plate.get());
tag(BlockTags.WOODEN_TRAPDOORS).add(ModBlocks.cedar_trapdoor.get());
tag(BlockTags.LOGS_THAT_BURN).addTag(TotemicBlockTags.CEDAR_LOGS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ protected void addTags() {
copy(TotemicBlockTags.CEDAR_LOGS, TotemicItemTags.CEDAR_LOGS);

//Minecraft and Forge tags
tag(ItemTags.SIGNS).add(ModItems.cedar_sign.get());

tag(Tags.Items.LEATHER).add(ModItems.buffalo_hide.get());

copy(BlockTags.PLANKS, ItemTags.PLANKS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void addTables() {
dropSelf(ModBlocks.cedar_fence.get());
dropSelf(ModBlocks.cedar_fence_gate.get());
dropSelf(ModBlocks.cedar_pressure_plate.get());
//dropSelf(ModBlocks.cedar_sign.get());
dropSelf(ModBlocks.cedar_sign.get());
add(ModBlocks.cedar_slab.get(), BlockLoot::createSlabItemTable);
dropSelf(ModBlocks.cedar_stairs.get());
add(ModBlocks.cedar_door.get(), BlockLoot::createDoorTable);
Expand Down
54 changes: 31 additions & 23 deletions src/main/java/pokefenn/totemic/init/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pokefenn.totemic.init;

import java.lang.invoke.MethodType;
import java.util.HashSet;

import net.minecraft.core.Direction.Axis;
import net.minecraft.data.BlockFamily;
Expand All @@ -19,9 +19,14 @@
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.StairBlock;
import net.minecraft.world.level.block.StandingSignBlock;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.WallSignBlock;
import net.minecraft.world.level.block.WoodButtonBlock;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockBehaviour.Properties;
import net.minecraft.world.level.block.state.properties.WoodType;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraftforge.event.RegistryEvent;
Expand All @@ -38,11 +43,10 @@
import pokefenn.totemic.block.music.WindChimeBlock;
import pokefenn.totemic.block.totem.TotemBaseBlock;
import pokefenn.totemic.block.totem.TotemPoleBlock;
import pokefenn.totemic.util.MethodHandleUtil;
import pokefenn.totemic.world.CedarTreeGrower;

public final class ModBlocks {
//public static final WoodType CEDAR_WOOD_TYPE = WoodType.register(WoodType.create("totemic:cedar"));
public static final WoodType CEDAR_WOOD_TYPE = WoodType.register(WoodType.create("totemic:cedar"));

public static final DeferredRegister<Block> REGISTER = DeferredRegister.create(ForgeRegistries.BLOCKS, TotemicAPI.MOD_ID);

Expand All @@ -59,8 +63,8 @@ public final class ModBlocks {
public static final RegistryObject<FenceBlock> cedar_fence = REGISTER.register("cedar_fence", () -> new FenceBlock(Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).strength(2.0F, 3.0F).sound(SoundType.WOOD)));
public static final RegistryObject<FenceGateBlock> cedar_fence_gate = REGISTER.register("cedar_fence_gate", () -> new FenceGateBlock(Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).strength(2.0F, 3.0F).sound(SoundType.WOOD)));
public static final RegistryObject<PressurePlateBlock> cedar_pressure_plate = REGISTER.register("cedar_pressure_plate", () -> new PressurePlateBlock(PressurePlateBlock.Sensitivity.EVERYTHING, Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).noCollission().strength(0.5F).sound(SoundType.WOOD)));
//public static final RegistryObject<StandingSignBlock> cedar_sign = REGISTER.register("cedar_sign", () -> new StandingSignBlock(Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).noCollission().strength(1.0F).sound(SoundType.WOOD), CEDAR_WOOD_TYPE));
//public static final RegistryObject<WallSignBlock> cedar_wall_sign = REGISTER.register("cedar_wall_sign", () -> new WallSignBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).noCollission().strength(1.0F).sound(SoundType.WOOD).lootFrom(cedar_sign), CEDAR_WOOD_TYPE));
public static final RegistryObject<StandingSignBlock> cedar_sign = REGISTER.register("cedar_sign", () -> new StandingSignBlock(Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).noCollission().strength(1.0F).sound(SoundType.WOOD), CEDAR_WOOD_TYPE));
public static final RegistryObject<WallSignBlock> cedar_wall_sign = REGISTER.register("cedar_wall_sign", () -> new WallSignBlock(BlockBehaviour.Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).noCollission().strength(1.0F).sound(SoundType.WOOD).lootFrom(cedar_sign), CEDAR_WOOD_TYPE));
public static final RegistryObject<SlabBlock> cedar_slab = REGISTER.register("cedar_slab", () -> new SlabBlock(Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).strength(2.0F, 3.0F).sound(SoundType.WOOD)));
public static final RegistryObject<StairBlock> cedar_stairs = REGISTER.register("cedar_stairs", () -> new StairBlock(() -> cedar_planks.get().defaultBlockState(), Properties.copy(cedar_planks.get())));
public static final RegistryObject<DoorBlock> cedar_door = REGISTER.register("cedar_door", () -> new DoorBlock(Properties.of(Material.WOOD, MaterialColor.COLOR_PINK).strength(3.0F).sound(SoundType.WOOD).noOcclusion()));
Expand All @@ -84,29 +88,33 @@ public static BlockFamily getCedarBlockFamily() {
public static void init(RegistryEvent.Register<Block> event) {
((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(cedar_sapling.getId(), potted_cedar_sapling);

CEDAR_FAMILY = new BlockFamily.Builder(cedar_planks.get()).button(cedar_button.get()).fence(cedar_fence.get()).fenceGate(cedar_fence_gate.get()).pressurePlate(cedar_pressure_plate.get())/*.sign(cedar_sign.get(), cedar_wall_sign.get())*/.slab(cedar_slab.get()).stairs(cedar_stairs.get()).door(cedar_door.get()).trapdoor(cedar_trapdoor.get())
CEDAR_FAMILY = new BlockFamily.Builder(cedar_planks.get()).button(cedar_button.get()).fence(cedar_fence.get()).fenceGate(cedar_fence_gate.get()).pressurePlate(cedar_pressure_plate.get()).sign(cedar_sign.get(), cedar_wall_sign.get()).slab(cedar_slab.get()).stairs(cedar_stairs.get()).door(cedar_door.get()).trapdoor(cedar_trapdoor.get())
.recipeGroupPrefix("totemic:wooden").recipeUnlockedBy("has_planks").getFamily();
}

public static void setFireInfo() {
try {
FireBlock fire = (FireBlock) Blocks.FIRE;
var setFlammableM = MethodHandleUtil.findMethod(FireBlock.class, "m_53444_", MethodType.methodType(void.class, Block.class, int.class, int.class));
FireBlock fire = (FireBlock) Blocks.FIRE;
//We only need to call this method for blocks we don't define our own class for
fire.setFlammable(cedar_log.get(), 5, 5);
fire.setFlammable(stripped_cedar_log.get(), 5, 5);
fire.setFlammable(cedar_wood.get(), 5, 5);
fire.setFlammable(stripped_cedar_wood.get(), 5, 5);
fire.setFlammable(cedar_leaves.get(), 30, 60);
fire.setFlammable(cedar_planks.get(), 5, 20);
fire.setFlammable(cedar_fence.get(), 5, 20);
fire.setFlammable(cedar_fence_gate.get(), 5, 20);
fire.setFlammable(cedar_slab.get(), 5, 20);
fire.setFlammable(cedar_stairs.get(), 5, 20);
}

//We only need to call this method for blocks we don't define our own class for
setFlammableM.invoke(fire, cedar_log.get(), 5, 5);
setFlammableM.invoke(fire, stripped_cedar_log.get(), 5, 5);
setFlammableM.invoke(fire, cedar_wood.get(), 5, 5);
setFlammableM.invoke(fire, stripped_cedar_wood.get(), 5, 5);
setFlammableM.invoke(fire, cedar_leaves.get(), 30, 60);
setFlammableM.invoke(fire, cedar_planks.get(), 5, 20);
setFlammableM.invoke(fire, cedar_fence.get(), 5, 20);
setFlammableM.invoke(fire, cedar_fence_gate.get(), 5, 20);
setFlammableM.invoke(fire, cedar_slab.get(), 5, 20);
setFlammableM.invoke(fire, cedar_stairs.get(), 5, 20);
}
catch(Throwable e) {
throw new RuntimeException("Could not set flammability for Totemic blocks", e);
//Modifies the validBlocks of the sign block entity type to add our own sign block to it
public static void addCedarSignToSignBlockEntityType() {
var signValidBlocks = BlockEntityType.SIGN.validBlocks;
if(!(signValidBlocks instanceof HashSet)) { //another mod might have already made the set mutable
BlockEntityType.SIGN.validBlocks = signValidBlocks = new HashSet<>(signValidBlocks); //if not, copy into a mutable set
}

signValidBlocks.add(ModBlocks.cedar_sign.get());
signValidBlocks.add(ModBlocks.cedar_wall_sign.get());
}
}
Loading

0 comments on commit f58a7c0

Please sign in to comment.