Jump to content

[1.20.4] make custom entity block Model using two or more textures


Recommended Posts

i wanna animate a custome door  the FallingEntityBlock thing stucks so im trying other thing

now i made up a custome entity whit the shape of the door the problem is its not applying the two textures the last declared texture overwrites the former and apply it to all the faces 

It must look like this whit the door texture for the faces and the stripped oak for the door borders 

customedoorentity.png

 

But the resulting is like this 

The second texture layer1 overwriting layer0 

 

//panel_ghost_model.java

Spoiler

				
			package mercmod.entity;
		
		import com.mojang.blaze3d.vertex.PoseStack;
		import com.mojang.blaze3d.vertex.VertexConsumer;
		import net.minecraft.resources.ResourceLocation;
		import org.joml.Matrix3f;
		import org.joml.Matrix4f;
		import com.mojang.math.Axis;
		import net.minecraft.client.renderer.MultiBufferSource;
		import net.minecraft.client.renderer.RenderType;
		import net.minecraft.client.renderer.entity.EntityRenderer;
		import net.minecraft.client.renderer.entity.EntityRendererProvider;
		import net.minecraft.client.renderer.texture.OverlayTexture;
		import net.minecraft.util.Mth;
		import net.minecraftforge.api.distmarker.Dist;
		import net.minecraftforge.api.distmarker.OnlyIn;
		
		@OnlyIn(Dist.CLIENT)
		public abstract class panel_ghost_model<T extends door_ghost2> extends EntityRenderer<T> {
		
		public static final ResourceLocation LAYER0 = new ResourceLocation("minecraft", "textures/block/oak_door_top.png");
		public static final ResourceLocation LAYER1 = new ResourceLocation("minecraft", "textures/block/stripped_oak_log.png");
		
		
		public panel_ghost_model(EntityRendererProvider.Context contex) {
		super(contex);
		}
		
		public void render(T entity, float p_225623_2_, float p_225623_3_, PoseStack matrixstack,
		MultiBufferSource irendertypebuffer, int p_225623_6_) {
		// public void render(T entity, float p_225623_2_, float p_225623_3_,
		// MatrixStack matrixstack, IRenderTypeBuffer irendertypebuffer, int
		// p_225623_6_) {
		
		int tick = entity.tickCount;
		int i = 0;
		float f = 0.0F;
		float f1 = 0.5F;
		float f2 = 0.0F;
		float f3 = 0.15625F;
		float f4 = 0.0F;
		float f5 = 0.15625F;
		float f6 = 0.15625F;
		float f7 = 0.3125F;
		float f8 = 0.05625F;
		float f9 = 0.0F;// (float)entity.shakeTime - p_225623_3_;
		float scale = 0.03125F;//0.03F; // 1 is like one chunck
		
		matrixstack.pushPose();
		matrixstack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(p_225623_3_, entity.yRotO, entity.getYRot()) - 90.0F ));//
		matrixstack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(p_225623_3_, entity.xRotO, entity.getXRot())));
		
		if (f9 > 0.0F) {
		float f10 = -Mth.sin(f9 * 3.0F) * f9;
		matrixstack.mulPose(Axis.ZP.rotationDegrees(f10));
		}
		
		matrixstack.mulPose(Axis.XP.rotationDegrees(0.0F));// rotation del modelo
		
		matrixstack.scale(scale, scale, scale);
		matrixstack.translate(0.0D, 0.0D, 0.0D);
		//VertexConsumer layer0 = irendertypebuffer.getBuffer( RenderType.entityCutout(this.getTextureLocation(entity) ));
		
		//######## ········######## ········ ######## ········ ######## ········ ######## ········
		//textures
		VertexConsumer layer0 = irendertypebuffer.getBuffer( RenderType.entityCutout(LAYER0 ));
		VertexConsumer layer1 = irendertypebuffer.getBuffer( RenderType.entityCutout(LAYER1 ));
		
		//VertexConsumer layer0 = irendertypebuffer.getBuffer( RenderType.eyes(entity.layer0) );//red eyes glow
		//.getBuffer(RenderType.eyes(this.getTextureLocation(entity)));//red eyes glow
		//.entityCutoutNoCull(this.getTextureLocation(entity), false)
		//.entityCutoutNoCull(this.getTextureLocation(entity)
		//.entitySolid(this.getTextureLocation(entity)
		//.entityTranslucentEmissive(this.getTextureLocation(entity)
		//.entityCutout(this.getTextureLocation(entity)
		PoseStack.Pose matrixstack$entry = matrixstack.last();
		
		Matrix4f matrix4f = matrixstack$entry.pose();
		Matrix3f matrix3f = matrixstack$entry.normal();
		
		Matrix4f matrix4v = matrixstack$entry.pose();
		Matrix3f matrix3v = matrixstack$entry.normal();
		
		
		//if (entity.visible)
		{ //
		
		//full aligned panel
		//if ( 8 < 3)
		{
		
		//Main faces of the block whit the door texture
		// el que se ve desde adelante x
		this.vertex(matrix4v, matrix3v, layer0, 16, 16, -16, 0.00F, 0.00F, -1, 0, 0, p_225623_6_);
		this.vertex(matrix4v, matrix3v, layer0, 16, 16, 16, 1.00F, 0.00F, -1, 0, 0, p_225623_6_);
		this.vertex(matrix4v, matrix3v, layer0, 16, -16, 16, 1.00F, 1.00F, -1, 0, 0, p_225623_6_);
		this.vertex(matrix4v, matrix3v, layer0, 16, -16, -16, 0.00F, 1.00F, -1, 0, 0, p_225623_6_);
		
		// el que se desde atraz x
		this.vertex(matrix4v, matrix3v, layer0, 10, -16, -16, 0.00F, 1.00F, -1, 0, 0, p_225623_6_);
		this.vertex(matrix4v, matrix3v, layer0, 10, -16, 16, 1.00F, 1.00F, -1, 0, 0, p_225623_6_);
		this.vertex(matrix4v, matrix3v, layer0, 10, 16, 16, 1.00F, 0.00F, -1, 0, 0, p_225623_6_);
		this.vertex(matrix4v, matrix3v, layer0, 10, 16, -16, 0.00F, 0.00F, -1, 0, 0, p_225623_6_);
		
		//Border Textures
		// el que se ve desde arriba y
		this.vertex(matrix4f, matrix3f, layer1, 16, 16, 16, 1.00F, 0.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 16, 16, -16, 0.00F, 0.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, 16, -16, 0.00F, 0.1875F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, 16, 16, 1.00F, 0.1875F, 0, 0, 0, p_225623_6_);
		
		// el que se ve desde abajo y
		this.vertex(matrix4f, matrix3f, layer1, 16, -16, -16, 0.0F, 1.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 16, -16, 16, 1.00F, 1.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, -16, 16, 1.00F, 0.8125F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, -16, -16, 0.0F, 0.8125F, 0, 0, 0, p_225623_6_);
		
		// el que se ve desde izquierda east z
		this.vertex(matrix4f, matrix3f, layer1, 10, -16, -16, 0.1875F, 1.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, 16, -16, 0.1875F, 0.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 16, 16, -16, 0.00F, 0.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 16, -16, -16, 0.00F, 1.00F, 0, 0, 0, p_225623_6_);
		
		// el que se ve desde derecha west z
		this.vertex(matrix4f, matrix3f, layer1, 16, -16, 16, 1.00F, 1.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 16, 16, 16, 1.00F, 0.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, 16, 16, 0.8125F, 0.00F, 0, 0, 0, p_225623_6_);
		this.vertex(matrix4f, matrix3f, layer1, 10, -16, 16, 0.8125F, 1.00F, 0, 0, 0, p_225623_6_);
		}
		}
		
		matrixstack.popPose();
		super.render(entity, p_225623_2_, p_225623_3_, matrixstack, irendertypebuffer, p_225623_6_);
		}
		
		public void vertex(Matrix4f matrix4f, Matrix3f matrix3f, VertexConsumer layer, int x, int y,
		int z, float layerx, float layery, int p_113834_, int p_113835_, int p_113836_,
		int p_113837_) {
		layer.vertex(matrix4f, (float) x, (float) y, (float) z).color(255, 255, 255, 255)
		.uv(layerx, layery).overlayCoords(OverlayTexture.NO_OVERLAY).uv2(p_113837_)
		.normal(matrix3f, (float) p_113834_, (float) p_113836_, (float) p_113835_).endVertex();
		}
		}				
			

 

