All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
dev.creoii.creoapi.impl.block.BlockImpl Maven / Gradle / Ivy
package dev.creoii.creoapi.impl.block;
import dev.creoii.creoapi.api.block.CreoBlock;
import org.jetbrains.annotations.ApiStatus;
import java.util.Optional;
import net.minecraft.class_1297;
import net.minecraft.class_2246;
import net.minecraft.class_2338;
import net.minecraft.class_239;
import net.minecraft.class_2680;
import net.minecraft.class_287;
import net.minecraft.class_3492;
import net.minecraft.class_3499;
import net.minecraft.class_3610;
import net.minecraft.class_3965;
import net.minecraft.class_4587;
import net.minecraft.class_4696;
import net.minecraft.class_5425;
import net.minecraft.class_5819;
import net.minecraft.class_750;
import net.minecraft.class_776;
import net.minecraft.class_853;
@ApiStatus.Internal
public final class BlockImpl {
public static void applyLookAtBlock(class_1297 entity) {
class_239 hitResult = entity.method_5745(64d, 0f, false);
if (hitResult.method_17783() == class_239.class_240.field_1332) {
class_3965 blockHitResult = (class_3965) hitResult;
class_2680 state = entity.method_37908().method_8320(blockHitResult.method_17777());
if (state.method_26204() instanceof CreoBlock creoBlock)
creoBlock.onLookedAt(entity.method_37908(), state, blockHitResult, entity, blockHitResult.method_24801(entity));
}
}
public static void applyOnPlacedByStructure(class_5425 world, class_2338 pivot, class_3492 placementData, class_5819 random, class_3499.class_3501 structureBlockInfo, class_2338 pos, class_3610 fluidState, class_2680 state, class_3499 structureTemplate) {
if (state.method_26204() instanceof CreoBlock creoBlock) {
creoBlock.onPlacedByStructure(world, pos, state, fluidState, random, pivot, structureTemplate, placementData, structureBlockInfo);
}
}
public static void applyCollideAdjacent(class_1297 entity) {
Optional optionalPos = class_2338.method_25997(entity.method_24515(), (int) (entity.method_17681() + .5f), (int) (entity.method_17682() + .5f), pos -> {
return entity.method_37908().method_8320(pos).method_26204() instanceof CreoBlock;
});
if (optionalPos.isPresent()) {
class_2338 pos = optionalPos.get();
class_2680 state = entity.method_37908().method_8320(pos);
if (state.method_26204() instanceof CreoBlock creoBlock) {
if (creoBlock.canEntityCollideAdjacent(entity, state, pos)) {
creoBlock.onAdjacentEntityCollision(entity, state, pos);
}
}
}
}
public static void applyRenderOverlayState(class_2680 blockState, class_2338 pos, class_5819 random, class_750 storage, class_776 blockRenderManager, class_853 chunkRendererRegion, class_4587 matrixStack) {
if (blockState.method_26204() instanceof CreoBlock creoBlock) {
class_2680 state = creoBlock.getOverlayState(blockState, pos, random);
class_287 bufferBuilder = storage.method_3154(class_4696.method_23679(state));
if (bufferBuilder.method_22893() && state != class_2246.field_10124.method_9564()) {
blockRenderManager.method_3355(state, pos, chunkRendererRegion, matrixStack, bufferBuilder, true, random);
}
}
}
}