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

Ciber's 1.20.4 patches #634

Merged
merged 10 commits into from
Sep 7, 2024
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Changed
- Structure Block Registry Processor can now be used for data generated structures through a processor_list
- Adjusted the hitbox size for Lotus Flowers
- The Lotus Time Capsule now spawns a Lotus Flower when placed
- Lotus Time Capsule blocks now remove any Lotus Flowers above them when destroyed

### Fixed
- The Umbral Infiltrator no longer jitters when thrown by a void player
kirderf1 marked this conversation as resolved.
Show resolved Hide resolved
- Manually-spawned Lotus Flowers can no longer be hurt or killed by any damage source
- Lotus Flowers no longer push entities inside of them away
- Ogres and Basilisks no longer slide around when idling

### Contributors for this release

- Dweblenod, sipherNil, gtzc
- Dweblenod, sipherNil, gtzc, Cibernet

## [Unreleased]

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/mraof/minestuck/block/CustomVoxelShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,12 @@ public ImmutableMap<Direction, VoxelShape> createRotatedShapesAllDirections()
{
return ImmutableMap.<Direction, VoxelShape>builder().put(Direction.UP, this.create(Direction.UP)).put(Direction.DOWN, this.create(Direction.DOWN)).put(Direction.NORTH, this.create(Direction.NORTH)).put(Direction.SOUTH, this.create(Direction.SOUTH)).put(Direction.WEST, this.create(Direction.WEST)).put(Direction.EAST, this.create(Direction.EAST)).build();
}

public double getMaxY()
{
double result = 0;
for(double[] part : parts)
result = Math.max(result, Math.max(part[1], part[4]));
return result / 16d;
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/mraof/minestuck/block/LotusTimeCapsuleBlock.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.mraof.minestuck.block;

import com.mraof.minestuck.block.machine.MultiMachineBlock;
import com.mraof.minestuck.entity.LotusFlowerEntity;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

Expand Down Expand Up @@ -46,4 +50,12 @@ public BlockState mirror(BlockState state, Mirror mirror)
}
return state;
}

@Override
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston)
{
super.onRemove(pState, pLevel, pPos, pNewState, pMovedByPiston);

pLevel.getEntitiesOfClass(LotusFlowerEntity.class, new AABB(pPos.above())).forEach(Entity::discard); //not entirely content with this implementation, but it should do the trick. contact me if bugs somehow arise from it. -Ciber
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package com.mraof.minestuck.block;

import com.mraof.minestuck.block.machine.MachineMultiblock;
import com.mraof.minestuck.entity.LotusFlowerEntity;
import com.mraof.minestuck.entity.MSEntityTypes;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.neoforged.neoforge.registries.DeferredRegister;

Expand All @@ -22,4 +27,21 @@ public LotusTimeCapsuleMultiblock(DeferredRegister.Blocks register)
addDirectionPlacement(1, 0, 1, CORNER, Direction.EAST);
}


@Override
public void placeAdditional(Level level, Placement placement)
{
super.placeAdditional(level, placement);

LotusFlowerEntity lotusFlowerEntity = MSEntityTypes.LOTUS_FLOWER.get().create(level);

BlockPos offset = new BlockPos(1, 0, 1).rotate(placement.rotation());

lotusFlowerEntity.moveTo(
placement.zeroPos().getX() + Math.max(0, offset.getX()),
placement.zeroPos().getY() + MSBlockShapes.LOTUS_TIME_CAPSULE.getMaxY(),
placement.zeroPos().getZ() + Math.max(0, offset.getZ()),
0F, 0);
level.addFreshEntity(lotusFlowerEntity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Rotation;
Expand Down Expand Up @@ -112,6 +113,14 @@ public void placeWithRotation(LevelAccessor level, Placement placement)
blockEntries.forEach(entry -> entry.placeWithRotation(level, placement));
}

/**
* Additional code to run after the multiblock has been placed.
*/
public void placeAdditional(Level level, Placement placement)
{

}

private boolean isInvalid(BlockGetter level, Placement placement)
{
for(PlacementEntry entry : blockEntries)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float

if(hoveredOrFocused && !wasHoveredOrFocused && this.active)
Minecraft.getInstance().player.playSound(SoundEvents.UI_BUTTON_CLICK.value(), 0.2F, 2.0F);
wasHoveredOrFocused = isMouseOver(mouseX, mouseY) || isFocused();

guiGraphics.blitWithBorder(gui, this.getX() + hoverFocusShift, this.getY(), 0, 176 + k * 20, this.width, trueHeight, 200, 20, 3, 3, 3, 3);

Expand All @@ -92,7 +93,6 @@ public void renderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float
guiGraphics.drawString(mc.font, messageLines.get(i), textX , pY, getFGColor(), false);
pY += TEXT_SPACING;
}

wasHoveredOrFocused = isMouseOver(mouseX, mouseY) || isFocused();
}

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.mraof.minestuck.client.renderer.entity;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import com.mraof.minestuck.client.model.ServerCursorModel;
import com.mraof.minestuck.entity.ServerCursorEntity;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Pose;
import software.bernie.geckolib.renderer.GeoEntityRenderer;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -34,4 +37,10 @@ public RenderType getRenderType(ServerCursorEntity animatable, ResourceLocation
{
return RenderType.entityTranslucentCull(getTextureLocation(animatable));
}

@Override
protected void applyRotations(ServerCursorEntity animatable, PoseStack poseStack, float ageInTicks, float rotationYaw, float partialTick)
{
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F - animatable.getYRot()));
}
kirderf1 marked this conversation as resolved.
Show resolved Hide resolved
}
38 changes: 12 additions & 26 deletions src/main/java/com/mraof/minestuck/entity/LotusFlowerEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mraof.minestuck.network.LotusFlowerPacket;
import com.mraof.minestuck.util.MSSoundEvents;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
Expand Down Expand Up @@ -44,7 +45,7 @@

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class LotusFlowerEntity extends LivingEntity implements GeoEntity, IEntityWithComplexSpawn
public class LotusFlowerEntity extends Entity implements GeoEntity, IEntityWithComplexSpawn
{
private static final Logger LOGGER = LogManager.getLogger();

Expand Down Expand Up @@ -103,6 +104,12 @@ public AnimatableInstanceCache getAnimatableInstanceCache()
return this.cache;
}