//panel_ghost_renderer.java

Spoiler

package mercmod.entity;

import mercmod.mercmod;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.LightLayer;

public class panel_ghost_renderer extends panel_ghost_model<door_ghost2> {
//public static final ResourceLocation TEXTURE = new ResourceLocation(mercmod.MOD_ID, "textures/entity/mercenary_arrow.png");



//For the test i move the textures to the model
//but the must come from the entity who takes them from the block



//public static final ResourceLocation TEXTURE = new ResourceLocation(mercmod.MOD_ID, "textures/entity/oak_door_top.png");
public static final ResourceLocation LAYER0 = new ResourceLocation("minecraft", "textures/block/oak_door_top.png");
public static final ResourceLocation LAYER1 = new ResourceLocation("minecraft", "textures/block/stripped_oak_log.png");
public static final ResourceLocation TRANSPARENT = new ResourceLocation(mercmod.MOD_ID, "textures/entity/transparent.png");
private final boolean fullBright;

public panel_ghost_renderer(EntityRendererProvider.Context context) {
super(context);
this.fullBright = false;
}

@Override
public ResourceLocation getTextureLocation(door_ghost2 ghost) {
if (ghost.tickCount < 2 ){
return TRANSPARENT;
}

return LAYER0;
}

public ResourceLocation getLayer0(door_ghost2 ghost) {
if (ghost.tickCount < 2 ){
return TRANSPARENT;
}
return LAYER0;
}

public ResourceLocation getLayer1(door_ghost2 ghost) {
if (ghost.tickCount < 2 ){
return TRANSPARENT;
}
return LAYER1;
}

Spoiler

 






@Override
protected int getBlockLightLevel(door_ghost2 ie, BlockPos pos) {
return this.fullBright ? 15 : super.getBlockLightLevel(ie, pos);
}

@Override
protected int getSkyLightLevel(door_ghost2 ie, BlockPos pos) {
return ie.level().getBrightness(LightLayer.SKY, pos);
//return 15;
}

}


 

