-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
3,607 additions
and
35 deletions.
There are no files selected for viewing
1,220 changes: 1,220 additions & 0 deletions
1,220
src/main/generated/assets/galacticraft/blockstates/parachest.json
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/main/generated/data/galacticraft/loot_tables/blocks/parachest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"type": "minecraft:block", | ||
"pools": [ | ||
{ | ||
"bonus_rolls": 0.0, | ||
"conditions": [ | ||
{ | ||
"condition": "minecraft:survives_explosion" | ||
} | ||
], | ||
"entries": [ | ||
{ | ||
"type": "minecraft:item", | ||
"name": "galacticraft:parachest" | ||
} | ||
], | ||
"rolls": 1.0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/ParachestScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2019-2023 Team Galacticraft | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package dev.galacticraft.mod.client.gui.screen.ingame; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import dev.galacticraft.mod.Constant; | ||
import dev.galacticraft.mod.screen.ParachestMenu; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Inventory; | ||
|
||
public class ParachestScreen extends AbstractContainerScreen<ParachestMenu> { | ||
private static ResourceLocation[] parachestTexture = new ResourceLocation[4]; | ||
|
||
static { | ||
for (int i = 0; i < 4; i++) { | ||
parachestTexture[i] = Constant.id("textures/gui/chest_" + i * 18 + ".png"); | ||
} | ||
} | ||
|
||
private int inventorySlots = 0; | ||
|
||
public ParachestScreen(ParachestMenu abstractContainerMenu, Inventory inventory, Component component) { | ||
super(abstractContainerMenu, inventory, component); | ||
this.inventorySlots = abstractContainerMenu.getBlockEntity().getContainerSize(); | ||
this.imageHeight = 146 + this.inventorySlots * 2; | ||
this.titleLabelX = 8; | ||
this.titleLabelY = 6; | ||
this.inventoryLabelX = 8; | ||
this.inventoryLabelY = this.imageHeight - 103 + (this.inventorySlots == 3 ? 2 : 4); | ||
} | ||
|
||
@Override | ||
protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) { | ||
ResourceLocation texture = parachestTexture[(this.inventorySlots - 3) / 18]; | ||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); | ||
int k = (this.width - this.imageWidth) / 2; | ||
int l = (this.height - this.imageHeight) / 2; | ||
guiGraphics.blit(texture, k, l, 0, 0, this.imageWidth, this.imageHeight); | ||
|
||
var tank = getMenu().getBlockEntity().tank; | ||
|
||
final double amount = tank.getAmount(); | ||
|
||
int fuelLevel = (int) (amount * 28 / tank.getCapacity()); | ||
guiGraphics.blit(texture, k + 17, l + (this.inventorySlots == 3 ? 40 : 42) - fuelLevel + this.inventorySlots * 2, 176, 28 - fuelLevel, 34, fuelLevel); | ||
} | ||
|
||
@Override | ||
public void render(GuiGraphics guiGraphics, int i, int j, float f) { | ||
renderBackground(guiGraphics); | ||
super.render(guiGraphics, i, j, f); | ||
renderTooltip(guiGraphics, i, j); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/dev/galacticraft/mod/client/model/GCModelLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2019-2023 Team Galacticraft | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package dev.galacticraft.mod.client.model; | ||
|
||
import dev.galacticraft.mod.Constant; | ||
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; | ||
import net.minecraft.client.resources.model.UnbakedModel; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.DyeColor; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class GCModelLoader implements ModelLoadingPlugin { | ||
public static final GCModelLoader INSTANCE = new GCModelLoader(); | ||
private static final ResourceLocation PARACHEST_ITEM = new ResourceLocation(Constant.MOD_ID, "item/parachest"); | ||
|
||
@Override | ||
public void onInitializeModelLoader(Context pluginContext) { | ||
|
||
pluginContext.resolveModel().register(context -> { | ||
if (context.id().equals(PARACHEST_ITEM)) { | ||
Map<DyeColor, UnbakedModel> chutes = new HashMap<>(); | ||
for (DyeColor color : DyeColor.values()) { | ||
chutes.put(color, context.getOrLoadModel(Constant.id("block/parachest/" + color.getName() + "_chute"))); | ||
} | ||
return new ParachestUnbakedModel(context.getOrLoadModel(Constant.id("block/parachest/parachest")), chutes); | ||
} | ||
return null; | ||
}); | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
src/main/java/dev/galacticraft/mod/client/model/ParaChestBakedModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright (c) 2019-2023 Team Galacticraft | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package dev.galacticraft.mod.client.model; | ||
|
||
import dev.galacticraft.mod.content.GCBlocks; | ||
import dev.galacticraft.mod.content.block.special.ParaChestBlock; | ||
import net.fabricmc.fabric.api.renderer.v1.model.WrapperBakedModel; | ||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; | ||
import net.minecraft.client.renderer.block.model.*; | ||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.client.resources.model.ModelBaker; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.item.BlockItem; | ||
import net.minecraft.world.item.DyeColor; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.Property; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
public record ParaChestBakedModel(BakedModel parent, Map<DyeColor, BakedModel> bakedChutes) implements BakedModel, WrapperBakedModel { | ||
@Override | ||
public List<BakedQuad> getQuads(@Nullable BlockState blockState, @Nullable Direction direction, RandomSource randomSource) { | ||
List<BakedQuad> quads = new ArrayList<>(parent.getQuads(blockState, direction, randomSource)); | ||
if (blockState != null) | ||
quads.addAll(bakedChutes.get(blockState.getValue(ParaChestBlock.COLOR)).getQuads(blockState, direction, randomSource)); | ||
return quads; | ||
} | ||
|
||
@Override | ||
public void emitItemQuads(ItemStack stack, Supplier<RandomSource> randomSupplier, RenderContext context) { | ||
BakedModel.super.emitItemQuads(stack, randomSupplier, context); | ||
CompoundTag compoundTag = stack.getTag(); | ||
if (compoundTag != null) { | ||
CompoundTag blockStateTag = compoundTag.getCompound("BlockStateTag"); | ||
StateDefinition<Block, BlockState> stateDefinition = GCBlocks.PARACHEST.getStateDefinition(); | ||
|
||
|
||
Property<?> property = stateDefinition.getProperty("color"); | ||
if (property != null) { | ||
bakedChutes.get(property.getValue(blockStateTag.getString("color")).get()).emitItemQuads(stack, randomSupplier, context); | ||
} | ||
} else { | ||
bakedChutes.get(DyeColor.WHITE).emitItemQuads(stack, randomSupplier, context); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isVanillaAdapter() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean useAmbientOcclusion() { | ||
return parent.usesBlockLight(); | ||
} | ||
|
||
@Override | ||
public boolean isGui3d() { | ||
return parent.isGui3d(); | ||
} | ||
|
||
@Override | ||
public boolean usesBlockLight() { | ||
return parent.usesBlockLight(); | ||
} | ||
|
||
@Override | ||
public boolean isCustomRenderer() { | ||
return parent.isCustomRenderer(); | ||
} | ||
|
||
@Override | ||
public TextureAtlasSprite getParticleIcon() { | ||
return parent.getParticleIcon(); | ||
} | ||
|
||
@Override | ||
public ItemTransforms getTransforms() { | ||
return parent.getTransforms(); | ||
} | ||
|
||
@Override | ||
public ItemOverrides getOverrides() { | ||
return parent.getOverrides(); | ||
} | ||
|
||
@Override | ||
public BakedModel getWrappedModel() { | ||
return parent; | ||
} | ||
|
||
public class ParaChestOverride extends ItemOverrides { | ||
|
||
public ParaChestOverride(ModelBaker modelBaker, BlockModel blockModel, List<ItemOverride> list) { | ||
super(modelBaker, blockModel, list); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/dev/galacticraft/mod/client/model/ParachestUnbakedModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2019-2023 Team Galacticraft | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package dev.galacticraft.mod.client.model; | ||
|
||
import net.minecraft.client.renderer.texture.TextureAtlasSprite; | ||
import net.minecraft.client.resources.model.*; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.DyeColor; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.*; | ||
import java.util.function.Function; | ||
|
||
public record ParachestUnbakedModel(UnbakedModel parentModel, Map<DyeColor, UnbakedModel> chutes) implements UnbakedModel { | ||
|
||
@Override | ||
public Collection<ResourceLocation> getDependencies() { | ||
List<ResourceLocation> depends = new ArrayList<>(parentModel.getDependencies()); | ||
chutes.forEach((color, unbakedModel) -> { | ||
depends.addAll(unbakedModel.getDependencies()); | ||
}); | ||
return depends; | ||
} | ||
|
||
@Override | ||
public void resolveParents(Function<ResourceLocation, UnbakedModel> function) { | ||
parentModel.resolveParents(function); | ||
chutes.forEach((color, unbakedModel) -> { | ||
unbakedModel.resolveParents(function); | ||
}); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BakedModel bake(ModelBaker modelBaker, Function<Material, TextureAtlasSprite> function, ModelState modelState, ResourceLocation resourceLocation) { | ||
Map<DyeColor, BakedModel> bakedChutes = new HashMap<>(); | ||
chutes.forEach((color, unbakedModel) -> { | ||
bakedChutes.put(color, unbakedModel.bake(modelBaker, function, modelState, resourceLocation)); | ||
}); | ||
return new ParaChestBakedModel(parentModel.bake(modelBaker, function, modelState, resourceLocation), bakedChutes); | ||
} | ||
} |
Oops, something went wrong.