Skip to content

Commit

Permalink
fix obj light + fix obj vertextype + set thread daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
Yefancy committed Apr 28, 2022
1 parent a825230 commit 935ed80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@
import com.cleanroommc.multiblocked.api.gui.widget.imp.DialogWidget;
import com.cleanroommc.multiblocked.api.gui.widget.imp.DraggableScrollableWidgetGroup;
import com.cleanroommc.multiblocked.api.gui.widget.imp.TextFieldWidget;
import com.cleanroommc.multiblocked.api.tile.ComponentTileEntity;
import com.cleanroommc.multiblocked.client.model.custommodel.CustomBakedModel;
import com.cleanroommc.multiblocked.client.renderer.IRenderer;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.common.model.TRSRTransformation;

import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -44,17 +53,28 @@ public String getType() {
@Override
protected IModel getModel() {
try {
if (flip_v) {
return OBJLoader.INSTANCE.loadModel(modelLocation).process(ImmutableMap.<String, String>builder().put("flip-v", "true").build());
} else {
return OBJLoader.INSTANCE.loadModel(modelLocation);
}
return OBJLoader.INSTANCE.loadModel(modelLocation).process(ImmutableMap.<String, String>builder()
.put("flip-v", flip_v ? "true" : "false")
.put("ambient", "false").build());
} catch (Exception e) {
Multiblocked.LOGGER.error(e);
}
return ModelLoaderRegistry.getMissingModel();
}

@Override
protected CustomBakedModel getBlockBakedModel(BlockPos pos, IBlockAccess blockAccess) {
TileEntity tileEntity = blockAccess.getTileEntity(pos);
EnumFacing frontFacing = EnumFacing.NORTH;
if (tileEntity instanceof ComponentTileEntity<?>) {
frontFacing = ((ComponentTileEntity<?>) tileEntity).getFrontFacing();
}
return blockModels.computeIfAbsent(frontFacing, facing -> new CustomBakedModel(getModel().bake(
TRSRTransformation.from(facing),
DefaultVertexFormats.ITEM,
ModelLoader.defaultTextureGetter())));
}

@Override
public JsonObject toJson(Gson gson, JsonObject jsonObject) {
if (!flip_v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public NBTTagCompound writeToNBT(@Nonnull NBTTagCompound compound) {
public void createSearchingThread() {
if (thread != null && !thread.isInterrupted()) return;
thread = new Thread(this::searchingTask);
thread.setDaemon(true);
thread.start();
}

Expand Down

0 comments on commit 935ed80

Please sign in to comment.