Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.1 Port #68

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions common/src/main/java/dev/itsmeow/whisperwoods/WhisperwoodsMod.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package dev.itsmeow.whisperwoods;

import dev.architectury.injectables.annotations.ExpectPlatform;
import dev.architectury.utils.PlatformExpectedError;
import dev.itsmeow.imdlib.IMDLib;
import dev.itsmeow.whisperwoods.init.*;
import dev.itsmeow.whisperwoods.network.WWNetwork;
import net.minecraft.world.item.CreativeModeTab;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -14,7 +11,7 @@
public class WhisperwoodsMod {

public static final String MODID = "whisperwoods";
private static final Logger LOGGER = LogManager.getLogger();
public static final Logger LOGGER = LogManager.getLogger();

public static void construct() {
IMDLib.setRegistry(MODID);
Expand All @@ -26,6 +23,7 @@ public static void construct() {
ModBlocks.init();
ModItems.init();
ModBlockEntities.init();
ModCreativeTabs.init();
WWNetwork.init();
LOGGER.info("Spooking you...");
}
Expand All @@ -34,11 +32,4 @@ public static void init(Consumer<Runnable> enqueue) {
LOGGER.info("Summoning a hidebehind to eat you...");
}

public static final CreativeModeTab TAB = getPlatformTab();

@ExpectPlatform
public static CreativeModeTab getPlatformTab() {
throw new PlatformExpectedError("getPlatformTab(): Expected Platform");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

public class GhostLightBlock extends Block implements EntityBlock, IHaveColor {

private static VoxelShape SHAPE;
private static final VoxelShape SHAPE;
static {
double d = 0.0625D * 5;
SHAPE = Shapes.box(d, 0.0D, d, 1D - d, 1D - d, 1D - d);
}

private int color = 0;
private int color;

public GhostLightBlock(int color) {
super(Properties.of(Material.DECORATION).sound(SoundType.LANTERN).lightLevel(state -> 12));
super(Properties.of().sound(SoundType.LANTERN).lightLevel(state -> 12));
this.color = color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

public class WispLanternBlock extends Block implements EntityBlock, SimpleWaterloggedBlock, IHaveColor {

private static VoxelShape[] SHAPES = new VoxelShape[Direction.values().length];
private static final VoxelShape[] SHAPES = new VoxelShape[Direction.values().length];
static {
for(Direction facing : Direction.values()) {
final double d = 0.0625D * 4;
Expand All @@ -47,7 +46,7 @@ public class WispLanternBlock extends Block implements EntityBlock, SimpleWaterl
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static final DirectionProperty HORIZONTAL_FACING = DirectionProperty.create("horizontal", Direction.Plane.HORIZONTAL);
private int color = 0;
private int color;

public WispLanternBlock(int color, Properties properties) {
super(properties);
Expand Down Expand Up @@ -79,7 +78,7 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
if(direction.getAxis() == Axis.Y) {
blockstate = blockstate.setValue(HORIZONTAL_FACING, context.getPlayer().getMotionDirection().getOpposite());
}
return blockstate.setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER));
return blockstate.setValue(WATERLOGGED, fluidstate.getType() == Fluids.WATER);
}
}

Expand All @@ -97,11 +96,6 @@ public boolean canSurvive(BlockState state, LevelReader worldIn, BlockPos pos) {
return Block.canSupportCenter(worldIn, pos.relative(direction), direction.getOpposite());
}

@Override
public PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.DESTROY;
}

@SuppressWarnings("deprecation")
@Override
public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import com.mojang.math.Vector3f;
import dev.architectury.registry.registries.Registries;
import dev.itsmeow.whisperwoods.WhisperwoodsMod;
import dev.itsmeow.whisperwoods.block.GhostLightBlock;
import dev.itsmeow.whisperwoods.block.HandOfFateBlock;
import dev.itsmeow.whisperwoods.entity.EntityWisp;
Expand All @@ -19,7 +16,7 @@
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
Expand Down Expand Up @@ -52,6 +49,7 @@
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.Shapes;
import org.joml.Vector3f;

import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -94,8 +92,7 @@ public void sync() {

public boolean isLit() {
Block b = this.getBlockState().getBlock();
if (b instanceof HandOfFateBlock && this.hasLevel()) {
HandOfFateBlock block = (HandOfFateBlock) b;
if (b instanceof HandOfFateBlock block && this.hasLevel()) {
return block.isLit(this.getLevel(), this.getBlockPos());
}
return false;
Expand Down Expand Up @@ -138,12 +135,11 @@ public static <T extends HandOfFateBlockEntity> void serverTick(Level level, Blo
}
blockEntity.setChanged();
break;
} else if (stack.getItem() instanceof BlockItem && level.isEmptyBlock(pos.above())) {
BlockItem i = (BlockItem) stack.getItem();
if (i.getBlock() instanceof GhostLightBlock) {
} else if (stack.getItem() instanceof BlockItem blockItem && level.isEmptyBlock(pos.above())) {
if (blockItem.getBlock() instanceof GhostLightBlock) {
item.getItem().shrink(1);
blockEntity.playSound(SoundEvents.END_PORTAL_FRAME_FILL, 1F, 1F);
level.setBlockAndUpdate(pos.above(), i.getBlock().defaultBlockState());
level.setBlockAndUpdate(pos.above(), blockItem.getBlock().defaultBlockState());
}
if (item.getItem().getCount() == 0) {
item.discard();
Expand Down Expand Up @@ -192,15 +188,14 @@ public InteractionResult reactToItem(ItemStack stack, BlockState state, Level wo
}

public void onRecipeComplete(HOFRecipe recipe, BlockState state, Level worldIn, BlockPos pos) {
if (worldIn instanceof ServerLevel && !worldIn.isClientSide) {
ServerLevel world = (ServerLevel) worldIn;
if (worldIn instanceof ServerLevel world && !worldIn.isClientSide) {
switch (recipe.getName()) {
case "hirschgeist":
HOFEffectPacket hgpk = new HOFEffectPacket(HOFEffectType.HIRSCHGEIST, new Vector3f(pos.getX() + 0.5F, pos.getY() + 1F, pos.getZ() + 0.5F), WispColors.BLUE.getColor());
this.sendToTrackers(hgpk);
this.playSound(SoundEvents.EVOKER_CAST_SPELL, 1F, 1F);
this.playSound(SoundEvents.BELL_RESONATE, 1F, 1F);
TaskQueue.QUEUE_SERVER.schedule(50, () -> ModEntities.HIRSCHGEIST.getEntityType().spawn((ServerLevel) worldIn, null, null, pos.above(), MobSpawnType.EVENT, false, false));
TaskQueue.QUEUE_SERVER.schedule(50, () -> ModEntities.HIRSCHGEIST.getEntityType().spawn((ServerLevel) worldIn, (CompoundTag) null, null, pos.above(), MobSpawnType.EVENT, false, false));
break;
case "wisp":
EntityWisp wisp = ModEntities.WISP.getEntityType().create(world);
Expand Down Expand Up @@ -267,7 +262,7 @@ public void dropItems(Level worldIn, BlockPos pos) {
if (worldIn != null && this.getRecipeContainer().hasRecipe() && this.getRecipeContainer().data != null) {
this.getRecipeContainer().data.getItemData().forEach((i, v) -> {
if (v) {
Item toDrop = Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).get(new ResourceLocation(i));
Item toDrop = BuiltInRegistries.ITEM.get(new ResourceLocation(i));
if (toDrop != null) {
Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(toDrop));
}
Expand Down Expand Up @@ -318,7 +313,7 @@ public boolean canRecipeAccept(Item item) {
if (this.hasRecipe() && data != null) {
String next = data.getNextNonContainedItem();
if (next != null) {
return next.equals(Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString());
return next.equals(BuiltInRegistries.ITEM.getKey(item).toString());
}
}
return false;
Expand All @@ -332,7 +327,7 @@ public Item getDisplayItem() {
if (this.hasRecipe() && data != null) {
String itemName = data.getNextNonContainedItem();
if (itemName != null) {
return Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).get(new ResourceLocation(itemName));
return BuiltInRegistries.ITEM.get(new ResourceLocation(itemName));
}
}
return null;
Expand Down Expand Up @@ -367,12 +362,12 @@ public static class RecipeItemData {
private final Map<String, Boolean> data = new LinkedHashMap<>();

public RecipeItemData(HOFRecipe recipe) {
recipe.items.forEach(item -> data.put(Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString(), false));
recipe.items.forEach(item -> data.put(BuiltInRegistries.ITEM.getKey(item).toString(), false));
}

public RecipeItemData(HOFRecipe recipe, Set<String> items) {
recipe.items.forEach(item -> {
String key = Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString();
String key = BuiltInRegistries.ITEM.getKey(item).toString();
data.put(key, items.contains(key));
});
}
Expand All @@ -387,7 +382,7 @@ public String getNextNonContainedItem() {
}

public boolean addItem(Item item) {
String key = Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString();
String key = BuiltInRegistries.ITEM.getKey(item).toString();
if (data.containsKey(key)) {
data.put(key, true);
return true;
Expand All @@ -396,7 +391,7 @@ public boolean addItem(Item item) {
}

public boolean hasItem(Item item) {
return data.getOrDefault(Registries.get(WhisperwoodsMod.MODID).get(Registry.ITEM_REGISTRY).getId(item).toString(), false);
return data.getOrDefault(BuiltInRegistries.ITEM.getKey(item).toString(), false);
}

public void read(CompoundTag nbt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ public class ClientLifecycleHandler {
public static void clientInit() {
ClientReloadShadersEvent.EVENT.register((resourceManager, shadersSink) -> {
try {
shadersSink.registerShader(new ShaderInstance(resourceManager,"ww_rendertype_eyes_custom", DefaultVertexFormat.NEW_ENTITY), shaderInstance -> {
RenderTypeAddition.eyesCustomShader = shaderInstance;
});
shadersSink.registerShader(new ShaderInstance(resourceManager,"ww_rendertype_eyes_custom", DefaultVertexFormat.NEW_ENTITY), shaderInstance -> RenderTypeAddition.eyesCustomShader = shaderInstance);
} catch (IOException e) {
e.printStackTrace();
WhisperwoodsMod.LOGGER.error(e);
}
});
BlockEntityRendererRegistry.register(ModBlockEntities.GHOST_LIGHT.get(), RenderTileGhostLight::new);
Expand Down Expand Up @@ -95,10 +93,10 @@ public void render(EntityHirschgeistFireball entity, float f, float g, PoseStack
if(System.nanoTime() - entity.lastSpawn >= 10_000_000L) {
entity.lastSpawn = System.nanoTime();
for(int j = 0; j < 5; j++) {
double xO = (entity.getRandom().nextFloat() * 2F - 1F);
double yO = (entity.getRandom().nextFloat() * 2F - 1F);
double zO = (entity.getRandom().nextFloat() * 2F - 1F);
entity.level.addParticle(ModParticles.SOUL_FLAME.get(),
double xO = (entity.level().getRandom().nextFloat() * 2F - 1F);
double yO = (entity.level().getRandom().nextFloat() * 2F - 1F);
double zO = (entity.level().getRandom().nextFloat() * 2F - 1F);
entity.level().addParticle(ModParticles.SOUL_FLAME.get(),
entity.getX() + xO,
entity.getY() + yO,
entity.getZ() + zO, 0, 0.005F, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;

import java.util.Iterator;
import java.util.List;

public class RenderHirschgeist extends LivingEntityRenderer<EntityHirschgeist, ModelHirschgeist> {
Expand All @@ -46,9 +45,8 @@ public void render(EntityHirschgeist livingEntity, float f, float g, PoseStack p
float j = Mth.rotLerp(g, livingEntity.yHeadRotO, livingEntity.yHeadRot);
float k = j - h;
float l;
if (livingEntity.isPassenger() && livingEntity.getVehicle() instanceof LivingEntity) {
LivingEntity livingEntity2 = (LivingEntity)livingEntity.getVehicle();
h = Mth.rotLerp(g, livingEntity2.yBodyRotO, livingEntity2.yBodyRot);
if (livingEntity.isPassenger() && livingEntity.getVehicle() instanceof LivingEntity mount) {
h = Mth.rotLerp(g, mount.yBodyRotO, mount.yBodyRot);
k = j - h;
l = Mth.wrapDegrees(k);
if (l < -85.0F) {
Expand Down Expand Up @@ -81,8 +79,8 @@ public void render(EntityHirschgeist livingEntity, float f, float g, PoseStack p
n = 0.0F;
float o = 0.0F;
if (!livingEntity.isPassenger() && livingEntity.isAlive()) {
n = Mth.lerp(g, livingEntity.animationSpeedOld, livingEntity.animationSpeed);
o = livingEntity.animationPosition - livingEntity.animationSpeed * (1.0F - g);
n = livingEntity.walkAnimation.speed(g);
o = livingEntity.walkAnimation.position(g);
if (livingEntity.isBaby()) {
o *= 3.0F;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public void render(EntityWisp entity, float entityYaw, float partialTicks, PoseS
float r = (color >> 16) & 0xFF;
float g = (color >> 8) & 0xFF;
float b = color & 0xFF;
float scale = 1;
float scale;
if(entity.hasSoul()) {
UUID target = UUID.fromString(entity.getEntityData().get(EntityWisp.TARGET_ID));
String name = entity.getEntityData().get(EntityWisp.TARGET_NAME);
if(target != null && name != null && !name.equals("")) {
if(target != null && name != null && !name.isEmpty()) {
stack.pushPose();
{
stack.translate(0F, 0.8F, 0F);
Expand All @@ -64,13 +64,13 @@ public void render(EntityWisp entity, float entityYaw, float partialTicks, PoseS
double xO = (entity.getRandom().nextFloat() * 2F - 1F) / 3.5;
double yO = (entity.getRandom().nextFloat() * 2F - 1F) / 6 + 0.8F;
double zO = (entity.getRandom().nextFloat() * 2F - 1F) / 3.5;
entity.level.addParticle(new WispParticleData(r, g, b, scale),
entity.level().addParticle(new WispParticleData(r, g, b, scale),
entity.getX() + xO,
entity.getY() + yO,
entity.getZ() + zO, 0, 0.005F, 0);
}
// spawn upper particle
entity.level.addParticle(new WispParticleData(r, g, b, scale),
entity.level().addParticle(new WispParticleData(r, g, b, scale),
entity.getX() + (entity.getRandom().nextFloat() * 2F - 1F) / 10,
entity.getY() + (entity.getRandom().nextFloat() * 2F - 1F) / 5 + 1.1F,
entity.getZ() + (entity.getRandom().nextFloat() * 2F - 1F) / 10, 0, 0.02F, 0);
Expand Down
Loading
Loading