Skip to content

Commit

Permalink
1.20.4 translation to mojmap completed
Browse files Browse the repository at this point in the history
  • Loading branch information
finallion committed Feb 22, 2024
1 parent 17abeaa commit e6b995f
Show file tree
Hide file tree
Showing 156 changed files with 3,977 additions and 4,227 deletions.
4 changes: 2 additions & 2 deletions common/src/main/java/com/lion/graveyard/GraveyardClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.lion.graveyard.init.*;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.Identifier;
import net.minecraft.resources.ResourceLocation;

public class GraveyardClient {

public static final Identifier SKULL_PACKET_ID = new Identifier(Graveyard.MOD_ID, "spawn_entity");
public static final ResourceLocation SKULL_PACKET_ID = new ResourceLocation(Graveyard.MOD_ID, "spawn_entity");

@Environment(EnvType.CLIENT)
public static void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@
import com.lion.graveyard.blocks.OssuaryBlock;
import com.lion.graveyard.init.TGBlockEntities;
import com.lion.graveyard.init.TGSounds;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.*;
import net.minecraft.core.BlockPos;
import net.minecraft.entity.player.Player;
import net.minecraft.sound.SoundSource;
import net.minecraft.sound.SoundEvents;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand Down Expand Up @@ -44,7 +37,7 @@ public void registerControllers(AnimatableManager.ControllerRegistrar data) {
if (level != null && !playedSound) {
Player playerEntity = level.getNearestPlayer((double)getBlockPos().getX() + 0.5D, (double)getBlockPos().getY() + 0.5D, (double)getBlockPos().getZ() + 0.5D, 4.0D, false);
if (playerEntity != null) {
playerEntity.playSound(TGSounds.OSSUARY_OPEN.get(), SoundSource.BLOCKS, 1.0F, -2.0F);
playerEntity.playNotifySound(TGSounds.OSSUARY_OPEN.get(), SoundSource.BLOCKS, 1.0F, -2.0F);
playedSound = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,15 @@
import com.lion.graveyard.blocks.SarcophagusBlock;
import com.lion.graveyard.init.TGBlockEntities;
import com.lion.graveyard.init.TGSounds;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.LidOpenable;
import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.block.entity.ViewerCountManager;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.entity.player.Player;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.DoubleInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.chat.Component;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.sound.SoundSource;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.CompoundContainer;
import net.minecraft.world.Container;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.World;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected boolean isOwnContainer(Player player) {

public void load(CompoundTag nbt) {
super.load(nbt);
this.inventory = NonNullList.withSize(this.size(), ItemStack.EMPTY);
this.inventory = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
if (!this.tryLoadLootTable(nbt)) {
ContainerHelper.loadAllItems(nbt, this.inventory);
}
Expand All @@ -71,7 +71,7 @@ protected void saveAdditional(CompoundTag nbt) {

}

public int size() {
public int getContainerSize() {
return 54;
}

Expand All @@ -87,7 +87,7 @@ protected Component getDefaultName() {
return Component.translatable("container.urn");
}

protected AbstractContainerMenu createScreenHandler(int syncId, Inventory playerInventory) {
protected AbstractContainerMenu createMenu(int syncId, Inventory playerInventory) {
boolean large = Graveyard.CONFIG.booleanEntries.get("urnHasDoubleInventory");
if (large) {
return ChestMenu.sixRows(syncId, playerInventory, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void renderGrave(BlockState state, float f, PoseStack matrixStack, MultiB
matrixStack.pushPose();
matrixStack.translate(0.5, 0.43, 0.5);
matrixStack.scale(2.28F, 2.15F, 2.28F);
float rotation = state.getValue(GravestoneBlock.FACING).asYRot();
float rotation = state.getValue(GravestoneBlock.FACING).toYRot();
matrixStack.mulPose(Axis.YP.rotationDegrees(rotation));
Minecraft.getInstance().getItemRenderer().renderStatic(new ItemStack(state.getBlock().asItem(), 1), ItemDisplayContext.GROUND, i, j, matrixStack, vertexConsumerProvider, world, 2);
matrixStack.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
import com.lion.graveyard.blocks.SarcophagusBlock;
import com.lion.graveyard.init.TGBlockEntities;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.DoubleBlockCombiner;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.LidBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -27,22 +31,22 @@ public SarcophagusBlockEntityRenderer(BlockEntityRendererProvider.Context ctx) {
}

@Override
public int getRenderDistance() {
public int getViewDistance() {
return 45;
}

@Override
public void render(SarcophagusBlockEntity entity, float tickDelta, PoseStack matrixStack, MultiBufferSource vertexConsumers, int light, int overlay) {
BlockState blockState = entity.getCachedState();
DoubleBlockProperties.PropertySource<? extends SarcophagusBlockEntity> propertySource = DoubleBlockProperties.toPropertySource(TGBlockEntities.SARCOPHAGUS_BLOCK_ENTITY.get(), SarcophagusBlock::getSarcophagusPart, SarcophagusBlock::getOppositePartDirection, ChestBlock.FACING, blockState, entity.getLevel(), entity.getPos(), (worldx, pos) -> false);
BlockState blockState = entity.getBlockState();
DoubleBlockCombiner.NeighborCombineResult<? extends SarcophagusBlockEntity> propertySource = DoubleBlockCombiner.combineWithNeigbour(TGBlockEntities.SARCOPHAGUS_BLOCK_ENTITY.get(), SarcophagusBlock::getBlockType, SarcophagusBlock::getConnectedDirection, ChestBlock.FACING, blockState, entity.getLevel(), entity.getBlockPos(), (worldx, pos) -> false);
float g = propertySource.apply(SarcophagusBlock.getAnimationProgressRetriever(entity)).get(tickDelta);
g = 1.0F - g;
g = 1.0F - g * g * g;

BakedModel base = getModel(((SarcophagusBlock)blockState.getBlock()).getBase().get());
BakedModel lid = getModel(((SarcophagusBlock)blockState.getBlock()).getLid().get());

if (entity.getLevel() != null && entity.getCachedState().get(SarcophagusBlock.PART) == SarcophagusPart.HEAD) {
if (entity.getLevel() != null && entity.getBlockState().getValue(SarcophagusBlock.PART) == SarcophagusPart.HEAD) {
render(entity, matrixStack, vertexConsumers, light, overlay, g, lid, true);
render(entity, matrixStack, vertexConsumers, light, overlay, g, base, false);
}
Expand All @@ -53,9 +57,9 @@ public void render(SarcophagusBlockEntity entity, float tickDelta, PoseStack mat
private void render(SarcophagusBlockEntity entity, PoseStack matrixStack, MultiBufferSource vertexConsumer, int light, int overlay, float g, BakedModel model, boolean isLid) {
matrixStack.pushPose();

Direction direction = entity.getCachedState().get(SarcophagusBlock.FACING).getOpposite();
float f = direction.asRotation();
matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-f));
Direction direction = entity.getBlockState().getValue(SarcophagusBlock.FACING).getOpposite();
float f = direction.toYRot();
matrixStack.mulPose(Axis.YP.rotationDegrees(-f));

switch (direction) {
case EAST -> matrixStack.translate(-1.0F, 0F, 1.0F);
Expand All @@ -64,17 +68,17 @@ private void render(SarcophagusBlockEntity entity, PoseStack matrixStack, MultiB
}

if (isLid) {
matrixStack.multiply(RotationAxis.NEGATIVE_Z.rotationDegrees(g * 45)); // lid rotation, originally 70
matrixStack.mulPose(Axis.ZN.rotationDegrees(g * 45)); // lid rotation, originally 70
matrixStack.translate(g * 0.3, g * 0.3, 0.0F); // moves lid away from body
}

client.getBlockRenderManager().getModelRenderer().render(matrixStack.peek(), vertexConsumer.getBuffer(RenderLayers.getEntityBlockLayer(entity.getCachedState(), false)), entity.getCachedState(), model, 1.0F, 1.0F, 1.0F, light, overlay);
client.getBlockRenderer().getModelRenderer().renderModel(matrixStack.last(), vertexConsumer.getBuffer(ItemBlockRenderTypes.getRenderType(entity.getBlockState(), false)), entity.getBlockState(), model, 1.0F, 1.0F, 1.0F, light, overlay);

matrixStack.pop();
matrixStack.popPose();
}

public BakedModel getModel(Item item) {
return client.getItemRenderer().getModel(item.getDefaultStack(), null, null, 0);
return client.getItemRenderer().getModel(item.getDefaultInstance(), null, null, 0);
}
}

Expand Down
40 changes: 19 additions & 21 deletions common/src/main/java/com/lion/graveyard/blocks/AltarBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.lion.graveyard.init.TGItems;
import com.lion.graveyard.init.TGSounds;
import com.lion.graveyard.item.VialOfBlood;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Difficulty;
Expand Down Expand Up @@ -83,12 +85,12 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
blood = VialOfBlood.getBlood(stack);
}

if (state.is(TGBlocks.ALTAR.get()) && (blood >= 0.8F || Graveyard.getConfig().corruptedChampionConfigEntries.get("corrupted_champion").isBossSummonableItem.contains(stack.getItem().getTranslationKey())) && world.getDifficulty() != Difficulty.PEACEFUL && (world.isNight() || world.getDimension().hasFixedTime())) {
if (state.is(TGBlocks.ALTAR.get()) && (blood >= 0.8F || Graveyard.getConfig().corruptedChampionConfigEntries.get("corrupted_champion").isBossSummonableItem.contains(stack.getItem().getDescriptionId())) && world.getDifficulty() != Difficulty.PEACEFUL && (world.isNight() || world.dimensionType().hasFixedTime())) {
BlockPattern.BlockPatternMatch result = AltarBlock.getCompletedFramePattern().find(world, pos);

if (!state.getValue(AltarBlock.BLOODY) && (result != null || !Graveyard.getConfig().corruptedChampionConfigEntries.get("corrupted_champion").summoningNeedsStaffFragments)) {
player.level().playSound((Player)null, player.blockPosition(), TGSounds.VIAL_SPLASH.get(), SoundSource.BLOCKS, 5.0F, 1.0F);
world.setBlock(pos, state.setValue(AltarBlock.BLOODY, true));
world.setBlock(pos, state.setValue(AltarBlock.BLOODY, true), 3);
Direction direction;

if (result == null) {
Expand All @@ -112,43 +114,39 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
for (int k = 0; k < 2; ++k) {
BlockPos iteratorPos = new BlockPos(corner.add(i, k, j));
BlockPos iteratorPos = new BlockPos(corner.offset(i, k, j));
BlockState blockState = world.getBlockState(iteratorPos);

if (blockState.getBlock() instanceof OminousBoneStaffFragment) {
world.setBlock(iteratorPos, Blocks.AIR.defaultBlockState());
world.setBlock(iteratorPos, Blocks.AIR.defaultBlockState(), 3);
}
}
}
}

LichEntity lich = (LichEntity) TGEntities.LICH.get().create(world);
BlockPos blockPos = pos.up();
lich.setYaw(direction.getOpposite().asRotation());
lich.setBodyYaw(direction.getOpposite().asRotation());
lich.setHeadYaw(direction.getOpposite().asRotation());
lich.refreshPositionAndAngles((double) blockPos.getX() + 0.5D, (double) blockPos.getY() + 0.55D, (double) blockPos.getZ() + 0.5D, 0.0F, 0.0F);
lich.onSummoned(direction.getOpposite(), pos.up());

Iterator var13 = world.getNonSpectatingEntities(ServerPlayerEntity.class, lich.getBoundingBox().expand(50.0D)).iterator();

while (var13.hasNext()) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) var13.next();
Criteria.SUMMONED_ENTITY.trigger(serverPlayerEntity, lich);
BlockPos blockPos = pos.above();
lich.setYHeadRot(direction.getOpposite().toYRot());
lich.setYBodyRot(direction.getOpposite().toYRot());
lich.setYRot(direction.getOpposite().toYRot());
lich.moveTo((double)blockPos.getX() + 0.5D, (double)blockPos.getY() + 0.55D, (double)blockPos.getZ() + 0.5D, 0.0F, 0.0F);
lich.onSummoned(direction.getOpposite(), pos.above());

for (ServerPlayer serverplayer : world.getEntitiesOfClass(ServerPlayer.class, lich.getBoundingBox().inflate(50.0D))) {
CriteriaTriggers.SUMMONED_ENTITY.trigger(serverplayer, lich);
}


world.spawnEntity(lich);
lich.addStatusEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 5));
world.addFreshEntity(lich);
lich.addEffect(new MobEffectInstance(MobEffects.INVISIBILITY, 5));

return InteractionResult.CONSUME;
}

return InteractionResult.success(player.getLevel().isClient);
return InteractionResult.sidedSuccess(player.level().isClientSide);
}
}


return super.onUse(state, world, pos, player, hand, hit);
return super.use(state, world, pos, player, hand, hit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class SarcophagusBlock extends BaseEntityBlock implements SimpleWaterlogg
private final Supplier<Item> base;
public SarcophagusBlock(BlockBehaviour.Properties settings, boolean isCoffin, Supplier<Item> lid, Supplier<Item> base) {
super(settings);
this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false).setValue(OPEN, false).setValue(PART, SarcophagusPart.FOOT).setValue(PLAYER_PLACED, false).with(IS_COFFIN, isCoffin));
this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false).setValue(OPEN, false).setValue(PART, SarcophagusPart.FOOT).setValue(PLAYER_PLACED, false).setValue(IS_COFFIN, isCoffin));
this.base = base;
this.lid = lid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RotatedPillarBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;

import java.util.function.Supplier;

public class TGDeepslateBlock extends PillarBlock {
public class TGDeepslateBlock extends RotatedPillarBlock {

private final Supplier<Block> clickedBlock;

Expand Down
22 changes: 7 additions & 15 deletions common/src/main/java/com/lion/graveyard/blocks/TGTurfBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,19 @@
import java.util.Optional;

import com.lion.graveyard.init.TGBlocks;
import net.minecraft.block.BlockState;
import net.minecraft.block.Fertilizable;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.placement.VegetationPlacements;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntry.Reference;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.RandomSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.feature.RandomPatchFeatureConfig;
import net.minecraft.world.gen.feature.VegetationPlacedFeatures;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
import net.minecraft.world.level.block.SpreadingSnowyDirtBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
Expand All @@ -42,6 +29,11 @@ public TGTurfBlock(BlockBehaviour.Properties settings) {
super(settings);
}

@Override
protected MapCodec<? extends SpreadingSnowyDirtBlock> codec() {
return null;
}

@Override
public boolean isValidBonemealTarget(LevelReader level, BlockPos pos, BlockState state) {
return level.getBlockState(pos.above()).isAir();
Expand Down
Loading

0 comments on commit e6b995f

Please sign in to comment.