//door_ghost2.java

Spoiler

package mercmod.entity;


import com.mojang.blaze3d.vertex.VertexConsumer;
import mercmod.blocks.PanelInit;
import mercmod.blocks.classes.door;
import mercmod.blocks.classes.trampilla;
import mercmod.util.Postate;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.FallingBlockEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

import java.util.*;
import java.util.function.Predicate;

//#################### #################### #################### #################### ####################
public class door_ghost2 extends Entity {

//public static final ResourceLocation TEXTURE = new ResourceLocation(mercmod.MOD_ID, "textures/entity/oak_door_top.png");
public ResourceLocation LAYER0 = new ResourceLocation("minecraft", "textures/block/oak_door_top.png");
public ResourceLocation LAYER1 = new ResourceLocation("minecraft", "textures/block/stripped_oak_log.png");


private static final EntityDataAccessor<BlockPos> TARGET_BLOCK =
SynchedEntityData.defineId(door_ghost2.class, EntityDataSerializers.BLOCK_POS);

private static final EntityDataAccessor<Long> START_TIME =
SynchedEntityData.defineId(door_ghost2.class, EntityDataSerializers.LONG);

private static final EntityDataAccessor<Boolean> ROT_DIR =
SynchedEntityData.defineId(door_ghost2.class, EntityDataSerializers.BOOLEAN);
private static final EntityDataAccessor<Boolean> HINGE =
SynchedEntityData.defineId(door_ghost2.class, EntityDataSerializers.BOOLEAN);


private static final EntityDataAccessor<Float> START_ROT_X =
SynchedEntityData.defineId(door_ghost2.class, EntityDataSerializers.FLOAT);
private static final EntityDataAccessor<Float> START_ROT_Y =
SynchedEntityData.defineId(door_ghost2.class, EntityDataSerializers.FLOAT);


private int tick;
//private ItemEntity target_entity = null;
private Level warudo;
private long start_time = 0L;

private float rot_dir = 1.0F;

public Boolean hinge = false;

public Boolean up = false;

public Boolean down = false;

private float start_rot_x = 0.0F;
private float start_rot_y = 0.0F;

private boolean initialize = false;

private BlockPos target_block = null;
private Postate target_postate = null;
private Set<Postate> target_blocks = new HashSet<Postate>();
private FallingBlockEntity fallingblk = null;


private boolean remove_the_block = false;
private boolean reset_the_block = false;



private boolean open = false;


// #################### #################### ####################
//Empty Constructor
public door_ghost2(EntityType<?> w_entity, Level warudo) {
super(w_entity, warudo);
this.start_time = System.currentTimeMillis();
this.warudo = warudo;
}

// #################### #################### ####################
public door_ghost2(EntityType<?> w_entity, Level warudo, BlockPos pos, boolean open) {
super(w_entity, warudo);
//System.out.println("puerta_watcher_entity()");
this.start_time = System.currentTimeMillis();
this.warudo = warudo;
this.target_block = pos;
this.open = open;
this.target_postate = new Postate(warudo, pos);

this.entityData.set(TARGET_BLOCK, this.target_block);
this.start_time = System.currentTimeMillis();
this.entityData.set( START_TIME ,this.start_time);

this.align_ghost( this.target_postate );

this.entityData.set( ROT_DIR , (this.rot_dir > 0.0F)? true : false );
this.entityData.set( START_ROT_X , this.start_rot_x );
this.entityData.set( START_ROT_Y , this.start_rot_y );
this.entityData.set( HINGE , this.hinge );

if( this.target_postate.getBlock() instanceof door ){
door dooor = (door)this.target_postate.getBlock();
LAYER0 = dooor.get_LAYER0();
LAYER1 = dooor.get_LAYER1();
}


//this.setPos( pos.getCenter() );

//this.target_block = this.entityData.get(TARGET_BLOCK);
//fallingblk = FallingBlockEntity.fall(warudo, this.target_block.above(), this.target_postate.getBlockState() );
//fallingblk.setNoGravity(true);
//warudo.addFreshEntity(fallingblk);
//this.fix_door();
}

public void align_ghost(Postate door){
if(door == null){return;}

Direction facing = door.get_FACING();
this.hinge = door.is_HINGE_LEFT();
this.up = door.get_UP();
this.down = door.get_DOWN();

if(facing == null){return;}

Double x = 0.0D;
Double y = 0.0D;
Double z = 0.0D;

if( !up && !down ) {
this.start_rot_x = 0.0F;
this.start_rot_y = 0.0F;

y = 0.0D;
switch (facing) {
default:
x = 0.0D;
z = 0.0D;
break;
case NORTH:
this.start_rot_y = (hinge)? 0.0F : 0.0F;
this.rot_dir = (hinge)? 1.0F : -1.0F;
x = (hinge)? -0.40625D : 0.40625D;
z = 0.40625D;
break;
case SOUTH:
this.start_rot_y = (hinge)? 180F : 180.0F;
this.rot_dir = (hinge)? 1.0F : -1.0F;
x = (hinge)? 0.40625D : -0.40625D;
z = -0.40625D;
break;

case EAST:
this.start_rot_y = (hinge)? -90F : -90.0F;
this.rot_dir = (hinge)? 1.0F : -1.0F;
z = (hinge)? -0.40625D : 0.40625D;
x = -0.40625D;
break;

case WEST:
this.start_rot_y = (hinge)? 90F : 90.0F;
this.rot_dir = (hinge)? 1.0F : -1.0F;
z = (hinge)? 0.40625D : -0.40625D;
x = 0.40625D;
break;


}
}

//this.start_rot_y = 180F;
//this.rot = 1;

Vec3 vd = this.target_block.getCenter().add( x + 0.0001D, y + 0.0001D , z + 0.0001D );
this.setPos(vd);

System.out.println(",,,,,,,,");
System.out.println("facing " + facing);
System.out.println("hinge " + hinge);
System.out.println("rot " + rot_dir);
System.out.println("this.start_rot_y " + this.start_rot_y);
System.out.println(",,,,,,,,");


}

public void open_door(Postate pstate){
DoorHingeSide hinge = pstate.get_HINGE();
Direction facing = pstate.get_FACING();

switch(facing){
default:
//Du nutting
break;

case NORTH:
facing = (hinge == DoorHingeSide.LEFT)? Direction.EAST : Direction.WEST;
hinge = (hinge == DoorHingeSide.LEFT)? DoorHingeSide.RIGHT : DoorHingeSide.LEFT;
break;
case SOUTH:
facing = (hinge == DoorHingeSide.LEFT)? Direction.WEST : Direction.EAST;
hinge = (hinge == DoorHingeSide.LEFT)? DoorHingeSide.RIGHT : DoorHingeSide.LEFT;
break;
case EAST:
facing = (hinge == DoorHingeSide.LEFT)? Direction.SOUTH : Direction.NORTH;
hinge = (hinge == DoorHingeSide.LEFT)? DoorHingeSide.RIGHT : DoorHingeSide.LEFT;
break;
case WEST:
facing = (hinge == DoorHingeSide.LEFT)? Direction.NORTH : Direction.SOUTH;
hinge = (hinge == DoorHingeSide.LEFT)? DoorHingeSide.RIGHT : DoorHingeSide.LEFT;
break;


}

pstate.set_FACING(facing);
pstate.set_HINGE(hinge);
pstate.setBlock(2);
}





// #################### #################### ####################
public static door_ghost2 get(Level warudo, BlockPos pos, boolean open) {

door_ghost2 ghost = find_ghost_around(warudo, pos);
if (ghost != null) {
return ghost;
}

if (ghost == null) {
if (!warudo.isClientSide()) {
ghost = new door_ghost2(EntityInit.DOOR_GHOST2.get(), warudo, pos, open);
warudo.addFreshEntity(ghost);
return ghost;
}
}
return null;
}


// ########## ########## ########## ##########
// this is just to avoid spawning multiple entities inside same block
// @Override
public static door_ghost2 find_ghost_around(Level warudo, BlockPos pos) {
AABB bb = new AABB(pos);

List<door_ghost2> list;// = new List<reset_swimming_pose_ghost>();
Predicate<? super Entity> cosa = target -> (target instanceof door_ghost2);//

list = warudo.getEntitiesOfClass(door_ghost2.class, bb);
for (door_ghost2 ghost : list) {
return ghost;
}

return null;
}



// #################### #################### ####################
public void kill_redundant_entityes() {
Set<Entity> lista = new HashSet<Entity>();
AABB box = null;

for (Postate cursor : this.target_blocks) {
box = new AABB(cursor.get_blockpos());//.inflate(1.0D, 1.0D, 1.0D);
lista.addAll(this.level().getEntities(this, box));
}

for (Entity coso : lista) {
if (coso instanceof door_ghost2) {
door_ghost2 cosa = (door_ghost2) coso;
if (cosa != this) {
cosa.kill();
}
}
if (coso instanceof FallingBlockEntity) {
if (coso != this) {
coso.kill();
}
}
}
}

// #################### #################### ####################
//conditions to end this entity
private void mustdie() {
boolean kill = false;

//life limit
if( !kill && this.tick > 600) {
kill = true;
}

//check if the block is valid;
/*
if( !kill ) {
this.target_postate = check_if_valid(this.target_block);
if( this.target_postate == null){
kill = true;
}
}*/

if(kill){
if( fallingblk != null ){
fallingblk.discard();
}

for( Postate cursor : this.target_blocks ){
cursor.kill_FallingBlocks();
}

//open_door(this.target_postate);

this.discard();
this.kill();
}
}

private void initialize(){
this.warudo = this.level();

this.target_block = this.entityData.get(TARGET_BLOCK);
this.start_time = this.entityData.get(START_TIME);

this.target_postate = new Postate(this.warudo, this.target_block);
//this.setPos( this.target_block.getCenter() );

this.kill_redundant_entityes();
this.target_blocks.addAll( this.check_surroundings(this.target_postate) );
this.target_blocks.add(this.target_postate);

//this.align_ghost(this.target_postate);

this.rot_dir = (this.entityData.get( ROT_DIR ))? 1.0F: -1.0F;
this.hinge = (this.entityData.get( HINGE ));

this.start_rot_x = this.entityData.get( START_ROT_X );
this.start_rot_y = this.entityData.get( START_ROT_Y );

if( this.target_postate.getBlock() instanceof door ){
door dooor = (door)this.target_postate.getBlock();
//LAYER0 = dooor.get_LAYER0();
//LAYER1 = dooor.get_LAYER1();
}

String world = (this.warudo.isClientSide())? "Mundo Local" : "Mundo Remoto";
System.out.println( "[ Creating ], " + world + " ("+ target_blocks.size() +")" );
System.out.println(this.target_block);
System.out.println(this.start_time);
System.out.println(this.position());
System.out.println("---------------");

this.initialize = true;
}


public int get_real_tick(){
return (int)((System.currentTimeMillis() - this.start_time) / 50) ;
}


// #################### #################### ####################
@Override
public void tick() {
if(!this.initialize){this.initialize();}
this.mustdie();
int rtick = this.get_real_tick();
float rottatio = 0.0F;

String world = (this.warudo.isClientSide())? "Local side" : "Server side";


if(!remove_the_block && rtick > 3 ){

Postate transparent = new Postate(this.warudo, this.target_block);
transparent.setBlockState( PanelInit.TRANSPARENT_DOOR.get() );

transparent.set_FACING( this.target_postate.get_FACING() );
transparent.set_HINGE( this.target_postate.get_HINGE() );
transparent.set_UP( this.target_postate.get_UP() );
transparent.set_DOWN( this.target_postate.get_DOWN() );
transparent.set_WATERLOGGED( this.target_postate.get_WATERLOGGED() );
transparent.setBlock(10);

remove_the_block = true;
}


//for( Postate cursor : this.target_blocks )

{
{
//[0.0,0.0, 0.0, 6.0, 9.0, 12.0, 30.0, 36.0, 42.0, 72.0, 81.0, 81.0, 90.0, 90.0, 90.0]

if( this.warudo.isClientSide() )
{
//float parabola =
rottatio = Math.min( 90.0F, (0 + (3 * ((rtick-1) * (1 * ((rtick)/(3)))))) );
rottatio = Math.max( 0.0F, rottatio);
this.setYRot( this.start_rot_y + ( rottatio * this.rot_dir) );
//this.setYRot( 180F );
System.out.println(world + "[" + rtick + "], " + " (" + this.getYRot() + ")");
}


if(!reset_the_block && rtick > 14){
open_door(this.target_postate);
reset_the_block = true;
}


//fbe.lerpTo( ps.x,ps.y + 1, ps.z + (this.tick * 0.05F) , 45.0f, 45.0f, 1 );
/*
CompoundTag NBT = fbe.serializeNBT();
//System.out.println(NbtUtils.prettyPrint(NBT));

if(NBT.contains("Rotation")){

ListTag listoftags = NBT.getList("Rotation", 2);// blockdata contains pos


if(this.tick < 10) {

//listoftags. (0, 45F);

listoftags = new ListTag();
listoftags.add(FloatTag.valueOf(90.0F));
listoftags.add(FloatTag.valueOf(90.0F));

//System.out.println("alt " + listoftags.getFloat(0) + "," + listoftags.getFloat(1));

NBT.put("Rotation", listoftags);
//fbe.deserializeNBT(NBT);
fbe.save(NBT);
//fbe.load();
NBT = fbe.serializeNBT();



}
else {
//System.out.println( "org " + listoftags.getFloat(0) + "," +listoftags.getFloat(1) );
}

//System.out.println(NbtUtils.prettyPrint(NBT));
*/
}

/*
"Rotation" : list<TAG_Float>[2] [
1456.0f,
1456.0f
],
"Rotation" : list<TAG_Float>[2] [
240.0f,
240.0f
],


//System.out.println( fbe.getYRot() );
}else{
//System.out.println( "{null}" );
}*/
}





/*
if ( tick > 2 && (tick % 3 == 0) && !this.level().isClientSide ) {
// reset position to match target entity
int level = 0;
boolean subopen;

if( this.target_postate == null){
return;
}

level = this.target_postate.get_AGE_3();

if(level == 0) {
this.playSound( ( (this.open)? SoundEvents.WOODEN_DOOR_OPEN : SoundEvents.WOODEN_DOOR_CLOSE ), 0.5F, 0.5F );
}

if (this.open) {
subopen = (level > 1)? true:false;
level++;
} else {
subopen = (level < 2)? false:true;
level--;
}

level = ( level < 0 )? 0 : (( level > 3 )? 3 : level );

for( Postate cursor : this.target_blocks ) {
cursor.set_AGE_3( level );
cursor.set_OPEN( subopen );
cursor.setBlock(10);
}

if(level == 0) {
this.playSound( ( (this.open)? SoundEvents.WOODEN_DOOR_OPEN : SoundEvents.WOODEN_DOOR_CLOSE ), 0.5F, 0.5F );
}
if (level > 2 && open) {
this.kill();
return;
}

if (level < 1 && !open) {
this.kill();
return;
}
}
*/

this.tick++;
}



// ########## ########## ########## ##########
//buscar en los alrededores todos los bloques
//que cumplan la condicion
public ArrayList<Postate> check_surroundings(Postate center) {
ArrayList<Postate> lista = new ArrayList<Postate>();

Set<BlockPos> sub_pos_list_A = new HashSet<BlockPos>();
Set<BlockPos> sub_pos_list_B = new HashSet<BlockPos>();
Set<BlockPos> cheked_blocks = new HashSet<BlockPos>();

if (check_if_valid(center.get_blockpos()) != null) {
lista.add(center);
}
cheked_blocks.add(center.get_blockpos());
sub_pos_list_A.add(center.get_blockpos());
// sub_pos_list_B.add(center.pos);

while (sub_pos_list_A.size() > 0) {
// System.out.println(String.format("revizar %1$s blockes",
// sub_pos_list_A.size()));

for (BlockPos cursor : sub_pos_list_A) {
sub_pos_list_B.addAll(check_surroundings_pos_6(cursor));
}

sub_pos_list_A.clear();
for (BlockPos cursor : sub_pos_list_B) {

if (cheked_blocks.add(cursor)) {// si ya se a revizado antes ignorelo
Postate sub_postate = check_if_valid(cursor);
if (sub_postate != null) {
lista.add(sub_postate);
sub_pos_list_A.add(cursor);
}
}

}
sub_pos_list_B.clear();
}

return lista;
}

// ########## ########## ########## ##########
public Postate check_if_valid(BlockPos pos) {
BlockState blkstate = this.warudo.getBlockState(pos);

if (blkstate.getBlock() instanceof door || blkstate.getBlock() instanceof trampilla)
{
Postate postate = new Postate(this.warudo, pos);
postate.setBlockState(blkstate);
return postate;
}

return null;
}

// ########## ########## ########## ##########
public ArrayList<BlockPos> check_surroundings_pos_6(BlockPos center) {
ArrayList<BlockPos> sub_lista = new ArrayList<BlockPos>();

sub_lista.add(center.above());
sub_lista.add(center.below());
sub_lista.add(center.east());
sub_lista.add(center.west());
sub_lista.add(center.north());
sub_lista.add(center.south());

return sub_lista;
}




// #################### #################### ####################
@Override
protected void defineSynchedData() {
//this.entityData.define(FACING, Direction.DOWN);
//this.entityData.define(DATA_ID_OWNER_UUID, Optional.empty());
//this.entityData.define(TYPE, 0);
this.entityData.define(TARGET_BLOCK, new BlockPos(0, -70, 0));
this.entityData.define(START_TIME, 0L );
this.entityData.define(ROT_DIR,true );
this.entityData.define(HINGE,true );
this.entityData.define(START_ROT_X,0.0F );
this.entityData.define(START_ROT_Y,0.0F );

// this.entityData.define(TARGET_STATE, Optional.empty() );//
// Blocks.AIR.defaultBlockState() );

}


@Override
protected void readAdditionalSaveData(CompoundTag p_70037_1_) {
// TODO Auto-generated method stub
}

@Override
protected void addAdditionalSaveData(CompoundTag p_213281_1_) {
// TODO Auto-generated method stub
}

// comunications
// in ExplosiveArrowEntity.java
@Override
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return new ClientboundAddEntityPacket(this);
}
// #################### #################### ####################
// #################### #################### ####################
}

 

