-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Sentry Mode ( temporarily for MarkThreeSuit )
todo: global model + rotation
- Loading branch information
Showing
11 changed files
with
269 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/mc/duzo/timeless/client/render/entity/IronManEntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mc.duzo.timeless.client.render.entity; | ||
|
||
import net.minecraft.client.render.LightmapTextureManager; | ||
import net.minecraft.client.render.RenderLayer; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import net.minecraft.client.render.entity.EntityRendererFactory; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.RotationAxis; | ||
|
||
import mc.duzo.timeless.suit.client.render.SuitModel; | ||
import mc.duzo.timeless.suit.ironman.IronManEntity; | ||
import mc.duzo.timeless.suit.ironman.IronManSuit; | ||
|
||
public class IronManEntityRenderer extends EntityRenderer<IronManEntity> { | ||
public IronManEntityRenderer(EntityRendererFactory.Context ctx) { | ||
super(ctx); | ||
} | ||
|
||
@Override | ||
public void render(IronManEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { | ||
super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light); | ||
|
||
IronManSuit suit = entity.getSuit(); | ||
SuitModel model = suit.toClient().model(); | ||
VertexConsumer consumer = vertexConsumers.getBuffer(RenderLayer.getEntityTranslucent(model.texture())); | ||
|
||
matrices.push(); | ||
|
||
matrices.translate(0, 3, 0); | ||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(entity.getYaw())); // todo - rotation is wrong | ||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180)); | ||
|
||
model.render(entity, tickDelta, matrices, consumer, light, 1, 1, 1, 1); // todo - the model appears to be global, meaning all transforms to one get applied to all. needs fixing ASAP | ||
|
||
if (model.emission().isPresent()) { | ||
VertexConsumer emissionConsumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutoutNoCullZOffset(model.emission().get(), true)); | ||
model.render(entity, tickDelta, matrices, emissionConsumer, LightmapTextureManager.MAX_LIGHT_COORDINATE, 1, 1, 1, 1); | ||
} | ||
|
||
matrices.pop(); | ||
} | ||
|
||
@Override | ||
public Identifier getTexture(IronManEntity entity) { | ||
return entity.getSuit().toClient().texture(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/main/java/mc/duzo/timeless/suit/ironman/IronManEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package mc.duzo.timeless.suit.ironman; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.data.DataTracker; | ||
import net.minecraft.entity.data.TrackedData; | ||
import net.minecraft.entity.data.TrackedDataHandlerRegistry; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Arm; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
import mc.duzo.timeless.registry.Register; | ||
import mc.duzo.timeless.suit.SuitRegistry; | ||
|
||
public class IronManEntity extends LivingEntity { // todo - PathAwareEntity for sentry mode | ||
private static final TrackedData<String> SUIT = DataTracker.registerData(IronManEntity.class, TrackedDataHandlerRegistry.STRING); | ||
|
||
public IronManEntity(EntityType<? extends IronManEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
public IronManEntity(World world, IronManSuit suit) { | ||
this(Register.Entities.IRON_MAN, world); | ||
|
||
this.setSuit(suit); | ||
} | ||
public IronManEntity(World world, IronManSuit suit, BlockPos pos, float yaw, float pitch) { | ||
this(world, suit); | ||
|
||
this.refreshPositionAndAngles(pos.getX(), pos.getY(), pos.getZ(), yaw, pitch); | ||
} | ||
public IronManEntity(World world, IronManSuit suit, ServerPlayerEntity source) { | ||
this(world, suit, source.getBlockPos(), source.getYaw(), source.getPitch()); | ||
} | ||
|
||
public IronManSuit getSuit() { | ||
return (IronManSuit) SuitRegistry.REGISTRY.get(new Identifier(this.dataTracker.get(SUIT))); | ||
} | ||
private void setSuit(String string) { | ||
this.dataTracker.set(SUIT, string); | ||
} | ||
private void setSuit(Identifier id) { | ||
this.setSuit(id.toString()); | ||
} | ||
private void setSuit(IronManSuit suit) { | ||
this.setSuit(suit.id()); | ||
} | ||
|
||
@Override | ||
public ActionResult interact(PlayerEntity player, Hand hand) { | ||
boolean success = this.getSuit().getSet().wear(player); | ||
|
||
if (success) { | ||
this.discard(); | ||
} | ||
|
||
return success ? ActionResult.SUCCESS : ActionResult.FAIL; | ||
} | ||
|
||
@Override | ||
protected void initDataTracker() { | ||
super.initDataTracker(); | ||
|
||
this.dataTracker.startTracking(SUIT, ""); | ||
} | ||
|
||
@Override | ||
public void writeCustomDataToNbt(NbtCompound nbt) { | ||
super.writeCustomDataToNbt(nbt); | ||
|
||
nbt.putString("Suit", this.dataTracker.get(SUIT)); | ||
} | ||
|
||
@Override | ||
public void readCustomDataFromNbt(NbtCompound nbt) { | ||
super.readCustomDataFromNbt(nbt); | ||
|
||
this.setSuit(nbt.getString("Suit")); | ||
} | ||
|
||
@Override | ||
public Iterable<ItemStack> getArmorItems() { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public ItemStack getEquippedStack(EquipmentSlot slot) { | ||
return ItemStack.EMPTY; | ||
} | ||
|
||
@Override | ||
public void equipStack(EquipmentSlot slot, ItemStack stack) { | ||
|
||
} | ||
|
||
@Override | ||
public Arm getMainArm() { | ||
return Arm.RIGHT; | ||
} | ||
} |
Oops, something went wrong.