Skip to content

Commit

Permalink
Convert and update to Fallen Star
Browse files Browse the repository at this point in the history
  • Loading branch information
weirtz committed Aug 17, 2023
1 parent 9e4648a commit 58f2974
Show file tree
Hide file tree
Showing 25 changed files with 7,370 additions and 157 deletions.
881 changes: 881 additions & 0 deletions hs_err_pid13064.log

Large diffs are not rendered by default.

880 changes: 880 additions & 0 deletions hs_err_pid25496.log

Large diffs are not rendered by default.

851 changes: 851 additions & 0 deletions hs_err_pid36388.log

Large diffs are not rendered by default.

867 changes: 867 additions & 0 deletions hs_err_pid44504.log

Large diffs are not rendered by default.

871 changes: 871 additions & 0 deletions hs_err_pid78416.log

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions src/main/java/com/seabreyh/mana/ManaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
// import com.seabreyh.mana.registry.ManaRecipes;
// import com.seabreyh.mana.registry.ManaSounds;
import com.seabreyh.mana.registry.ManaParticles;
import com.seabreyh.mana.registry.damage.DamageTypeDataProvider;
import com.seabreyh.mana.registry.damage.DamageTypeTagGen;
import com.seabreyh.mana.screen.ManaMenuTypes;

