Skip to content

Instantly share code, notes, and snippets.

View isXander's full-sized avatar

Xander isXander

View GitHub Profile
pub fn receive_generated_chunks(&mut self, texture_atlas: &Arc<TextureAtlas>) {
while let Ok((coords, state)) = self.chunkgen_thread_receiver.try_recv() {
let (x, z) = Self::unpack_coordinates(coords);
println!("Generated chunk at {},{}", x, z);
self.chunks.insert(coords, state);
let state = self.chunks.get(&coords).unwrap();
if let ChunkState::Loaded(LoadedChunk::Stored { chunk }) = state {
fn create_face(
x: f32, y: f32, z: f32,
face: Face,
) -> Vec<engine::model::ModelVertex> {
let mut vertices = Vec::new();
println!("Creating face: {:?}", face);
let (x_axis, y_axis, z_axis, x_off, y_off, z_off, norm_x, norm_y, norm_z) = match face {
Face::Top => (1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0),
private static AnimatedNativeImageBacked createFromImageReader(ImageReader reader, AnimFrameProvider animationProvider, ResourceLocation uniqueLocation) throws Exception {
if (reader.isSeekForwardOnly()) {
throw new RuntimeException("Image reader is not seekable");
}
int frameCount = reader.getNumImages(true);
// Because this is being backed into a texture atlas, we need a maximum dimension
// so you can get the texture atlas size.
// Smaller frames are given black borders
package dev.isxander.yacl3.mixin;
import net.minecraft.client.gui.components.events.ContainerEventHandler;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.components.tabs.TabNavigationBar;
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
import net.minecraft.client.gui.navigation.ScreenAxis;
import net.minecraft.client.gui.navigation.ScreenDirection;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import org.jetbrains.annotations.Nullable;
var rootLayout = layout.createRowHelper(3);
rootLayout.addChild(new TabListWidget<>(
() -> new ScreenRectangle(tabArea.position(), tabArea.width() / 3 * 2 + 1, tabArea.height()),
this.optionList
), 2);
var buttonGrid = new GridLayout();
buttonGrid.defaultCellSetting().padding(2, 2, 2, 0);
rootLayout.addChild(buttonGrid, 1, rootLayout.newCellSettings().alignHorizontallyRight().alignVerticallyBottom());
private void addMessage(Component message, @Nullable MessageSignature signature, int ticks, @Nullable GuiMessageTag tag, boolean refresh) {
int i = Mth.floor((double)this.getWidth() / this.getScale());
if (tag != null && tag.icon() != null) {
i -= tag.icon().width + 4 + 2;
}
List<FormattedCharSequence> list = ComponentRenderUtils.wrapComponents(message, i, this.minecraft.font);
boolean bl = this.isChatFocused();
for(int j = 0; j < list.size(); ++j) {
private void onPress(long window, int button, int action, int modifiers) {
boolean bl;
if (window != this.minecraft.getWindow().getWindow()) {
return;
}
if (this.minecraft.screen != null) {
this.minecraft.setLastInputType(InputType.MOUSE);
}
boolean bl2 = bl = action == 1;
if (Minecraft.ON_OSX && button == 0) {
@Mixin(AbstractContainerScreen.class)
public abstract class AbstractContainerScreenMixin implements ScreenProcessorProvider {
@Shadow @Nullable protected Slot hoveredSlot;
@Shadow protected abstract void slotClicked(Slot slot, int slotId, int button, ClickType actionType);
@Unique private final ScreenProcessor<?> screenProcessor = new AbstractContainerScreenProcessor<>((AbstractContainerScreen<?>) (Object) this, () -> hoveredSlot, this::slotClicked);
@Override
public ScreenProcessor<?> screenProcessor() {
public void renderScrollingString(PoseStack matrices, Font textRenderer, int xOffset, int color) {
int i = this.getX() + xOffset;
int j = this.getX() + this.getWidth() - xOffset;
Component var10002 = this.getMessage();
int var10004 = this.getY();
int var10006 = this.getY() + this.getHeight();
int var7 = this.localvar$zei000$controlify$shiftDrawSize(i);
renderScrollingString(matrices, textRenderer, var10002, i, var10004, j, var10006, color);
}
@isXander
isXander / Options.java
Created February 5, 2023 21:40
how to
public final KeyMapping keySprint = new ToggleKeyMapping("key.sprint", 341, "key.categories.movement", this.toggleSprint::get);