server hit stuff
This commit is contained in:
@@ -22,8 +22,8 @@ public class NeoComputersFabricClient implements ClientModInitializer {
|
|||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
ModelLoadingPlugin.register(new ModelLoader());
|
ModelLoadingPlugin.register(new ModelLoader());
|
||||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getSCREEN_ENTITY().get(), ScreenEntityRenderer::new); // TODO: put this in common
|
BlockEntityRenderers.register(BlockEntities.INSTANCE.getSCREEN_ENTITY().get(), ScreenEntityRenderer::new); // TODO: put this in common
|
||||||
// BlockEntityRenderers.register(BlockEntities.INSTANCE.getCASE_ENTITY().get(), CaseEntityRenderer::new);
|
BlockEntityRenderers.register(BlockEntities.INSTANCE.getCASE_ENTITY().get(), CaseEntityRenderer::new);
|
||||||
// BlockEntityRenderers.register(BlockEntities.INSTANCE.getRELAY_ENTITY().get(), RelayEntityRenderer::new);
|
BlockEntityRenderers.register(BlockEntities.INSTANCE.getRELAY_ENTITY().get(), RelayEntityRenderer::new);
|
||||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getROBOT_ENTITY().get(), RobotEntityRenderer::new);
|
BlockEntityRenderers.register(BlockEntities.INSTANCE.getROBOT_ENTITY().get(), RobotEntityRenderer::new);
|
||||||
BlockEntityRenderers.register(BlockEntities.INSTANCE.getRACK_ENTITY().get(), RackEntityRenderer::new);
|
BlockEntityRenderers.register(BlockEntities.INSTANCE.getRACK_ENTITY().get(), RackEntityRenderer::new);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.neoflock.neocomputers.block
|
package org.neoflock.neocomputers.block
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos
|
import net.minecraft.core.BlockPos
|
||||||
|
import net.minecraft.network.chat.Component
|
||||||
import net.minecraft.world.InteractionResult
|
import net.minecraft.world.InteractionResult
|
||||||
import net.minecraft.world.entity.player.Player
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.level.BlockGetter
|
import net.minecraft.world.level.BlockGetter
|
||||||
@@ -13,6 +14,7 @@ import net.minecraft.world.phys.BlockHitResult
|
|||||||
import net.minecraft.world.phys.shapes.CollisionContext
|
import net.minecraft.world.phys.shapes.CollisionContext
|
||||||
import net.minecraft.world.phys.shapes.Shapes
|
import net.minecraft.world.phys.shapes.Shapes
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape
|
import net.minecraft.world.phys.shapes.VoxelShape
|
||||||
|
import org.neoflock.neocomputers.NeoComputers
|
||||||
import org.neoflock.neocomputers.entity.BlockEntities
|
import org.neoflock.neocomputers.entity.BlockEntities
|
||||||
import org.neoflock.neocomputers.entity.RackEntity
|
import org.neoflock.neocomputers.entity.RackEntity
|
||||||
|
|
||||||
@@ -38,12 +40,19 @@ class RackBlock : BaseBlock(Properties.of().noOcclusion()), EntityBlock {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// override fun useWithoutItem(
|
override fun useWithoutItem(state: BlockState, level: Level, pos: BlockPos, player: Player, hitResult: BlockHitResult): InteractionResult? {
|
||||||
// state: BlockState,
|
val res = hitResult.location
|
||||||
// level: Levesl,
|
if(res.x == 18.0) { // TODO: handle rotation
|
||||||
// pos: BlockPos,
|
NeoComputers.LOGGER.info("{} > {} > {}, {} > {} > {}", pos.z+15/16f, res.z, pos.z+1/16f, pos.y+14/16f, res.y, pos.y+2/16f)
|
||||||
// player: Player,
|
if (pos.z + 15 / 16f > res.z && res.z > pos.z + 1 / 16f && pos.y + 14 / 16f > res.y && res.y > pos.y + 2 / 16f) {
|
||||||
// hitResult: BlockHitResult
|
var rack = 0
|
||||||
// ): InteractionResult? {
|
rack += if(res.y < pos.y+5/16f) 1 else 0
|
||||||
// return super.useWithoutItem(state, level, pos, player, hitResult)
|
rack += if(res.y < pos.y+8/16f) 1 else 0
|
||||||
|
rack += if(res.y < pos.y+12/16f) 1 else 0
|
||||||
|
|
||||||
|
player.sendSystemMessage(Component.literal(String.format("Hit server #%d", rack))) // TODO: call some RackItem method
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.useWithoutItem(state, level, pos, player, hitResult)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,10 @@ class RackEntityRenderer(val context: BlockEntityRendererProvider.Context) : Blo
|
|||||||
poseStack.pushPose()
|
poseStack.pushPose()
|
||||||
poseStack.translate(1/16f, 11/16f, 1/16f)
|
poseStack.translate(1/16f, 11/16f, 1/16f)
|
||||||
|
|
||||||
val render_slot = 2 // this is purely temporary type shit like true alpha shit, anyway it go to 0-3, change and test it if you want
|
val render_slot = (ent.level!!.dayTime/40)%4 // this is purely temporary type shit like true alpha shit, anyway it go to 0-3, change and test it if you want
|
||||||
poseStack.translate(0f, (render_slot)*-3/16f, 0f)
|
poseStack.translate(0f, (render_slot)*-3/16f, 0f)
|
||||||
val server = object : RackItem {}
|
val server = object : RackItem {}
|
||||||
server.render(source, poseStack, packedLight) // who knows atp
|
server.render(source, poseStack, packedLight, 2f+(3*render_slot)) // who knows atp
|
||||||
poseStack.popPose()
|
poseStack.popPose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
|
|||||||
import net.minecraft.resources.ResourceLocation
|
import net.minecraft.resources.ResourceLocation
|
||||||
import org.neoflock.neocomputers.NeoComputers
|
import org.neoflock.neocomputers.NeoComputers
|
||||||
import org.neoflock.neocomputers.block.RelayEntity
|
import org.neoflock.neocomputers.block.RelayEntity
|
||||||
|
import java.util.Timer
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
class RelayEntityRenderer(val context: BlockEntityRendererProvider.Context?): BlockEntityRenderer<RelayEntity> {
|
class RelayEntityRenderer(val context: BlockEntityRendererProvider.Context?): BlockEntityRenderer<RelayEntity> {
|
||||||
|
|||||||
Reference in New Issue
Block a user