-
Notifications
You must be signed in to change notification settings - Fork 17
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
1 parent
89e566d
commit b077acd
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/com/blamejared/contenttweaker/blocks/types/glass/BlockBuilderGlass.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,33 @@ | ||
package com.blamejared.contenttweaker.blocks.types.glass; | ||
|
||
import com.blamejared.contenttweaker.VanillaFactory; | ||
import com.blamejared.contenttweaker.api.blocks.BlockTypeBuilder; | ||
import com.blamejared.contenttweaker.blocks.BlockBuilder; | ||
import com.blamejared.contenttweaker.blocks.render.BlockRenderType; | ||
import com.blamejared.crafttweaker.api.annotations.ZenRegister; | ||
import com.blamejared.crafttweaker_annotations.annotations.Document; | ||
import net.minecraft.util.ResourceLocation; | ||
import org.openzen.zencode.java.ZenCodeType; | ||
|
||
/** | ||
* A special builder that allows you to create glass blocks. | ||
* | ||
* @docParam this new BlockBuilder().withType<BlockBuilderGlass>() | ||
*/ | ||
@ZenRegister | ||
@Document("mods/contenttweaker/API/block/basic/BlockBuilderGlass") | ||
@ZenCodeType.Name("mods.contenttweaker.block.basic.BlockBuilderGlass") | ||
public class BlockBuilderGlass extends BlockTypeBuilder { | ||
|
||
public BlockBuilderGlass(BlockBuilder blockBuilder) { | ||
super(blockBuilder); | ||
} | ||
|
||
@Override | ||
public void build(ResourceLocation location) { | ||
CoTBlockGlass blockBasic = new CoTBlockGlass(blockBuilder.getBlockProperties(), blockBuilder.getItemProperties(), location); | ||
BlockRenderType renderType = this.blockBuilder.getRenderType(); | ||
VanillaFactory.queueBlockForRegistration(blockBasic, renderType); | ||
} | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/blamejared/contenttweaker/blocks/types/glass/CoTBlockGlass.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,64 @@ | ||
package com.blamejared.contenttweaker.blocks.types.glass; | ||
|
||
import com.blamejared.contenttweaker.ContentTweaker; | ||
import com.blamejared.contenttweaker.api.blocks.IIsCoTBlock; | ||
import com.blamejared.contenttweaker.api.items.IIsCotItem; | ||
import com.blamejared.contenttweaker.api.resources.ImageType; | ||
import com.blamejared.contenttweaker.api.resources.ResourceType; | ||
import com.blamejared.contenttweaker.api.resources.WriteableResource; | ||
import com.blamejared.contenttweaker.api.resources.WriteableResourceImage; | ||
import com.blamejared.contenttweaker.api.resources.WriteableResourceLootTableItem; | ||
import com.blamejared.contenttweaker.api.resources.WriteableResourceTemplate; | ||
import com.blamejared.contenttweaker.blocks.CoTBlockItem; | ||
import net.minecraft.block.AbstractGlassBlock; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.loot.LootTables; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class CoTBlockGlass extends AbstractGlassBlock implements IIsCoTBlock { | ||
|
||
private final IIsCotItem item; | ||
|
||
public CoTBlockGlass(Properties properties, Item.Properties itemProperties, ResourceLocation location) { | ||
super(properties); | ||
this.setRegistryName(location); | ||
item = new CoTBlockItem(this, itemProperties); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public IIsCotItem getItem() { | ||
return item; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Collection<WriteableResource> getResourcePackResources() { | ||
final ResourceLocation location = getRegistryNameNonNull(); | ||
final Collection<WriteableResource> out = new ArrayList<>(); | ||
|
||
out.add(WriteableResourceImage.noImage(ImageType.BLOCK, location)); | ||
|
||
final WriteableResourceTemplate modelTemplate = new WriteableResourceTemplate(ResourceType.ASSETS, location, "models", "block").withTemplate(ResourceType.ASSETS, new ResourceLocation(ContentTweaker.MOD_ID, "models/block/block_basic")).setLocationProperty(location); | ||
out.add(modelTemplate); | ||
|
||
final WriteableResourceTemplate blockstateTemplate = new WriteableResourceTemplate(ResourceType.ASSETS, location, "blockstates").withTemplate(ResourceType.ASSETS, new ResourceLocation(ContentTweaker.MOD_ID, "blockstates/block_basic")).setLocationProperty(location); | ||
out.add(blockstateTemplate); | ||
|
||
return out; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Collection<WriteableResource> getDataPackResources() { | ||
final Collection<WriteableResource> out = new ArrayList<>(); | ||
if(getLootTable() != LootTables.EMPTY) { | ||
out.add(new WriteableResourceLootTableItem(getRegistryName())); | ||
} | ||
return out; | ||
} | ||
} |