Is this matrixstack thing was codec way it only accepts one texture ?

does i misunderstand the matrixstack thing and the way of using two texture is different ?

 

 

 

 



 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • That looks pretty cool, nice!   Sure, so looking at that JSON file I posted, I pretty much made a record class for each "custom" data type in that JSON. The Input is a good example of why ``` "inputs": [ { "ingredient": { "item": "relativedimensions:aberrant_shard" }, "count": 8 } ], ``` So here's the inputs, it's an array, which we can use the Codec builder's builder.listOf to define an array. Each Item is of some arbitrary object with keys "ingredient" (which we know is an Ingredient) and a "count" which is an int. You don't have to have an intermediate class to map this to necessarily but I found that it's just easier to see the data that way, hence the 'ParticleReboundIngredient' represents one of these inputs.   Let me know if that makes sense or not. 
    • Pretty much, although all the recipes im planning to make on it are shapeless. The idea is that the chamber uses energy to "fuse" the items in each of the center slots together, in this case an ingot. The two slots at the sides are fuel. (A special kind of wood in this case). Here is an image of the interface just for reference (The center slot is the output)   As for the code- Can you elaborate a little bit on it? Seeing three different record classes has confused me a lot. (Elaborate as in why make them in three different records. I understand the code itself more or less)
    • Hello im trying to make a mod and the past few days GSON has almost killed me, when i export the mod and then launch it through minecraft launcher i get java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement; i have literally tried everything here is my build config   dependencies { minecraft("com.mojang:minecraft:1.8.9") mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+") shadowImpl("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") { isTransitive = false exclude(module = "gson") } shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false exclude(module = "gson") } annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT") shadowImpl("org.javassist:javassist:3.15.0-GA") { isTransitive = false exclude(module = "gson") } shadowImpl("com.neovisionaries:nv-i18n:1.28") { isTransitive = false exclude(module = "gson") } shadowImpl("org.apache.commons:commons-lang3:3.4") { isTransitive = false exclude(module = "gson") } shadowImpl("org.apache.httpcomponents:httpcore:4.4.5") { isTransitive = false exclude(module = "gson") } compileOnly("com.google.code.gson:gson:2.8.6") { isTransitive = false } configurations.all { resolutionStrategy { force("com.google.code.gson:gson:2.8.6") } } shadowImpl(fileTree( mapOf( "dir" to "libs", "include" to listOf("*.jar"), "exclude" to listOf( "asm", "asm-commons", "asm-tree", "gson", "unspecified", "nv-i18n" ) ) )) }  
    • @chxr Looks like you're making some sort of a crafting table / furnace hybrid? Are the inputs needing arranging like a shaped recipe, or is it shapeless? I'll assume it's shapeless since that just adds a lot more complexity. In that case I'd probably do something like this { "type": "relativedimensions:particle_rebound", "inputs": [ { "ingredient": { "item": "relativedimensions:aberrant_shard" }, "count": 8 } ], "fuel": { "tag": "relativedimensions:block/aberrant_fuel" }, "output": { "Count": 1, "id": "relativedimensions:aberrant_ingot" } } inputs: A list of ingredients and how many are needed. The count among each input adds up to 8. Since there's only 1 ingredient, the count is set to 8. fuel: Same thing as before but remove the list and just make it an object with a tag. output: Kept the same.   In this case the Codec I would make is public record ParticleReboundIngredient(Ingredient ingredient, int count) { public static final Codec<ParticleReboundIngredient> CODEC = RecordCodecBuilder.create( builder -> builder.group( Ingredient.CODEC.fieldOf("ingredient").forGetter((i) -> i.ingredient), Codec.INT.fieldOf("count").forGetter(i -> i.count) ).apply(builder, ParticleReboundIngredient::new) ); } public record ParticleReboundFuel(String tag) { public static final Codec<ParticleReboundFuel> CODEC = RecordCodecBuilder.create( builder -> builder.group(Codec.STRING.fieldOf("tag").forGetter(f -> f.tag)).apply(builder, ParticleReboundFuel::new) ); public boolean isFuel(ItemStack stack) { // TODO: Check if fuel item matches the tag } } public record ParticleReboundRecipe(List<ParticleReboundIngredient> inputs, ParticleReboundFuel fuel, ItemStack output) { public static final Codec<ParticleReboundRecipe> CODEC = RecordCodecBuilder.create( builder -> builder.group( ParticleReboundIngredient.CODEC.listOf().fieldOf("inputs").forGetter(r -> r.inputs), ParticleReboundFuel.CODEC.fieldOf("fuel").forGetter(r -> r.fuel), ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output) ).apply(builder, ParticleReboundRecipe::new) ); }   There might be a more proper Codec for the fuel and the tag that's built into minecraft / forge, but I didn't look
    • Tested with 5900X, 64GB 3200 MHz, 3070 Ti, driver 551.86 GPU clock range: 200 - 1950 MHz, usually 210 MHz with 10-30% utilisation on desktop idle use Render settings: Vsync ON, Framerate unlimited, Render distance 32, Fullscreen ON (60hz monitor, so 60 fps with vsync) Vanilla minecraft: Main menu: 210mhz idle clock always, ingame clock around 400 - 1000 mhz with ~30% utilisation and after alt+tab stays at same. Modded install with curseforge app, only said forge added: Main menu: 210 mhz idle clock always, ingame clock around 400 - 1000 mhz with ~30% utilisation, but after alt+tab gpu clock shoots up to 1950 mhz and utilisation is at 50-60% After disabling all render and chunk related stuff in config, after alt+tab it goes up to 1500 mhz. So game turns gpu into space heater when its not even seen. GPU usage returns to expected when game comes back on top. If instead of unlimited fps, fps is set to ~60, then during alt+tab gpu stays at same range as vanilla, but minecraft has horrible limit logic and framerate limit causes lot of tearing, so its not an option. So it seems that when alt+tabbing, for some reason logic no longer takes vsync toggle into account. So expected behaviour would be for it to work like vanilla does. keep rendering in same manner, no matter if its seen and use same amount of resources. Essentially noticed this behaviour while playing Supersymmetry and after elimination testing, result was that only Forge was enough to cause it. And also confirmed it by doing fresh pack with only Forge added, so no other mods even in disabled state. Also happened with both singleplayer and remote multiplayer. Other offender was "Universal Tweaks" which introduced same effect to main menu with its # Removes the hardcoded 30 FPS limit in screens like the main menu B:"Uncap FPS"=true setting, meaning when game was on top, it still worked in limits of vsync cap, but after alt+tabbing even in main menu gpu usage shot up to max.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.