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

#feat: 添加了蜂群和幽灵的原型 #12

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions bbmodel/missile_bullet/0.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Made with Blockbench 4.8.3
// Exported for Minecraft version 1.17 or later with Mojang mappings
// Paste this class into your mod and generate all required imports


public class 0<T extends Entity> extends EntityModel<T> {
// This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("modid", "0"), "main");
private final ModelPart bb_main;

public 0(ModelPart root) {
this.bb_main = root.getChild("bb_main");
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition bb_main = partdefinition.addOrReplaceChild("bb_main", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));

return LayerDefinition.create(meshdefinition, 16, 16);
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {

}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
bb_main.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}
}
1 change: 1 addition & 0 deletions bbmodel/missile_bullet/missile_bullet.bbmodel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"meta":{"format_version":"4.5","model_format":"modded_entity","box_uv":true},"name":"MissileBullet","model_identifier":"0","modded_entity_version":"1.17","modded_entity_flip_y":true,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"unhandled_root_fields":{},"resolution":{"width":16,"height":16},"elements":[{"name":"cube","box_uv":true,"rescale":false,"locked":false,"render_order":"default","allow_mirror_modeling":true,"from":[-1,-1,-1],"to":[1,1,1],"autouv":1,"color":4,"origin":[0,0,0],"faces":{"north":{"uv":[2,2,4,4],"texture":0},"east":{"uv":[0,2,2,4],"texture":0},"south":{"uv":[6,2,8,4],"texture":0},"west":{"uv":[4,2,6,4],"texture":0},"up":{"uv":[4,2,2,0],"texture":0},"down":{"uv":[6,0,4,2],"texture":0}},"type":"cube","uuid":"0ad43cce-9897-9d64-e4ea-5fda6c45ff7d"}],"outliner":["0ad43cce-9897-9d64-e4ea-5fda6c45ff7d"],"textures":[{"path":"C:\\Users\\qiuzhenxuan\\Desktop\\Project\\MinecraftMod\\mindustry\\bbmodel\\missile_bullet\\missile_bullet.png","name":"missile_bullet.png","folder":"block","namespace":"","id":"0","particle":false,"render_mode":"default","render_sides":"auto","frame_time":1,"frame_order_type":"loop","frame_order":"","frame_interpolate":false,"visible":true,"mode":"bitmap","saved":true,"uuid":"44a9d5b5-1787-d722-088f-09dc550d0c66","relative_path":"../missile_bullet.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAB9JREFUOE9jZKAQMFKon2HUAIbRMGAYDQNQPhr4vAAAJpgAEX/anFwAAAAASUVORK5CYII="}]}
Binary file added bbmodel/missile_bullet/missile_bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/main/java/com/hechu/mindustry/Mindustry.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.hechu.mindustry;