import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.crafting.RecipeSerializer;
Expand All @@ -30,6 +35,7 @@
import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.data.event.GatherDataEvent;
//import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.registries.RegisterEvent;
import net.minecraftforge.eventbus.api.IEventBus;
Expand Down Expand Up @@ -140,4 +146,32 @@ public static void onBlocksRegistry(final RegisterEvent.RegisterHelper<Block> bl
public Object getISTERProperties() {
return null;
}

public static ResourceLocation asResource(String path) {
return new ResourceLocation(MOD_ID, path);
}

public static void gatherData(GatherDataEvent event) {
// TagGen.datagen();
DataGenerator gen = event.getGenerator();
PackOutput output = gen.getPackOutput();

// if (event.includeClient()) {
// gen.addProvider(true, AllSoundEvents.provider(gen));
// LangMerger.attachToRegistrateProvider(gen, output);
// }

if (event.includeServer()) {
// gen.addProvider(true, new AllAdvancements(output));
// gen.addProvider(true, new StandardRecipeGen(output));
// gen.addProvider(true, new MechanicalCraftingRecipeGen(output));
// gen.addProvider(true, new //SequencedAssemblyRecipeGen(output));
// ProcessingRecipeGen.registerAll(gen, output);
// gen.addProvider(true,
// WorldgenDataProvider.makeFactory(event.getLookupProvider()));
gen.addProvider(true, DamageTypeDataProvider.makeFactory(event.getLookupProvider()));
gen.addProvider(true,
new DamageTypeTagGen(output, event.getLookupProvider(), event.getExistingFileHelper()));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.seabreyh.mana.blocks.entity;

import com.seabreyh.mana.entity.FallenStar;
import com.seabreyh.mana.ManaMod;
import com.seabreyh.mana.entity.FallenStarEntity;
import com.seabreyh.mana.registry.ManaBlockEntities;
import com.seabreyh.mana.registry.ManaItems;
import com.seabreyh.mana.screen.StarCatcherMenu;
Expand Down Expand Up @@ -54,6 +55,7 @@ protected void onContentsChanged(int slot) {

public StarCatcherEntityBlock(BlockPos pWorldPosition, BlockState pBlockState) {
super(ManaBlockEntities.STAR_CATCHER_ENTITY_BLOCK.get(), pWorldPosition, pBlockState);
ManaMod.LOGGER.info("StarCatcher init");
}

@Override
Expand Down Expand Up @@ -152,14 +154,15 @@ private static void locateStars(Level plevel, StarCatcherEntityBlock pBlockEntit
if (hasNotReachedStackLimit(pBlockEntity)) {

AABB area = pBlockEntity.getRenderBoundingBox().inflate(80.0D, 80.0D, 80.0D);
List<FallenStar> fallenStars = plevel.getEntitiesOfClass(FallenStar.class, area);
List<FallenStarEntity> fallenStars = plevel.getEntitiesOfClass(FallenStarEntity.class, area);

for (FallenStar foundStar : fallenStars) {
for (FallenStarEntity foundStar : fallenStars) {
// make sure star can only be targeted by one star catcher
if (foundStar.getIsFalling() == false
if (foundStar.isFalling == false
&& foundStar.getIsTargeted() == false) {
if (foundStar instanceof FallenStar) {
if (foundStar instanceof FallenStarEntity) {
if (foundStar.getIsTargeted() == false) {
ManaMod.LOGGER.info("FOUDN STAR: " + foundStar);
foundStar.setIsTargeted(true);
foundStar.toStarCatcher(pBlockEntity.getBlockPos(), pBlockEntity);
pBlockEntity.catchCount++;
Expand All @@ -171,9 +174,9 @@ private static void locateStars(Level plevel, StarCatcherEntityBlock pBlockEntit

} else {
AABB area = pBlockEntity.getRenderBoundingBox().inflate(80.0D, 80.0D, 80.0D);
List<FallenStar> fallenStars = plevel.getEntitiesOfClass(FallenStar.class, area);
List<FallenStarEntity> fallenStars = plevel.getEntitiesOfClass(FallenStarEntity.class, area);

for (FallenStar foundStar : fallenStars) {
for (FallenStarEntity foundStar : fallenStars) {
if (foundStar.getIsTargeted()) {
foundStar.stopStarCatch();
pBlockEntity.catchCount--;
Expand All @@ -185,10 +188,10 @@ private static void locateStars(Level plevel, StarCatcherEntityBlock pBlockEntit
// in order to set the spin speed in the renderer

AABB area = pBlockEntity.getRenderBoundingBox().inflate(80.0D, 80.0D, 80.0D);
List<FallenStar> fallenStars = plevel.getEntitiesOfClass(FallenStar.class, area);
List<FallenStarEntity> fallenStars = plevel.getEntitiesOfClass(FallenStarEntity.class, area);

pBlockEntity.catchCount = 0;
for (FallenStar foundStar : fallenStars) {
for (FallenStarEntity foundStar : fallenStars) {
pBlockEntity.catchCount++;

// Dummy statement to get linter to not complain about unused vars
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.seabreyh.mana.client.renderers.entity;

import com.seabreyh.mana.ManaMod;
import com.seabreyh.mana.entity.FallenStar;
import com.seabreyh.mana.entity.FallenStarEntity;

import org.joml.Matrix4f;
import org.joml.Quaternionf;
Expand Down Expand Up @@ -34,7 +34,7 @@
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class FallenStarRenderer<T extends FallenStar> extends EntityRenderer<T> {
public class FallenStarRenderer<T extends FallenStarEntity> extends EntityRenderer<T> {
private static final ResourceLocation TEXTURE = new ResourceLocation(ManaMod.MOD_ID,
"textures/entity/fallen_star/fallen_star.png");
private static final float SIN_45 = (float) Math.sin((Math.PI / 4D));
Expand Down Expand Up @@ -64,22 +64,22 @@ public void render(T fallenStar, float floatOne, float floatTwo, PoseStack poseS
float animSpeed = 3.0F;
poseStack.pushPose();
float f = getY(fallenStar, floatTwo);
float f1 = ((float) fallenStar.getAge() * animSpeed + floatTwo) * 3.0F;
float f1 = ((float) fallenStar.tickCount * animSpeed + floatTwo) * 3.0F;
VertexConsumer vertexconsumer = multBuff.getBuffer(RenderType.entityTranslucent(TEXTURE, true));
poseStack.pushPose();
poseStack.scale(0.45F, 0.45F, 0.45F);
poseStack.translate(0.0D, -0.25D, 0.0D);
poseStack.scale(0.35F, 0.35F, 0.35F);
poseStack.translate(0.0D, 0.25D, 0.0D);
int i = OverlayTexture.NO_OVERLAY;

poseStack.mulPose(Axis.YP.rotationDegrees(f1));
poseStack.translate(0.0D, (double) (1.5F + f / 2.0F), 0.0D);
poseStack.mulPose(new Quaternionf(((float) Math.PI / 3F), SIN_45, 0.0F, SIN_45));
poseStack.translate(0.0D, (double) (1.5F + f / 1.5F), 0.0D);
poseStack.mulPose(new Quaternionf(SIN_45, 0.0F, SIN_45, ((float) Math.PI / 6F)));
poseStack.scale(1.65F, 1.65F, 1.65F);
this.glass.render(poseStack, vertexconsumer, 6029544, i);

poseStack.scale(0.375F, 0.375F, 0.375F);
poseStack.mulPose(new Quaternionf(((float) Math.PI / 3F), SIN_45, 0.0F, SIN_45));
poseStack.mulPose(new Quaternionf(SIN_45, 0.0F, SIN_45, ((float) Math.PI / 3F)));
poseStack.mulPose(com.mojang.math.Axis.XP.rotationDegrees(f1));
poseStack.scale(0.65F, 0.65F, 0.65F);
poseStack.scale(0.25F, 0.25F, 0.25F);
this.cube.render(poseStack, vertexconsumer, 6029544, i);

poseStack.popPose();
Expand All @@ -93,12 +93,14 @@ public void render(T fallenStar, float floatOne, float floatTwo, PoseStack poseS

this.renderNameTag(fallenStar, Component.literal(
"ID:" + fallenStar.getId() +
" Age:" + fallenStar.getAge() + "/" + fallenStar.getMaxAge() +
// " PickUp:" + fallenStar.pickup +
" Age:" + fallenStar.getAge() +
" PickUp:" + fallenStar.pickup
// " Targeted:" + fallenStar.getIsTargeted() +
// " MoveToCatcher: " + fallenStar.getMoveToCatcher() +
" isFalling: " + fallenStar.isFalling
// + "This is clientThread data, needs to be server. Need Entity packet sync"
// " isFalling: " + fallenStar.isFalling +
// " moveToCatcher: " + fallenStar.getSyncMoveToCatcher() + " catcher: "
// + fallenStar.getCatcher()
+ " [CLIENT THREAD]"

), poseStack, multBuff, intOne);

Expand All @@ -108,10 +110,12 @@ public void render(T fallenStar, float floatOne, float floatTwo, PoseStack poseS
// DEV STAR DATA
// -----------------

protected void renderNameTag(T fallenStar, Component text, PoseStack pose, MultiBufferSource multBuff,
protected void renderNameTag(T fallenStar, Component text, PoseStack pose,
MultiBufferSource multBuff,
int p_114502_) {
double d0 = this.entityRenderDispatcher.distanceToSqr(fallenStar);
if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(fallenStar, d0)) {
if (net.minecraftforge.client.ForgeHooksClient.isNameplateInRenderDistance(fallenStar,
d0)) {
boolean flag = !fallenStar.isDiscrete();
float f = fallenStar.getNameTagOffsetY();
int i = "deadmau5".equals(text.getString()) ? -10 : 0;
Expand All @@ -127,22 +131,23 @@ protected void renderNameTag(T fallenStar, Component text, PoseStack pose, Multi
font.drawInBatch(text, f2, (float) i, 553648127, false, matrix4f, multBuff,
flag ? Font.DisplayMode.NORMAL : Font.DisplayMode.SEE_THROUGH, j, p_114502_);
if (flag) {
font.drawInBatch(text, f2, (float) i, -1, false, matrix4f, multBuff, Font.DisplayMode.SEE_THROUGH, 0,
font.drawInBatch(text, f2, (float) i, -1, false, matrix4f, multBuff,
Font.DisplayMode.SEE_THROUGH, 0,
p_114502_);
}

pose.popPose();
}
}

public static float getY(FallenStar fallenStar, float floatTwo) {
float f = (float) fallenStar.getAge() + floatTwo;
public static float getY(FallenStarEntity fallenStar, float floatTwo) {
float f = (float) fallenStar.tickCount + floatTwo;
float f1 = Mth.sin(f * 0.2F) / 2.0F + 0.5F;
f1 = (f1 * f1 + f1) * 0.4F;
return f1 - 1.4F;
}

public ResourceLocation getTextureLocation(FallenStar fallenStar) {
public ResourceLocation getTextureLocation(FallenStarEntity fallenStar) {
return TEXTURE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

import org.apache.commons.lang3.mutable.MutableBoolean;

import com.seabreyh.mana.entity.FallenStar;
import com.seabreyh.mana.blocks.entity.StarCatcherEntityBlock;
import com.seabreyh.mana.entity.AbstractStarEntity;
import com.seabreyh.mana.entity.FallenStarEntity;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -31,32 +35,33 @@
import net.minecraft.world.phys.Vec3;

public class FallenStarSyncData {

public boolean isFalling;
public int age;
public boolean noPhysics;
public boolean inGround;
public AbstractArrow.Pickup pickup;
public boolean isTargeted;
public StarCatcherEntityBlock catcher;
public boolean moveToCatcher;

public FallenStarSyncData() {
isFalling = true;
noPhysics = false;
}

public FallenStarSyncData copy() {
return null;
// public void setNoPhysics(boolean bool) {
// this.noPhysics = bool;
// }

public FallenStarSyncData copy() {
FallenStarSyncData data = new FallenStarSyncData();
data.noPhysics = noPhysics;
return data;
}

public void write(FriendlyByteBuf buffer) {

buffer.writeBoolean(noPhysics);
}

public void read(FriendlyByteBuf buffer) {

}

public void update(FallenStar entity) {

}

public void apply(FallenStar fallenStar) {
noPhysics = buffer.readBoolean();
}

}
Loading

0 comments on commit 58f2974

Please sign in to comment.