@Override
public boolean isPickable()
{
return true;
}

@Override
public InteractionResult interact(Player player, InteractionHand hand)
{
Expand All @@ -129,9 +136,9 @@ public InteractionResult interact(Player player, InteractionHand hand)
}

@Override
public void aiStep()
public void tick()
{
super.aiStep();
super.tick();

if(!level().isClientSide)
{
Expand Down Expand Up @@ -227,16 +234,12 @@ protected void spawnLoot()
@Override
public void addAdditionalSaveData(CompoundTag compound)
{
super.addAdditionalSaveData(compound);

compound.putInt("EventTimer", eventTimer);
}

@Override
public void readAdditionalSaveData(CompoundTag compound)
{
super.readAdditionalSaveData(compound);

if(compound.contains("EventTimer", Tag.TAG_ANY_NUMERIC))
{
eventTimer = compound.getInt("EventTimer");
Expand Down Expand Up @@ -289,31 +292,14 @@ protected MovementEmission getMovementEmission()
}

@Override
public void move(MoverType typeIn, Vec3 pos)
protected void defineSynchedData()
{
}

@Override
public Iterable<ItemStack> getArmorSlots()
{
return Collections.emptyList();
}

@Override
public ItemStack getItemBySlot(EquipmentSlot slotIn)
{
return ItemStack.EMPTY;
}

@Override
public void setItemSlot(EquipmentSlot slotIn, ItemStack stack)
{
}

@Override
public HumanoidArm getMainArm()
public void move(MoverType typeIn, Vec3 pos)
{
return HumanoidArm.RIGHT;
}

public enum Animation //animationName set in assets/minestuck/animations/lotus_flower.animation.json. Animated blocks/entities also need a section in assets/minestuck/geo
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/mraof/minestuck/entity/MSEntityTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class MSEntityTypes
public static final Supplier<EntityType<SbahjPosterEntity>> SBAHJ_POSTER = REGISTER.register("sbahj_poster", () -> EntityType.Builder.<SbahjPosterEntity>of(SbahjPosterEntity::new, MobCategory.MISC).sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(false).setTrackingRange(10).setUpdateInterval(Integer.MAX_VALUE).build(new ResourceLocation(Minestuck.MOD_ID, "sbahj_poster").toString()));
public static final Supplier<EntityType<ShopPosterEntity>> SHOP_POSTER = REGISTER.register("shop_poster", () -> EntityType.Builder.<ShopPosterEntity>of(ShopPosterEntity::new, MobCategory.MISC).sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(false).setTrackingRange(10).setUpdateInterval(Integer.MAX_VALUE).build(new ResourceLocation(Minestuck.MOD_ID, "shop_poster").toString()));
public static final Supplier<EntityType<HologramEntity>> HOLOGRAM = REGISTER.register("hologram", () -> EntityType.Builder.<HologramEntity>of(HologramEntity::new, MobCategory.MISC).sized(0.25F, 0.25F).setShouldReceiveVelocityUpdates(false).setTrackingRange(10).setUpdateInterval(Integer.MAX_VALUE).fireImmune().build(new ResourceLocation(Minestuck.MOD_ID, "hologram").toString()));
public static final Supplier<EntityType<LotusFlowerEntity>> LOTUS_FLOWER = REGISTER.register("lotus_flower", () -> EntityType.Builder.of(LotusFlowerEntity::new, MobCategory.MISC).sized(2F, 2F).setShouldReceiveVelocityUpdates(false).setTrackingRange(10).fireImmune().build(new ResourceLocation(Minestuck.MOD_ID, "lotus_flower").toString()));
public static final Supplier<EntityType<LotusFlowerEntity>> LOTUS_FLOWER = REGISTER.register("lotus_flower", () -> EntityType.Builder.of(LotusFlowerEntity::new, MobCategory.MISC).sized(1.25F, 1.6F).setShouldReceiveVelocityUpdates(false).setTrackingRange(10).fireImmune().build(new ResourceLocation(Minestuck.MOD_ID, "lotus_flower").toString()));

public static final Supplier<EntityType<ConsumableProjectileEntity>> CONSUMABLE_PROJECTILE = REGISTER.register("consumable_projectile", () -> EntityType.Builder.<ConsumableProjectileEntity>of(ConsumableProjectileEntity::new, MobCategory.MISC).sized(0.25F, 0.25F).setTrackingRange(4).setUpdateInterval(10).fireImmune().build(new ResourceLocation(Minestuck.MOD_ID, "consumable_projectile").toString()));
public static final Supplier<EntityType<ReturningProjectileEntity>> RETURNING_PROJECTILE = REGISTER.register("returning_projectile", () -> EntityType.Builder.<ReturningProjectileEntity>of(ReturningProjectileEntity::new, MobCategory.MISC).sized(0.25F, 0.25F).setTrackingRange(6).setUpdateInterval(2).fireImmune().build(new ResourceLocation(Minestuck.MOD_ID, "returning_projectile").toString())); //TODO smaller update interval value is temporary solution to improve client rendering
Expand Down Expand Up @@ -111,8 +111,5 @@ public static void onEntityAttributeCreation(EntityAttributeCreationEvent event)
event.put(PROSPITIAN_ROOK.get(), RookEntity.rookAttributes().build());

event.put(PLAYER_DECOY.get(), Mob.createMobAttributes().build());

event.put(LOTUS_FLOWER.get(), LivingEntity.createLivingAttributes().build());
event.put(SERVER_CURSOR.get(), LivingEntity.createLivingAttributes().build());
}
}
34 changes: 14 additions & 20 deletions src/main/java/com/mraof/minestuck/entity/ServerCursorEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import com.mraof.minestuck.network.ServerCursorPacket;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.neoforged.neoforge.entity.IEntityWithComplexSpawn;
Expand All @@ -21,11 +19,10 @@

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collections;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ServerCursorEntity extends LivingEntity implements GeoEntity, IEntityWithComplexSpawn
public class ServerCursorEntity extends Entity implements GeoEntity, IEntityWithComplexSpawn
{

private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
Expand Down Expand Up @@ -84,9 +81,9 @@ public void readSpawnData(FriendlyByteBuf additionalData)
}

@Override
public void aiStep()
public void tick()
{
super.aiStep();
super.tick();

if(!level().isClientSide)
{
Expand All @@ -105,6 +102,7 @@ public void aiStep()
}
}

/*
//Ensures that the head and body always face the same way as the root Y rotation.
@Override
protected float tickHeadTurn(float pYRot, float pAnimStep)
Expand All @@ -125,34 +123,30 @@ public void lerpTo(double pX, double pY, double pZ, float pYaw, float pPitch, in
this.yBodyRot = this.getYRot();
this.yHeadRot = this.getYRot();
}
*/

@Override
protected MovementEmission getMovementEmission()
protected void defineSynchedData()
{
return MovementEmission.NONE;
}

@Override
public Iterable<ItemStack> getArmorSlots()
{
return Collections.emptyList();
}

@Override
public ItemStack getItemBySlot(EquipmentSlot pSlot)
protected MovementEmission getMovementEmission()
{
return ItemStack.EMPTY;
return MovementEmission.NONE;
}

@Override
public void setItemSlot(EquipmentSlot pSlot, ItemStack pStack)
protected void readAdditionalSaveData(CompoundTag pCompound)
{

}

@Override
public HumanoidArm getMainArm()
protected void addAdditionalSaveData(CompoundTag pCompound)
{
return HumanoidArm.RIGHT;

}

public void setAnimation(AnimationType animation)
Expand Down
Loading