import com.hechu.mindustry.client.model.MissileBulletModel;
import com.hechu.mindustry.client.renderer.blockentity.MechanicalDrillBlockEntityRenderer;
import com.hechu.mindustry.client.renderer.blockentity.PneumaticDrillBlockEntityRenderer;
import com.hechu.mindustry.client.renderer.blockentity.PowerNodeRenderer;
import com.hechu.mindustry.client.renderer.blockentity.TurretRenderer;
import com.hechu.mindustry.client.renderer.entity.BasicBulletRender;
import com.hechu.mindustry.client.renderer.entity.MissileBulletRender;
import com.hechu.mindustry.config.CommonConfig;
import com.hechu.mindustry.config.ConfigHandler;
import com.hechu.mindustry.kiwi.BlockEntityModule;
Expand Down Expand Up @@ -47,15 +50,23 @@ public Mindustry() {

@Mod.EventBusSubscriber(modid = MindustryConstants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModEvents {
@SubscribeEvent
public static void onRegisterLayers(EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(MissileBulletModel.LAYER_LOCATION, MissileBulletModel::createBodyLayer);
}

@SubscribeEvent
public static void onRegisterRenderers(EntityRenderersEvent.RegisterRenderers event) {

event.registerBlockEntityRenderer(BlockEntityModule.MECHANICAL_DRILL_BLOCK_ENTITY.get(), context -> new MechanicalDrillBlockEntityRenderer());
event.registerBlockEntityRenderer(BlockEntityModule.PNEUMATIC_DRILL_BLOCK_ENTITY.get(), context -> new PneumaticDrillBlockEntityRenderer());
event.registerBlockEntityRenderer(BlockEntityModule.TURRET_BLOCK_ENTITY.get(), TurretRenderer::new);
event.registerBlockEntityRenderer(BlockEntityModule.SWARMER_TURRET_BLOCK_ENTITY.get(), TurretRenderer::new);
event.registerBlockEntityRenderer(BlockEntityModule.SPECTRE_TURRET_BLOCK_ENTITY.get(), TurretRenderer::new);
event.registerBlockEntityRenderer(BlockEntityModule.POWER_NODE_BLOCK_ENTITY.get(), pContext -> new PowerNodeRenderer());

event.registerEntityRenderer(EntityModule.DUO.get(), DuoRenderer::new);
event.registerEntityRenderer(EntityModule.MISSILE_BULLET.get(), MissileBulletRender::new);
event.registerEntityRenderer(EntityModule.BASIC_BULLET.get(), BasicBulletRender::new);
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.hechu.mindustry.client.model;// Made with Blockbench 4.8.3
// Exported for Minecraft version 1.17 or later with Mojang mappings
// Paste this class into your mod and generate all required imports


import com.hechu.mindustry.MindustryConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.*;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;

public class MissileBulletModel<T extends Entity> extends EntityModel<T> {
// This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor
public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation(MindustryConstants.MOD_ID, "missile_bullet"), "main");
private final ModelPart body;

public MissileBulletModel(ModelPart root) {
super(RenderType::entitySolid);
this.body = root;
}

public static LayerDefinition createBodyLayer() {
MeshDefinition meshdefinition = new MeshDefinition();
PartDefinition partdefinition = meshdefinition.getRoot();

PartDefinition bb_main = partdefinition.addOrReplaceChild("main", CubeListBuilder.create().texOffs(0, 0).addBox(-1.0F, -1.0F, -1.0F, 2.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));

return LayerDefinition.create(meshdefinition, 16, 16);
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {

}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
body.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hechu.mindustry.client.renderer.blockentity;

import com.hechu.mindustry.world.level.block.entity.turrets.TurretBlockEntity;
import com.hechu.mindustry.world.level.block.entity.turrets.SwarmerTurretBlockEntity;
import com.hechu.mindustry.world.level.block.entity.turrets.TurretBlockEntityBase;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
Expand All @@ -21,15 +22,15 @@
import org.jetbrains.annotations.NotNull;

@OnlyIn(Dist.CLIENT)
public class TurretRenderer implements BlockEntityRenderer<TurretBlockEntity> {
public class TurretRenderer implements BlockEntityRenderer<TurretBlockEntityBase> {
public static final Material TURRET_LOCATION = new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation("entity/turret"));

public TurretRenderer(BlockEntityRendererProvider.Context context) {

}

@Override
public void render(@NotNull TurretBlockEntity blockEntity, float partialTick, @NotNull PoseStack poseStack, @NotNull MultiBufferSource buffer, int packedLight, int packedOverlay) {
public void render(@NotNull TurretBlockEntityBase blockEntity, float partialTick, @NotNull PoseStack poseStack, @NotNull MultiBufferSource buffer, int packedLight, int packedOverlay) {
BlockRenderDispatcher blockRenderer = Minecraft.getInstance().getBlockRenderer();

// poseStack.pushPose();
Expand All @@ -54,10 +55,10 @@ public void render(@NotNull TurretBlockEntity blockEntity, float partialTick, @N

float f2 = blockEntity.oRot + f1 * partialTick;
float f3;
if (blockEntity.targetPosX != 0 || blockEntity.targetPosY != 0 || blockEntity.targetPosZ != 0) {
f3 = (float) Mth.atan2(blockEntity.targetPosY - blockEntity.getBlockPos().getCenter().y,
Mth.sqrt((float) (Mth.square(blockEntity.targetPosX - blockEntity.getBlockPos().getCenter().x)
+ Mth.square(blockEntity.targetPosZ - blockEntity.getBlockPos().getCenter().z))));
if (blockEntity.target != null) {
f3 = (float) Mth.atan2(blockEntity.targetPos.y - blockEntity.getBlockPos().getCenter().y,
Mth.sqrt((float) (Mth.square(blockEntity.targetPos.x - blockEntity.getBlockPos().getCenter().x)
+ Mth.square(blockEntity.targetPos.z - blockEntity.getBlockPos().getCenter().z))));
// poseStack.mulPose(Axis.XN.rotationDegrees(90.0f));
} else {
f3 = 0f;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.hechu.mindustry.client.renderer.entity;

import com.hechu.mindustry.MindustryConstants;
import com.hechu.mindustry.client.model.MissileBulletModel;
import com.hechu.mindustry.world.entity.projectile.BasicBullet;
import com.hechu.mindustry.world.entity.projectile.MissileBullet;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

public class BasicBulletRender extends EntityRenderer<BasicBullet> {
private EntityModel<BasicBullet> model;

public static final ResourceLocation TEXTURE = new ResourceLocation(MindustryConstants.MOD_ID, "textures/entity/bullets/missile_bullet.png");

public BasicBulletRender(EntityRendererProvider.Context pContext) {
super(pContext);
model = new MissileBulletModel(pContext.bakeLayer(MissileBulletModel.LAYER_LOCATION));
}

/**
* Returns the location of an entity's texture.
*
* @param pEntity
*/
@Override
public ResourceLocation getTextureLocation(BasicBullet pEntity) {
return TEXTURE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.hechu.mindustry.client.renderer.entity;

import com.hechu.mindustry.MindustryConstants;
import com.hechu.mindustry.client.model.MissileBulletModel;
import com.hechu.mindustry.world.entity.projectile.MissileBullet;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;

public class MissileBulletRender extends EntityRenderer<MissileBullet> {
private EntityModel<MissileBullet> model;

public static final ResourceLocation TEXTURE = new ResourceLocation(MindustryConstants.MOD_ID, "textures/entity/bullets/missile_bullet.png");

public MissileBulletRender(EntityRendererProvider.Context pContext) {
super(pContext);
model = new MissileBulletModel(pContext.bakeLayer(MissileBulletModel.LAYER_LOCATION));
}

/**
* Returns the location of an entity's texture.
*
* @param pEntity
*/
@Override
public ResourceLocation getTextureLocation(MissileBullet pEntity) {
return TEXTURE;
}
}
6 changes: 4 additions & 2 deletions src/main/java/com/hechu/mindustry/kiwi/BlockEntityModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import com.hechu.mindustry.world.level.block.entity.PneumaticDrillBlockEntity;
import com.hechu.mindustry.world.level.block.entity.multiblock.KilnBlockEntity;
import com.hechu.mindustry.world.level.block.entity.multiblock.TestTurretMultiblockEntity;
import com.hechu.mindustry.world.level.block.entity.turrets.TurretBlockEntity;
import com.hechu.mindustry.world.level.block.entity.turrets.SpectreTurretBlockEntity;
import com.hechu.mindustry.world.level.block.entity.turrets.SwarmerTurretBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import snownee.kiwi.AbstractModule;
import snownee.kiwi.KiwiGO;
Expand All @@ -17,8 +18,9 @@ public class BlockEntityModule extends AbstractModule {
public static final KiwiGO<BlockEntityType<MechanicalDrillBlockEntity>> MECHANICAL_DRILL_BLOCK_ENTITY = blockEntity(MechanicalDrillBlockEntity::new, null, MutilBlockModule.MECHANICAL_DRILL);
public static final KiwiGO<BlockEntityType<PneumaticDrillBlockEntity>> PNEUMATIC_DRILL_BLOCK_ENTITY = blockEntity(PneumaticDrillBlockEntity::new, null, MutilBlockModule.PNEUMATIC_DRILL);
public static final KiwiGO<BlockEntityType<HealthTestBlockEntity>> HEALTH_TEST_BLOCK_ENTITY = blockEntity(HealthTestBlockEntity::new, null, MutilBlockModule.HEALTH_TEST);
public static final KiwiGO<BlockEntityType<TurretBlockEntity>> TURRET_BLOCK_ENTITY = blockEntity(TurretBlockEntity::new, null, MutilBlockModule.TURRET);
public static final KiwiGO<BlockEntityType<TestTurretMultiblockEntity>> TEST_TURRET_MULTIBLOCK_ENTITY_BLOCK_ENTITY = blockEntity(TestTurretMultiblockEntity::new, null, MutilBlockModule.TEST_TURRET_MULTIBLOCK_ENTITY_BLOCK);
public static final KiwiGO<BlockEntityType<KilnBlockEntity>> KILN_BLOCK_ENTITY = blockEntity(KilnBlockEntity::new, null, MutilBlockModule.KILN_BLOCK);
public static final KiwiGO<BlockEntityType<PowerNodeBlockEntity>> POWER_NODE_BLOCK_ENTITY = blockEntity(PowerNodeBlockEntity::new, null, BlockModule.POWER_NODE);
public static final KiwiGO<BlockEntityType<SwarmerTurretBlockEntity>> SWARMER_TURRET_BLOCK_ENTITY = blockEntity(SwarmerTurretBlockEntity::new, null, MutilBlockModule.SWARMER_TURRET);
public static final KiwiGO<BlockEntityType<SpectreTurretBlockEntity>> SPECTRE_TURRET_BLOCK_ENTITY = blockEntity(SpectreTurretBlockEntity::new, null, MutilBlockModule.SPECTRE_TURRET);
}
6 changes: 5 additions & 1 deletion src/main/java/com/hechu/mindustry/kiwi/BlockModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.hechu.mindustry.MindustryConstants;
import com.hechu.mindustry.world.level.block.Equipment.PowerNodeBlock;
import com.hechu.mindustry.world.level.block.ore.*;
import com.hechu.mindustry.world.level.block.turrets.SpectreTurretBlock;
import com.hechu.mindustry.world.level.block.turrets.SwarmerTurretBlock;
import net.minecraft.world.level.block.Block;
import snownee.kiwi.AbstractModule;
import snownee.kiwi.KiwiGO;
Expand Down Expand Up @@ -32,8 +34,10 @@ public class BlockModule extends AbstractModule {
public static final KiwiGO<Block> THORIUM_ORE_BLOCK = go(ThoriumOreBlock::new);
@KiwiModule.Name("titanium_ore")
public static final KiwiGO<Block> TITANIUM_ORE_BLOCK = go(TitaniumOreBlock::new);

private static Set<Block> blocks = null;
private static Set<String> registerName = null;

public static Set<Block> getBlocks() {
if (blocks == null) {
blocks = Arrays.stream(BlockModule.class.getFields())
Expand Down Expand Up @@ -67,7 +71,7 @@ public static Set<String> getRegisterName() {
})
.map(field -> {
KiwiModule.Name annotated = field.getAnnotation(KiwiModule.Name.class);
if (annotated == null){
if (annotated == null) {
return field.getName();
}
return annotated.value();
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/hechu/mindustry/kiwi/EntityModule.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.hechu.mindustry.kiwi;

import com.hechu.mindustry.world.entity.Turret;
import com.hechu.mindustry.world.entity.projectile.BasicBullet;
import com.hechu.mindustry.world.entity.projectile.MissileBullet;
import com.hechu.mindustry.world.entity.turrets.Duo;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
Expand All @@ -14,8 +16,18 @@ public class EntityModule extends AbstractModule {
EntityType.Builder.of(Duo::new, MobCategory.MISC)
.sized(0.5F, 0.8F)
.build("duo"));

public static final KiwiGO<EntityType<MissileBullet>> MISSILE_BULLET = go(() ->
EntityType.Builder.<MissileBullet>of(MissileBullet::new, MobCategory.MISC)
.sized(0.5F, 0.5F)
.build("missile_bullet"));
// public static final KiwiGO<EntityType<Turret>> TURRET = go(() ->
// EntityType.Builder.of(Turret::new, MobCategory.MISC)
// .sized(0.5f, 0.8f)
// .build("turret"));

public static final KiwiGO<EntityType<BasicBullet>> BASIC_BULLET = go(() ->
EntityType.Builder.<BasicBullet>of(BasicBullet::new, MobCategory.MISC)
.sized(0.5F, 0.5F)
.build("basic_bullet"));
}
6 changes: 4 additions & 2 deletions src/main/java/com/hechu/mindustry/kiwi/MutilBlockModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import com.hechu.mindustry.world.level.block.multiblock.MultiblockCoreBlock;
import com.hechu.mindustry.world.level.block.multiblock.TestMultiblockCoreBlock;
import com.hechu.mindustry.world.level.block.multiblock.TestTurretMultiblockEntityBlock;
import com.hechu.mindustry.world.level.block.turrets.TurretBlock;
import com.hechu.mindustry.world.level.block.turrets.SpectreTurretBlock;
import com.hechu.mindustry.world.level.block.turrets.SwarmerTurretBlock;
import net.minecraft.world.level.block.Block;
import snownee.kiwi.AbstractModule;
import snownee.kiwi.KiwiGO;
Expand All @@ -27,7 +28,8 @@ public class MutilBlockModule extends AbstractModule {
public static final KiwiGO<Block> MECHANICAL_DRILL = go(MechanicalDrillBlock::new);
public static final KiwiGO<Block> PNEUMATIC_DRILL = go(PneumaticDrillBlock::new);
public static final KiwiGO<Block> HEALTH_TEST = go(HealthTestBlock::new);
public static final KiwiGO<Block> TURRET = go(TurretBlock::new);
public static final KiwiGO<Block> SWARMER_TURRET = go(SwarmerTurretBlock::new);
public static final KiwiGO<Block> SPECTRE_TURRET = go(SpectreTurretBlock::new);
public static final KiwiGO<Block> TEST_MULTIBLOCK_CORE = go(TestMultiblockCoreBlock::new);
public static final KiwiGO<Block> TEST_TURRET_MULTIBLOCK_ENTITY_BLOCK = go(TestTurretMultiblockEntityBlock::new);
public static final KiwiGO<Block> KILN_BLOCK = go(KilnBlock::new);
Expand Down
Loading
Loading